]> git.sesse.net Git - vlc/commitdiff
* src/input/decoder.c, modules/codec/faad.c: work around another bug in libfaad with...
authorGildas Bazin <gbazin@videolan.org>
Tue, 7 Sep 2004 09:34:03 +0000 (09:34 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 7 Sep 2004 09:34:03 +0000 (09:34 +0000)
modules/codec/faad.c
src/input/decoder.c

index e5a71f762b8d2125621b678d61bb840abc850ab8..806943f5b2fa5fce7472f4c31e7fd9c8f8c066fa 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *          Gildas Bazin <gbazin@netcourrier.com>
+ *          Gildas Bazin <gbazin@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -200,6 +200,22 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         p_block->i_buffer = 0;
     }
 
+    if( p_dec->fmt_out.audio.i_rate == 0 && p_dec->fmt_in.i_extra > 0 )
+    {
+        /* We have a decoder config so init the handle */
+        unsigned long i_rate;
+        unsigned char i_channels;
+
+        if( faacDecInit2( p_sys->hfaad, p_dec->fmt_in.p_extra,
+                          p_dec->fmt_in.i_extra,
+                          &i_rate, &i_channels ) >= 0 )
+        {
+            p_dec->fmt_out.audio.i_rate = i_rate;
+            p_dec->fmt_out.audio.i_channels = i_channels;
+            aout_DateInit( &p_sys->date, i_rate );
+        }
+    }
+
     if( p_dec->fmt_out.audio.i_rate == 0 && p_sys->i_buffer )
     {
         unsigned long i_rate;
@@ -308,6 +324,13 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                     break;
                 }
             }
+
+            if( j == MAX_CHANNEL_POSITIONS )
+            {
+                msg_Warn( p_dec, "unknow channel ordering" );
+                block_Release( p_block );
+                return NULL;
+            }
         }
         p_dec->fmt_out.audio.i_original_channels =
             p_dec->fmt_out.audio.i_physical_channels;
index 3eee0e8fecd121037cc88fd7f05d3b35ce0c7b74..0cd2a9330e3f23c3a066d74941f16343582d2e5e 100644 (file)
@@ -589,6 +589,15 @@ static int DecoderDecode( decoder_t *p_dec, block_t *p_block )
             while( (p_packetized_block =
                     p_packetizer->pf_packetize( p_packetizer, &p_block )) )
             {
+                if( p_packetizer->fmt_out.i_extra && !p_dec->fmt_in.i_extra )
+                {
+                    p_dec->fmt_in.i_extra = p_packetizer->fmt_out.i_extra;
+                    p_dec->fmt_in.p_extra = malloc( p_dec->fmt_in.i_extra );
+                    memcpy( p_dec->fmt_in.p_extra,
+                            p_packetizer->fmt_out.p_extra,
+                            p_dec->fmt_in.i_extra );
+                }
+
                 while( p_packetized_block )
                 {
                     block_t *p_next = p_packetized_block->p_next;