X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=tests%2Fcheckasm%2Fcheckasm.c;h=7f2cf8ef30ad55711236c47be60651c115a5b724;hb=9507f68deb664c19aceddcf1451f7237aae919c3;hp=3548bb33b500be8146c852bd9125d1c2a6233ca8;hpb=5f2d12b82494220f2fa65bd3295617e09ef25cad;p=ffmpeg diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 3548bb33b50..7f2cf8ef30a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -27,6 +27,7 @@ #include "checkasm.h" #include "libavutil/common.h" #include "libavutil/cpu.h" +#include "libavutil/intfloat.h" #include "libavutil/random_seed.h" #if HAVE_IO_H @@ -64,9 +65,16 @@ static const struct { #if CONFIG_BSWAPDSP { "bswapdsp", checkasm_check_bswapdsp }, #endif + #if CONFIG_DCA_DECODER + { "dcadsp", checkasm_check_dcadsp }, + { "synth_filter", checkasm_check_synth_filter }, + #endif #if CONFIG_FLACDSP { "flacdsp", checkasm_check_flacdsp }, #endif + #if CONFIG_FMTCONVERT + { "fmtconvert", checkasm_check_fmtconvert }, + #endif #if CONFIG_H264PRED { "h264pred", checkasm_check_h264pred }, #endif @@ -103,6 +111,7 @@ static const struct { { "ARMV6", "armv6", AV_CPU_FLAG_ARMV6 }, { "ARMV6T2", "armv6t2", AV_CPU_FLAG_ARMV6T2 }, { "VFP", "vfp", AV_CPU_FLAG_VFP }, + { "VFP_VM", "vfp_vm", AV_CPU_FLAG_VFP_VM }, { "VFPV3", "vfp3", AV_CPU_FLAG_VFPV3 }, { "NEON", "neon", AV_CPU_FLAG_NEON }, #elif ARCH_PPC @@ -165,6 +174,78 @@ static struct { /* PRNG state */ AVLFG checkasm_lfg; +/* float compare support code */ +static int is_negative(union av_intfloat32 u) +{ + return u.i >> 31; +} + +int float_near_ulp(float a, float b, unsigned max_ulp) +{ + union av_intfloat32 x, y; + + x.f = a; + y.f = b; + + if (is_negative(x) != is_negative(y)) { + // handle -0.0 == +0.0 + return a == b; + } + + if (abs(x.i - y.i) <= max_ulp) + return 1; + + return 0; +} + +int float_near_ulp_array(const float *a, const float *b, unsigned max_ulp, + unsigned len) +{ + unsigned i; + + for (i = 0; i < len; i++) { + if (!float_near_ulp(a[i], b[i], max_ulp)) + return 0; + } + return 1; +} + +int float_near_abs_eps(float a, float b, float eps) +{ + float abs_diff = fabsf(a - b); + + return abs_diff < eps; +} + +int float_near_abs_eps_array(const float *a, const float *b, float eps, + unsigned len) +{ + unsigned i; + + for (i = 0; i < len; i++) { + if (!float_near_abs_eps(a[i], b[i], eps)) + return 0; + } + return 1; +} + +int float_near_abs_eps_ulp(float a, float b, float eps, unsigned max_ulp) +{ + return float_near_ulp(a, b, max_ulp) || float_near_abs_eps(a, b, eps); +} + +int float_near_abs_eps_array_ulp(const float *a, const float *b, float eps, + unsigned max_ulp, unsigned len) +{ + unsigned i; + + for (i = 0; i < len; i++) { + if (!float_near_abs_eps_ulp(a[i], b[i], eps, max_ulp)) + return 0; + } + return 1; +} + /* Print colored text to stderr if the terminal supports it */ static void color_printf(int color, const char *fmt, ...) {