Commit af7804d91d for ffmpeg
commit af7804d91d5260c8609f268ce8eef525fb8c17ba
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Sat Oct 31 09:57:15 2026 -0500
fate/flac: add chained and mid-stream parameter change tests
The chained tests pipe two generated Ogg FLAC links into one decoder,
the second link changing the block size or bit depth.
The flac-midstream tests make the same changes inside one raw FLAC
stream without a new STREAMINFO, which the decoder keeps rejecting,
and each frame-threads variant expects the output of its
single-threaded test.
The references record what decoding gives today, for the following
commits to update as they fix each case.
diff --git a/tests/fate/flac.mak b/tests/fate/flac.mak
index 62f2126d92..511c049739 100644
--- a/tests/fate/flac.mak
+++ b/tests/fate/flac.mak
@@ -32,5 +32,40 @@ fate-flac-%: FUZZ = 0
FATE_FLAC-$(call ENCMUX, FLAC, FLAC, PIPE_PROTOCOL) += $(FATE_FLAC)
+# One stream whose second half changes the bit depth, or exceeds the block size
+# its STREAMINFO declares, without a new STREAMINFO: the decoder rejects those
+# frames.
+#
+# The first half ends on a whole frame, since a short frame anywhere but last
+# gets a bogus timestamp from the parser.
+FLAC_MIDSTREAM_CHANGE = { ffmpeg -auto_conversion_filters -f lavfi -i sine=frequency=440:duration=0.5 \
+ -af atrim=end_sample=21504 \
+ -c:a flac -frame_size 1024 -flags +bitexact -fflags +bitexact -f flac - && \
+ ffmpeg -auto_conversion_filters -f lavfi -i sine=frequency=660:duration=0.5 \
+ -c:a flac $(1) -flags +bitexact -fflags +bitexact -f flac -write_header 0 -; } |
+
+FLAC_MIDSTREAM_BLOCKSIZE = $(call FLAC_MIDSTREAM_CHANGE,-frame_size 4096) framecrc -i -
+FLAC_MIDSTREAM_BPS = $(call FLAC_MIDSTREAM_CHANGE,-sample_fmt s32 -bits_per_raw_sample 24) \
+ framecrc -auto_conversion_filters -i - -c:a pcm_s32le
+
+# Each frame-threaded variant expects the output of its single-threaded test.
+FATE_FLAC_MIDSTREAM-$(call TRANSCODE, FLAC, FLAC, LAVFI_INDEV SINE_FILTER ATRIM_FILTER FLAC_PARSER FD_PROTOCOL PCM_S16LE_DECODER) += fate-flac-midstream-blocksize fate-flac-midstream-blocksize-frame-threads
+fate-flac-midstream-blocksize: CMD = $(FLAC_MIDSTREAM_BLOCKSIZE)
+fate-flac-midstream-blocksize-frame-threads: CMD = $(FLAC_MIDSTREAM_BLOCKSIZE)
+fate-flac-midstream-blocksize-frame-threads: REF = $(SRC_PATH)/tests/ref/fate/flac-midstream-blocksize
+fate-flac-midstream-blocksize-frame-threads: THREADS = 2
+fate-flac-midstream-blocksize-frame-threads: THREAD_TYPE = frame
+
+FATE_FLAC_MIDSTREAM-$(call TRANSCODE, FLAC, FLAC, LAVFI_INDEV SINE_FILTER ATRIM_FILTER FLAC_PARSER ARESAMPLE_FILTER PCM_S32LE_ENCODER FD_PROTOCOL PCM_S16LE_DECODER) += fate-flac-midstream-bps fate-flac-midstream-bps-frame-threads
+fate-flac-midstream-bps: CMD = $(FLAC_MIDSTREAM_BPS)
+fate-flac-midstream-bps-frame-threads: CMD = $(FLAC_MIDSTREAM_BPS)
+fate-flac-midstream-bps-frame-threads: REF = $(SRC_PATH)/tests/ref/fate/flac-midstream-bps
+fate-flac-midstream-bps-frame-threads: THREADS = 2
+fate-flac-midstream-bps-frame-threads: THREAD_TYPE = frame
+
+$(FATE_FLAC_MIDSTREAM-yes): CMP = diff
+
+FATE_FFMPEG += $(FATE_FLAC_MIDSTREAM-yes)
+
FATE_SAMPLES_AVCONV += $(FATE_FLAC-yes)
-fate-flac: $(FATE_FLAC)
+fate-flac: $(FATE_FLAC) $(FATE_FLAC_MIDSTREAM-yes)
diff --git a/tests/fate/ogg-flac.mak b/tests/fate/ogg-flac.mak
index 204ea3f32b..0b83c1f97e 100644
--- a/tests/fate/ogg-flac.mak
+++ b/tests/fate/ogg-flac.mak
@@ -22,6 +22,32 @@ fate-ogg-flac-serial-offset: libavformat/tests/ogg_pages$(EXESUF)
fate-ogg-flac-serial-offset: CMD = run_with_temp $(OGG_FLAC_SERIAL_MUX)" -serial_offset 67574 -f ogg -y" \
"libavformat/tests/ogg_pages$(EXESUF)" ogg
+# Two links of tones piped as one chained stream, the second encoded with
+# options $(2) that the first, encoded with $(1), does not share.
+OGG_FLAC_CHAIN = { ffmpeg -auto_conversion_filters -f lavfi -i sine=frequency=440:duration=0.5 \
+ -c:a flac $(1) -flags +bitexact -fflags +bitexact -f ogg - && \
+ ffmpeg -auto_conversion_filters -f lavfi -i sine=frequency=660:duration=0.5 \
+ -c:a flac $(2) -flags +bitexact -fflags +bitexact -serial_offset 1 -f ogg -; } |
+
+OGG_FLAC_CHAINED_BLOCKSIZE = $(call OGG_FLAC_CHAIN,-frame_size 1024,-frame_size 4096) framecrc -i -
+OGG_FLAC_CHAINED_BPS = $(call OGG_FLAC_CHAIN,,-sample_fmt s32 -bits_per_raw_sample 24) \
+ framecrc -auto_conversion_filters -i - -c:a pcm_s32le
+
+# Each frame-threaded variant expects the output of its single-threaded test.
+FATE_OGG_FLAC_CHAIN-$(call TRANSCODE, FLAC, OGG, LAVFI_INDEV SINE_FILTER FLAC_PARSER FD_PROTOCOL PCM_S16LE_DECODER) += fate-ogg-flac-chained-blocksize fate-ogg-flac-chained-blocksize-frame-threads
+fate-ogg-flac-chained-blocksize: CMD = $(OGG_FLAC_CHAINED_BLOCKSIZE)
+fate-ogg-flac-chained-blocksize-frame-threads: CMD = $(OGG_FLAC_CHAINED_BLOCKSIZE)
+fate-ogg-flac-chained-blocksize-frame-threads: REF = $(SRC_PATH)/tests/ref/fate/ogg-flac-chained-blocksize
+fate-ogg-flac-chained-blocksize-frame-threads: THREADS = 2
+fate-ogg-flac-chained-blocksize-frame-threads: THREAD_TYPE = frame
+
+FATE_OGG_FLAC_CHAIN-$(call TRANSCODE, FLAC, OGG, LAVFI_INDEV SINE_FILTER FLAC_PARSER ARESAMPLE_FILTER PCM_S32LE_ENCODER FD_PROTOCOL PCM_S16LE_DECODER) += fate-ogg-flac-chained-bps fate-ogg-flac-chained-bps-frame-threads
+fate-ogg-flac-chained-bps: CMD = $(OGG_FLAC_CHAINED_BPS)
+fate-ogg-flac-chained-bps-frame-threads: CMD = $(OGG_FLAC_CHAINED_BPS)
+fate-ogg-flac-chained-bps-frame-threads: REF = $(SRC_PATH)/tests/ref/fate/ogg-flac-chained-bps
+fate-ogg-flac-chained-bps-frame-threads: THREADS = 2
+fate-ogg-flac-chained-bps-frame-threads: THREAD_TYPE = frame
+
FATE_OGG_FLAC-$(call DEMDEC, OGG, FLAC, FLAC_PARSER) += $(FATE_OGG_FLAC)
FATE_SAMPLES_DUMP_STREAM_META += $(FATE_OGG_FLAC-yes)
@@ -30,4 +56,6 @@ FATE_EXTERN += $(FATE_OGG_FLAC-yes)
FATE_SAMPLES_FFMPEG += $(FATE_OGG_COPY_FLAC-yes)
-fate-ogg-flac: $(FATE_OGG_FLAC-yes) $(FATE_OGG_COPY_FLAC-yes)
+FATE_FFMPEG += $(FATE_OGG_FLAC_CHAIN-yes)
+
+fate-ogg-flac: $(FATE_OGG_FLAC-yes) $(FATE_OGG_COPY_FLAC-yes) $(FATE_OGG_FLAC_CHAIN-yes)
diff --git a/tests/ref/fate/flac-midstream-blocksize b/tests/ref/fate/flac-midstream-blocksize
new file mode 100644
index 0000000000..036eaef687
--- /dev/null
+++ b/tests/ref/fate/flac-midstream-blocksize
@@ -0,0 +1,26 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+0, 0, 0, 1024, 2048, 0x2096f45b
+0, 1024, 1024, 1024, 2048, 0x2262f6ec
+0, 2048, 2048, 1024, 2048, 0xaa83fe05
+0, 3072, 3072, 1024, 2048, 0x487e06b5
+0, 4096, 4096, 1024, 2048, 0xb0abfcca
+0, 5120, 5120, 1024, 2048, 0x869ef510
+0, 6144, 6144, 1024, 2048, 0x547cf717
+0, 7168, 7168, 1024, 2048, 0xca830826
+0, 8192, 8192, 1024, 2048, 0xf7700954
+0, 9216, 9216, 1024, 2048, 0x3759f55c
+0, 10240, 10240, 1024, 2048, 0x0ca9f7ee
+0, 11264, 11264, 1024, 2048, 0xfb78fe99
+0, 12288, 12288, 1024, 2048, 0x93580191
+0, 13312, 13312, 1024, 2048, 0x079f0797
+0, 14336, 14336, 1024, 2048, 0xcf5ff38b
+0, 15360, 15360, 1024, 2048, 0xb201f701
+0, 16384, 16384, 1024, 2048, 0x7aac0476
+0, 17408, 17408, 1024, 2048, 0xd89b0222
+0, 18432, 18432, 1024, 2048, 0x160b013e
+0, 19456, 19456, 1024, 2048, 0x950ef0eb
+0, 20480, 20480, 1024, 2048, 0x9b51fada
diff --git a/tests/ref/fate/flac-midstream-bps b/tests/ref/fate/flac-midstream-bps
new file mode 100644
index 0000000000..1e93bcfc81
--- /dev/null
+++ b/tests/ref/fate/flac-midstream-bps
@@ -0,0 +1,26 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s32le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+0, 0, 0, 1024, 4096, 0x4c38f45b
+0, 1024, 1024, 1024, 4096, 0x4b0cf6ec
+0, 2048, 2048, 1024, 4096, 0x59c4fe05
+0, 3072, 3072, 1024, 4096, 0x8b7006b5
+0, 4096, 4096, 1024, 4096, 0x6799fcca
+0, 5120, 5120, 1024, 4096, 0x1753f510
+0, 6144, 6144, 1024, 4096, 0xaf7ef717
+0, 7168, 7168, 1024, 4096, 0x8d0a0826
+0, 8192, 8192, 1024, 4096, 0xe4520954
+0, 9216, 9216, 1024, 4096, 0x7c69f55c
+0, 10240, 10240, 1024, 4096, 0x1db1f7ee
+0, 11264, 11264, 1024, 4096, 0xf6e4fe99
+0, 12288, 12288, 1024, 4096, 0x2a8c0191
+0, 13312, 13312, 1024, 4096, 0x05940797
+0, 14336, 14336, 1024, 4096, 0xabadf38b
+0, 15360, 15360, 1024, 4096, 0x6a0af701
+0, 16384, 16384, 1024, 4096, 0xf0fe0476
+0, 17408, 17408, 1024, 4096, 0xb3ec0222
+0, 18432, 18432, 1024, 4096, 0x27c0013e
+0, 19456, 19456, 1024, 4096, 0x3b94f0eb
+0, 20480, 20480, 1024, 4096, 0x3973fada
diff --git a/tests/ref/fate/ogg-flac-chained-blocksize b/tests/ref/fate/ogg-flac-chained-blocksize
new file mode 100644
index 0000000000..0fb6fa8292
--- /dev/null
+++ b/tests/ref/fate/ogg-flac-chained-blocksize
@@ -0,0 +1,27 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+0, 0, 0, 1024, 2048, 0x2096f45b
+0, 1024, 1024, 1024, 2048, 0x2262f6ec
+0, 2048, 2048, 1024, 2048, 0xaa83fe05
+0, 3072, 3072, 1024, 2048, 0x487e06b5
+0, 4096, 4096, 1024, 2048, 0xb0abfcca
+0, 5120, 5120, 1024, 2048, 0x869ef510
+0, 6144, 6144, 1024, 2048, 0x547cf717
+0, 7168, 7168, 1024, 2048, 0xca830826
+0, 8192, 8192, 1024, 2048, 0xf7700954
+0, 9216, 9216, 1024, 2048, 0x3759f55c
+0, 10240, 10240, 1024, 2048, 0x0ca9f7ee
+0, 11264, 11264, 1024, 2048, 0xfb78fe99
+0, 12288, 12288, 1024, 2048, 0x93580191
+0, 13312, 13312, 1024, 2048, 0x079f0797
+0, 14336, 14336, 1024, 2048, 0xcf5ff38b
+0, 15360, 15360, 1024, 2048, 0xb201f701
+0, 16384, 16384, 1024, 2048, 0x7aac0476
+0, 17408, 17408, 1024, 2048, 0xd89b0222
+0, 18432, 18432, 1024, 2048, 0x160b013e
+0, 19456, 19456, 1024, 2048, 0x950ef0eb
+0, 20480, 20480, 1024, 2048, 0x9b51fada
+0, 21504, 21504, 546, 1092, 0x60af340b
diff --git a/tests/ref/fate/ogg-flac-chained-bps b/tests/ref/fate/ogg-flac-chained-bps
new file mode 100644
index 0000000000..291e7d9cf5
--- /dev/null
+++ b/tests/ref/fate/ogg-flac-chained-bps
@@ -0,0 +1,27 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s32le
+#sample_rate 0: 44100
+#channel_layout_name 0: mono
+0, 0, 0, 1024, 4096, 0x4c38f45b
+0, 1024, 1024, 1024, 4096, 0x4b0cf6ec
+0, 2048, 2048, 1024, 4096, 0x59c4fe05
+0, 3072, 3072, 1024, 4096, 0x8b7006b5
+0, 4096, 4096, 1024, 4096, 0x6799fcca
+0, 5120, 5120, 1024, 4096, 0x1753f510
+0, 6144, 6144, 1024, 4096, 0xaf7ef717
+0, 7168, 7168, 1024, 4096, 0x8d0a0826
+0, 8192, 8192, 1024, 4096, 0xe4520954
+0, 9216, 9216, 1024, 4096, 0x7c69f55c
+0, 10240, 10240, 1024, 4096, 0x1db1f7ee
+0, 11264, 11264, 1024, 4096, 0xf6e4fe99
+0, 12288, 12288, 1024, 4096, 0x2a8c0191
+0, 13312, 13312, 1024, 4096, 0x05940797
+0, 14336, 14336, 1024, 4096, 0xabadf38b
+0, 15360, 15360, 1024, 4096, 0x6a0af701
+0, 16384, 16384, 1024, 4096, 0xf0fe0476
+0, 17408, 17408, 1024, 4096, 0xb3ec0222
+0, 18432, 18432, 1024, 4096, 0x27c0013e
+0, 19456, 19456, 1024, 4096, 0x3b94f0eb
+0, 20480, 20480, 1024, 4096, 0x3973fada
+0, 21504, 21504, 546, 2184, 0x7e55340b