[FFmpeg-devel] [PATCHv2] avutil/libm: correct isnan, isinf compat hacks

Ganesh Ajjanagadde gajjanag at mit.edu
Sat Nov 21 14:53:28 CET 2015

On Wed, Nov 18, 2015 at 3:04 PM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
> On Wed, Nov 18, 2015 at 2:58 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> On Tue, Nov 17, 2015 at 04:54:10PM -0500, Ganesh Ajjanagadde wrote:
>>> isnan and isinf are actually macros as per the standard. In particular,
>>> the existing implementation has incorrect signature. Furthermore, this
>>> results in undefined behavior for e.g double values outside float range
>>> as per the standard.
>>> This patch corrects the undefined behavior for all usage within FFmpeg.
>>> Note that long double is not handled as it is not used in FFmpeg.
>>> Furthermore, even if at some point long double gets used, it is likely
>>> not needed to modify the macro in practice for usage in FFmpeg. See
>>> below for analysis.
>>> Getting long double to work strictly per the spec is significantly harder
>>> since a long double may be an IEEE 128 bit quad (very rare), 80 bit
>>> extended precision value (on GCC/Clang), or simply double (on recent Microsoft).
>>> On the other hand, any potential future usage of long double is likely
>>> for precision (when a platform offers extra precision) and not for range, since
>>> the range anyway varies and is not as portable as IEEE 754 single/double
>>> precision. In such cases, the implicit cast to a double is well defined
>>> and isinf and isnan should work as intended.
>>> Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
>>> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>>> ---
>>>  libavutil/libm.h | 34 ++++++++++++++++++++++++++++++++--
>>>  1 file changed, 32 insertions(+), 2 deletions(-)
>> probably ok
>> maybe wait a day or 2 before pushing so people can test it on more
>> obscure platforms
>> thx
> ok, will wait for 2 days for the hypot hack as well. Thanks.

pushed, thanks

>> [...]
>> --
>> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>> I do not agree with what you have to say, but I'll defend to the death your
>> right to say it. -- Voltaire
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

More information about the ffmpeg-devel mailing list