diff options
author | Alex Converse <alex.converse@gmail.com> | 2009-07-08 23:04:22 +0000 |
---|---|---|
committer | Alex Converse <alex.converse@gmail.com> | 2009-07-08 23:04:22 +0000 |
commit | 7a4eebcdce1e7b2ef8d9546ad46742f42531431e (patch) | |
tree | d07a0991b2ec1f2599ada729c4734e013292b1f3 /libavcodec | |
parent | c8f47d8b79b7ac82cd2bff6ffcc9d5168ad7e571 (diff) | |
download | ffmpeg-7a4eebcdce1e7b2ef8d9546ad46742f42531431e.tar.gz |
Turn on AAC rate control.
Originally committed as revision 19379 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aaccoder.c | 19 | ||||
-rw-r--r-- | libavcodec/aacenc.c | 1 |
2 files changed, 6 insertions, 14 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 3e90880feb..920ae53929 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -457,15 +457,6 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce } } -static void encode_window_bands_info_fixed(AACEncContext *s, - SingleChannelElement *sce, - int win, int group_len, - const float lambda) -{ - encode_window_bands_info(s, sce, win, group_len, 1.0f); -} - - typedef struct TrellisPath { float cost; int prev; @@ -700,7 +691,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, sce->ics.swb_sizes[g], sce->sf_idx[w*16+g], ESC_BT, - 1.0, + lambda, INFINITY, &b); bb += b; @@ -710,7 +701,7 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, minbits = bb; } } - dists[w*16+g] = mindist - minbits; + dists[w*16+g] = (mindist - minbits) / lambda; bits = minbits; if (prev != -1) { bits += ff_aac_scalefactor_bits[sce->sf_idx[w*16+g] - prev + SCALE_DIFF_ZERO]; @@ -870,12 +861,12 @@ static void search_for_quantizers_faac(AVCodecContext *avctx, AACEncContext *s, sce->ics.swb_sizes[g], scf, ESC_BT, - 1.0, + lambda, INFINITY, &b); dist -= b; } - dist *= 1.0f/512.0f; + dist *= 1.0f / 512.0f / lambda; quant_max = quant(maxq[w*16+g], ff_aac_pow2sf_tab[200 - scf + SCALE_ONE_POS - SCALE_DIV_512]); if (quant_max >= 8191) { // too much, return to the previous quantizer sce->sf_idx[w*16+g] = prev_scf; @@ -1019,7 +1010,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe, AACCoefficientsEncoder ff_aac_coders[] = { { search_for_quantizers_faac, - encode_window_bands_info_fixed, + encode_window_bands_info, quantize_and_encode_band, // search_for_ms, }, diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 0c921a55d2..61e0f52cc4 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -583,6 +583,7 @@ static int aac_encode_frame(AVCodecContext *avctx, if (!(avctx->flags & CODEC_FLAG_QSCALE)) { float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; s->lambda *= ratio; + s->lambda = fminf(s->lambda, 65536.f); } if (avctx->frame_bits > 6144*avctx->channels) |