[MPlayer-dev-eng] [PATCH] latm faad handling
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Wed Jun 23 18:43:21 CEST 2010
On Wed, Jun 23, 2010 at 04:28:08PM +0200, Dan Oscarsson wrote:
> --- libmpcodecs/ad_faad.c.org 2010-06-12 17:25:38.999522927 +0200
> +++ libmpcodecs/ad_faad.c 2010-06-23 16:21:09.499616544 +0200
> @@ -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],
> --- libfaad2/decoder.c.org 2010-06-12 17:25:44.551522935 +0200
> +++ libfaad2/decoder.c 2010-06-12 17:26:28.402526157 +0200
> @@ -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') &&
> --- libfaad2/neaacdec.h.org 2010-06-12 17:25:50.023648076 +0200
> +++ libfaad2/neaacdec.h 2010-06-12 17:26:28.430527529 +0200
> @@ -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,
> --- libfaad2/decoder.h.org 2010-06-12 17:25:54.536522999 +0200
> +++ libfaad2/decoder.h 2010-06-12 17:26:28.430527529 +0200
> @@ -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,
Whoever can test it, feel free to apply...
> --- etc/codecs.conf.org 2010-06-12 17:26:03.576523024 +0200
> +++ etc/codecs.conf 2010-06-12 17:26:28.436522599 +0200
> @@ -4017,7 +4017,7 @@
> audiocodec faad
> info "FAAD AAC (MPEG-2/MPEG-4 Audio)"
> status working
> - fourcc mp4a,MP4A
> + fourcc mp4a,MP4A,MP4L
> fourcc "VLB " ; Used in NSV, not really working
> fourcc "AAC " ; Used in NSV
> fourcc "AACP" ; Used in NSV for AACPlus
This is already in SVN...
More information about the MPlayer-dev-eng
mailing list