[FFmpeg-cvslog] fftools/ffmpeg_filter: return error codes from init_input_filter() instead of aborting

Anton Khirnov git at videolan.org
Thu Jul 20 21:56:53 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Jul 13 15:11:07 2023 +0200| [a52ee1aa47b5a4a489ec0c34f7bc752a95dbae04] | committer: Anton Khirnov

fftools/ffmpeg_filter: return error codes from init_input_filter() instead of aborting

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

 fftools/ffmpeg_filter.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index cdf5610620..79e034d248 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -908,7 +908,7 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
     return 0;
 }
 
-static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
+static int init_input_filter(FilterGraph *fg, InputFilter *ifilter)
 {
     FilterGraphPriv *fgp = fgp_from_fg(fg);
     InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
@@ -920,7 +920,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
     if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
         av_log(fg, AV_LOG_FATAL, "Only video and audio filters supported "
                "currently.\n");
-        exit_program(1);
+        return AVERROR(ENOSYS);
     }
 
     if (ifp->linklabel) {
@@ -932,7 +932,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
         if (file_idx < 0 || file_idx >= nb_input_files) {
             av_log(fg, AV_LOG_FATAL, "Invalid file index %d in filtergraph description %s.\n",
                    file_idx, fgp->graph_desc);
-            exit_program(1);
+            return AVERROR(EINVAL);
         }
         s = input_files[file_idx]->ctx;
 
@@ -950,7 +950,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
         if (!st) {
             av_log(fg, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
                    "matches no streams.\n", p, fgp->graph_desc);
-            exit_program(1);
+            return AVERROR(EINVAL);
         }
         ist = input_files[file_idx]->streams[st->index];
     } else {
@@ -958,7 +958,7 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
         if (!ist) {
             av_log(fg, AV_LOG_FATAL, "Cannot find a matching stream for "
                    "unlabeled input pad %s\n", ifilter->name);
-            exit_program(1);
+            return AVERROR(EINVAL);
         }
     }
     av_assert0(ist);
@@ -968,15 +968,20 @@ static void init_input_filter(FilterGraph *fg, InputFilter *ifilter)
         av_log(fg, AV_LOG_ERROR,
                "Error binding an input stream to complex filtergraph input %s.\n",
                ifilter->name);
-        exit_program(1);
+        return ret;
     }
+
+    return 0;
 }
 
 int init_complex_filtergraph(FilterGraph *fg)
 {
     // bind filtergraph inputs to input streams
-    for (int i = 0; i < fg->nb_inputs; i++)
-        init_input_filter(fg, fg->inputs[i]);
+    for (int i = 0; i < fg->nb_inputs; i++) {
+        int ret = init_input_filter(fg, fg->inputs[i]);
+        if (ret < 0)
+            return ret;
+    }
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list