diff options
author | Alex Converse | 2010-05-14 16:49:30 +0000 |
---|---|---|
committer | Alex Converse | 2010-05-14 16:49:30 +0000 |
commit | 51cbabc79241dc9089d98965079fe1da4742d966 (patch) | |
tree | d49dbc08ce94318c88581b76403023246db02512 /libavcodec/aaccoder.c | |
parent | 960323a2304253bad5c9896e6b1060eb136b579b (diff) |
aacenc: Use an estimated codebook for the TLS (two loop search).
Originally committed as revision 23134 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r-- | libavcodec/aaccoder.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 0957469957..b9ae79927d 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -604,9 +604,26 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, 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 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, &b); bb += b; } - if (dist < mindist) { mindist = dist; minbits = bb; - } } dists[w*16+g] = (mindist - minbits) / lambda; bits = minbits; |