diff mbox series

[FFmpeg-devel,4/4] tests/checkasm: add check for vf_exposure

Message ID 20211022085231.93931-4-jianhua.wu@intel.com
State New
Headers show
Series [FFmpeg-devel,1/4] avfilter/x86/vf_exposure: add x86 SIMD optimization | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wu Jianhua Oct. 22, 2021, 8:52 a.m. UTC
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
---
 tests/checkasm/Makefile      |  1 +
 tests/checkasm/checkasm.c    |  3 ++
 tests/checkasm/checkasm.h    |  1 +
 tests/checkasm/vf_exposure.c | 68 ++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak      |  1 +
 5 files changed, 74 insertions(+)
 create mode 100644 tests/checkasm/vf_exposure.c
diff mbox series

Patch

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 4ef5fa87da..7b86ffca6b 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -37,6 +37,7 @@  AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
 AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
 AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
 AVFILTEROBJS-$(CONFIG_EQ_FILTER)         += vf_eq.o
+AVFILTEROBJS-$(CONFIG_EXPOSURE_FILTER)   += vf_exposure.o
 AVFILTEROBJS-$(CONFIG_GBLUR_FILTER)      += vf_gblur.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)      += vf_hflip.o
 AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index b1353f7cbe..50961d9961 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -169,6 +169,9 @@  static const struct {
     #if CONFIG_EQ_FILTER
         { "vf_eq", checkasm_check_vf_eq },
     #endif
+    #if CONFIG_EXPOSURE_FILTER
+        { "vf_exposure", checkasm_check_vf_exposure },
+    #endif
     #if CONFIG_GBLUR_FILTER
         { "vf_gblur", checkasm_check_vf_gblur },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 68b0697d3e..b402894ad3 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -78,6 +78,7 @@  void checkasm_check_utvideodsp(void);
 void checkasm_check_v210dec(void);
 void checkasm_check_v210enc(void);
 void checkasm_check_vf_eq(void);
+void checkasm_check_vf_exposure(void);
 void checkasm_check_vf_gblur(void);
 void checkasm_check_vf_hflip(void);
 void checkasm_check_vf_threshold(void);
diff --git a/tests/checkasm/vf_exposure.c b/tests/checkasm/vf_exposure.c
new file mode 100644
index 0000000000..fb79c920df
--- /dev/null
+++ b/tests/checkasm/vf_exposure.c
@@ -0,0 +1,68 @@ 
+/*
+ * 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 <float.h>
+#include <string.h>
+#include "checkasm.h"
+#include "libavfilter/exposure.h"
+
+#define PIXELS 256
+#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)
+
+static void check_exposure(float *dst_ref, float *dst_new, float black, float scale)
+{
+    declare_func(void, float *dst, int length, float black, float scale);
+    call_ref(dst_ref, PIXELS, black, scale);
+    call_new(dst_new, PIXELS, black, scale);
+
+    if (!float_near_abs_eps_array(dst_ref, dst_new, 0.01f, PIXELS)) {
+        fail();
+    }
+    bench_new(dst_new, PIXELS, black, scale);
+}
+
+void checkasm_check_vf_exposure(void)
+{
+    float *dst_ref = av_malloc(BUF_SIZE);
+    float *dst_new = av_malloc(BUF_SIZE);
+    ExposureContext s;
+
+    s.black = 0.1;
+    s.exposure = 1.4;
+
+    randomize_buffers(dst_ref, PIXELS);
+    memcpy(dst_new, dst_ref, BUF_SIZE);
+
+    ff_exposure_init(&s);
+
+    if (check_func(s.exposure_func, "exposure")) {
+        check_exposure(dst_ref, dst_new, s.black, s.scale);
+    }
+    report("exposure");
+
+    av_freep(&dst_ref);
+    av_freep(&dst_new);
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index 6e7edbe655..4d4cd6cc88 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -34,6 +34,7 @@  FATE_CHECKASM = fate-checkasm-aacpsdsp                                  \
                 fate-checkasm-vf_blend                                  \
                 fate-checkasm-vf_colorspace                             \
                 fate-checkasm-vf_eq                                     \
+                fate-checkasm-vf_exposure                               \
                 fate-checkasm-vf_gblur                                  \
                 fate-checkasm-vf_hflip                                  \
                 fate-checkasm-vf_nlmeans                                \