Martin Storsjö <[email protected]> writes:

> ---
>  configure        |    4 ++++
>  libavutil/libm.h |   21 +++++++++++++++++++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/configure b/configure
> index d3795e4..0f85f9a 100755
> --- a/configure
> +++ b/configure
> @@ -1095,6 +1095,8 @@ HAVE_LIST="
>      inline_asm
>      io_h
>      isatty
> +    isinf
> +    isnan
>      jack_port_get_latency_range
>      ldbrx
>      libdc1394_1
> @@ -2926,6 +2928,8 @@ enabled vaapi && require vaapi va/va.h vaInitialize -lva
>  check_mathfunc cbrtf
>  check_mathfunc exp2
>  check_mathfunc exp2f
> +check_mathfunc isnan
> +check_mathfunc isinf
>  check_mathfunc llrint
>  check_mathfunc llrintf
>  check_mathfunc log2
> diff --git a/libavutil/libm.h b/libavutil/libm.h
> index b6d8a94..49d26f0 100644
> --- a/libavutil/libm.h
> +++ b/libavutil/libm.h
> @@ -27,6 +27,7 @@
>  #include <math.h>
>  #include "config.h"
>  #include "attributes.h"
> +#include "intfloat.h"
>
>  #if !HAVE_CBRTF
>  static av_always_inline float cbrtf(float x)
> @@ -45,6 +46,26 @@ static av_always_inline float cbrtf(float x)
>  #define exp2f(x) ((float)exp2(x))
>  #endif /* HAVE_EXP2F */
>
> +#if !HAVE_ISNAN
> +static av_always_inline av_const int isnan(double x)
> +{
> +    uint64_t v = av_double2int(x);
> +    if ((v & UINT64_C(0x7ff0000000000000)) != UINT64_C(0x7ff0000000000000))
> +        return 0;
> +    return (v & UINT64_C(0x000fffffffffffff)) != 0;
> +}
> +#endif /* HAVE_ISNAN */
> +
> +#if !HAVE_ISINF
> +static av_always_inline av_const int isinf(double x)
> +{
> +    uint64_t v = av_double2int(x);
> +    if ((v & UINT64_C(0x7ff0000000000000)) != UINT64_C(0x7ff0000000000000))
> +        return 0;
> +    return !(v & UINT64_C(0x000fffffffffffff));
> +}
> +#endif /* HAVE_ISINF */

There is no need to use doubles here.  A double-precision inf or nan
converted to float will still be an inf/nan.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to