[FFmpeg-devel] [PATCH 2/2] checkasm: float_dsp: Scale FLT/DBL_EPSILON sufficiently when comparing
Martin Storsjö
martin at martin.st
Tue Dec 10 22:10:40 EET 2019
This fixes the float_dsp checkasm test for some seeds, when built
with clang for mingw/x86_32.
---
tests/checkasm/float_dsp.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tests/checkasm/float_dsp.c b/tests/checkasm/float_dsp.c
index 2abe4eccbd..9f7caa1456 100644
--- a/tests/checkasm/float_dsp.c
+++ b/tests/checkasm/float_dsp.c
@@ -51,7 +51,11 @@ static void test_vector_fmul(const float *src0, const float *src1)
call_ref(cdst, src0, src1, LEN);
call_new(odst, src0, src1, LEN);
for (i = 0; i < LEN; i++) {
- if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) {
+ // EPSILON corresponds to 1 ulp at 1.0, but the output here can be
+ // much larger (the two input values have a stddev of 10), so the
+ // product can be significantly larger.
+ if (!float_near_abs_eps(cdst[i], odst[i],
+ fabsf(cdst[i]) * 2 * FLT_EPSILON)) {
fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
i, cdst[i], odst[i], cdst[i] - odst[i]);
fail();
@@ -73,7 +77,11 @@ static void test_vector_dmul(const double *src0, const double *src1)
call_ref(cdst, src0, src1, LEN);
call_new(odst, src0, src1, LEN);
for (i = 0; i < LEN; i++) {
- if (!double_near_abs_eps(cdst[i], odst[i], DBL_EPSILON)) {
+ // EPSILON corresponds to 1 ulp at 1.0, but the output here can be
+ // much larger (the two input values have a stddev of 10), so the
+ // product can be significantly larger.
+ if (!double_near_abs_eps(cdst[i], odst[i],
+ fabs(cdst[i]) * 2 * DBL_EPSILON)) {
fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
i, cdst[i], odst[i], cdst[i] - odst[i]);
fail();
@@ -117,7 +125,8 @@ static void test_vector_fmul_scalar(const float *src0, const float *src1)
call_ref(cdst, src0, src1[0], LEN);
call_new(odst, src0, src1[0], LEN);
for (i = 0; i < LEN; i++) {
- if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) {
+ if (!float_near_abs_eps(cdst[i], odst[i],
+ fabsf(cdst[i]) * 2 * FLT_EPSILON)) {
fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
i, cdst[i], odst[i], cdst[i] - odst[i]);
fail();
--
2.17.1
More information about the ffmpeg-devel
mailing list