[vlc-commits] commit: AVCodec : Allow delayed opening of audio codecs. (Jai Menon )

git at videolan.org git at videolan.org
Mon Aug 9 23:08:32 CEST 2010


vlc | branch: master | Jai Menon <jmenon86 at gmail.com> | Thu Aug  5 16:36:18 2010 +0530| [49b3b98b18b9a082c561b26f487789e7b8b305ee] | committer: Jean-Baptiste Kempf 

AVCodec : Allow delayed opening of audio codecs.

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.

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=49b3b98b18b9a082c561b26f487789e7b8b305ee
---

 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 9b54976..a09be39 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 );



More information about the vlc-commits mailing list