diff mbox series

[FFmpeg-devel,07/18] fftools/ffmpeg_filter: move filtergraph input type check to a better place

Message ID 20240306110319.17339-7-anton@khirnov.net
State Accepted
Commit cb0ec854fd2c1248412f725b343cb8bfa95a1898
Headers show
Series [FFmpeg-devel,01/18] fftools/cmdutils: fix printing group name in split_commandline() | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 6, 2024, 11:03 a.m. UTC
Perform it right after we figure out what the type is.
---
 fftools/ffmpeg_filter.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 7425e3d2ed..eb8d0aee78 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1005,6 +1005,14 @@  int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
 
         ifp->type      = avfilter_pad_get_type(cur->filter_ctx->input_pads,
                                                cur->pad_idx);
+
+        if (ifp->type != AVMEDIA_TYPE_VIDEO && ifp->type != AVMEDIA_TYPE_AUDIO) {
+            av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported "
+                   "currently.\n");
+            ret = AVERROR(ENOSYS);
+            goto fail;
+        }
+
         ifilter->name  = describe_filter_link(fg, cur, 1);
         if (!ifilter->name) {
             ret = AVERROR(ENOMEM);
@@ -1104,13 +1112,6 @@  static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
     enum AVMediaType type = ifp->type;
     int i, ret;
 
-    // TODO: support other filter types
-    if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
-        av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported "
-               "currently.\n");
-        return AVERROR(ENOSYS);
-    }
-
     if (ifp->linklabel) {
         AVFormatContext *s;
         AVStream       *st = NULL;