Originally committed as revision 25691 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/graphparser.c (1 of 1 file). Show all
Unified · Split
| @@ -86,21 +86,20 @@ static char *parse_link_name(const char **buf, AVClass *log_ctx) · 85 unmodified lines | |||
| 86 | * filtergraph in *ctx. | 86 | * filtergraph in *ctx. |
| 87 | * | 87 | * |
| 88 | * @param ctx the filtergraph context | 88 | * @param ctx the filtergraph context |
| 89 | * @param put here a filter context in case of successful creation and configuration, NULL otherwise. | ||
| 89 | * @param index an index which is supposed to be unique for each filter instance added to the filtergraph | 90 | * @param index an index which is supposed to be unique for each filter instance added to the filtergraph |
| 90 | * @param filt_name the name of the filter to create | 91 | * @param filt_name the name of the filter to create |
| 91 | * @param args the arguments provided to the filter during its initialization | 92 | * @param args the arguments provided to the filter during its initialization |
| 92 | * @param log_ctx the log context to use | 93 | * @param log_ctx the log context to use |
| 93 | * @return a filter context in case of successful creation and configuration, NULL otherwise. | 94 | * @return 0 in case of success, a negative AVERROR code otherwise |
| 94 | */ | 95 | */ |
| 95 | static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, | 96 | static int create_filter(AVFilterContext **filt_ctx, AVFilterGraph *ctx, int index, |
| 96 | const char *filt_name, const char *args, | 97 | const char *filt_name, const char *args, AVClass *log_ctx) |
| 97 | AVClass *log_ctx) | ||
| 98 | { | 98 | { |
| 99 | AVFilterContext *filt_ctx; | ||
| 100 | |||
| 101 | AVFilter *filt; | 99 | AVFilter *filt; |
| 102 | char inst_name[30]; | 100 | char inst_name[30]; |
| 103 | char tmp_args[256]; | 101 | char tmp_args[256]; |
| 102 | int ret; | ||
| 104 | 103 | ||
| 105 | snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name); | 104 | snprintf(inst_name, sizeof(inst_name), "Filter %d %s", index, filt_name); |
| 106 | 105 | ||
| @@ -109,19 +108,19 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 2 unmodified lines | |||
| 109 | if (!filt) { | 108 | if (!filt) { |
| 110 | av_log(log_ctx, AV_LOG_ERROR, | 109 | av_log(log_ctx, AV_LOG_ERROR, |
| 111 | "No such filter: '%s'\n", filt_name); | 110 | "No such filter: '%s'\n", filt_name); |
| 112 | return NULL; | 111 | return AVERROR(EINVAL); |
| 113 | } | 112 | } |
| 114 | 113 | ||
| 115 | avfilter_open(&filt_ctx, filt, inst_name); | 114 | ret = avfilter_open(filt_ctx, filt, inst_name); |
| 116 | if (!filt_ctx) { | 115 | if (!*filt_ctx) { |
| 117 | av_log(log_ctx, AV_LOG_ERROR, | 116 | av_log(log_ctx, AV_LOG_ERROR, |
| 118 | "Error creating filter '%s'\n", filt_name); | 117 | "Error creating filter '%s'\n", filt_name); |
| 119 | return NULL; | 118 | return ret; |
| 120 | } | 119 | } |
| 121 | 120 | ||
| 122 | if (avfilter_graph_add_filter(ctx, filt_ctx) < 0) { | 121 | if ((ret = avfilter_graph_add_filter(ctx, *filt_ctx)) < 0) { |
| 123 | avfilter_destroy(filt_ctx); | 122 | avfilter_destroy(*filt_ctx); |
| 124 | return NULL; | 123 | return ret; |
| 125 | } | 124 | } |
| 126 | 125 | ||
| 127 | if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) { | 126 | if (!strcmp(filt_name, "scale") && !strstr(args, "flags")) { |
| @@ -130,13 +129,13 @@ static AVFilterContext *create_filter(AVFilterGraph *ctx, int index, · 2 unmodified lines | |||
| 130 | args = tmp_args; | 129 | args = tmp_args; |
| 131 | } | 130 | } |
| 132 | 131 | ||
| 133 | if (avfilter_init_filter(filt_ctx, args, NULL)) { | 132 | if ((ret = avfilter_init_filter(*filt_ctx, args, NULL)) < 0) { |
| 134 | av_log(log_ctx, AV_LOG_ERROR, | 133 | av_log(log_ctx, AV_LOG_ERROR, |
| 135 | "Error initializing filter '%s' with args '%s'\n", filt_name, args); | 134 | "Error initializing filter '%s' with args '%s'\n", filt_name, args); |
| 136 | return NULL; | 135 | return ret; |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | return filt_ctx; | 138 | return 0; |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | /** | 141 | /** |
| @@ -147,17 +146,18 @@ static AVFilterContext *parse_filter(const char **buf, AVFilterGraph *graph, · 4 unmodified lines | |||
| 147 | { | 146 | { |
| 148 | char *opts = NULL; | 147 | char *opts = NULL; |
| 149 | char *name = av_get_token(buf, "=,;[\n"); | 148 | char *name = av_get_token(buf, "=,;[\n"); |
| 150 | AVFilterContext *ret; | 149 | AVFilterContext *filt_ctx; |
| 150 | int ret; | ||
| 151 | 151 | ||
| 152 | if (**buf == '=') { | 152 | if (**buf == '=') { |
| 153 | (*buf)++; | 153 | (*buf)++; |
| 154 | opts = av_get_token(buf, "[],;\n"); | 154 | opts = av_get_token(buf, "[],;\n"); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | ret = create_filter(graph, index, name, opts, log_ctx); | 157 | ret = create_filter(&filt_ctx, graph, index, name, opts, log_ctx); |
| 158 | av_free(name); | 158 | av_free(name); |
| 159 | av_free(opts); | 159 | av_free(opts); |
| 160 | return ret; | 160 | return filt_ctx; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | static void free_inout(AVFilterInOut *head) | 163 | static void free_inout(AVFilterInOut *head) |