[FFmpeg-devel] [PATCH 1/2] avutil/common: add av_rint64_clip

Ganesh Ajjanagadde gajjanagadde at gmail.com
Fri Nov 13 13:40:50 CET 2015


On Fri, Nov 13, 2015 at 7:05 AM, Pedro Arthur <bygrandao at gmail.com> wrote:
>
>> +static av_always_inline av_const int64_t av_rint64_clip_c(double a,
>> int64_t amin, int64_t amax)
>> +{
>> +#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >=
>> 2
>> +    if (amin > amax) abort();
>> +#endif
>> +    // INT64_MAX+1,INT64_MIN are exactly representable as IEEE doubles
>> +    if (a >= 9223372036854775808.0)
>> +        return INT64_MAX;
>> +    if (a <= INT64_MIN)
>> +        return INT64_MIN;
>> +    // Finally safe to call av_clipd_c
>> +    return (int64_t)av_clipd_c(a, amin, amax);
>> +}
>
>
> If I use av_rint64_clip_c(INT64_MAX+2, 0, 10) this function will return
> INT64_MAX instead of 10. Is that the intended behavior?

Not at all, thanks for this. Fixed locally by placing some FFMIN, FFMAX.

>


More information about the ffmpeg-devel mailing list