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

Alex Converse alex.converse
Wed May 19 08:13:09 CEST 2010


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 :/

> [...]
>> +static int chomp_filter(AVBitStreamFilterContext *bsfc,
>> + ? ? ? ? ? ? ? ? ? ? ? ?AVCodecContext *avctx, const char *args,
>> + ? ? ? ? ? ? ? ? ? ? ? ?uint8_t ?**poutbuf, int *poutbuf_size,
>> + ? ? ? ? ? ? ? ? ? ? ? ?const uint8_t *buf, int ? ? ?buf_size,
>> + ? ? ? ? ? ? ? ? ? ? ? ?int keyframe)
>> +{
>> + ? ?int i = buf_size;
>> + ? ?while (i > 0 && !buf[i-1])
>> + ? ? ? ?i--;
>> +
>> + ? ?*poutbuf = (uint8_t*) buf;
>> + ? ?*poutbuf_size = i;
>
> you dont need i, buf_size should do

Fixed (locally)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-aac_decode_frame-consume-zero-padding-at-the-en.patch
Type: text/x-patch
Size: 1666 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100519/3380297a/attachment.bin>



More information about the ffmpeg-devel mailing list