[FFmpeg-cvslog] fftools/ffmpeg_filter: consolidate decoder/filter type checks

Anton Khirnov git at videolan.org
Tue Jan 30 11:07:20 EET 2024


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jan 10 12:31:58 2024 +0100| [d47bb91f8bc67427ee8e4f8855878f19efa6ef38] | committer: Anton Khirnov

fftools/ffmpeg_filter: consolidate decoder/filter type checks

Also perform them earlier.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d47bb91f8bc67427ee8e4f8855878f19efa6ef38
---

 fftools/ffmpeg_filter.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ab64b4610a..3e41e57986 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -663,6 +663,13 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
 
     av_assert0(!ifp->ist);
 
+    if (ifp->type != ist->par->codec_type &&
+        !(ifp->type == AVMEDIA_TYPE_VIDEO && ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE)) {
+        av_log(fgp, AV_LOG_ERROR, "Tried to connect %s stream to %s filtergraph input\n",
+               av_get_media_type_string(ist->par->codec_type), av_get_media_type_string(ifp->type));
+        return AVERROR(EINVAL);
+    }
+
     ifp->ist             = ist;
     ifp->type_src        = ist->st->codecpar->codec_type;
 
@@ -1476,12 +1483,6 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
     if (!par)
         return AVERROR(ENOMEM);
 
-    if (ist->dec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
-        av_log(fg, AV_LOG_ERROR, "Cannot connect video filter to audio input\n");
-        ret = AVERROR(EINVAL);
-        goto fail;
-    }
-
     if (!fr.num)
         fr = ist->framerate_guessed;
 
@@ -1598,11 +1599,6 @@ static int configure_input_audio_filter(FilterGraph *fg, AVFilterGraph *graph,
     int ret, pad_idx = 0;
     int64_t tsoffset = 0;
 
-    if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) {
-        av_log(fg, AV_LOG_ERROR, "Cannot connect audio filter to non audio input\n");
-        return AVERROR(EINVAL);
-    }
-
     ifp->time_base = (AVRational){ 1, ifp->sample_rate };
 
     av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);



More information about the ffmpeg-cvslog mailing list