[FFmpeg-cvslog] checkasm: add an af_afir test

James Almer git at videolan.org
Thu Jan 3 15:13:12 EET 2019


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Jan  2 20:54:34 2019 -0300| [ba89dc27b50cf6e1bcafe473ce8f2e4363be18ee] | committer: James Almer

checkasm: add an af_afir test

Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba89dc27b50cf6e1bcafe473ce8f2e4363be18ee
---

 tests/checkasm/Makefile   |  1 +
 tests/checkasm/af_afir.c  | 83 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 89 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 9484acbbd7..47b7b06d28 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -31,6 +31,7 @@ AVCODECOBJS-$(CONFIG_VP9_DECODER)       += vp9dsp.o
 CHECKASMOBJS-$(CONFIG_AVCODEC)          += $(AVCODECOBJS-yes)
 
 # libavfilter tests
+AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
 AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
 AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
 AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)      += vf_hflip.o
diff --git a/tests/checkasm/af_afir.c b/tests/checkasm/af_afir.c
new file mode 100644
index 0000000000..54e2f68d6c
--- /dev/null
+++ b/tests/checkasm/af_afir.c
@@ -0,0 +1,83 @@
+/*
+ * 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 "config.h"
+
+#include <float.h>
+#include <stdint.h>
+
+#include "libavfilter/af_afir.h"
+#include "libavutil/internal.h"
+#include "checkasm.h"
+
+#define LEN 256
+
+#define randomize_buffer(buf)                 \
+do {                                          \
+    int i;                                    \
+    double bmg[2], stddev = 10.0, mean = 0.0; \
+                                              \
+    for (i = 0; i < LEN*2+8; i += 2) {        \
+        av_bmg_get(&checkasm_lfg, bmg);       \
+        buf[i]     = bmg[0] * stddev + mean;  \
+        buf[i + 1] = bmg[1] * stddev + mean;  \
+    }                                         \
+} while(0);
+
+static void test_fcmul_add(const float *src0, const float *src1, const float *src2)
+{
+    LOCAL_ALIGNED_32(float, cdst, [LEN*2+8]);
+    LOCAL_ALIGNED_32(float, odst, [LEN*2+8]);
+    int i;
+
+    declare_func(void, float *sum, const float *t, const float *c,
+                 ptrdiff_t len);
+
+    memcpy(cdst, src0, (LEN*2+8) * sizeof(float));
+    memcpy(odst, src0, (LEN*2+8) * sizeof(float));
+    call_ref(cdst, src1, src2, LEN);
+    call_new(odst, src1, src2, LEN);
+    for (i = 0; i <= LEN*2; i++) {
+        if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) {
+            fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n",
+                    i, cdst[i], odst[i], cdst[i] - odst[i]);
+            fail();
+            break;
+        }
+    }
+    memcpy(odst, src0, (LEN*2+8) * sizeof(float));
+    bench_new(odst, src1, src2, LEN);
+}
+
+void checkasm_check_afir(void)
+{
+    LOCAL_ALIGNED_32(float, src0, [LEN*2+8]);
+    LOCAL_ALIGNED_32(float, src1, [LEN*2+8]);
+    LOCAL_ALIGNED_32(float, src2, [LEN*2+8]);
+    AudioFIRDSPContext fir = { 0 };
+
+    ff_afir_init(&fir);
+
+    randomize_buffer(src0);
+    randomize_buffer(src1);
+    randomize_buffer(src2);
+
+    if (check_func(fir.fcmul_add, "fcmul_add"))
+        test_fcmul_add(src0, src1, src2);
+    report("fcmul_add");
+}
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 721a0912fb..c3f5160132 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -150,6 +150,9 @@ static const struct {
     #endif
 #endif
 #if CONFIG_AVFILTER
+    #if CONFIG_AFIR_FILTER
+        { "af_afir", checkasm_check_afir },
+    #endif
     #if CONFIG_BLEND_FILTER
         { "vf_blend", checkasm_check_blend },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index c45cfb46f8..9e8e879fd3 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -40,6 +40,7 @@
 #include "libavutil/timer.h"
 
 void checkasm_check_aacpsdsp(void);
+void checkasm_check_afir(void);
 void checkasm_check_alacdsp(void);
 void checkasm_check_audiodsp(void);
 void checkasm_check_blend(void);
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index a722b4a917..d59e9d293a 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -1,4 +1,5 @@
 FATE_CHECKASM = fate-checkasm-aacpsdsp                                  \
+                fate-checkasm-af_afir                                   \
                 fate-checkasm-alacdsp                                   \
                 fate-checkasm-audiodsp                                  \
                 fate-checkasm-blockdsp                                  \



More information about the ffmpeg-cvslog mailing list