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

Git pushed a commit to branch master
in repository ffmpeg.

commit deac9101027fd5f9d55708e6e90408afe2e5b8c8
Author:     Jun Zhao <[email protected]>
AuthorDate: Wed Nov 18 15:09:47 2026 +0800
Commit:     Jun Zhao <[email protected]>
CommitDate: Thu Nov 19 06:55:44 2026 +0000

    tests/fate/apng: cover a large ancillary chunk before the first IDAT
    
    Extend apnggen with a biganc mode that emits a 4096-byte caBX chunk before
    the first IDAT, and a plain mode for a non-animated PNG control. bndhdr and
    bndplte place a caBX after IHDR so the 4096-byte probe boundary splits the
    next header or a 4-bit PLTE.
    
    The probe tests require FILE_PROTOCOL because probefmt opens a local file.
    They check that the animated files probe as apng and the plain file probes
    as png_pipe. framecrc checks all six frames. Files are generated locally,
    so no fate-suite media is needed.
    
    Signed-off-by: Jun Zhao <[email protected]>
---
 tests/Makefile                                     | 10 +++
 tests/apnggen.c                                    | 74 +++++++++++++++++-----
 tests/fate/apng.mak                                | 40 +++++++++++-
 .../{apng-small-bpp-1bit => apng-biganc-frames}    |  0
 4 files changed, 106 insertions(+), 18 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 0656946f11..2fb8a368cc 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -77,6 +77,16 @@ tests/data/fate/apng-small-bpp-%.png: TAG = GEN
 tests/data/fate/apng-small-bpp-%.png: tests/apnggen$(HOSTEXESUF) | 
tests/data/fate
        $(M)./$< $@
 
+# Large ancillary chunk before the first IDAT (issue #26132).
+tests/data/fate/apng-biganc-%.png: TAG = GEN
+tests/data/fate/apng-biganc-%.png: tests/apnggen$(HOSTEXESUF) | tests/data/fate
+       $(M)./$< $@
+
+# Ancillary chunk placed so a probe boundary splits the next header or PLTE.
+tests/data/fate/apng-bnd%.png: TAG = GEN
+tests/data/fate/apng-bnd%.png: tests/apnggen$(HOSTEXESUF) | tests/data/fate
+       $(M)./$< $@
+
 RUNNING_FATE := $(filter check fate%,$(filter-out fate-rsync,$(MAKECMDGOALS)))
 
 # Check sanity of dependencies when running FATE tests.
diff --git a/tests/apnggen.c b/tests/apnggen.c
index daf69f1ecb..07752dbf05 100644
--- a/tests/apnggen.c
+++ b/tests/apnggen.c
@@ -7,6 +7,16 @@
  * here, the same way audiogen builds its wave files, so the tests do not
  * need media from the fate-suite.
  *
+ * A file name containing "biganc" gets a large private ancillary chunk
+ * before the first IDAT, to check that probing still finds the animation
+ * (issue #26132). A file name containing "plain" omits acTL/fcTL and emits
+ * a single frame, giving a non-animated PNG control case.
+ *
+ * "bndhdr" inserts a caBX immediately after IHDR sized so the next chunk
+ * starts at offset 4096, where the probe buffer ends on a header boundary.
+ * "bndplte" inserts a 4000-byte caBX there, so a 4-bit PLTE crosses offset
+ * 4096. Both names require the depth marker as well.
+ *
  * Copyright (c) 2026 Jun Zhao
  *
  * This file is part of FFmpeg.
@@ -32,7 +42,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-enum { CANVAS_W = 24, CANVAS_H = 20, FRAMES = 6 };
+/* Large enough to push the first IDAT past the 2048-byte probe buffer. */
+enum { CANVAS_W = 24, CANVAS_H = 20, FRAMES = 6, ANC_SIZE = 4096 };
+
+static const uint8_t ancillary[ANC_SIZE] = { 0 };
 
 static const uint8_t palette[16][3] = {
     {   0,   0,   0 }, { 255,   0,   0 }, {   0, 255,   0 }, {   0,   0, 255 },
@@ -42,7 +55,7 @@ static const uint8_t palette[16][3] = {
 };
 
 typedef struct {
-    uint8_t data[2048];
+    uint8_t data[ANC_SIZE + 2048];
     int len;
 } Buf;
 
@@ -153,7 +166,8 @@ static void put_stored(Buf *b, const uint8_t *raw, int n)
     put_be32(b, (s << 16) | a);
 }
 
-static void write_apng(const char *path, int depth)
+static void write_apng(const char *path, int depth, int big_anc, int plain,
+                        int anc_after_ihdr)
 {
     static const uint8_t sig[8] = { 137, 80, 78, 71, 13, 10, 26, 10 };
     uint8_t ihdr[13] = { 0, 0, 0, CANVAS_W, 0, 0, 0, CANVAS_H, depth, 3 };
@@ -161,32 +175,44 @@ static void write_apng(const char *path, int depth)
     uint8_t plte[16 * 3], raw[512], fctl[26];
     Buf out = { 0 }, image = { 0 };
     FILE *f;
-    int colors = 1 << depth, seq = 0, frame, i;
+    int colors = 1 << depth, seq = 0, frame, frames = plain ? 1 : FRAMES, i;
+
+    if (anc_after_ihdr < 0 || anc_after_ihdr > ANC_SIZE) {
+        fprintf(stderr, "apnggen: ancillary payload does not fit\n");
+        exit(1);
+    }
 
     for (i = 0; i < colors; i++)
         memcpy(plte + 3 * i, palette[i], 3);
 
     put(&out, sig, 8);
     chunk(&out, "IHDR", ihdr, sizeof(ihdr));
-    chunk(&out, "acTL", actl, sizeof(actl));
+    if (anc_after_ihdr)
+        chunk(&out, "caBX", ancillary, anc_after_ihdr);
+    if (!plain)
+        chunk(&out, "acTL", actl, sizeof(actl));
     chunk(&out, "PLTE", plte, colors * 3);
+    if (big_anc)
+        chunk(&out, "caBX", ancillary, sizeof(ancillary));
 
-    for (frame = 0; frame < FRAMES; frame++) {
+    for (frame = 0; frame < frames; frame++) {
         int sub = frame != 0;
         int x = sub ? 1 + 2 * (frame - 1) : 0;
         int y = sub ? 1 + (frame - 1) : 0;
         int w = sub ? 7 : CANVAS_W;
         int h = sub ? 5 : CANVAS_H;
 
-        memset(fctl, 0, sizeof(fctl));
-        fctl[3] = seq++;
-        fctl[7] = w;
-        fctl[11] = h;
-        fctl[15] = x;
-        fctl[19] = y;
-        fctl[21] = 1;  /* delay numerator */
-        fctl[23] = 10; /* delay denominator: 1/10 s */
-        chunk(&out, "fcTL", fctl, sizeof(fctl));
+        if (!plain) {
+            memset(fctl, 0, sizeof(fctl));
+            fctl[3] = seq++;
+            fctl[7] = w;
+            fctl[11] = h;
+            fctl[15] = x;
+            fctl[19] = y;
+            fctl[21] = 1;  /* delay numerator */
+            fctl[23] = 10; /* delay denominator: 1/10 s */
+            chunk(&out, "fcTL", fctl, sizeof(fctl));
+        }
 
         image.len = 0;
         if (sub)
@@ -204,7 +230,7 @@ static void write_apng(const char *path, int depth)
 int main(int argc, char **argv)
 {
     const char *path = argc == 2 ? argv[1] : NULL;
-    int depth = 0;
+    int depth = 0, anc_after_ihdr = 0;
 
     if (!path) {
         fprintf(stderr, "usage: apnggen OUTPUT.png\n");
@@ -220,6 +246,20 @@ int main(int argc, char **argv)
         fprintf(stderr, "apnggen: unsupported file name %s\n", path);
         return 1;
     }
-    write_apng(path, depth);
+    /* IHDR ends at offset 33. A 4051-byte payload plus its 12-byte wrapper
+     * ends at 4096, so the next header is absent from that probe buffer.
+     * A 4000-byte payload leaves a 4-bit PLTE crossing the same offset:
+     * the chunk ends at 4045, acTL at 4065, and PLTE at 4125. */
+    if (strstr(path, "bndhdr"))
+        anc_after_ihdr = 4051;
+    else if (strstr(path, "bndplte")) {
+        if (depth != 4) {
+            fprintf(stderr, "apnggen: bndplte requires a 4-bit file name\n");
+            return 1;
+        }
+        anc_after_ihdr = 4000;
+    }
+    write_apng(path, depth, strstr(path, "biganc") != NULL,
+               strstr(path, "plain") != NULL, anc_after_ihdr);
     return 0;
 }
diff --git a/tests/fate/apng.mak b/tests/fate/apng.mak
index 5aec0ad7b7..276aa286b1 100644
--- a/tests/fate/apng.mak
+++ b/tests/fate/apng.mak
@@ -34,4 +34,42 @@ fate-apng-small-bpp-4bit: 
tests/data/fate/apng-small-bpp-4bit.png
 FATE_APNG_SMALL_BPP-$(call FRAMECRC, APNG, APNG) += $(FATE_APNG_SMALL_BPP)
 FATE_FFMPEG += $(FATE_APNG_SMALL_BPP-yes)
 
-fate-apng: $(FATE_APNG-yes) $(FATE_APNG_SMALL_BPP-yes)
+# A large ancillary chunk before the first IDAT must not hide the animation
+# from the probe (issue #26132). "plain" is a non-animated control: it has
+# the same big chunk but no acTL, so png_pipe must still win.
+FATE_APNG_BIGANC-$(call ALLYES, APNG_DEMUXER IMAGE_PNG_PIPE_DEMUXER 
FILE_PROTOCOL) += fate-apng-biganc-probe
+fate-apng-biganc-probe: CMD = probefmt 
$(TARGET_PATH)/tests/data/fate/apng-biganc-1bit.png
+fate-apng-biganc-probe: REF = apng
+fate-apng-biganc-probe: CMP = oneline
+fate-apng-biganc-probe: tests/data/fate/apng-biganc-1bit.png
+
+FATE_APNG_BIGANC-$(call ALLYES, APNG_DEMUXER IMAGE_PNG_PIPE_DEMUXER 
FILE_PROTOCOL) += fate-apng-biganc-plain-probe
+fate-apng-biganc-plain-probe: CMD = probefmt 
$(TARGET_PATH)/tests/data/fate/apng-biganc-plain-1bit.png
+fate-apng-biganc-plain-probe: REF = png_pipe
+fate-apng-biganc-plain-probe: CMP = oneline
+fate-apng-biganc-plain-probe: tests/data/fate/apng-biganc-plain-1bit.png
+
+FATE_FFPROBE += $(FATE_APNG_BIGANC-yes)
+
+# The 4096-byte probe boundary falls inside the next chunk header, or inside
+# a valid PLTE. Both must still probe as apng (issue #26132).
+FATE_APNG_BND-$(call ALLYES, APNG_DEMUXER IMAGE_PNG_PIPE_DEMUXER 
FILE_PROTOCOL) += fate-apng-bndhdr-probe
+fate-apng-bndhdr-probe: CMD = probefmt 
$(TARGET_PATH)/tests/data/fate/apng-bndhdr-4bit.png
+fate-apng-bndhdr-probe: REF = apng
+fate-apng-bndhdr-probe: CMP = oneline
+fate-apng-bndhdr-probe: tests/data/fate/apng-bndhdr-4bit.png
+
+FATE_APNG_BND-$(call ALLYES, APNG_DEMUXER IMAGE_PNG_PIPE_DEMUXER 
FILE_PROTOCOL) += fate-apng-bndplte-probe
+fate-apng-bndplte-probe: CMD = probefmt 
$(TARGET_PATH)/tests/data/fate/apng-bndplte-4bit.png
+fate-apng-bndplte-probe: REF = apng
+fate-apng-bndplte-probe: CMP = oneline
+fate-apng-bndplte-probe: tests/data/fate/apng-bndplte-4bit.png
+
+FATE_FFPROBE += $(FATE_APNG_BND-yes)
+
+FATE_APNG_BIGANC_FRAMES-$(call FRAMECRC, APNG, APNG) += fate-apng-biganc-frames
+fate-apng-biganc-frames: CMD = framecrc -i 
$(TARGET_PATH)/tests/data/fate/apng-biganc-1bit.png -fps_mode passthrough
+fate-apng-biganc-frames: tests/data/fate/apng-biganc-1bit.png
+FATE_FFMPEG += $(FATE_APNG_BIGANC_FRAMES-yes)
+
+fate-apng: $(FATE_APNG-yes) $(FATE_APNG_SMALL_BPP-yes) $(FATE_APNG_BIGANC-yes) 
$(FATE_APNG_BND-yes) $(FATE_APNG_BIGANC_FRAMES-yes)
diff --git a/tests/ref/fate/apng-small-bpp-1bit 
b/tests/ref/fate/apng-biganc-frames
similarity index 100%
copy from tests/ref/fate/apng-small-bpp-1bit
copy to tests/ref/fate/apng-biganc-frames

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to