[FFmpeg-cvslog] checkasm/diracdsp: test add_dirac_obmc

Kyosuke Kawakami git at videolan.org
Fri Nov 15 21:09:53 EET 2024


ffmpeg | branch: master | Kyosuke Kawakami <kawakami150708 at gmail.com> | Fri Nov 15 03:25:31 2024 +0900| [711290f9a3a86f437d3df119c37d152aad4ecb47] | committer: Ronald S. Bultje

checkasm/diracdsp: test add_dirac_obmc

Signed-off-by: Kyosuke Kawakami <kawakami150708 at gmail.com>
Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

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

 tests/checkasm/Makefile   |  1 +
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 tests/checkasm/diracdsp.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak   |  1 +
 5 files changed, 97 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index ae324ced3f..c7268d836e 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -29,6 +29,7 @@ AVCODECOBJS-$(CONFIG_AAC_DECODER)       += aacpsdsp.o \
 AVCODECOBJS-$(CONFIG_AAC_ENCODER)       += aacencdsp.o
 AVCODECOBJS-$(CONFIG_ALAC_DECODER)      += alacdsp.o
 AVCODECOBJS-$(CONFIG_DCA_DECODER)       += synth_filter.o
+AVCODECOBJS-$(CONFIG_DIRAC_DECODER)     += diracdsp.o
 AVCODECOBJS-$(CONFIG_EXR_DECODER)       += exrdsp.o
 AVCODECOBJS-$(CONFIG_FLAC_DECODER)      += flacdsp.o
 AVCODECOBJS-$(CONFIG_HUFFYUV_DECODER)   += huffyuvdsp.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index c9d2b5faf1..fb307af0ae 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -138,6 +138,9 @@ static const struct {
     #if CONFIG_DCA_DECODER
         { "synth_filter", checkasm_check_synth_filter },
     #endif
+    #if CONFIG_DIRAC_DECODER
+        { "diracdsp", checkasm_check_diracdsp },
+    #endif
     #if CONFIG_EXR_DECODER
         { "exrdsp", checkasm_check_exrdsp },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 866eef01e9..0ba5c3040d 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -84,6 +84,7 @@ void checkasm_check_blend(void);
 void checkasm_check_blockdsp(void);
 void checkasm_check_bswapdsp(void);
 void checkasm_check_colorspace(void);
+void checkasm_check_diracdsp(void);
 void checkasm_check_exrdsp(void);
 void checkasm_check_fdctdsp(void);
 void checkasm_check_fixed_dsp(void);
diff --git a/tests/checkasm/diracdsp.c b/tests/checkasm/diracdsp.c
new file mode 100644
index 0000000000..e7dbbe184b
--- /dev/null
+++ b/tests/checkasm/diracdsp.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2024 Kyosuke Kawakami
+ *
+ * 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 "checkasm.h"
+
+#include "libavcodec/diracdsp.h"
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+
+#define RANDOMIZE_DESTS(name, size)             \
+    do {                                        \
+        int i;                                  \
+        for (i = 0; i < size; ++i) {            \
+            uint16_t r = rnd();                 \
+            AV_WN16A(name##0 + i, r);           \
+            AV_WN16A(name##1 + i, r);           \
+        }                                       \
+    } while (0)
+
+#define RANDOMIZE_BUFFER8(name, size)         \
+    do {                                      \
+        int i;                                \
+        for (i = 0; i < size; ++i) {          \
+            uint8_t r = rnd();                \
+            name[i] = r;                      \
+        }                                     \
+    } while (0)
+
+#define OBMC_STRIDE 32
+#define XBLEN_MAX 32
+#define YBLEN_MAX 64
+
+static void check_add_obmc(size_t func_index, int xblen)
+{
+    LOCAL_ALIGNED_8(uint8_t, src, [XBLEN_MAX * YBLEN_MAX]);
+    LOCAL_ALIGNED_16(uint16_t, _dst0, [XBLEN_MAX * YBLEN_MAX + 4]);
+    LOCAL_ALIGNED_16(uint16_t, _dst1, [XBLEN_MAX * YBLEN_MAX + 4]);
+    LOCAL_ALIGNED_8(uint8_t, obmc_weight, [XBLEN_MAX * YBLEN_MAX]);
+
+    // Ensure that they accept unaligned buffer.
+    // Not using LOCAL_ALIGNED_8 because it might make 16 byte aligned buffer.
+    uint16_t *dst0 = _dst0 + 4;
+    uint16_t *dst1 = _dst1 + 4;
+
+    int yblen;
+    DiracDSPContext h;
+
+    ff_diracdsp_init(&h);
+
+    if (check_func(h.add_dirac_obmc[func_index], "diracdsp.add_dirac_obmc_%d", xblen)) {
+        declare_func(void, uint16_t*, const uint8_t*, int, const uint8_t *, int);
+
+        RANDOMIZE_BUFFER8(src, YBLEN_MAX * xblen);
+        RANDOMIZE_DESTS(dst, YBLEN_MAX * xblen);
+        RANDOMIZE_BUFFER8(obmc_weight, YBLEN_MAX * OBMC_STRIDE);
+
+        yblen = 1 + (rnd() % YBLEN_MAX);
+        call_ref(dst0, src, xblen, obmc_weight, yblen);
+        call_new(dst1, src, xblen, obmc_weight, yblen);
+        if (memcmp(dst0, dst1, yblen * xblen))
+            fail();
+
+        bench_new(dst1, src, xblen, obmc_weight, YBLEN_MAX);
+    }
+}
+
+void checkasm_check_diracdsp(void)
+{
+    check_add_obmc(0, 8);
+    check_add_obmc(1, 16);
+    check_add_obmc(2, 32);
+    report("diracdsp");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index d1396cb641..8a2c04e1cd 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -7,6 +7,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp                                 \
                 fate-checkasm-av_tx                                     \
                 fate-checkasm-blockdsp                                  \
                 fate-checkasm-bswapdsp                                  \
+                fate-checkasm-diracdsp                                  \
                 fate-checkasm-exrdsp                                    \
                 fate-checkasm-fdctdsp                                   \
                 fate-checkasm-fixed_dsp                                 \



More information about the ffmpeg-cvslog mailing list