Mercurial > mplayer.hg
changeset 6894:a32870fd043b
support for packetized aac streams (used in .mp4 files)
author | arpi |
---|---|
date | Sun, 04 Aug 2002 15:33:41 +0000 |
parents | c46a092020e2 |
children | e0fa2a6a8843 |
files | libmpcodecs/ad_faad.c |
diffstat | 1 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/ad_faad.c Sun Aug 04 13:52:24 2002 +0000 +++ b/libmpcodecs/ad_faad.c Sun Aug 04 15:33:41 2002 +0000 @@ -50,8 +50,6 @@ int faac_init; faac_hdec = faacDecOpen(); - sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size); - // If we don't get the ES descriptor, try manual config if(!sh->codecdata_len) { #if 1 @@ -84,10 +82,14 @@ faacDecSetConfiguration(faac_hdec, faac_conf); #endif + sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size); + /* init the codec */ faac_init = faacDecInit(faac_hdec, sh->a_in_buffer, &faac_samplerate, &faac_channels); + 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 } else { // We have ES DS in codecdata /*int i; @@ -143,7 +145,9 @@ void *faac_sample_buffer; while(len < minlen) { - /* update buffer */ + + /* update buffer for raw aac streams: */ + if(!sh->codecdata_len) 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], @@ -156,7 +160,10 @@ printf ("%02X ", sh->a_in_buffer[i]); printf ("\n");} #endif - do { + + if(!sh->codecdata_len){ + // raw aac stream: + do { faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer+j); /* update buffer index after faacDecDecode */ if(faac_finfo.bytesconsumed >= sh->a_in_buffer_len) { @@ -171,8 +178,16 @@ j++; } else break; - } while(j < FAAD_BUFFLEN); - + } while(j < FAAD_BUFFLEN); + } else { + // packetized (.mp4) aac stream: + unsigned char* bufptr=NULL; + int buflen=ds_get_packet(sh->ds, &bufptr); + if(buflen<=0) break; + faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr); +// printf("FAAC decoded %d of %d (err: %d) \n",faac_finfo.bytesconsumed,buflen,faac_finfo.error); + } + if(faac_finfo.error > 0) { mp_msg(MSGT_DECAUDIO,MSGL_WARN,"FAAD: Failed to decode frame: %s \n", faacDecGetErrorMessage(faac_finfo.error));