[FFmpeg-devel] [PATCH 2/9] Change the signature of create_filter() to make it return an error code.
Stefano Sabatini
stefano.sabatini-lala
Fri Nov 5 18:20:26 CET 2010
---
libavfilter/graphparser.c | 35 +++++++++++++++++------------------
1 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index caaa505..7d75704 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -97,15 +97,13 @@ static int parse_link_name(char **link_name, const char **buf, AVClass *log_ctx)
* @param log_ctx the log context to use
* @return a filter context in case of successful creation and configuration, NULL otherwise.
*/
-static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
- const char *filt_name, const char *args,
- AVClass *log_ctx)
+static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index,
+ const char *filt_name, const char *args, AVClass *log_ctx)
{
- AVFilterContext *filt_ctx;
-
AVFilter *filt;
char inst_name[30];
char tmp_args[256];
+ int ret;
snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name);
@@ -114,19 +112,19 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
if (!filt) {
av_log(log_ctx, AV_LOG_ERROR,
"No such filter: '%s'\n", filt_name);
- return NULL;
+ return AVERROR(EINVAL);
}
- avfilter_open(&filt_ctx, filt, inst_name);
- if (!filt_ctx) {
+ ret = avfilter_open(filt_ctx, filt, inst_name);
+ if (!*filt_ctx) {
av_log(log_ctx, AV_LOG_ERROR,
"Error creating filter '%s'\n", filt_name);
- return NULL;
+ return ret;
}
- if (avfilter_graph_add_filter(ctx, filt_ctx) < 0) {
- avfilter_destroy(filt_ctx);
- return NULL;
+ if ((ret = avfilter_graph_add_filter(ctx, *filt_ctx)) < 0) {
+ avfilter_destroy(*filt_ctx);
+ return ret;
}
if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) {
@@ -135,13 +133,13 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index,
args = tmp_args;
}
- if (avfilter_init_filter(filt_ctx, args, NULL)) {
+ if ((ret = avfilter_init_filter(*filt_ctx, args, NULL)) < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Error initializing filter '%s' with args '%s'\n", filt_name, args);
- return NULL;
+ return ret;
}
- return filt_ctx;
+ return 0;
}
/**
@@ -152,17 +150,18 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph,
{
char *opts = NULL;
char *name = av_get_token(buf, "=,;[\n");
- AVFilterContext *ret;
+ AVFilterContext *filt_ctx;
+ int ret;
if (**buf == '=') {
(*buf)++;
opts = av_get_token(buf, "[],;\n");
}
- ret = create_filter(graph, index, name, opts, log_ctx);
+ ret = create_filter(&filt_ctx, graph, index, name, opts, log_ctx);
av_free(name);
av_free(opts);
- return ret;
+ return filt_ctx;
}
static void free_inout(AVFilterInOut *head)
--
1.7.1
More information about the ffmpeg-devel
mailing list