# HG changeset patch # User alexc # Date 1273855770 0 # Node ID 5e8702ddbb937d49261f439dfe1fe6bef4627bcf # Parent 6598cef880fc615c0dc3d5c4a71c2732b3f58897 aacenc: Use an estimated codebook for the TLS (two loop search). diff -r 6598cef880fc -r 5e8702ddbb93 aaccoder.c --- a/aaccoder.c Fri May 14 16:49:21 2010 +0000 +++ b/aaccoder.c Fri May 14 16:49:30 2010 +0000 @@ -604,9 +604,26 @@ continue; } minscaler = FFMIN(minscaler, sce->sf_idx[w*16+g]); - for (cb = 0; cb <= ESC_BT; cb++) { + { float dist = 0.0f; int bb = 0; + float maxval = 0.0f; + float Q = ff_aac_pow2sf_tab[200 - sce->sf_idx[w*16+g] + SCALE_ONE_POS - SCALE_DIV_512]; + float Q34 = sqrtf(Q * sqrtf(Q)); + int qmaxval; + for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { + for (i = 0; i < sce->ics.swb_sizes[g]; i++) { + maxval = fmaxf(maxval, scaled[w2*128+i]); + } + } + qmaxval = maxval * Q34 + 0.4054; + if (qmaxval == 0) cb = 0; + else if (qmaxval == 1) cb = 1; + else if (qmaxval == 2) cb = 3; + else if (qmaxval <= 4) cb = 5; + else if (qmaxval <= 7) cb = 7; + else if (qmaxval <= 12) cb = 9; + else cb = 11; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { int b; dist += quantize_band_cost(s, coefs + w2*128, @@ -619,10 +636,8 @@ &b); bb += b; } - if (dist < mindist) { mindist = dist; minbits = bb; - } } dists[w*16+g] = (mindist - minbits) / lambda; bits = minbits;