PR #26099 opened by Forgejo_Fairy
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26099
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26099.patch

When `apad` is timeline-disabled at input EOF, `push_frame()` returns success 
without producing a frame or signaling EOF, leaving the graph unable to finish. 
Return `AVERROR_EOF` so `activate()` propagates EOF at `next_pts`.

Fixes #26062. The regression was verified at a756ae41ed74 and its immediate 
parent 4583a24c653e: the parent completes the constant-disable reproducer, 
while the conversion to activate hangs.

Add three generated-input FATE tests for constant disable and a time window 
with 10- and 200-sample input frames. Expected output is stored in 
`tests/ref/fate/`.

Validation on AArch64 Linux with GCC 13.3.0:

- Existing `fate-filter-apad` and all three new tests pass.
- Both disabled test cases hang on unfixed master cc36bf4f5bb6 and terminate 
with the change.
- Byte comparisons confirm unchanged input for disabled length/duration padding 
options, zero padding, an already-satisfied whole length, and unspecified 
padding length.
- The enabled time-window case preserves the 200 input samples and appends 
exactly 40 samples of silence.


>From ec268bb7b9116caba63323a3ede13c20bc3ea568 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <[email protected]>
Date: Mon, 16 Nov 2026 11:52:19 +0000
Subject: [PATCH] avfilter/apad: signal EOF when disabled by the timeline

After input EOF, returning success from push_frame() while disabled
neither produces a frame nor signals output EOF. Return AVERROR_EOF so
activate() can terminate the output at next_pts.

Add FATE coverage for constant disable and a time window with input frame
sizes that leave apad disabled or enabled at EOF.

Fixes: a756ae41ed745af3ae93a71f3a38f277abba33ef
Fixes: #26062
Reported by yutong.

Assisted-by: Fairy
---
 libavfilter/af_apad.c                        |  2 +-
 tests/fate/filter-audio.mak                  |  7 ++++++
 tests/ref/fate/filter-apad-disabled          |  6 +++++
 tests/ref/fate/filter-apad-timeline-disabled | 25 ++++++++++++++++++++
 tests/ref/fate/filter-apad-timeline-enabled  |  7 ++++++
 5 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/filter-apad-disabled
 create mode 100644 tests/ref/fate/filter-apad-timeline-disabled
 create mode 100644 tests/ref/fate/filter-apad-timeline-enabled

diff --git a/libavfilter/af_apad.c b/libavfilter/af_apad.c
index cc214f7cc88..eaebfb7fc4b 100644
--- a/libavfilter/af_apad.c
+++ b/libavfilter/af_apad.c
@@ -96,7 +96,7 @@ static int push_frame(AVFilterLink *outlink)
     int n_out;
 
     if (ctx->is_disabled)
-        return 0;
+        return AVERROR_EOF;
     n_out = s->packet_size;
 
     if (s->whole_len >= 0 && s->pad_len < 0) {
diff --git a/tests/fate/filter-audio.mak b/tests/fate/filter-audio.mak
index f1035bba24a..3607741389e 100644
--- a/tests/fate/filter-audio.mak
+++ b/tests/fate/filter-audio.mak
@@ -86,6 +86,13 @@ fate-filter-apad: tests/data/asynth-44100-2.wav
 fate-filter-apad: SRC = $(TARGET_PATH)/tests/data/asynth-44100-2.wav
 fate-filter-apad: CMD = framecrc -i $(SRC) -af apad=pad_len=10
 
+FATE_AFILTER-$(call ALLYES, SINE_FILTER APAD_FILTER PCM_S16LE_ENCODER 
FRAMECRC_MUXER PIPE_PROTOCOL) += fate-filter-apad-disabled
+fate-filter-apad-disabled: CMD = framecrc -filter_complex 
"sine=r=1000:d=0.2,apad=pad_len=40:enable=0"
+
+FATE_AFILTER-$(call ALLYES, SINE_FILTER ASETNSAMPLES_FILTER APAD_FILTER 
PCM_S16LE_ENCODER FRAMECRC_MUXER PIPE_PROTOCOL) += 
fate-filter-apad-timeline-disabled fate-filter-apad-timeline-enabled
+fate-filter-apad-timeline-disabled: CMD = framecrc -filter_complex 
"sine=r=1000:d=0.2,asetnsamples=n=10:p=0,apad=pad_len=40:enable=lt(t\,0.05)"
+fate-filter-apad-timeline-enabled: CMD = framecrc -filter_complex 
"sine=r=1000:d=0.2,asetnsamples=n=200:p=0,apad=pad_len=40:enable=lt(t\,0.05)"
+
 FATE_AFILTER-$(call FILTERDEMDECENCMUX, ANEQUALIZER ARESAMPLE, WAV, PCM_S16LE, 
PCM_S16LE, WAV) += fate-filter-anequalizer
 fate-filter-anequalizer: tests/data/asynth-44100-2.wav
 fate-filter-anequalizer: tests/data/filtergraphs/anequalizer
diff --git a/tests/ref/fate/filter-apad-disabled 
b/tests/ref/fate/filter-apad-disabled
new file mode 100644
index 00000000000..05cfd93057d
--- /dev/null
+++ b/tests/ref/fate/filter-apad-disabled
@@ -0,0 +1,6 @@
+#tb 0: 1/1000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 1000
+#channel_layout_name 0: mono
+0,          0,          0,      200,      400, 0xcf3cbfb0
diff --git a/tests/ref/fate/filter-apad-timeline-disabled 
b/tests/ref/fate/filter-apad-timeline-disabled
new file mode 100644
index 00000000000..7c4e2624872
--- /dev/null
+++ b/tests/ref/fate/filter-apad-timeline-disabled
@@ -0,0 +1,25 @@
+#tb 0: 1/1000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 1000
+#channel_layout_name 0: mono
+0,          0,          0,       10,       20, 0x4ca40909
+0,         10,         10,       10,       20, 0x603a08a2
+0,         20,         20,       10,       20, 0x73be09b6
+0,         30,         30,       10,       20, 0x6bbb0a0c
+0,         40,         40,       10,       20, 0x6add0a7f
+0,         50,         50,       10,       20, 0x4ca40909
+0,         60,         60,       10,       20, 0x603a08a2
+0,         70,         70,       10,       20, 0x73be09b6
+0,         80,         80,       10,       20, 0x6bbb0a0c
+0,         90,         90,       10,       20, 0x6add0a7f
+0,        100,        100,       10,       20, 0x4ca40909
+0,        110,        110,       10,       20, 0x603a08a2
+0,        120,        120,       10,       20, 0x73be09b6
+0,        130,        130,       10,       20, 0x6bbb0a0c
+0,        140,        140,       10,       20, 0x6add0a7f
+0,        150,        150,       10,       20, 0x4ca40909
+0,        160,        160,       10,       20, 0x603a08a2
+0,        170,        170,       10,       20, 0x73be09b6
+0,        180,        180,       10,       20, 0x6bbb0a0c
+0,        190,        190,       10,       20, 0x6add0a7f
diff --git a/tests/ref/fate/filter-apad-timeline-enabled 
b/tests/ref/fate/filter-apad-timeline-enabled
new file mode 100644
index 00000000000..1eb42f69499
--- /dev/null
+++ b/tests/ref/fate/filter-apad-timeline-enabled
@@ -0,0 +1,7 @@
+#tb 0: 1/1000
+#media_type 0: audio
+#codec_id 0: pcm_s16le
+#sample_rate 0: 1000
+#channel_layout_name 0: mono
+0,          0,          0,      200,      400, 0xcf3cbfb0
+0,        200,        200,       40,       80, 0x00000000
-- 
2.54.0

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

Reply via email to