[FFmpeg-devel] [PATCH] configure, avutil/libm: add fmax, fmaxf, fmin, fminf support

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Oct 15 17:29:56 CEST 2015


On Thu, Oct 15, 2015 at 11:12 AM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Thu, Oct 15, 2015 at 10:18 AM, Hendrik Leppkes <h.leppkes at gmail.com> wrote:
>> On Thu, Oct 15, 2015 at 4:04 PM, Derek Buitenhuis
>> <derek.buitenhuis at gmail.com> wrote:
>>> On 10/15/2015 1:18 PM, Ganesh Ajjanagadde wrote:
>>>> It has been demonstrated that using libc provided floating point
>>>> functions is beneficial, in the context of fabs() vs FFABS.
>>>>
>>>> Unfortunately, MSVC 2012 (and earlier) lack the ISO C99 fmax, fmaxf,
>>>> fmin, fminf functions. This patch adds them, thus making their usage in
>>>> FFmpeg safe.
>>>
>>> We previously had at least fmin emulation in libm.h, but it
>>> caused problems on some systems and was removed.
>>>
>>> Carl and Michael should remember.
>>
>> See 4436a8f44dedc83767b3d9da9beb85d1fae2ca30
>
> Thanks for the reference, patch dropped.
> -ffinite-math (and some other floating point optimizations) look
> interesting and could be useful in libavfilter. I will look at this a
> little more carefully.
>
> Of course, we should never enable associative optimizations - that
> would be bad from an accuracy standpoint.

Did some digging - I don't think any of these are a good idea. For
instance, avfilter can deal with essentially untrusted audio. I also
assume that there exists an audio format whose samples are inherently
floating point and not the standard 8/16 bit pcm etc. In such a
scenario, we want a filter to do something that makes more
mathematical sense. Any of these optimizations cause one or the other
mathematical issue to happen.

In fact, getting fmin or fmax to work might be useful from a
non-performance standpoint, just to make the result make more sense
when NaN is signalled. For instance, consider the -volumedetect
filter. A single NaN (e.g in the input file, or after another filter
in a filtergraph) could clobber the peak detection. How to get them to
work while not breaking stuff as noticed in commit
4436a8f44dedc83767b3d9da9beb85d1fae2ca30 is a trickier question. Any
ideas?

>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list