changeset 11393:d23864bc3887 libavcodec

AAC: Set codec parameters in the first frame rather than in .init()
author alexc
date Sun, 07 Mar 2010 23:46:40 +0000
parents 384d803faff4
children 9a171a2c04d9
files aac.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/aac.c	Sun Mar 07 21:56:45 2010 +0000
+++ b/aac.c	Sun Mar 07 23:46:40 2010 +0000
@@ -509,17 +509,14 @@
     int i;
 
     ac->avccontext = avccontext;
+    ac->m4ac.sample_rate = avccontext->sample_rate;
 
     if (avccontext->extradata_size > 0) {
         if (decode_audio_specific_config(ac, avccontext->extradata, avccontext->extradata_size))
             return -1;
-        avccontext->sample_rate = ac->m4ac.sample_rate;
-    } else if (avccontext->channels > 0) {
-        ac->m4ac.sample_rate = avccontext->sample_rate;
     }
 
     avccontext->sample_fmt = SAMPLE_FMT_S16;
-    avccontext->frame_size = 1024;
 
     AAC_INIT_VLC_STATIC( 0, 304);
     AAC_INIT_VLC_STATIC( 1, 270);
@@ -1950,6 +1947,7 @@
     enum RawDataBlockType elem_type;
     int err, elem_id, data_size_tmp;
     int buf_consumed;
+    int samples = 1024, multiplier;
 
     init_get_bits(&gb, buf, buf_size * 8);
 
@@ -2036,6 +2034,13 @@
 
     spectral_to_sample(ac);
 
+    multiplier = 1;
+    samples <<= multiplier;
+    if (ac->output_configured < OC_LOCKED) {
+        avccontext->sample_rate = ac->m4ac.sample_rate << multiplier;
+        avccontext->frame_size = samples;
+    }
+
     data_size_tmp = 1024 * avccontext->channels * sizeof(int16_t);
     if (*data_size < data_size_tmp) {
         av_log(avccontext, AV_LOG_ERROR,