Commit cbff97350a for ffmpeg

commit cbff97350a7ace07f66d61e64b94ef8c52c32aa0
Author: Reinhard Nißl <rnissl@gmx.de>
Date:   Sun Oct 11 19:26:56 2026 +0200

    tests/fate/jpegapp: add jpegapp bitstream-filter tests

    Cover APP1 insertion that keeps APP0, a zero-length record, APP0
    replacement, a missing record, an oversized record, and continuation
    after an oversized record. The sidecars are generated with printf from
    the existing smjpeg sample, so no new sample is required.

    Escape colons in sidecar target paths through both BSF parsing layers,
    so drive-letter and other colon-containing paths reach the filter intact.

    Co-authored-by: Cursor <cursoragent@cursor.com>
    Signed-off-by: Reinhard Nißl <rnissl@gmx.de>
    Assisted-by: Fairy

diff --git a/tests/Makefile b/tests/Makefile
index bd83c8df91..97e9d39339 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -210,6 +210,7 @@ include $(SRC_PATH)/tests/fate/image.mak
 include $(SRC_PATH)/tests/fate/imf.mak
 include $(SRC_PATH)/tests/fate/indeo.mak
 include $(SRC_PATH)/tests/fate/jpeg2000.mak
+include $(SRC_PATH)/tests/fate/jpegapp.mak
 include $(SRC_PATH)/tests/fate/jxl.mak
 include $(SRC_PATH)/tests/fate/libavcodec.mak
 include $(SRC_PATH)/tests/fate/libavdevice.mak
diff --git a/tests/fate/jpegapp.mak b/tests/fate/jpegapp.mak
new file mode 100644
index 0000000000..995189af11
--- /dev/null
+++ b/tests/fate/jpegapp.mak
@@ -0,0 +1,48 @@
+# jpegapp bitstream filter: per-packet injection of APP segments from a
+# u32be-length-prefixed sidecar. The sidecars below are written by printf;
+# each record is "u32be length, FF En marker, u16be segment length, payload"
+# and injects a segment carrying the payload FATE.
+
+FATE_JPEGAPP-$(call ALLYES, SMJPEG_DEMUXER JPEGAPP_BSF MJPEG_MUXER FILE_PROTOCOL) += fate-bsf-jpegapp
+fate-bsf-jpegapp: CMD = \
+    cleanfiles="$${cleanfiles} $${outfile}.bin"; \
+    printf "\\000\\000\\000\\010\\377\\341\\000\\006FATE\\000\\000\\000\\000\\000\\000\\000\\010\\377\\340\\000\\006FATE" > "$${outfile}.bin"; \
+    md5 -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -map 0:v:0 -frames:v 3 -c:v copy \
+        -bsf:v "jpegapp=filename=$$(target_path "$${outfile}.bin" | sed "s/:/\\\\\\\\:/g")" -fflags +bitexact -f mjpeg
+
+# One record for three packets: the second packet must fail instead of
+# silently passing through without its metadata.
+FATE_JPEGAPP-$(call ALLYES, SMJPEG_DEMUXER JPEGAPP_BSF MJPEG_MUXER FILE_PROTOCOL) += fate-bsf-jpegapp-missing
+fate-bsf-jpegapp-missing: CMP = grep
+fate-bsf-jpegapp-missing: REF = jpegapp: no sidecar record for packet 1
+fate-bsf-jpegapp-missing: CMD = \
+    cleanfiles="$${cleanfiles} $${outfile}.bin $${outfile}.mjpeg"; \
+    printf "\\000\\000\\000\\000" > "$${outfile}.bin"; \
+    ffmpeg -xerror -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -map 0:v:0 -frames:v 3 -c:v copy \
+        -bsf:v "jpegapp=filename=$$(target_path "$${outfile}.bin" | sed "s/:/\\\\\\\\:/g")" \
+        -fflags +bitexact -f mjpeg -y "$$(target_path "$${outfile}.mjpeg")" ; \
+    test $$? -ne 0
+
+# A record longer than the 16 MiB limit must be rejected.
+FATE_JPEGAPP-$(call ALLYES, SMJPEG_DEMUXER JPEGAPP_BSF MJPEG_MUXER FILE_PROTOCOL) += fate-bsf-jpegapp-oversize
+fate-bsf-jpegapp-oversize: CMP = grep
+fate-bsf-jpegapp-oversize: REF = jpegapp: record length 16777217 too large
+fate-bsf-jpegapp-oversize: CMD = \
+    cleanfiles="$${cleanfiles} $${outfile}.bin $${outfile}.mjpeg"; \
+    printf "\\001\\000\\000\\001\\377\\341\\000\\006FATE" > "$${outfile}.bin"; \
+    ffmpeg -xerror -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -map 0:v:0 -frames:v 3 -c:v copy \
+        -bsf:v "jpegapp=filename=$$(target_path "$${outfile}.bin" | sed "s/:/\\\\\\\\:/g")" \
+        -fflags +bitexact -f mjpeg -y "$$(target_path "$${outfile}.mjpeg")" ; \
+    test $$? -ne 0
+
+# Without -xerror, subsequent packets must still fail after an oversized
+# record. Only the first (passthrough) packet may reach the output; the bytes
+# after the oversized prefix would form valid records if reading resumed.
+FATE_JPEGAPP-$(call ALLYES, SMJPEG_DEMUXER JPEGAPP_BSF MJPEG_MUXER FILE_PROTOCOL) += fate-bsf-jpegapp-oversize-continuation
+fate-bsf-jpegapp-oversize-continuation: CMD = \
+    cleanfiles="$${cleanfiles} $${outfile}.bin"; \
+    printf "\\000\\000\\000\\000\\001\\000\\000\\001\\000\\000\\000\\010\\377\\341\\000\\006FATE\\000\\000\\000\\000" > "$${outfile}.bin"; \
+    md5 -i $(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -map 0:v:0 -frames:v 4 -c:v copy \
+        -bsf:v "jpegapp=filename=$$(target_path "$${outfile}.bin" | sed "s/:/\\\\\\\\:/g")" -fflags +bitexact -f mjpeg
+
+FATE_SAMPLES_FFMPEG += $(FATE_JPEGAPP-yes)
diff --git a/tests/ref/fate/bsf-jpegapp b/tests/ref/fate/bsf-jpegapp
new file mode 100644
index 0000000000..e178c3642f
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp
@@ -0,0 +1 @@
+678f8793377d063b0e7a841f89f7331d
diff --git a/tests/ref/fate/bsf-jpegapp-oversize-continuation b/tests/ref/fate/bsf-jpegapp-oversize-continuation
new file mode 100644
index 0000000000..3010830420
--- /dev/null
+++ b/tests/ref/fate/bsf-jpegapp-oversize-continuation
@@ -0,0 +1 @@
+f55b4c37d2b64eb899abe55443867eb7