History

Add avfilter_graph_create_filter().

Originally committed as revision 25862 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini committed 15 years ago

Commit 037be761 parent 93980246 files · +62 −36Browse files

Showing the changes to libavfilter/avfiltergraph.c (1 of 6 files). Show all

Unified · Split

libavfilter/avfiltergraph.c+27−11
@@ -53,6 +53,27 @@ int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) · 52 unmodified lines
5353 return 0;
5454 }
5555
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+
5677 int ff_avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
5778 {
5879 AVFilterContext *filt;
@@ -113,7 +134,7 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name) · 54 unmodified lines
113134
114135 static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
115136 {
116− int i, j;
137+ int i, j, ret;
117138 int scaler_count = 0;
118139 char inst_name[30];
119140
@@ -139,17 +160,12 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) · 19 unmodified lines
139160 /* couldn't merge format lists. auto-insert scale filter */
140161 snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
141162 scaler_count++);
142− avfilter_open(&scale, avfilter_get_by_name("scale"), inst_name);
143−
144163 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;
153169
154170 scale->filter->query_formats(scale);
155171 if (((link = scale-> inputs[0]) &&

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t