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

Git pushed a commit to branch master
in repository ffmpeg.

commit a0d4c07b86319ccd76684b765d62b497308a1be8
Author:     Zhao Zhili <[email protected]>
AuthorDate: Sun Jan 4 17:22:56 2026 +0800
Commit:     Zhao Zhili <[email protected]>
CommitDate: Wed Feb 4 12:05:35 2026 +0800

    tests/checkasm: add test for png
    
    Signed-off-by: Zhao Zhili <[email protected]>
---
 tests/checkasm/Makefile   |   1 +
 tests/checkasm/checkasm.c |   3 ++
 tests/checkasm/checkasm.h |   1 +
 tests/checkasm/png.c      | 116 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/fate/checkasm.mak   |   1 +
 5 files changed, 122 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index f4ac5a940f..48de4d22a0 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -43,6 +43,7 @@ AVCODECOBJS-$(CONFIG_JPEG2000_DECODER)  += jpeg2000dsp.o
 AVCODECOBJS-$(CONFIG_OPUS_DECODER)      += opusdsp.o
 AVCODECOBJS-$(CONFIG_PIXBLOCKDSP)       += pixblockdsp.o
 AVCODECOBJS-$(CONFIG_HEVC_DECODER)      += hevc_add_res.o hevc_deblock.o 
hevc_dequant.o hevc_idct.o hevc_sao.o hevc_pel.o
+AVCODECOBJS-$(CONFIG_PNG_DECODER)       += png.o
 AVCODECOBJS-$(CONFIG_RV34DSP)           += rv34dsp.o
 AVCODECOBJS-$(CONFIG_RV40_DECODER)      += rv40dsp.o
 AVCODECOBJS-$(CONFIG_SVQ1_ENCODER)      += svq1enc.o
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index f9ccb30ce9..bdaaa8695d 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -231,6 +231,9 @@ static const struct {
     #if CONFIG_PIXBLOCKDSP
         { "pixblockdsp", checkasm_check_pixblockdsp },
     #endif
+    #if CONFIG_PNG_DECODER
+        { "png", checkasm_check_png },
+    #endif
     #if CONFIG_QPELDSP
         { "qpeldsp", checkasm_check_qpeldsp },
     #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index b246d0c4da..2a6c7e8ea6 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -130,6 +130,7 @@ void checkasm_check_mpegvideoencdsp(void);
 void checkasm_check_nlmeans(void);
 void checkasm_check_opusdsp(void);
 void checkasm_check_pixblockdsp(void);
+void checkasm_check_png(void);
 void checkasm_check_qpeldsp(void);
 void checkasm_check_sbrdsp(void);
 void checkasm_check_rv34dsp(void);
diff --git a/tests/checkasm/png.c b/tests/checkasm/png.c
new file mode 100644
index 0000000000..0807d3ab7b
--- /dev/null
+++ b/tests/checkasm/png.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2026 Zhao Zhili <[email protected]>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "libavutil/mem_internal.h"
+#include "libavcodec/pngdsp.h"
+
+#include "checkasm.h"
+
+#define BUF_SIZE 4096
+
+#define randomize_buf(buf, size)        \
+    do {                                \
+        for (int i = 0; i < size; i++)  \
+            buf[i] = (uint8_t)rnd();    \
+    } while (0)
+
+static void check_add_bytes_l2(const PNGDSPContext *c)
+{
+    LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(uint8_t, src, [2], [BUF_SIZE]);
+
+    declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t * dst, const uint8_t 
*src1,
+                      const uint8_t *src2, int w);
+
+    randomize_buf(dst0, BUF_SIZE);
+    memcpy(dst1, dst0, BUF_SIZE);
+    randomize_buf(src[0], BUF_SIZE);
+    randomize_buf(src[1], BUF_SIZE);
+
+    const int size[] = {15, 2043, 4096};
+    for (int i = 0; i < FF_ARRAY_ELEMS(size); i++) {
+        if (check_func(c->add_bytes_l2, "add_bytes_l2_%d", size[i])) {
+            call_ref(dst0, src[0], src[1], size[i]);
+            call_new(dst1, src[0], src[1], size[i]);
+            checkasm_check(uint8_t, dst0, BUF_SIZE, dst1, BUF_SIZE, BUF_SIZE, 
1, "dst");
+            if (size[i] == BUF_SIZE)
+                bench_new(dst1, src[0], src[1], BUF_SIZE);
+        }
+    }
+}
+
+static void check_add_paeth_prediction(const PNGDSPContext *c)
+{
+    LOCAL_ALIGNED_16(uint8_t, dst0_buf, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(uint8_t, dst1_buf, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(uint8_t, src, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(uint8_t, top_buf, [BUF_SIZE]);
+
+    randomize_buf(dst0_buf, BUF_SIZE);
+    randomize_buf(src, BUF_SIZE);
+    randomize_buf(top_buf, BUF_SIZE);
+
+    declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t * dst, const uint8_t *src,
+                      const uint8_t *top, int w, int bpp);
+
+    const int bpps[] = {3, 4, 6, 8};
+    for (int i = 0; i < FF_ARRAY_ELEMS(bpps); i++) {
+        int bpp = bpps[i];
+        if (check_func(c->add_paeth_prediction, "add_paeth_prediction_%d", 
bpp)) {
+            // add_paeth_prediction reads start from (dst - bpp) and (top - 
bpp).
+            uint8_t *dst0 = &dst0_buf[bpp];
+            uint8_t *dst1 = &dst1_buf[bpp];
+            uint8_t *top = &top_buf[bpp];
+            int w = (BUF_SIZE - bpp) / bpp * bpp;
+
+            // dst buffer is both read and written, so dst0 and dst1 must 
remain the same before test
+            memcpy(dst1_buf, dst0_buf, BUF_SIZE);
+
+            call_ref(dst0, src, top, w, bpp);
+            call_new(dst1, src, top, w, bpp);
+
+            /* This match the use case in ff_png_filter_row, that x86 asm 
version of
+             * add_paeth_prediction doesn't write last two bytes for bpp = 3 
and 6.
+             * The C function takes care to rewrite the last 3 bytes.
+             */
+            if (bpp & 3) {
+                for (int j = w - 3; j < w; j++)
+                    dst1[j] = dst0[j];
+            }
+            // check dst_buf to ensure there is no overwrite
+            checkasm_check(uint8_t, dst0_buf, 0, dst1_buf, 0, BUF_SIZE, 1, 
"dst");
+            bench_new(dst1, src, top, w, bpp);
+        }
+    }
+}
+
+void checkasm_check_png(void)
+{
+    PNGDSPContext c;
+
+    ff_pngdsp_init(&c);
+
+    check_add_bytes_l2(&c);
+    report("add_bytes_l2");
+    check_add_paeth_prediction(&c);
+    report("add_paeth_prediction");
+}
diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak
index f55febfbdd..16c6f1f775 100644
--- a/tests/fate/checkasm.mak
+++ b/tests/fate/checkasm.mak
@@ -45,6 +45,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp                       
          \
                 fate-checkasm-mpegvideoencdsp                           \
                 fate-checkasm-opusdsp                                   \
                 fate-checkasm-pixblockdsp                               \
+                fate-checkasm-png                                       \
                 fate-checkasm-qpeldsp                                   \
                 fate-checkasm-sbrdsp                                    \
                 fate-checkasm-rv34dsp                                   \

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

Reply via email to