Originally committed as revision 25862 to svn://svn.ffmpeg.org/ffmpeg/trunk
Showing the changes to libavfilter/avfiltergraph.c (1 of 6 files). Show all
Unified · Split
| @@ -53,6 +53,27 @@ int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) · 52 unmodified lines | ||
| 53 | 53 | return 0; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | +int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, | |
| 57 | + const char *name, const char *args, void *opaque, | |
| 58 | + AVFilterGraph *graph_ctx) | |
| 59 | +{ | |
| 60 | + int ret; | |
| 61 | + | |
| 62 | + if ((ret = avfilter_open(filt_ctx, filt, name)) < 0) | |
| 63 | + goto fail; | |
| 64 | + if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0) | |
| 65 | + goto fail; | |
| 66 | + if ((ret = avfilter_graph_add_filter(graph_ctx, *filt_ctx)) < 0) | |
| 67 | + goto fail; | |
| 68 | + return 0; | |
| 69 | + | |
| 70 | +fail: | |
| 71 | + if (*filt_ctx) | |
| 72 | + avfilter_free(*filt_ctx); | |
| 73 | + *filt_ctx = NULL; | |
| 74 | + return ret; | |
| 75 | +} | |
| 76 | + | |
| 56 | 77 | int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx) |
| 57 | 78 | { |
| 58 | 79 | AVFilterContext *filt; |
| @@ -113,7 +134,7 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name) · 54 unmodified lines | ||
| 113 | 134 | |
| 114 | 135 | static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) |
| 115 | 136 | { |
| 116 | − int i, j; | |
| 137 | + int i, j, ret; | |
| 117 | 138 | int scaler_count = 0; |
| 118 | 139 | char inst_name[30]; |
| 119 | 140 | |
| @@ -139,17 +160,12 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 19 unmodified lines | ||
| 139 | 160 | /* couldn't merge format lists. auto-insert scale filter */ |
| 140 | 161 | snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d", |
| 141 | 162 | scaler_count++); |
| 142 | − avfilter_open(&scale, avfilter_get_by_name("scale"), inst_name); | |
| 143 | − | |
| 144 | 163 | snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts); |
| 145 | − if(!scale || scale->filter->init(scale, scale_args, NULL) || | |
| 146 | − avfilter_insert_filter(link, scale, 0, 0)) { | |
| 147 | − avfilter_free(scale); | |
| 148 | − return -1; | |
| 149 | − } | |
| 150 | − | |
| 151 | − if (avfilter_graph_add_filter(graph, scale) < 0) | |
| 152 | − return -1; | |
| 164 | + if ((ret = avfilter_graph_create_filter(&scale, avfilter_get_by_name("scale"), | |
| 165 | + inst_name, scale_args, NULL, graph)) < 0) | |
| 166 | + return ret; | |
| 167 | + if ((ret = avfilter_insert_filter(link, scale, 0, 0)) < 0) | |
| 168 | + return ret; | |
| 153 | 169 | |
| 154 | 170 | scale->filter->query_formats(scale); |
| 155 | 171 | if (((link = scale-> inputs[0]) && |