mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Make avfilter_graph_parse() always return meaningful error codes.
Originally committed as revision 25699 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
0cc8b65950
commit
c24f76b948
@ -316,7 +316,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|||||||
AVFilterInOut *open_inputs,
|
AVFilterInOut *open_inputs,
|
||||||
AVFilterInOut *open_outputs, AVClass *log_ctx)
|
AVFilterInOut *open_outputs, AVClass *log_ctx)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0, ret;
|
||||||
char chr = 0;
|
char chr = 0;
|
||||||
|
|
||||||
AVFilterInOut *curr_inputs = NULL;
|
AVFilterInOut *curr_inputs = NULL;
|
||||||
@ -325,24 +325,24 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|||||||
AVFilterContext *filter;
|
AVFilterContext *filter;
|
||||||
filters += strspn(filters, WHITESPACES);
|
filters += strspn(filters, WHITESPACES);
|
||||||
|
|
||||||
if (parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx) < 0)
|
if ((ret = parse_inputs(&filters, &curr_inputs, &open_outputs, log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (parse_filter(&filter, &filters, graph, index, log_ctx) < 0)
|
if ((ret = parse_filter(&filter, &filters, graph, index, log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (filter->input_count == 1 && !curr_inputs && !index) {
|
if (filter->input_count == 1 && !curr_inputs && !index) {
|
||||||
/* First input can be omitted if it is "[in]" */
|
/* First input can be omitted if it is "[in]" */
|
||||||
const char *tmp = "[in]";
|
const char *tmp = "[in]";
|
||||||
if(parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx) < 0)
|
if ((ret = parse_inputs(&tmp, &curr_inputs, &open_outputs, log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx) < 0)
|
if ((ret = link_filter_inouts(filter, &curr_inputs, &open_inputs, log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
|
if ((ret = parse_outputs(&filters, &curr_inputs, &open_inputs, &open_outputs,
|
||||||
log_ctx) < 0)
|
log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
filters += strspn(filters, WHITESPACES);
|
filters += strspn(filters, WHITESPACES);
|
||||||
@ -352,6 +352,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|||||||
av_log(log_ctx, AV_LOG_ERROR,
|
av_log(log_ctx, AV_LOG_ERROR,
|
||||||
"Could not find a output to link when parsing \"%s\"\n",
|
"Could not find a output to link when parsing \"%s\"\n",
|
||||||
filters - 1);
|
filters - 1);
|
||||||
|
ret = AVERROR(EINVAL);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
@ -361,14 +362,15 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|||||||
av_log(log_ctx, AV_LOG_ERROR,
|
av_log(log_ctx, AV_LOG_ERROR,
|
||||||
"Unable to parse graph description substring: \"%s\"\n",
|
"Unable to parse graph description substring: \"%s\"\n",
|
||||||
filters - 1);
|
filters - 1);
|
||||||
|
ret = AVERROR(EINVAL);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
|
if (open_inputs && !strcmp(open_inputs->name, "out") && curr_inputs) {
|
||||||
/* Last output can be omitted if it is "[out]" */
|
/* Last output can be omitted if it is "[out]" */
|
||||||
const char *tmp = "[out]";
|
const char *tmp = "[out]";
|
||||||
if (parse_outputs(&tmp, &curr_inputs, &open_inputs,
|
if ((ret = parse_outputs(&tmp, &curr_inputs, &open_inputs, &open_outputs,
|
||||||
&open_outputs, log_ctx) < 0)
|
log_ctx)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,5 +381,5 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters,
|
|||||||
free_inout(open_inputs);
|
free_inout(open_inputs);
|
||||||
free_inout(open_outputs);
|
free_inout(open_outputs);
|
||||||
free_inout(curr_inputs);
|
free_inout(curr_inputs);
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user