[FFmpeg-cvslog] r25691 - trunk/libavfilter/graphparser.c

stefano subversion
Sun Nov 7 19:39:52 CET 2010


Author: stefano
Date: Sun Nov  7 19:39:52 2010
New Revision: 25691

Log:
Change the signature of create_filter() to make it return an error code.

Modified:
   trunk/libavfilter/graphparser.c

Modified: trunk/libavfilter/graphparser.c
==============================================================================
--- trunk/libavfilter/graphparser.c	Sun Nov  7 19:04:46 2010	(r25690)
+++ trunk/libavfilter/graphparser.c	Sun Nov  7 19:39:52 2010	(r25691)
@@ -86,21 +86,20 @@ static char *parse_link_name(const char 
  * filtergraph in *ctx.
  *
  * @param ctx the filtergraph context
+ * @param put here a filter context in case of successful creation and configuration, NULL otherwise.
  * @param index an index which is supposed to be unique for each filter instance added to the filtergraph
  * @param filt_name the name of the filter to create
  * @param args the arguments provided to the filter during its initialization
  * @param log_ctx the log context to use
- * @return a filter context in case of successful creation and configuration, NULL otherwise.
+ * @return 0 in case of success, a negative AVERROR code 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);
 
@@ -109,19 +108,19 @@ static AVFilterContext *create_filter(AV
     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")) {
@@ -130,13 +129,13 @@ static AVFilterContext *create_filter(AV
         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;
 }
 
 /**
@@ -147,17 +146,18 @@ static AVFilterContext *parse_filter(con
 {
     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)



More information about the ffmpeg-cvslog mailing list