Commit 864b7a9d10 for ffmpeg

commit 864b7a9d1040fe1b91ebf095872d29c5fa2324d1
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date:   Thu Oct 15 17:09:46 2026 +0200

    tests/fate: show the priming and pre-roll of audio codecs across containers

    Discarding samples at the start of a stream and after a seek should work
    the same way for every codec that needs it, whatever the container.

    For AAC in MP4, CAF, ADTS, FLV and Matroska, Opus in Ogg, Matroska, CAF
    and MPEG-TS, and MP3 with LAME and iTunes gapless info, print the
    priming and pre-roll declared for the audio stream, list the first
    packets read after a seek to 0.53 s, and decode 0.15 s from there. The
    decoded output is silenced so that only its timing is compared, as the
    decoders are not bit-exact across platforms.

    The references record the current output. Only Opus in Ogg and Matroska
    declares a pre-roll. MP3 declares no priming, as the demuxer applies it
    on its own. The decoding of AAC from MP4 and CAF starts late, by the
    container's priming applied after the seek, and the seek in Ogg lands
    at the start of the stream.

diff --git a/tests/Makefile b/tests/Makefile
index de71678e5c..54b1b7005f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -246,6 +246,7 @@ include $(SRC_PATH)/tests/fate/opus.mak
 include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/pixfmt.mak
 include $(SRC_PATH)/tests/fate/pixlet.mak
+include $(SRC_PATH)/tests/fate/preroll.mak
 include $(SRC_PATH)/tests/fate/probe.mak
 include $(SRC_PATH)/tests/fate/prores.mak
 include $(SRC_PATH)/tests/fate/qoa.mak
diff --git a/tests/fate/preroll.mak b/tests/fate/preroll.mak
new file mode 100644
index 0000000000..dabad89dcf
--- /dev/null
+++ b/tests/fate/preroll.mak
@@ -0,0 +1,52 @@
+# Codecs that need samples discarded: the priming at the start of a stream,
+# and the pre-roll before the target of a seek.
+#
+# For each sample: the priming and pre-roll declared for the audio stream,
+# the first packets read after a seek, and the timing of the decoded output
+# after a seek, with and without the samples before the target. The output
+# is silenced, as only its timing is compared and the decoders are not
+# bit-exact across platforms.
+
+PREROLL_SEEK_TS = 0.53
+
+# 1: test name, 2: demuxer, 3: decoder, 4: sample
+define FATE_PREROLL_TEST
+FATE_PREROLL_FFPROBE-$(call DEMDEC, $(2), $(3)) += fate-preroll-$(1)-declared fate-preroll-$(1)-landing
+fate-preroll-$(1)-declared: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -select_streams a:0 -show_entries stream=codec_name,sample_rate,initial_padding,seek_preroll -print_format compact $(TARGET_SAMPLES)/$(4)
+fate-preroll-$(1)-landing: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -select_streams a:0 -read_intervals $(PREROLL_SEEK_TS)%+\#3 -show_entries packet=pts,dts,duration -print_format compact $(TARGET_SAMPLES)/$(4)
+FATE_PREROLL_FFMPEG-$(call FRAMECRC, $(2), $(3), PCM_S16LE_ENCODER ARESAMPLE_FILTER VOLUME_FILTER) += fate-preroll-$(1)-decode
+fate-preroll-$(1)-decode: CMD = framecrc -ss $(PREROLL_SEEK_TS) -t 0.15 -i $(TARGET_SAMPLES)/$(4) -map 0:a:0 -af volume=0,aresample -c:a pcm_s16le
+FATE_PREROLL_FFMPEG-$(call FRAMECRC, $(2), $(3), PCM_S16LE_ENCODER ARESAMPLE_FILTER VOLUME_FILTER) += fate-preroll-$(1)-decode-noaccurate
+fate-preroll-$(1)-decode-noaccurate: CMD = framecrc -noaccurate_seek -ss $(PREROLL_SEEK_TS) -t 0.15 -i $(TARGET_SAMPLES)/$(4) -map 0:a:0 -af volume=0,aresample -c:a pcm_s16le
+endef
+
+$(eval $(call FATE_PREROLL_TEST,aac-mov,MOV,AAC,gapless/102400samples_qt-lc-aac.m4a))
+$(eval $(call FATE_PREROLL_TEST,aac-caf,CAF,AAC,caf/aac.caf))
+$(eval $(call FATE_PREROLL_TEST,aac-adts,AAC,AAC,aac/id3v2.aac))
+$(eval $(call FATE_PREROLL_TEST,aac-flv,FLV,AAC,h264/test-4867.flv))
+$(eval $(call FATE_PREROLL_TEST,aac-mkv,MATROSKA,AAC,mkv/test7_cut.mkv))
+$(eval $(call FATE_PREROLL_TEST,aac-he-adts,AAC,AAC,audiomatch/tones_afconvert_44100_stereo_aac_he.adts))
+$(eval $(call FATE_PREROLL_TEST,aac-he-implicit-mov,MOV,AAC,aac/CT_DecoderCheck/sbr_i-ps_i.mp4))
+$(eval $(call FATE_PREROLL_TEST,opus-ogg,OGG,OPUS,audiomatch/tones_opus_48000_stereo.opus))
+$(eval $(call FATE_PREROLL_TEST,opus-mkv,MATROSKA,OPUS,mkv/codec_delay_opus.mkv))
+$(eval $(call FATE_PREROLL_TEST,opus-caf,CAF,OPUS,caf/opus.caf))
+$(eval $(call FATE_PREROLL_TEST,opus-mpegts,MPEGTS,OPUS,opus/test-8-7.1.opus-small.ts))
+$(eval $(call FATE_PREROLL_TEST,mp3,MP3,MP3FLOAT,gapless/gapless.mp3))
+$(eval $(call FATE_PREROLL_TEST,mp3-itunes,MP3,MP3FLOAT,gapless/gapless-itunes.mp3))
+
+# A seek that lands inside the priming, which here spans the first three
+# packets: only the rest of the priming is to be skipped.
+FATE_PREROLL_FFMPEG-$(call FRAMECRC, CAF, AAC, PCM_S16LE_ENCODER ARESAMPLE_FILTER VOLUME_FILTER) += fate-preroll-aac-caf-decode-in-priming
+fate-preroll-aac-caf-decode-in-priming: CMD = framecrc -noaccurate_seek -ss 0.01 -t 0.1 -i $(TARGET_SAMPLES)/caf/aac.caf -af volume=0,aresample -c:a pcm_s16le
+
+# A forward seek, as ffplay does: the range starts before the target and is
+# open at the end.
+FATE_PREROLL_SEEK-$(call DEMDEC, MOV, AAC) += fate-preroll-aac-mov-seek-forward
+fate-preroll-aac-mov-seek-forward: CMD = run libavformat/tests/seek$(EXESUF) $(TARGET_SAMPLES)/gapless/102400samples_qt-lc-aac.m4a -seekforw 530000 -seekmin 400000 -frames 2 -duration 3
+$(FATE_PREROLL_SEEK-yes): libavformat/tests/seek$(EXESUF)
+
+FATE_SAMPLES_FFPROBE += $(FATE_PREROLL_FFPROBE-yes)
+FATE_SAMPLES_AVCONV  += $(FATE_PREROLL_SEEK-yes)
+FATE_SAMPLES_FFMPEG  += $(FATE_PREROLL_FFMPEG-yes)
+
+fate-preroll: $(FATE_PREROLL_FFPROBE-yes) $(FATE_PREROLL_FFMPEG-yes) $(FATE_PREROLL_SEEK-yes)
diff --git a/tests/ref/fate/preroll-aac-adts-declared b/tests/ref/fate/preroll-aac-adts-declared
new file mode 100644
index 0000000000..ff5c5aab2a
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-adts-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=48000|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-adts-decode b/tests/ref/fate/preroll-aac-adts-decode
new file mode 100644
index 0000000000..b968a77f21
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-adts-decode
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: mono
+0,          0,          0,      160,      320, 0x00000000
+0,        160,        160,     1024,     2048, 0x00000000
+0,       1184,       1184,     1024,     2048, 0x00000000
+0,       2208,       2208,     1024,     2048, 0x00000000
+0,       3232,       3232,     1024,     2048, 0x00000000
+0,       4256,       4256,     1024,     2048, 0x00000000
+0,       5280,       5280,     1024,     2048, 0x00000000
+0,       6304,       6304,      896,     1792, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-adts-decode-noaccurate b/tests/ref/fate/preroll-aac-adts-decode-noaccurate
new file mode 100644
index 0000000000..975ab4b272
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-adts-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: mono
+0,       -864,       -864,     1024,     2048, 0x00000000
+0,        160,        160,     1024,     2048, 0x00000000
+0,       1184,       1184,     1024,     2048, 0x00000000
+0,       2208,       2208,     1024,     2048, 0x00000000
+0,       3232,       3232,     1024,     2048, 0x00000000
+0,       4256,       4256,     1024,     2048, 0x00000000
+0,       5280,       5280,     1024,     2048, 0x00000000
+0,       6304,       6304,       32,       64, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-adts-landing b/tests/ref/fate/preroll-aac-adts-landing
new file mode 100644
index 0000000000..a5b0c457fb
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-adts-landing
@@ -0,0 +1,3 @@
+packet|pts=14450688|dts=14450688|duration=602112
+packet|pts=15052800|dts=15052800|duration=602112
+packet|pts=15654912|dts=15654912|duration=602112
diff --git a/tests/ref/fate/preroll-aac-caf-declared b/tests/ref/fate/preroll-aac-caf-declared
new file mode 100644
index 0000000000..444e0046b3
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-caf-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=48000|initial_padding=2112|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-caf-decode b/tests/ref/fate/preroll-aac-caf-decode
new file mode 100644
index 0000000000..e687d4d4c7
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-caf-decode
@@ -0,0 +1,11 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,       1184,       1184,      960,     3840, 0x00000000
+0,       2144,       2144,     1024,     4096, 0x00000000
+0,       3168,       3168,     1024,     4096, 0x00000000
+0,       4192,       4192,     1024,     4096, 0x00000000
+0,       5216,       5216,     1024,     4096, 0x00000000
+0,       6240,       6240,      960,     3840, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-caf-decode-in-priming b/tests/ref/fate/preroll-aac-caf-decode-in-priming
new file mode 100644
index 0000000000..c7fe14ad30
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-caf-decode-in-priming
@@ -0,0 +1,10 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,       1568,       1568,      960,     3840, 0x00000000
+0,       2528,       2528,     1024,     4096, 0x00000000
+0,       3552,       3552,     1024,     4096, 0x00000000
+0,       4576,       4576,     1024,     4096, 0x00000000
+0,       5600,       5600,      768,     3072, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-caf-decode-noaccurate b/tests/ref/fate/preroll-aac-caf-decode-noaccurate
new file mode 100644
index 0000000000..32e7585257
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-caf-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,       1184,       1184,      960,     3840, 0x00000000
+0,       2144,       2144,     1024,     4096, 0x00000000
+0,       3168,       3168,     1024,     4096, 0x00000000
+0,       4192,       4192,     1024,     4096, 0x00000000
+0,       5216,       5216,     1024,     4096, 0x00000000
+0,       6240,       6240,     1024,     4096, 0x00000000
+0,       7264,       7264,     1024,     4096, 0x00000000
+0,       8288,       8288,       96,      384, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-caf-landing b/tests/ref/fate/preroll-aac-caf-landing
new file mode 100644
index 0000000000..97b1da94e4
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-caf-landing
@@ -0,0 +1,3 @@
+packet|pts=24512|dts=24512|duration=1024
+packet|pts=25536|dts=25536|duration=1024
+packet|pts=26560|dts=26560|duration=1024
diff --git a/tests/ref/fate/preroll-aac-flv-declared b/tests/ref/fate/preroll-aac-flv-declared
new file mode 100644
index 0000000000..ff5c5aab2a
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-flv-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=48000|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-flv-decode b/tests/ref/fate/preroll-aac-flv-decode
new file mode 100644
index 0000000000..d245781d6a
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-flv-decode
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,          0,          0,      544,     2176, 0x00000000
+0,        544,        544,     1024,     4096, 0x00000000
+0,       1568,       1568,     1024,     4096, 0x00000000
+0,       2592,       2592,     1024,     4096, 0x00000000
+0,       3616,       3616,     1024,     4096, 0x00000000
+0,       4640,       4640,     1024,     4096, 0x00000000
+0,       5664,       5664,     1024,     4096, 0x00000000
+0,       6688,       6688,      512,     2048, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-flv-decode-noaccurate b/tests/ref/fate/preroll-aac-flv-decode-noaccurate
new file mode 100644
index 0000000000..614a78c46f
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-flv-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,     -25056,     -25056,     1024,     4096, 0x00000000
+0,     -24032,     -24032,     1024,     4096, 0x00000000
+0,     -23008,     -23008,     1024,     4096, 0x00000000
+0,     -21984,     -21984,     1024,     4096, 0x00000000
+0,     -20960,     -20960,     1024,     4096, 0x00000000
+0,     -19936,     -19936,     1024,     4096, 0x00000000
+0,     -18912,     -18912,     1024,     4096, 0x00000000
+0,     -17888,     -17888,       32,      128, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-flv-landing b/tests/ref/fate/preroll-aac-flv-landing
new file mode 100644
index 0000000000..48a85ca942
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-flv-landing
@@ -0,0 +1,3 @@
+packet|pts=520|dts=520|duration=21
+packet|pts=541|dts=541|duration=21
+packet|pts=563|dts=563|duration=21
diff --git a/tests/ref/fate/preroll-aac-he-adts-declared b/tests/ref/fate/preroll-aac-he-adts-declared
new file mode 100644
index 0000000000..4428dd300e
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-adts-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=44100|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-he-adts-decode b/tests/ref/fate/preroll-aac-he-adts-decode
new file mode 100644
index 0000000000..a6552ba4e9
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-adts-decode
@@ -0,0 +1,9 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,          0,          0,     1203,     4812, 0x00000000
+0,       1203,       1203,     2048,     8192, 0x00000000
+0,       3251,       3251,     2048,     8192, 0x00000000
+0,       5299,       5299,     1316,     5264, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-he-adts-decode-noaccurate b/tests/ref/fate/preroll-aac-he-adts-decode-noaccurate
new file mode 100644
index 0000000000..7499e24eb4
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-adts-decode-noaccurate
@@ -0,0 +1,9 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       -845,       -845,     2048,     8192, 0x00000000
+0,       1203,       1203,     2048,     8192, 0x00000000
+0,       3251,       3251,     2048,     8192, 0x00000000
+0,       5299,       5299,      471,     1884, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-he-adts-landing b/tests/ref/fate/preroll-aac-he-adts-landing
new file mode 100644
index 0000000000..1a25edb5ab
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-adts-landing
@@ -0,0 +1,3 @@
+packet|pts=14417920|dts=14417920|duration=1310720
+packet|pts=15728640|dts=15728640|duration=1310720
+packet|pts=17039360|dts=17039360|duration=1310720
diff --git a/tests/ref/fate/preroll-aac-he-implicit-mov-declared b/tests/ref/fate/preroll-aac-he-implicit-mov-declared
new file mode 100644
index 0000000000..4428dd300e
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-implicit-mov-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=44100|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-he-implicit-mov-decode b/tests/ref/fate/preroll-aac-he-implicit-mov-decode
new file mode 100644
index 0000000000..fe7cbac731
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-implicit-mov-decode
@@ -0,0 +1,9 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,          0,          0,     1202,     4808, 0x00000000
+0,       1202,       1202,     2048,     8192, 0x00000000
+0,       3250,       3250,     2048,     8192, 0x00000000
+0,       5298,       5298,     1317,     5268, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-he-implicit-mov-decode-noaccurate b/tests/ref/fate/preroll-aac-he-implicit-mov-decode-noaccurate
new file mode 100644
index 0000000000..35c4c19cf0
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-implicit-mov-decode-noaccurate
@@ -0,0 +1,9 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       -846,       -846,     2048,     8192, 0x00000000
+0,       1202,       1202,     2048,     8192, 0x00000000
+0,       3250,       3250,     2048,     8192, 0x00000000
+0,       5298,       5298,      471,     1884, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-he-implicit-mov-landing b/tests/ref/fate/preroll-aac-he-implicit-mov-landing
new file mode 100644
index 0000000000..2aba1a3532
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-he-implicit-mov-landing
@@ -0,0 +1,3 @@
+packet|pts=11264|dts=11264|duration=1024
+packet|pts=12288|dts=12288|duration=1024
+packet|pts=13312|dts=13312|duration=1024
diff --git a/tests/ref/fate/preroll-aac-mkv-declared b/tests/ref/fate/preroll-aac-mkv-declared
new file mode 100644
index 0000000000..ff5c5aab2a
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mkv-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=48000|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-mkv-decode b/tests/ref/fate/preroll-aac-mkv-decode
new file mode 100644
index 0000000000..07b26cf18b
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mkv-decode
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,          0,          0,      552,     2208, 0x00000000
+0,        552,        552,     1024,     4096, 0x00000000
+0,       1560,       1560,     1024,     4096, 0x00000000
+0,       2584,       2584,     1024,     4096, 0x00000000
+0,       3608,       3608,     1024,     4096, 0x00000000
+0,       4632,       4632,     1024,     4096, 0x00000000
+0,       5656,       5656,     1024,     4096, 0x00000000
+0,       6680,       6680,      520,     2080, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-mkv-decode-noaccurate b/tests/ref/fate/preroll-aac-mkv-decode-noaccurate
new file mode 100644
index 0000000000..3cb5a136bd
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mkv-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,     -25056,     -25056,     1024,     4096, 0x00000000
+0,     -24032,     -24032,     1024,     4096, 0x00000000
+0,     -23016,     -23016,     1024,     4096, 0x00000000
+0,     -21992,     -21992,     1024,     4096, 0x00000000
+0,     -20968,     -20968,     1024,     4096, 0x00000000
+0,     -19944,     -19944,     1024,     4096, 0x00000000
+0,     -18920,     -18920,     1024,     4096, 0x00000000
+0,     -17896,     -17896,       40,      160, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-mkv-landing b/tests/ref/fate/preroll-aac-mkv-landing
new file mode 100644
index 0000000000..5b89b5dcc7
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mkv-landing
@@ -0,0 +1,3 @@
+packet|pts=520|dts=520|duration=21
+packet|pts=541|dts=541|duration=21
+packet|pts=562|dts=562|duration=22
diff --git a/tests/ref/fate/preroll-aac-mov-declared b/tests/ref/fate/preroll-aac-mov-declared
new file mode 100644
index 0000000000..373bee20c9
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mov-declared
@@ -0,0 +1 @@
+stream|codec_name=aac|sample_rate=44100|initial_padding=2112|seek_preroll=0
diff --git a/tests/ref/fate/preroll-aac-mov-decode b/tests/ref/fate/preroll-aac-mov-decode
new file mode 100644
index 0000000000..a2c70e25a5
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mov-decode
@@ -0,0 +1,11 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       1203,       1203,      960,     3840, 0x00000000
+0,       2163,       2163,     1024,     4096, 0x00000000
+0,       3187,       3187,     1024,     4096, 0x00000000
+0,       4211,       4211,     1024,     4096, 0x00000000
+0,       5235,       5235,     1024,     4096, 0x00000000
+0,       6259,       6259,      356,     1424, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-mov-decode-noaccurate b/tests/ref/fate/preroll-aac-mov-decode-noaccurate
new file mode 100644
index 0000000000..b04a555267
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mov-decode-noaccurate
@@ -0,0 +1,12 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       1203,       1203,      960,     3840, 0x00000000
+0,       2163,       2163,     1024,     4096, 0x00000000
+0,       3187,       3187,     1024,     4096, 0x00000000
+0,       4211,       4211,     1024,     4096, 0x00000000
+0,       5235,       5235,     1024,     4096, 0x00000000
+0,       6259,       6259,     1024,     4096, 0x00000000
+0,       7283,       7283,      535,     2140, 0x00000000
diff --git a/tests/ref/fate/preroll-aac-mov-landing b/tests/ref/fate/preroll-aac-mov-landing
new file mode 100644
index 0000000000..d4660a6cad
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mov-landing
@@ -0,0 +1,3 @@
+packet|pts=22528|dts=22528|duration=1024
+packet|pts=23552|dts=23552|duration=1024
+packet|pts=24576|dts=24576|duration=1024
diff --git a/tests/ref/fate/preroll-aac-mov-seek-forward b/tests/ref/fate/preroll-aac-mov-seek-forward
new file mode 100644
index 0000000000..9c7a58068e
--- /dev/null
+++ b/tests/ref/fate/preroll-aac-mov-seek-forward
@@ -0,0 +1,80 @@
+ret: 0         st: 0 flags:1 dts: 0.534059 pts: 0.534059 pos:   2389 size:    27
+ret: 0         st: 0 flags:1 dts: 0.557279 pts: 0.557279 pos:   2416 size:    27
+ret: 0         st:-1 flags:0  ts:-1.000000
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st:-1 flags:1  ts:-0.105833
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st: 0 flags:0  ts: 0.788345
+ret: 0         st: 0 flags:1 dts: 0.789478 pts: 0.789478 pos:   2691 size:    28
+ret: 0         st: 0 flags:1 dts: 0.812698 pts: 0.812698 pos:   2719 size:    28
+ret: 0         st: 0 flags:1  ts: 1.682494
+ret: 0         st: 0 flags:1 dts: 1.671837 pts: 1.671837 pos:   3903 size:    39
+ret: 0         st: 0 flags:1 dts: 1.695057 pts: 1.695057 pos:   3942 size:    42
+ret: 0         st:-1 flags:0  ts:-0.423332
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st:-1 flags:1  ts: 0.470835
+ret: 0         st: 0 flags:1 dts: 0.464399 pts: 0.464399 pos:   2309 size:    27
+ret: 0         st: 0 flags:1 dts: 0.487619 pts: 0.487619 pos:   2336 size:    27
+ret: 0         st: 0 flags:0  ts: 1.365011
+ret: 0         st: 0 flags:1 dts: 1.369977 pts: 1.369977 pos:   3405 size:    30
+ret: 0         st: 0 flags:1 dts: 1.393197 pts: 1.393197 pos:   3435 size:    30
+ret: 0         st: 0 flags:1  ts:-0.740839
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st:-1 flags:0  ts: 0.153336
+ret: 0         st: 0 flags:1 dts: 0.162540 pts: 0.162540 pos:   1961 size:    26
+ret: 0         st: 0 flags:1 dts: 0.185760 pts: 0.185760 pos:   1987 size:    27
+ret: 0         st:-1 flags:1  ts: 1.047503
+ret: 0         st: 0 flags:1 dts: 1.044898 pts: 1.044898 pos:   2996 size:    28
+ret: 0         st: 0 flags:1 dts: 1.068118 pts: 1.068118 pos:   3024 size:    28
+ret: 0         st: 0 flags:0  ts: 1.941678
+ret: 0         st: 0 flags:1 dts: 1.950476 pts: 1.950476 pos:   4392 size:    41
+ret: 0         st: 0 flags:1 dts: 1.973696 pts: 1.973696 pos:   4433 size:    41
+ret: 0         st: 0 flags:1  ts:-0.164172
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st:-1 flags:0  ts: 0.730004
+ret: 0         st: 0 flags:1 dts: 0.743039 pts: 0.743039 pos:   2636 size:    27
+ret: 0         st: 0 flags:1 dts: 0.766259 pts: 0.766259 pos:   2663 size:    28
+ret: 0         st:-1 flags:1  ts: 1.624171
+ret: 0         st: 0 flags:1 dts: 1.602177 pts: 1.602177 pos:   3780 size:    41
+ret: 0         st: 0 flags:1 dts: 1.625397 pts: 1.625397 pos:   3821 size:    41
+ret: 0         st: 0 flags:0  ts:-0.481655
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st: 0 flags:1  ts: 0.412494
+ret: 0         st: 0 flags:1 dts: 0.394739 pts: 0.394739 pos:   2229 size:    26
+ret: 0         st: 0 flags:1 dts: 0.417959 pts: 0.417959 pos:   2255 size:    27
+ret: 0         st:-1 flags:0  ts: 1.306672
+ret: 0         st: 0 flags:1 dts: 1.323537 pts: 1.323537 pos:   3346 size:    29
+ret: 0         st: 0 flags:1 dts: 1.346757 pts: 1.346757 pos:   3375 size:    30
+ret: 0         st:-1 flags:1  ts:-0.799161
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st: 0 flags:0  ts: 0.095011
+ret: 0         st: 0 flags:1 dts: 0.116100 pts: 0.116100 pos:   1907 size:    27
+ret: 0         st: 0 flags:1 dts: 0.139320 pts: 0.139320 pos:   1934 size:    27
+ret: 0         st: 0 flags:1  ts: 0.989184
+ret: 0         st: 0 flags:1 dts: 0.975238 pts: 0.975238 pos:   2913 size:    27
+ret: 0         st: 0 flags:1 dts: 0.998458 pts: 0.998458 pos:   2940 size:    28
+ret: 0         st:-1 flags:0  ts: 1.883340
+ret: 0         st: 0 flags:1 dts: 1.904036 pts: 1.904036 pos:   4311 size:    39
+ret: 0         st: 0 flags:1 dts: 1.927256 pts: 1.927256 pos:   4350 size:    42
+ret: 0         st:-1 flags:1  ts:-0.222493
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st: 0 flags:0  ts: 0.671678
+ret: 0         st: 0 flags:1 dts: 0.673379 pts: 0.673379 pos:   2553 size:    28
+ret: 0         st: 0 flags:1 dts: 0.696599 pts: 0.696599 pos:   2581 size:    28
+ret: 0         st: 0 flags:1  ts: 1.565850
+ret: 0         st: 0 flags:1 dts: 1.555737 pts: 1.555737 pos:   3699 size:    39
+ret: 0         st: 0 flags:1 dts: 1.578957 pts: 1.578957 pos:   3738 size:    42
+ret: 0         st:-1 flags:0  ts:-0.539992
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1366 size:     6 skip:2112 discard:0
+ret: 0         st: 0 flags:1 dts: 0.023220 pts: 0.023220 pos:   1372 size:   251
+ret: 0         st:-1 flags:1  ts: 0.354175
+ret: 0         st: 0 flags:1 dts: 0.348299 pts: 0.348299 pos:   2175 size:    27
+ret: 0         st: 0 flags:1 dts: 0.371519 pts: 0.371519 pos:   2202 size:    27
diff --git a/tests/ref/fate/preroll-mp3-declared b/tests/ref/fate/preroll-mp3-declared
new file mode 100644
index 0000000000..a8ddf5753b
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-declared
@@ -0,0 +1 @@
+stream|codec_name=mp3|sample_rate=44100|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-mp3-decode b/tests/ref/fate/preroll-mp3-decode
new file mode 100644
index 0000000000..4be4c12085
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-decode
@@ -0,0 +1,11 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,          0,          0,      866,     3464, 0x00000000
+0,        866,        866,     1152,     4608, 0x00000000
+0,       2018,       2018,     1152,     4608, 0x00000000
+0,       3170,       3170,     1152,     4608, 0x00000000
+0,       4322,       4322,     1152,     4608, 0x00000000
+0,       5474,       5474,     1141,     4564, 0x00000000
diff --git a/tests/ref/fate/preroll-mp3-decode-noaccurate b/tests/ref/fate/preroll-mp3-decode-noaccurate
new file mode 100644
index 0000000000..4726a2af44
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-decode-noaccurate
@@ -0,0 +1,11 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       -286,       -286,     1152,     4608, 0x00000000
+0,        866,        866,     1152,     4608, 0x00000000
+0,       2018,       2018,     1152,     4608, 0x00000000
+0,       3170,       3170,     1152,     4608, 0x00000000
+0,       4322,       4322,     1152,     4608, 0x00000000
+0,       5474,       5474,      855,     3420, 0x00000000
diff --git a/tests/ref/fate/preroll-mp3-itunes-declared b/tests/ref/fate/preroll-mp3-itunes-declared
new file mode 100644
index 0000000000..a8ddf5753b
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-itunes-declared
@@ -0,0 +1 @@
+stream|codec_name=mp3|sample_rate=44100|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-mp3-itunes-decode b/tests/ref/fate/preroll-mp3-itunes-decode
new file mode 100644
index 0000000000..7c29cc513d
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-itunes-decode
@@ -0,0 +1,12 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,          0,          0,      291,     1164, 0x00000000
+0,        291,        291,     1152,     4608, 0x00000000
+0,       1443,       1443,     1152,     4608, 0x00000000
+0,       2595,       2595,     1152,     4608, 0x00000000
+0,       3747,       3747,     1152,     4608, 0x00000000
+0,       4899,       4899,     1152,     4608, 0x00000000
+0,       6051,       6051,      564,     2256, 0x00000000
diff --git a/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate b/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate
new file mode 100644
index 0000000000..960cd66525
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-itunes-decode-noaccurate
@@ -0,0 +1,11 @@
+#tb 0: 1/44100
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 44100
+#channel_layout_name 0: stereo
+0,       -861,       -861,     1152,     4608, 0x00000000
+0,        291,        291,     1152,     4608, 0x00000000
+0,       1443,       1443,     1152,     4608, 0x00000000
+0,       2595,       2595,     1152,     4608, 0x00000000
+0,       3747,       3747,     1152,     4608, 0x00000000
+0,       4899,       4899,      855,     3420, 0x00000000
diff --git a/tests/ref/fate/preroll-mp3-itunes-landing b/tests/ref/fate/preroll-mp3-itunes-landing
new file mode 100644
index 0000000000..a52c329e73
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-itunes-landing
@@ -0,0 +1,3 @@
+packet|pts=7372800|dts=7372800|duration=368640
+packet|pts=7741440|dts=7741440|duration=368640
+packet|pts=8110080|dts=8110080|duration=368640
diff --git a/tests/ref/fate/preroll-mp3-landing b/tests/ref/fate/preroll-mp3-landing
new file mode 100644
index 0000000000..a52c329e73
--- /dev/null
+++ b/tests/ref/fate/preroll-mp3-landing
@@ -0,0 +1,3 @@
+packet|pts=7372800|dts=7372800|duration=368640
+packet|pts=7741440|dts=7741440|duration=368640
+packet|pts=8110080|dts=8110080|duration=368640
diff --git a/tests/ref/fate/preroll-opus-caf-declared b/tests/ref/fate/preroll-opus-caf-declared
new file mode 100644
index 0000000000..41af72aed5
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-caf-declared
@@ -0,0 +1 @@
+stream|codec_name=opus|sample_rate=48000|initial_padding=312|seek_preroll=0
diff --git a/tests/ref/fate/preroll-opus-caf-decode b/tests/ref/fate/preroll-opus-caf-decode
new file mode 100644
index 0000000000..7af034f637
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-caf-decode
@@ -0,0 +1,14 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,          0,          0,      168,      672, 0x00000000
+0,        168,        168,      960,     3840, 0x00000000
+0,       1128,       1128,      960,     3840, 0x00000000
+0,       2088,       2088,      960,     3840, 0x00000000
+0,       3048,       3048,      960,     3840, 0x00000000
+0,       4008,       4008,      960,     3840, 0x00000000
+0,       4968,       4968,      960,     3840, 0x00000000
+0,       5928,       5928,      960,     3840, 0x00000000
+0,       6888,       6888,      312,     1248, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-caf-decode-noaccurate b/tests/ref/fate/preroll-opus-caf-decode-noaccurate
new file mode 100644
index 0000000000..a35cbac6a2
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-caf-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,       -480,       -480,      648,     2592, 0x00000000
+0,        168,        168,      960,     3840, 0x00000000
+0,       1128,       1128,      960,     3840, 0x00000000
+0,       2088,       2088,      960,     3840, 0x00000000
+0,       3048,       3048,      960,     3840, 0x00000000
+0,       4008,       4008,      960,     3840, 0x00000000
+0,       4968,       4968,      960,     3840, 0x00000000
+0,       5928,       5928,      792,     3168, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-caf-landing b/tests/ref/fate/preroll-opus-caf-landing
new file mode 100644
index 0000000000..59f055919e
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-caf-landing
@@ -0,0 +1,3 @@
+packet|pts=24648|dts=24648|duration=960
+packet|pts=25608|dts=25608|duration=960
+packet|pts=26568|dts=26568|duration=960
diff --git a/tests/ref/fate/preroll-opus-mkv-declared b/tests/ref/fate/preroll-opus-mkv-declared
new file mode 100644
index 0000000000..1ccaf495bd
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mkv-declared
@@ -0,0 +1 @@
+stream|codec_name=opus|sample_rate=48000|initial_padding=312|seek_preroll=3840
diff --git a/tests/ref/fate/preroll-opus-mkv-decode b/tests/ref/fate/preroll-opus-mkv-decode
new file mode 100644
index 0000000000..ea28fd6c45
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mkv-decode
@@ -0,0 +1,14 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: mono
+0,          0,          0,      216,      432, 0x00000000
+0,        216,        216,      960,     1920, 0x00000000
+0,       1176,       1176,      960,     1920, 0x00000000
+0,       2136,       2136,      960,     1920, 0x00000000
+0,       3096,       3096,      960,     1920, 0x00000000
+0,       4056,       4056,      960,     1920, 0x00000000
+0,       5016,       5016,      960,     1920, 0x00000000
+0,       5976,       5976,      960,     1920, 0x00000000
+0,       6936,       6936,      264,      528, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-mkv-decode-noaccurate b/tests/ref/fate/preroll-opus-mkv-decode-noaccurate
new file mode 100644
index 0000000000..2e46ab5e4b
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mkv-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: mono
+0,       -432,       -432,      648,     1296, 0x00000000
+0,        216,        216,      960,     1920, 0x00000000
+0,       1176,       1176,      960,     1920, 0x00000000
+0,       2136,       2136,      960,     1920, 0x00000000
+0,       3096,       3096,      960,     1920, 0x00000000
+0,       4056,       4056,      960,     1920, 0x00000000
+0,       5016,       5016,      960,     1920, 0x00000000
+0,       5976,       5976,      792,     1584, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-mkv-landing b/tests/ref/fate/preroll-opus-mkv-landing
new file mode 100644
index 0000000000..7104a308cb
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mkv-landing
@@ -0,0 +1,3 @@
+packet|pts=514|dts=514|duration=20
+packet|pts=534|dts=534|duration=20
+packet|pts=554|dts=554|duration=20
diff --git a/tests/ref/fate/preroll-opus-mpegts-declared b/tests/ref/fate/preroll-opus-mpegts-declared
new file mode 100644
index 0000000000..5a47f4983a
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mpegts-declared
@@ -0,0 +1 @@
+stream|codec_name=opus|sample_rate=48000|initial_padding=0|seek_preroll=0
diff --git a/tests/ref/fate/preroll-opus-mpegts-decode b/tests/ref/fate/preroll-opus-mpegts-decode
new file mode 100644
index 0000000000..c47f4f565e
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mpegts-decode
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: 7.1
+0,          0,          0,      480,     7680, 0x00000000
+0,        480,        480,      960,    15360, 0x00000000
+0,       1440,       1440,      960,    15360, 0x00000000
+0,       2400,       2400,      960,    15360, 0x00000000
+0,       3360,       3360,      960,    15360, 0x00000000
+0,       4320,       4320,      960,    15360, 0x00000000
+0,       5280,       5280,      960,    15360, 0x00000000
+0,       6240,       6240,      960,    15360, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-mpegts-decode-noaccurate b/tests/ref/fate/preroll-opus-mpegts-decode-noaccurate
new file mode 100644
index 0000000000..8567e242e2
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mpegts-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: 7.1
+0,       -480,       -480,      960,    15360, 0x00000000
+0,        480,        480,      960,    15360, 0x00000000
+0,       1440,       1440,      960,    15360, 0x00000000
+0,       2400,       2400,      960,    15360, 0x00000000
+0,       3360,       3360,      960,    15360, 0x00000000
+0,       4320,       4320,      960,    15360, 0x00000000
+0,       5280,       5280,      960,    15360, 0x00000000
+0,       6240,       6240,      480,     7680, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-mpegts-landing b/tests/ref/fate/preroll-opus-mpegts-landing
new file mode 100644
index 0000000000..29f4104fb9
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-mpegts-landing
@@ -0,0 +1,3 @@
+packet|pts=46800|dts=46800|duration=1800
+packet|pts=48600|dts=48600|duration=1800
+packet|pts=50400|dts=50400|duration=1800
diff --git a/tests/ref/fate/preroll-opus-ogg-declared b/tests/ref/fate/preroll-opus-ogg-declared
new file mode 100644
index 0000000000..1ccaf495bd
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-ogg-declared
@@ -0,0 +1 @@
+stream|codec_name=opus|sample_rate=48000|initial_padding=312|seek_preroll=3840
diff --git a/tests/ref/fate/preroll-opus-ogg-decode b/tests/ref/fate/preroll-opus-ogg-decode
new file mode 100644
index 0000000000..7af034f637
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-ogg-decode
@@ -0,0 +1,14 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,          0,          0,      168,      672, 0x00000000
+0,        168,        168,      960,     3840, 0x00000000
+0,       1128,       1128,      960,     3840, 0x00000000
+0,       2088,       2088,      960,     3840, 0x00000000
+0,       3048,       3048,      960,     3840, 0x00000000
+0,       4008,       4008,      960,     3840, 0x00000000
+0,       4968,       4968,      960,     3840, 0x00000000
+0,       5928,       5928,      960,     3840, 0x00000000
+0,       6888,       6888,      312,     1248, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-ogg-decode-noaccurate b/tests/ref/fate/preroll-opus-ogg-decode-noaccurate
new file mode 100644
index 0000000000..d3544a7f4a
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-ogg-decode-noaccurate
@@ -0,0 +1,13 @@
+#tb 0: 1/48000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 48000
+#channel_layout_name 0: stereo
+0,     -25440,     -25440,      648,     2592, 0x00000000
+0,     -24792,     -24792,      960,     3840, 0x00000000
+0,     -23832,     -23832,      960,     3840, 0x00000000
+0,     -22872,     -22872,      960,     3840, 0x00000000
+0,     -21912,     -21912,      960,     3840, 0x00000000
+0,     -20952,     -20952,      960,     3840, 0x00000000
+0,     -19992,     -19992,      960,     3840, 0x00000000
+0,     -19032,     -19032,      792,     3168, 0x00000000
diff --git a/tests/ref/fate/preroll-opus-ogg-landing b/tests/ref/fate/preroll-opus-ogg-landing
new file mode 100644
index 0000000000..5c7b0428c1
--- /dev/null
+++ b/tests/ref/fate/preroll-opus-ogg-landing
@@ -0,0 +1,3 @@
+packet|pts=-312|dts=-312|duration=960
+packet|pts=648|dts=648|duration=960
+packet|pts=1608|dts=1608|duration=960