Mercurial > mplayer.hg
changeset 31477:86888a4c406e
Improve LATM recognition.
Patch by Dan Oscarsson, Dan d Oscarsson a tieto d com
author | cehoyos |
---|---|
date | Wed, 23 Jun 2010 18:44:06 +0000 |
parents | d7ef415c30fa |
children | bd0f47e100f8 |
files | libfaad2/decoder.c libfaad2/decoder.h libfaad2/neaacdec.h libmpcodecs/ad_faad.c |
diffstat | 4 files changed, 32 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libfaad2/decoder.c Wed Jun 23 17:34:19 2010 +0000 +++ b/libfaad2/decoder.c Wed Jun 23 18:44:06 2010 +0000 @@ -222,7 +222,7 @@ 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 @@ 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') &&
--- a/libfaad2/decoder.h Wed Jun 23 17:34:19 2010 +0000 +++ b/libfaad2/decoder.h Wed Jun 23 18:44:06 2010 +0000 @@ -86,7 +86,8 @@ 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,
--- a/libfaad2/neaacdec.h Wed Jun 23 17:34:19 2010 +0000 +++ b/libfaad2/neaacdec.h Wed Jun 23 18:44:06 2010 +0000 @@ -211,7 +211,8 @@ 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,
--- a/libmpcodecs/ad_faad.c Wed Jun 23 17:34:19 2010 +0000 +++ b/libmpcodecs/ad_faad.c Wed Jun 23 18:44:06 2010 +0000 @@ -126,6 +126,26 @@ 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 @@ /* 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 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],