[vlc-devel] [PATCH 3/3] AVCodec : Allow delayed opening of audio codecs.

Jai Menon jmenon86 at gmail.com
Thu Aug 5 10:33:28 CEST 2010


Additionally, enable delayed opening for AAC which fixes decoding
of media where we rely on decoder configuration being supplied by
the packetizer instead of the container.
---
 modules/codec/avcodec/audio.c   |   15 ++++++++++++++-
 modules/codec/avcodec/avcodec.c |    3 ++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/modules/codec/avcodec/audio.c b/modules/codec/avcodec/audio.c
index 483c306..8e35ffa 100644
--- a/modules/codec/avcodec/audio.c
+++ b/modules/codec/avcodec/audio.c
@@ -159,7 +159,7 @@ int InitAudioDec( decoder_t *p_dec, AVCodecContext *p_context,
     p_sys->p_codec = p_codec;
     p_sys->i_codec_id = i_codec_id;
     p_sys->psz_namecodec = psz_namecodec;
-    p_sys->b_delayed_open = false;
+    p_sys->b_delayed_open = true;
 
     // Initialize decoder extradata
     InitDecoderConfig( p_dec, p_context);
@@ -265,6 +265,19 @@ aout_buffer_t * DecodeAudio ( decoder_t *p_dec, block_t **pp_block )
 
     p_block = *pp_block;
 
+    if( !p_sys->p_context->extradata_size && p_dec->fmt_in.i_extra &&
+        p_sys->b_delayed_open)
+    {
+        InitDecoderConfig( p_dec, p_sys->p_context);
+        if( ffmpeg_OpenCodec( p_dec ) )
+            msg_Err( p_dec, "Cannot open decoder %s", p_sys->psz_namecodec );
+    }
+    if( p_sys->b_delayed_open )
+    {
+        block_Release( p_block );
+        return NULL;
+    }
+
     if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )
     {
         block_Release( p_block );
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 0f64690..be82f75 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -409,7 +409,8 @@ int ffmpeg_OpenCodec( decoder_t *p_dec )
     {
         if( p_sys->i_codec_id == CODEC_ID_VC1 ||
             p_sys->i_codec_id == CODEC_ID_VORBIS ||
-            p_sys->i_codec_id == CODEC_ID_THEORA )
+            p_sys->i_codec_id == CODEC_ID_THEORA ||
+            p_sys->i_codec_id == CODEC_ID_AAC )
         {
             msg_Warn( p_dec, "waiting for extra data for codec %s",
                       p_sys->psz_namecodec );
-- 
1.7.1.1




More information about the vlc-devel mailing list