[FFmpeg-devel] [PATCH] aac: Clip large (legal) PNS/IS values

Alex Converse alex.converse
Sat Oct 10 03:50:30 CEST 2009


On Fri, Oct 9, 2009 at 7:34 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Fri, Oct 09, 2009 at 12:38:17PM -0400, Alex Converse wrote:
>> On Fri, Oct 9, 2009 at 9:37 AM, Robert Swain <robert.swain at gmail.com> wrote:
>> > 2009/10/6 Alex Converse <alex.converse at gmail.com>:
>> >> Large intensity stereo and PNS indices are legal. Clip them instead of
>> >> erroring out. A magnitude of 100 corresponds to 2^25 so the will most
>> >> likely result in clipped output anyway.
>> >>
>> >> None of the conformance streams fall in the range that need to be clipped.
>> >
>> > Looks OK to me as long as it isn't arbitrary clipping but rather
>> > something needed/allowed within and specified by the specification.
>> >
>>
>> The clipping is semi-arbitrary. It was designed such that after the
>> third patch the ranges are the same as regular scalefactors. However
>> these large vales (even when clipped) should cause cause output
>> clipping on any streams that aren't purely academic exercises.
>
> IMHO, either
> A. it can be in a valid stream -> we should support it
> B. it can not be in a valid stream -> error concealment (silence /repeat
> ? last block / something better) should be applied
> cliping seems always wrong (to me) unless mandated by a spec.
> switching between A and B, in the sense of "it could be valid but most
> likely is not, lets ask the user" can be done by using
> AVCodecContext.error_recognition
>

It's a mix between that (the error recognition case) and the fact that
even if you decode it properly there isn't going to be a difference
between clipping and not.

For instance let's look at intensity stereo. If the IS scalefactor is
100, associated then the gain is 2^-25 The only way for the channel
receiving the intensity stereo to get something that doesn't round to
zero is for the source channel to be clipped beyond belief.

If that gain of 2**-25 seems reasonable to you, then consider another
legal IS scalefactor, 512. 512 corresponds to a gain of 2**128. That
is larger than the maximum finite float.

IS scalefactors are coded differentially from 0 with a maximum step of
+/-60 which is another reason why very large values are unlikely.



More information about the ffmpeg-devel mailing list