[vlc-devel] commit: Fix aac decoding when muxed with ADTS headers + AudioSpecificConfig ( Rafaël Carré )

git version control git at videolan.org
Fri Mar 14 19:24:42 CET 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Fri Mar 14 19:24:01 2008 +0100| [66eef912955166cb5eaa7d1a6e051c47ace70852]

Fix aac decoding when muxed with ADTS headers + AudioSpecificConfig

When AudioSpecificConfig is available in fmt->i_extra, faad need the ADTS headers removed

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

 modules/codec/faad.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 69100cc..68f3e95 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -220,6 +220,25 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
     if( p_block->i_rate > 0 )
         p_sys->i_input_rate = p_block->i_rate;
 
+    /* Remove ADTS header if we have decoder specific config */
+    if( p_dec->fmt_in.i_extra && p_block->i_buffer > 7 )
+    {
+        if( p_block->p_buffer[0] == 0xff &&
+            ( p_block->p_buffer[1] & 0xf0 ) == 0xf0 ) /* syncword */
+        {   /* ADTS header present */
+            size_t i_header_size; /* 7 bytes (+ 2 bytes for crc) */
+            i_header_size = 7 + ( ( p_block->p_buffer[1] & 0x01 ) ? 0 : 2 );
+            /* FIXME: multiple blocks per frame */
+            if( p_block->i_buffer > i_header_size )
+            {
+                memcpy( p_block->p_buffer,
+                        p_block->p_buffer + i_header_size,
+                        p_block->i_buffer - i_header_size );
+                p_block->i_buffer -= i_header_size;
+            }
+        }
+    }
+
     /* Append the block to the temporary buffer */
     if( p_sys->i_buffer_size < p_sys->i_buffer + p_block->i_buffer )
     {




More information about the vlc-devel mailing list