[FFmpeg-devel,V2,2/2] checkasm/vf_gblur: add test for horiz_slice simd

Submitted by Ruiling Song on June 4, 2019, 8:42 a.m.

Details

Message ID 20190604084209.26860-2-ruiling.song@intel.com
State New
Headers show

Commit Message

Ruiling Song June 4, 2019, 8:42 a.m.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/vf_gblur.c | 67 +++++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 73 insertions(+)
 create mode 100644 tests/checkasm/vf_gblur.c

Comments

Michael Niedermayer June 4, 2019, 8:15 p.m.
On Tue, Jun 04, 2019 at 04:42:09PM +0800, Ruiling Song wrote:
> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> ---
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 ++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/vf_gblur.c | 67 +++++++++++++++++++++++++++++++++++++++
>  tests/fate/checkasm.mak   |  1 +
>  5 files changed, 73 insertions(+)
>  create mode 100644 tests/checkasm/vf_gblur.c

this fails here: (ubuntu x86-64)

Test checkasm-vf_gblur failed. Look at tests/data/fate/checkasm-vf_gblur.err for details.
checkasm: using random seed 1608403213
test failed comparing 258.619 with 212.24 (abs diff=46.3793 with EPS=0.01)
SSE4.1:
   horiz_slice_sse4 (vf_gblur.c:60)
 - vf_gblur.horiz_slice [FAILED]
checkasm: 1 of 1 tests have failed
make: *** [fate-checkasm-vf_gblur] Error 1



[...]
Ruiling Song June 5, 2019, 2:40 p.m.
> -----Original Message-----
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Wednesday, June 5, 2019 4:16 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH V2 2/2] checkasm/vf_gblur: add test for
> horiz_slice simd
> 
> On Tue, Jun 04, 2019 at 04:42:09PM +0800, Ruiling Song wrote:
> > Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> > ---
> >  tests/checkasm/Makefile   |  1 +
> >  tests/checkasm/checkasm.c |  3 ++
> >  tests/checkasm/checkasm.h |  1 +
> >  tests/checkasm/vf_gblur.c | 67
> +++++++++++++++++++++++++++++++++++++++
> >  tests/fate/checkasm.mak   |  1 +
> >  5 files changed, 73 insertions(+)
> >  create mode 100644 tests/checkasm/vf_gblur.c
> 
> this fails here: (ubuntu x86-64)
> 
> Test checkasm-vf_gblur failed. Look at tests/data/fate/checkasm-
> vf_gblur.err for details.
> checkasm: using random seed 1608403213
> test failed comparing 258.619 with 212.24 (abs diff=46.3793 with EPS=0.01)
> SSE4.1:
>    horiz_slice_sse4 (vf_gblur.c:60)
>  - vf_gblur.horiz_slice [FAILED]
> checkasm: 1 of 1 tests have failed
> make: *** [fate-checkasm-vf_gblur] Error 1
Hi Michael,

Thanks so much for testing. I tried on three different hardware with Ubuntu 18.04, and failed to reproduce the issue. It's really strange:(
But I reproduce a failure on WIN64. the root-cause of the bug is I missed the important fact that the 'int' parameter was passed in using lower 32bit of the 64bit register. The upper 32bit may have garbage.
I have fixed the issue in V3. Hope it can solve the issue you met. Please help take a test when you have time.
If it cannot fix your issue, please help share me your CPU info, Ubuntu version, gcc version, and nasm/yasm version. Thanks so much!

Thanks!
Ruiling
> 
> 
> 
> [...]
> --
> Michael     GnuPG fingerprint:
> 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> You can kill me, but you cannot change the truth.

Patch hide | download patch | download mbox

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 886ae33167..f5780eedb2 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -35,6 +35,7 @@  CHECKASMOBJS-$(CONFIG_AVCODEC)          += $(AVCODECOBJS-yes)
 AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
 AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
 AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
+AVFILTEROBJS-$(CONFIG_GBLUR_FILTER)      += vf_gblur.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)      += vf_hflip.o
 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o
 AVFILTEROBJS-$(CONFIG_NLMEANS_FILTER)    += vf_nlmeans.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index bf51e00eab..3e2ec377be 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -162,6 +162,9 @@  static const struct {
     #if CONFIG_COLORSPACE_FILTER
         { "vf_colorspace", checkasm_check_colorspace },
     #endif
+    #if CONFIG_GBLUR_FILTER
+        { "vf_gblur", checkasm_check_vf_gblur },
+    #endif
     #if CONFIG_HFLIP_FILTER
         { "vf_hflip", checkasm_check_vf_hflip },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 9b8d2f5419..aed15b5fa4 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -71,6 +71,7 @@  void checkasm_check_sw_rgb(void);
 void checkasm_check_utvideodsp(void);
 void checkasm_check_v210dec(void);
 void checkasm_check_v210enc(void);
+void checkasm_check_vf_gblur(void);
 void checkasm_check_vf_hflip(void);
 void checkasm_check_vf_threshold(void);
 void checkasm_check_vp8dsp(void);
diff --git a/tests/checkasm/vf_gblur.c b/tests/checkasm/vf_gblur.c
new file mode 100644
index 0000000000..582bc7cc0f
--- /dev/null
+++ b/tests/checkasm/vf_gblur.c
@@ -0,0 +1,67 @@ 
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <string.h>
+#include "checkasm.h"
+#include "libavfilter/gblur.h"
+
+#define WIDTH 256
+#define HEIGHT 256
+#define PIXELS (WIDTH * HEIGHT)
+#define BUF_SIZE (PIXELS * 4)
+
+#define randomize_buffers(buf, size)             \
+    do {                                         \
+        int j;                                   \
+        float *tmp_buf = (float *)buf;           \
+        for (j = 0; j < size; j++)               \
+            tmp_buf[j] = (float)(rnd() & 0xFF); \
+    } while (0)
+
+void checkasm_check_vf_gblur(void)
+{
+    float *dst_ref = av_malloc(BUF_SIZE);
+    float *dst_new = av_malloc(BUF_SIZE);
+    int i, j;
+    int w = WIDTH;
+    int h = HEIGHT;
+    int steps = 2;
+    float nu = 0.101f;
+    float bscale = 1.112f;
+    GBlurContext s;
+
+    declare_func(void, float *dst, int w, int h, int steps, float nu, float bscale);
+
+    randomize_buffers(dst_ref, PIXELS);
+    memcpy(dst_new, dst_ref, BUF_SIZE);
+
+    ff_gblur_init(&s);
+
+    if (check_func(s.horiz_slice, "horiz_slice")) {
+        call_ref(dst_ref, w, h, steps, nu, bscale);
+        call_new(dst_new, w, h, steps, nu, bscale);
+
+        if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
+            fail();
+        }
+        bench_new(dst_new, w, h, 1, nu, bscale);
+    }
+    report("horiz_slice");
+    av_freep(&dst_ref);
+    av_freep(&dst_new);
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index c453273cd0..618bde509f 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -27,6 +27,7 @@  FATE_CHECKASM = fate-checkasm-aacpsdsp                                  \
                 fate-checkasm-v210enc                                   \
                 fate-checkasm-vf_blend                                  \
                 fate-checkasm-vf_colorspace                             \
+                fate-checkasm-vf_gblur                                  \
                 fate-checkasm-vf_hflip                                  \
                 fate-checkasm-vf_threshold                              \
                 fate-checkasm-videodsp                                  \