This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 2862fa37e1907a3479d0bcabcedd697086bda60d
Author:     Andreas Rheinhardt <[email protected]>
AuthorDate: Wed Mar 4 18:29:21 2026 +0100
Commit:     Andreas Rheinhardt <[email protected]>
CommitDate: Mon Mar 9 10:17:26 2026 +0100

    tests/checkasm: Add pixelutils test
    
    Signed-off-by: Andreas Rheinhardt <[email protected]>
---
 tests/checkasm/Makefile     |  3 +-
 tests/checkasm/checkasm.c   |  3 ++
 tests/checkasm/checkasm.h   |  1 +
 tests/checkasm/pixelutils.c | 99 +++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak     |  1 +
 5 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index a9b58f5d1d..1e23587de9 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -97,8 +97,9 @@ AVUTILOBJS                              += crc.o
 AVUTILOBJS                              += fixed_dsp.o
 AVUTILOBJS                              += float_dsp.o
 AVUTILOBJS                              += lls.o
+AVUTILOBJS-$(CONFIG_PIXELUTILS)         += pixelutils.o
 
-CHECKASMOBJS-$(CONFIG_AVUTIL)  += $(AVUTILOBJS)
+CHECKASMOBJS-$(CONFIG_AVUTIL)  += $(AVUTILOBJS) $(AVUTILOBJS-yes)
 
 CHECKASMOBJS-$(ARCH_AARCH64)            += aarch64/checkasm.o
 CHECKASMOBJS-$(HAVE_ARMV5TE_EXTERNAL)   += arm/checkasm.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index a4ac8f1483..9ab448685b 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -355,6 +355,9 @@ static const struct {
         { "fixed_dsp", checkasm_check_fixed_dsp },
         { "float_dsp", checkasm_check_float_dsp },
         { "lls",       checkasm_check_lls },
+#if CONFIG_PIXELUTILS
+        { "pixelutils",checkasm_check_pixelutils },
+#endif
         { "av_tx",     checkasm_check_av_tx },
 #endif
     { NULL }
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 568b40530c..25654b20ba 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -131,6 +131,7 @@ void checkasm_check_mpegvideoencdsp(void);
 void checkasm_check_nlmeans(void);
 void checkasm_check_opusdsp(void);
 void checkasm_check_pixblockdsp(void);
+void checkasm_check_pixelutils(void);
 void checkasm_check_png(void);
 void checkasm_check_qpeldsp(void);
 void checkasm_check_sbrdsp(void);
diff --git a/tests/checkasm/pixelutils.c b/tests/checkasm/pixelutils.c
new file mode 100644
index 0000000000..17d04eb928
--- /dev/null
+++ b/tests/checkasm/pixelutils.c
@@ -0,0 +1,99 @@
+/*
+ * 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 <stddef.h>
+#include <stdint.h>
+
+#include "checkasm.h"
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
+#include "libavutil/pixelutils.h"
+
+enum {
+    LOG2_MIN_DIMENSION = 1,
+    LOG2_MAX_DIMENSION = 5,
+    BUF_SIZE           = 4096, ///< arbitrary
+};
+
+#define randomize_buffer(buf)                              \
+    do {                                                   \
+        for (size_t k = 0; k < sizeof(buf); k += 4) {      \
+            uint32_t r = rnd();                            \
+            AV_WN32A(buf + k, r);                          \
+        }                                                  \
+    } while (0)
+
+static void checkasm_check_sad(void)
+{
+    DECLARE_ALIGNED(32, uint8_t, buf1)[BUF_SIZE];
+    DECLARE_ALIGNED(32, uint8_t, buf2)[BUF_SIZE];
+    int inited = 0;
+
+    declare_func(int, const uint8_t *src1, ptrdiff_t stride1,
+                      const uint8_t *src2, ptrdiff_t stride2);
+
+    for (int i = LOG2_MIN_DIMENSION; i <= LOG2_MAX_DIMENSION; ++i) {
+        const size_t width = 1 << i, height = 1 << i;
+
+        for (int aligned = 0; aligned <= 2; ++aligned) {
+            av_pixelutils_sad_fn fn = av_pixelutils_get_sad_fn(i, i, aligned, 
NULL);
+            if (check_func(fn, "sad_%zux%zu_%d", width, width, aligned)) {
+                const uint8_t *src1 = buf1 + ((aligned != 0) ? 0 : rnd() % 
width);
+                const uint8_t *src2 = buf2 + ((aligned == 2) ? 0 : rnd() % 
width);
+                // stride * (height - 1) needs to be so small that the 
alignment offset
+                // and the last line fit into the remaining buffer.
+                size_t   max_stride = (BUF_SIZE - 2 * width) / (height - 1);
+                ptrdiff_t   stride1 = 1 + rnd() % max_stride;
+                ptrdiff_t   stride2 = 1 + rnd() % max_stride;
+
+                if (aligned != 0)
+                    stride1 &= ~(width - 1);
+                if (aligned == 2)
+                    stride2 &= ~(width - 1);
+
+                if (rnd() & 1) { // negate stride
+                    src1   += (height - 1) * stride1;
+                    stride1 = -stride1;
+                }
+                if (rnd() & 1) { // negate stride
+                    src2   += (height - 1) * stride2;
+                    stride2 = -stride2;
+                }
+
+                if (!inited) {
+                    randomize_buffer(buf1);
+                    randomize_buffer(buf2);
+                    inited = 1;
+                }
+                int res_ref = call_ref(src1, stride1, src2, stride2);
+                int ref_new = call_new(src1, stride1, src2, stride2);
+                if (res_ref != ref_new)
+                    fail();
+
+                bench_new(src1, stride1, src2, stride2);
+            }
+        }
+    }
+}
+
+void checkasm_check_pixelutils(void)
+{
+    checkasm_check_sad();
+    report("sad");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index b05dc61f67..bd44bfd536 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -46,6 +46,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp                       
          \
                 fate-checkasm-mpegvideoencdsp                           \
                 fate-checkasm-opusdsp                                   \
                 fate-checkasm-pixblockdsp                               \
+                fate-checkasm-pixelutils                                \
                 fate-checkasm-png                                       \
                 fate-checkasm-qpeldsp                                   \
                 fate-checkasm-sbrdsp                                    \

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to