[FFmpeg-devel] [fix-multiple-filter-chain.patch PATCH 1/2] Make configure_filters() return a meaningful error code rather than always -1.

Stefano Sabatini stefano.sabatini-lala
Wed Jul 7 13:21:49 CEST 2010


---
 ffmpeg.c |   53 +++++++++++++++++++++++++++--------------------------
 1 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d5fd6a0..d734cdf 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -406,20 +406,21 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
     AVCodecContext *codec = ost->st->codec;
     AVCodecContext *icodec = ist->st->codec;
     char args[255];
+    int ret;
 
     graph = av_mallocz(sizeof(AVFilterGraph));
 
     if (!(ist->input_video_filter = avfilter_open(avfilter_get_by_name("buffer"), "src")))
-        return -1;
+        return AVERROR(EINVAL);
     if (!(ist->out_video_filter = avfilter_open(&output_filter, "out")))
-        return -1;
+        return AVERROR(EINVAL);
 
     snprintf(args, 255, "%d:%d:%d", ist->st->codec->width,
              ist->st->codec->height, ist->st->codec->pix_fmt);
-    if (avfilter_init_filter(ist->input_video_filter, args, NULL))
-        return -1;
-    if (avfilter_init_filter(ist->out_video_filter, NULL, &codec->pix_fmt))
-        return -1;
+    if ((ret = avfilter_init_filter(ist->input_video_filter, args, NULL)) < 0)
+        return ret;
+    if ((ret = avfilter_init_filter(ist->out_video_filter, NULL, &codec->pix_fmt)) < 0)
+        return ret;
 
     /* add input and output filters to the overall graph */
     avfilter_graph_add_filter(graph, ist->input_video_filter);
@@ -433,11 +434,11 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
                  codec->height);
         filter = avfilter_open(avfilter_get_by_name("crop"), NULL);
         if (!filter)
-            return -1;
-        if (avfilter_init_filter(filter, args, NULL))
-            return -1;
-        if (avfilter_link(last_filter, 0, filter, 0))
-            return -1;
+            return AVERROR(EINVAL);
+        if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
+            return ret;
+        if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
+            return ret;
         last_filter = filter;
         avfilter_graph_add_filter(graph, last_filter);
     }
@@ -451,11 +452,11 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
                  (int)av_get_int(sws_opts, "sws_flags", NULL));
         filter = avfilter_open(avfilter_get_by_name("scale"), NULL);
         if (!filter)
-            return -1;
-        if (avfilter_init_filter(filter, args, NULL))
-            return -1;
-        if (avfilter_link(last_filter, 0, filter, 0))
-            return -1;
+            return AVERROR(EINVAL);
+        if ((ret = avfilter_init_filter(filter, args, NULL)) < 0)
+            return ret;
+        if ((ret = avfilter_link(last_filter, 0, filter, 0)) < 0)
+            return ret;
         last_filter = filter;
         avfilter_graph_add_filter(graph, last_filter);
     }
@@ -477,21 +478,21 @@ static int configure_filters(AVInputStream *ist, AVOutputStream *ost)
         inputs->pad_idx = 0;
         inputs->next    = NULL;
 
-        if (avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL) < 0)
-            return -1;
+        if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
+            return ret;
         av_freep(&vfilters);
     } else {
-        if (avfilter_link(last_filter, 0, ist->out_video_filter, 0) < 0)
-            return -1;
+        if ((ret = avfilter_link(last_filter, 0, ist->out_video_filter, 0)) < 0)
+            return ret;
     }
 
     /* configure all the filter links */
-    if (avfilter_graph_check_validity(graph, NULL))
-        return -1;
-    if (avfilter_graph_config_formats(graph, NULL))
-        return -1;
-    if (avfilter_graph_config_links(graph, NULL))
-        return -1;
+    if ((ret = avfilter_graph_check_validity(graph, NULL)) < 0)
+        return ret;
+    if ((ret = avfilter_graph_config_formats(graph, NULL)) < 0)
+        return ret;
+    if ((ret = avfilter_graph_config_links(graph, NULL)) < 0)
+        return ret;
 
     codec->width = ist->out_video_filter->inputs[0]->w;
     codec->height = ist->out_video_filter->inputs[0]->h;
-- 
1.7.1




More information about the ffmpeg-devel mailing list