mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
ad_faad: Improve LATM recognition
Patch by Dan Oscarsson, Dan d Oscarsson a tieto d com git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31543 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
c795508d5f
commit
f455b6e91b
@ -222,7 +222,7 @@ static int latmCheck(latm_header *latm, bitfile *ld)
|
||||
|
||||
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(NeAACDecHandle hDecoder, uint8_t *buffer,
|
||||
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') &&
|
||||
|
@ -86,7 +86,8 @@ int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
|
||||
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,
|
||||
|
@ -211,7 +211,8 @@ long NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder,
|
||||
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,
|
||||
|
@ -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],
|
||||
|
Loading…
Reference in New Issue
Block a user