[FFmpeg-devel] [RFC/PATCH] Dealing with 0 padded audio packets

Michael Niedermayer michaelni
Wed May 19 15:54:51 CEST 2010


On Wed, May 19, 2010 at 02:13:09AM -0400, Alex Converse wrote:
> On Tue, May 18, 2010 at 8:06 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Tue, May 18, 2010 at 06:16:35PM -0400, Alex Converse wrote:
> >> Currently the FFmpeg stumbles when decoding AAC where the container
> >> has zero padded audio frames to make a constant packet size. This
> >> situation is common for AAC in ASF[1] and WMP handles it fine.
> >> QuickTime seems to handle the MP4 analog fine.
> >>
> >> The best idea I can come up with is a chomp[2] bitstream filter to
> >> trim these when remuxing and to make the AAC decoder consume the rest
> >> of a packet if it is all zero.
> >>
> >> Other ideas are welcome.
> >
> > i wish i had a better idea, but i dont.
> > no real objections from me on this, just 2 nitpicks below
> >
> >
> > [...]
> >>
> >> @@ -2065,6 +2066,12 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data,
> >> ? ? ? ? ?ac->output_configured = OC_LOCKED;
> >>
> >> ? ? ?buf_consumed = (get_bits_count(&gb) + 7) >> 3;
> >> + ? ?i = buf_consumed;
> >> + ? ?while (i < buf_size && !buf[i])
> >> + ? ? ? ?i++;
> >> + ? ?if (i == buf_size)
> >> + ? ? ? ?buf_consumed = buf_size;
> >> +
> >> ? ? ?return buf_size > buf_consumed ? buf_consumed : buf_size;
> >
> > this can be done less convoluted i think
> 
> Is [attached] any better? It's the same length :/
[...]
> @@ -2065,6 +2066,12 @@ static int aac_decode_frame(AVCodecContext *avccontext, void *data,
>          ac->output_configured = OC_LOCKED;
>  
>      buf_consumed = (get_bits_count(&gb) + 7) >> 3;
> +    for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
> +        if (!buf[buf_offset])
> +            break;
> +    if (buf_offset == buf_size)
> +        buf_consumed = buf_size;
> +
>      return buf_size > buf_consumed ? buf_consumed : buf_size;

i was thinking of:

for (buf_offset = buf_consumed; buf_offset < buf_size; buf_offset++)
    if (!buf[buf_offset])
        break;

return buf_size > buf_offset ? buf_consumed : buf_size;

or even

for (; buf_consumed < buf_size; buf_consumed++)
    if (!buf[buf_consumed])
        break;

return buf_size > buf_consumed ? buf_consumed : buf_size;


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100519/dd12bc0e/attachment.pgp>



More information about the ffmpeg-devel mailing list