From e9a889bfbf38bda7855792edd8248f4f4a56af7e Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Tue, 21 Feb 2023 12:58:38 -0500 Subject: [PATCH 1/2] Fix build on Android due to termbits.h collision! Applied to libavcodec/aaccoder.c: :%s/\([*]\)\?\([ \t]\{-}\)\?\(\<[BD-Z]\([0-9]*\)\)\>/\1\2_\3/g This stops B0 and B1 from colliding with a define in /usr/include/asm-generic/termbits.h: ```c ``` Because of other defines in the file I used a more inclusive regex as there's a warning at top that it's autogenerated and may be expanded. --- libavcodec/aaccoder.c | 62 +++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 6291c16123..35791c3040 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -83,8 +83,8 @@ static av_always_inline float quantize_and_encode_band_cost_template( const float ROUNDING) { const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512; - const float Q = ff_aac_pow2sf_tab [q_idx]; - const float Q34 = ff_aac_pow34sf_tab[q_idx]; + const float _Q = ff_aac_pow2sf_tab [q_idx]; + const float _Q34 = ff_aac_pow34sf_tab[q_idx]; const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; const float CLIPPED_ESCAPE = 165140.0f*IQ; float cost = 0; @@ -111,7 +111,7 @@ static av_always_inline float quantize_and_encode_band_cost_template( s->abs_pow34(s->scoefs, in, size); scaled = s->scoefs; } - s->quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], Q34, ROUNDING); + s->quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], _Q34, ROUNDING); if (BT_UNSIGNED) { off = 0; } else { @@ -138,7 +138,7 @@ static av_always_inline float quantize_and_encode_band_cost_template( quantized = CLIPPED_ESCAPE; curbits += 21; } else { - int c = av_clip_uintp2(quant(t, Q, ROUNDING), 13); + int c = av_clip_uintp2(quant(t, _Q, ROUNDING), 13); quantized = c*cbrtf(c)*IQ; curbits += av_log2(c)*2 - 4 + 1; } @@ -175,7 +175,7 @@ static av_always_inline float quantize_and_encode_band_cost_template( if (BT_ESC) { for (int j = 0; j < 2; j++) { if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) { - int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q, ROUNDING), 13); + int coef = av_clip_uintp2(quant(fabsf(in[i+j]), _Q, ROUNDING), 13); int len = av_log2(coef); put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2); @@ -979,9 +979,9 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) { int start = 0, i, w, w2, g, sid_sf_boost, prev_mid, prev_side; uint8_t nextband0[128], nextband1[128]; - float *M = s->scoefs + 128*0, *S = s->scoefs + 128*1; - float *L34 = s->scoefs + 128*2, *R34 = s->scoefs + 128*3; - float *M34 = s->scoefs + 128*4, *S34 = s->scoefs + 128*5; + float *_M = s->scoefs + 128*0, *_S = s->scoefs + 128*1; + float *_L34 = s->scoefs + 128*2, *_R34 = s->scoefs + 128*3; + float *_M34 = s->scoefs + 128*4, *_S34 = s->scoefs + 128*5; const float lambda = s->lambda; const float mslambda = FFMIN(1.0f, lambda / 120.f); SingleChannelElement *sce0 = &cpe->ch[0]; @@ -1007,22 +1007,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) /* Must compute mid/side SF and book for the whole window group */ for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { - M[i] = (sce0->coeffs[start+(w+w2)*128+i] + _M[i] = (sce0->coeffs[start+(w+w2)*128+i] + sce1->coeffs[start+(w+w2)*128+i]) * 0.5; - S[i] = M[i] + _S[i] = _M[i] - sce1->coeffs[start+(w+w2)*128+i]; } - s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]); - s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]); + s->abs_pow34(_M34, _M, sce0->ics.swb_sizes[g]); + s->abs_pow34(_S34, _S, sce0->ics.swb_sizes[g]); for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) { - Mmax = FFMAX(Mmax, M34[i]); - Smax = FFMAX(Smax, S34[i]); + Mmax = FFMAX(Mmax, _M34[i]); + Smax = FFMAX(Smax, _S34[i]); } } for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) { float dist1 = 0.0f, dist2 = 0.0f; - int B0 = 0, B1 = 0; + int _B0 = 0, _B1 = 0; int minidx; int mididx, sididx; int midcb, sidcb; @@ -1050,46 +1050,46 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) float minthr = FFMIN(band0->threshold, band1->threshold); int b1,b2,b3,b4; for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { - M[i] = (sce0->coeffs[start+(w+w2)*128+i] + _M[i] = (sce0->coeffs[start+(w+w2)*128+i] + sce1->coeffs[start+(w+w2)*128+i]) * 0.5; - S[i] = M[i] + _S[i] = _M[i] - sce1->coeffs[start+(w+w2)*128+i]; } - s->abs_pow34(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); - s->abs_pow34(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); - s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]); - s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]); + s->abs_pow34(_L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); + s->abs_pow34(_R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); + s->abs_pow34(_M34, _M, sce0->ics.swb_sizes[g]); + s->abs_pow34(_S34, _S, sce0->ics.swb_sizes[g]); dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128], - L34, + _L34, sce0->ics.swb_sizes[g], sce0->sf_idx[w*16+g], sce0->band_type[w*16+g], lambda / (band0->threshold + FLT_MIN), INFINITY, &b1, NULL); dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128], - R34, + _R34, sce1->ics.swb_sizes[g], sce1->sf_idx[w*16+g], sce1->band_type[w*16+g], lambda / (band1->threshold + FLT_MIN), INFINITY, &b2, NULL); - dist2 += quantize_band_cost(s, M, - M34, + dist2 += quantize_band_cost(s, _M, + _M34, sce0->ics.swb_sizes[g], mididx, midcb, lambda / (minthr + FLT_MIN), INFINITY, &b3, NULL); - dist2 += quantize_band_cost(s, S, - S34, + dist2 += quantize_band_cost(s, _S, + _S34, sce1->ics.swb_sizes[g], sididx, sidcb, mslambda / (minthr * bmax + FLT_MIN), INFINITY, &b4, NULL); - B0 += b1+b2; - B1 += b3+b4; + _B0 += b1+b2; + _B1 += b3+b4; dist1 -= b1+b2; dist2 -= b3+b4; } - cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0; + cpe->ms_mask[w*16+g] = dist2 <= dist1 && _B1 < _B0; if (cpe->ms_mask[w*16+g]) { if (sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) { sce0->sf_idx[w*16+g] = mididx; @@ -1101,7 +1101,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe) cpe->ms_mask[w*16+g] = 0; } break; - } else if (B1 > B0) { + } else if (_B1 > _B0) { /* More boost won't fix this */ break; } -- 2.39.2