diff mbox series

[FFmpeg-devel,11/36] fftools/ffmpeg_demux: disallow using disabled input streams

Message ID 20230517102029.541-11-anton@khirnov.net
State Accepted
Commit 65f3d042a614ed62f4bc272f3859bb092e56e35e
Headers show
Series [FFmpeg-devel,01/36] fftools/ffmpeg: shorten a variable name | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed

Commit Message

Anton Khirnov May 17, 2023, 10:20 a.m. UTC
This is less ad-hoc than checking explicitly in every place that binds
an input stream to a filter or output.
---
 fftools/ffmpeg_demux.c  | 6 ++++++
 fftools/ffmpeg_filter.c | 5 -----
 2 files changed, 6 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index ae2133bdbf..df87e0f30a 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -848,6 +848,12 @@  static int ist_use(InputStream *ist, int decoding_needed)
 {
     DemuxStream *ds = ds_from_ist(ist);
 
+    if (ist->user_set_discard == AVDISCARD_ALL) {
+        av_log(ist, AV_LOG_ERROR, "Cannot %s a disabled input stream\n",
+               decoding_needed ? "decode" : "streamcopy");
+        return AVERROR(EINVAL);
+    }
+
     ist->discard          = 0;
     ist->st->discard      = ist->user_set_discard;
     ist->decoding_needed |= decoding_needed;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ca43b4803a..2c3e2a96f7 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -417,11 +417,6 @@  static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
             exit_program(1);
         }
         ist = input_files[file_idx]->streams[st->index];
-        if (ist->user_set_discard == AVDISCARD_ALL) {
-            av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
-                   "matches a disabled input stream.\n", p, fgp->graph_desc);
-            exit_program(1);
-        }
     } else {
         ist = ist_find_unused(type);
         if (!ist) {