]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/graphparser.c
vsrc_buffer.h: add file doxy
[ffmpeg] / libavfilter / graphparser.c
index 076b22a83cc19448d2bdcd4d526aed81a9138e41..00fb57ad5764efef7b56c59e9d1fa0f438e2c88f 100644 (file)
@@ -1,22 +1,22 @@
 /*
  * filter graph parser
- * copyright (c) 2008 Vitor Sessak
- * copyright (c) 2007 Bobby Bingham
+ * Copyright (c) 2008 Vitor Sessak
+ * Copyright (c) 2007 Bobby Bingham
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <string.h>
 
 #include "libavutil/avstring.h"
-#include "graphparser.h"
 #include "avfilter.h"
 #include "avfiltergraph.h"
-#include "parseutils.h"
 
 #define WHITESPACES " \n\t"
 
@@ -101,7 +99,7 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind
     char tmp_args[256];
     int ret;
 
-    snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name);
+    snprintf(inst_name, sizeof(inst_name), "Parsed filter %d %s", index, filt_name);
 
     filt = avfilter_get_by_name(filt_name);
 
@@ -119,11 +117,11 @@ static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int ind
     }
 
     if ((ret = avfilter_graph_add_filter(ctx, *filt_ctx)) < 0) {
-        avfilter_destroy(*filt_ctx);
+        avfilter_free(*filt_ctx);
         return ret;
     }
 
-    if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) {
+    if (!strcmp(filt_name, "scale") && args && !strstr(args, "flags")) {
         snprintf(tmp_args, sizeof(tmp_args), "%s:%s",
                  args, ctx->scale_sws_opts);
         args = tmp_args;
@@ -295,6 +293,12 @@ static int parse_outputs(const char **buf, AVFilterInOut **curr_inputs,
         AVFilterInOut *match;
 
         AVFilterInOut *input = *curr_inputs;
+        if (!input) {
+            av_log(log_ctx, AV_LOG_ERROR,
+                   "No output pad can be associated to link label '%s'.\n",
+                   name);
+            return AVERROR(EINVAL);
+        }
         *curr_inputs = (*curr_inputs)->next;
 
         if (!name)
@@ -334,6 +338,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
 
     do {
         AVFilterContext *filter;
+        const char *filterchain = filters;
         filters += strspn(filters, WHITESPACES);
 
         if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
@@ -361,8 +366,8 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
 
         if (chr == ';' && curr_inputs) {
             av_log(log_ctx, AV_LOG_ERROR,
-                   "Could not find a output to link when parsing \"%s\"\n",
-                   filters - 1);
+                   "Invalid filterchain containing an unlabelled output pad: \"%s\"\n",
+                   filterchain);
             ret = AVERROR(EINVAL);
             goto fail;
         }
@@ -388,7 +393,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
     return 0;
 
  fail:
-    avfilter_graph_free(graph);
+    for (; graph->filter_count > 0; graph->filter_count--)
+        avfilter_free(graph->filters[graph->filter_count - 1]);
+    av_freep(&graph->filters);
     free_inout(open_inputs);
     free_inout(open_outputs);
     free_inout(curr_inputs);