[FFmpeg-devel] [PATCH 3/4] softfloat: fix av_add_sf if one argument is zero

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sun Nov 8 15:01:29 CET 2015


On 08.11.2015 00:54, Michael Niedermayer wrote:
> On Sun, Nov 08, 2015 at 12:08:54AM +0100, Andreas Cadhalpun wrote:
>> Otherwise (0x20000000, 1) + (0, 33) gives (0, 33), i.e. 1 + 0 = 0.
>>
>> This fixes a division by zero in the aac_fixed decoder.
>>
>> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
>> ---
>>  libavutil/softfloat.h | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
>> index e87cbf4..fefde8c 100644
>> --- a/libavutil/softfloat.h
>> +++ b/libavutil/softfloat.h
>> @@ -130,7 +130,9 @@ static inline av_const int av_gt_sf(SoftFloat a, SoftFloat b)
>>  
>>  static inline av_const SoftFloat av_add_sf(SoftFloat a, SoftFloat b){
>>      int t= a.exp - b.exp;
>> -    if      (t <-31) return b;
>> +    if      (a.mant == 0) return b;
>> +    else if (b.mant == 0) return a;
> 
> this looks strange
> 0 should probably have the minimum exponent not 33

Probably it should, but before commits a66b243 and dcf1cf5 it hadn't.

> now if you want to support denormalized numbers, that is ones that
> have exponents larger than needed then this patch is not sufficient
> the same problem would arrise with non 0 mantisses too if their
> exponents arent minimal

I don't really want to support denormalized numbers, it just shouldn't
crash. Your fixes are fine, patch dropped.

Best regards,
Andreas



More information about the ffmpeg-devel mailing list