[FFmpeg-soc] [soc]: r4236 - aacenc/aacenc.c

kostya subversion at mplayerhq.hu
Fri Apr 24 08:23:23 CEST 2009


Author: kostya
Date: Fri Apr 24 08:23:23 2009
New Revision: 4236

Log:
Add rate control stub

Modified:
   aacenc/aacenc.c

Modified: aacenc/aacenc.c
==============================================================================
--- aacenc/aacenc.c	Fri Apr 24 08:22:36 2009	(r4235)
+++ aacenc/aacenc.c	Fri Apr 24 08:23:23 2009	(r4236)
@@ -195,6 +195,7 @@ static av_cold int aac_encode_init(AVCod
     s->psypp = ff_psy_preprocess_init(avctx);
     s->coder = &ff_aac_coders[0];
 
+    s->lambda = avctx->global_quality ? avctx->global_quality : 120;
 #if !CONFIG_HARDCODED_TABLES
     for (i = 0; i < 428; i++)
         ff_aac_pow2sf_tab[i] = pow(2, (i - 200)/4.);
@@ -510,7 +511,6 @@ static int aac_encode_frame(AVCodecConte
         samples2 = samples + start_ch;
         la = samples2 + 1024 * avctx->channels + start_ch;
         if(!data) la = NULL;
-        s->lambda = 5e-7f;
         for(j = 0; j < chans; j++){
             IndividualChannelStream *ics = &cpe->ch[j].ics;
             int k;
@@ -566,6 +566,12 @@ static int aac_encode_frame(AVCodecConte
     flush_put_bits(&s->pb);
     avctx->frame_bits = put_bits_count(&s->pb);
 
+    // rate control stuff
+    if(!(avctx->flags & CODEC_FLAG_QSCALE)){
+        float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits;
+        s->lambda *= ratio;
+    }
+
     if(!data)
         s->last_frame = 1;
     memcpy(s->samples, s->samples + 1024 * avctx->channels, 1024 * avctx->channels * sizeof(s->samples[0]));


More information about the FFmpeg-soc mailing list