[MPlayer-dev-eng] [PATCH] latm faad handling
Dan Oscarsson
Dan.Oscarsson at tieto.com
Wed Jun 23 16:28:08 CEST 2010
On 2010-06-21 at 18:48 +0200 Reimar Döffinger wrote:
> > --- libmpcodecs/ad_faad.c.org 2010-06-12 17:25:38.999522927 +0200
> > +++ libmpcodecs/ad_faad.c 2010-06-21 18:00:21.204759059 +0200
> > @@ -126,6 +126,27 @@
> > 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->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 && sh->a_in_buffer_len >= 3; 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 >= 3 should always be true except possibly during the first iteration,
> so this check can go into the first if (though it might actually be better to call demux_read_data
> in a loop untile we get enough data, and I really suspect 3 bytes are not enough for faacDecInit
> in general...)
Test moved to if statement. As I do not know minimum required data and I
expect demux_read normally would fill buffer, I have not changed reading
of data.
>
> > + 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);
>
> This may cause an endless loop if demux_read_data always returns 0 due to reaching eof.
For loop limits this, so it is no endless loop.
>
> > + pos = 0;
>
> Setting this to 0 inside the loop seems pointless...
Removed.
Attached is updated patch.
Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: faad-latm2.diff
Type: text/x-patch
Size: 4568 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20100623/f5256c18/attachment.bin>
More information about the MPlayer-dev-eng
mailing list