/*
* 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"
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);
}
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;
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)
do {
AVFilterContext *filter;
+ const char *filterchain = filters;
filters += strspn(filters, WHITESPACES);
if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
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;
}
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);