[MPlayer-cvslog] r31543 - in trunk: libfaad2/decoder.c libfaad2/decoder.h libfaad2/neaacdec.h libmpcodecs/ad_faad.c

cehoyos subversion at mplayerhq.hu
Wed Jun 23 20:44:06 CEST 2010


Author: cehoyos
Date: Wed Jun 23 20:44:06 2010
New Revision: 31543

Log:
Improve LATM recognition.

Patch by Dan Oscarsson,  Dan d Oscarsson a tieto d com

Modified:
   trunk/libfaad2/decoder.c
   trunk/libfaad2/decoder.h
   trunk/libfaad2/neaacdec.h
   trunk/libmpcodecs/ad_faad.c

Modified: trunk/libfaad2/decoder.c
==============================================================================
--- trunk/libfaad2/decoder.c	Wed Jun 23 19:34:19 2010	(r31542)
+++ trunk/libfaad2/decoder.c	Wed Jun 23 20:44:06 2010	(r31543)
@@ -222,7 +222,7 @@ static int latmCheck(latm_header *latm, 
 
 int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer,
                                  uint32_t buffer_size,
-                                 uint32_t *samplerate, uint8_t *channels)
+                                 uint32_t *samplerate, uint8_t *channels, int latm_stream)
 {
     uint32_t bits = 0;
     bitfile ld;
@@ -257,6 +257,9 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDe
                 hDecoder->latm_header_present = 0;
             return x;
         }
+        else if (latm_stream) {
+            return -1;
+        }
         else
         /* Check if an ADIF header is present */
         if ((buffer[0] == 'A') && (buffer[1] == 'D') &&

Modified: trunk/libfaad2/decoder.h
==============================================================================
--- trunk/libfaad2/decoder.h	Wed Jun 23 19:34:19 2010	(r31542)
+++ trunk/libfaad2/decoder.h	Wed Jun 23 20:44:06 2010	(r31543)
@@ -86,7 +86,8 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDe
                                  uint8_t *buffer,
                                  uint32_t buffer_size,
                                  uint32_t *samplerate,
-                                 uint8_t *channels);
+                                 uint8_t *channels,
+                                 int      latm_stream);
 
 /* Init the library using a DecoderSpecificInfo */
 int8_t NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, uint8_t *pBuffer,

Modified: trunk/libfaad2/neaacdec.h
==============================================================================
--- trunk/libfaad2/neaacdec.h	Wed Jun 23 19:34:19 2010	(r31542)
+++ trunk/libfaad2/neaacdec.h	Wed Jun 23 20:44:06 2010	(r31543)
@@ -211,7 +211,8 @@ long NEAACDECAPI NeAACDecInit(NeAACDecHa
                               unsigned char *buffer,
                               unsigned long buffer_size,
                               unsigned long *samplerate,
-                              unsigned char *channels);
+                              unsigned char *channels,
+                              int           latm_stream);
 
 /* Init the library using a DecoderSpecificInfo */
 char NEAACDECAPI NeAACDecInit2(NeAACDecHandle hDecoder, unsigned char *pBuffer,

Modified: trunk/libmpcodecs/ad_faad.c
==============================================================================
--- trunk/libmpcodecs/ad_faad.c	Wed Jun 23 19:34:19 2010	(r31542)
+++ trunk/libmpcodecs/ad_faad.c	Wed Jun 23 20:44:06 2010	(r31543)
@@ -126,6 +126,26 @@ static int init(sh_audio_t *sh)
     faacDecSetConfiguration(faac_hdec, faac_conf);
 
     sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size);
+    /* init the codec, look for LATM */
+    faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
+                            sh->a_in_buffer_len, &faac_samplerate, &faac_channels,1);
+    if (faac_init < 0 && sh->a_in_buffer_len >= 3 && sh->format == mmioFOURCC('M', 'P', '4', 'L')) {
+        // working LATM not found at first try, look further on in stream
+        int i;
+
+        for (i = 0; i < 5; i++) {
+            pos = sh->a_in_buffer_len-3;
+            memmove(sh->a_in_buffer, &(sh->a_in_buffer[pos]), 3);
+            sh->a_in_buffer_len  = 3;
+            sh->a_in_buffer_len += demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
+                                                   sh->a_in_buffer_size - sh->a_in_buffer_len);
+            faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
+                                    sh->a_in_buffer_len, &faac_samplerate, &faac_channels,1);
+            if (faac_init >= 0) break;
+        }
+    }
+
+    if (faac_init < 0) {
     pos = aac_probe(sh->a_in_buffer, sh->a_in_buffer_len);
     if(pos) {
       sh->a_in_buffer_len -= pos;
@@ -138,7 +158,8 @@ static int init(sh_audio_t *sh)
 
     /* init the codec */
     faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
-       sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
+          sh->a_in_buffer_len, &faac_samplerate, &faac_channels,0);
+    }
 
     sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed
     // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi
@@ -189,7 +210,8 @@ static void uninit(sh_audio_t *sh)
 static int aac_sync(sh_audio_t *sh)
 {
   int pos = 0;
-  if(!sh->codecdata_len) {
+  // do not probe LATM, faad does that
+  if(!sh->codecdata_len && sh->format != mmioFOURCC('M', 'P', '4', 'L')) {
     if(sh->a_in_buffer_len < sh->a_in_buffer_size){
       sh->a_in_buffer_len +=
 	demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],


More information about the MPlayer-cvslog mailing list