History

Rewrite colorspace negotiation.

Commited in SoC by Bobby Bingham on 2007-12-20 19:36:26 Originally committed as revision 12027 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak committed 18 years ago

Commit 75ce6541 parent 52362e91 file · +0 −85Browse files

Unified · Split

libavfilter/avfilter.c+0−85
@@ -96,18 +96,6 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, · 95 unmodified lines
96 return 0;96 return 0;
97}97}
98 98
99static int common_format(int *fmts0, int *fmts1)
100{
101 int i, j;
102
103 for(i = 0; fmts0[i] != -1; i ++)
104 for(j = 0; fmts1[j] != -1; j ++)
105 if(fmts0[i] == fmts1[j])
106 return fmts0[i];
107
108 return -1;
109}
110
111int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,99int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
112 unsigned in, unsigned out)100 unsigned in, unsigned out)
113{101{
@@ -131,57 +119,11 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, · 17 unmodified lines
131 119
132int avfilter_config_link(AVFilterLink *link)120int avfilter_config_link(AVFilterLink *link)
133{121{
134 int *fmts[3] = {NULL,NULL,NULL};
135 int (*config_link)(AVFilterLink *);122 int (*config_link)(AVFilterLink *);
136 int *(*query_formats)(AVFilterLink *link);
137
138 AVFilterContext *scale;
139 AVFilterLink *link2 = NULL;
140 123
141 if(!link)124 if(!link)
142 return 0;125 return 0;
143 126
144 /* find a format both filters support */
145 if(!(query_formats = link_spad(link).query_formats))
146 query_formats = avfilter_default_query_output_formats;
147 fmts[0] = query_formats(link);
148 fmts[1] = link_dpad(link).query_formats(link);
149 if((link->format = common_format(fmts[0], fmts[1])) == -1) {
150 /* no common format found. insert scale filter to convert */
151 if(!(scale = avfilter_open(&avfilter_vf_scale, NULL)))
152 goto format_done;
153 if(scale->filter->init(scale, NULL, NULL)) {
154 avfilter_destroy(scale);
155 goto format_done;
156 }
157 if(avfilter_insert_filter(link, scale, 0, 0))
158 goto format_done;
159 link2 = scale->outputs[0];
160
161 /* now try again to find working colorspaces.
162 * XXX: is it safe to assume that the scale filter always supports the
163 * same input and output colorspaces? */
164 fmts[2] = scale->input_pads[0].query_formats(link);
165 link->format = common_format(fmts[0], fmts[2]);
166 link2->format = common_format(fmts[1], fmts[2]);
167 }
168
169format_done:
170 av_free(fmts[0]);
171 av_free(fmts[1]);
172 av_free(fmts[2]);
173 if(link->format == -1 || (link2 && link2->format == -1)) {
174 if(link2) {
175 link->dst = link2->dst;
176 link->dstpad = link2->dstpad;
177 link->dst->inputs[link->dstpad] = link;
178 link->format = -1;
179 avfilter_destroy(scale);
180 av_free(link2);
181 }
182 return -1;
183 }
184
185 if(!(config_link = link_spad(link).config_props))127 if(!(config_link = link_spad(link).config_props))
186 config_link = avfilter_default_config_output_link;128 config_link = avfilter_default_config_output_link;
187 if(config_link(link))129 if(config_link(link))
@@ -192,18 +134,6 @@ format_done: · 4 unmodified lines
192 if(config_link(link))134 if(config_link(link))
193 return -1;135 return -1;
194 136
195 if(link2) {
196 if(!(config_link = link_spad(link2).config_props))
197 config_link = avfilter_default_config_output_link;
198 if(config_link(link2))
199 return -1;
200
201 if(!(config_link = link_dpad(link2).config_props))
202 config_link = avfilter_default_config_input_link;
203 if(config_link(link2))
204 return -1;
205 }
206
207 return 0;137 return 0;
208}138}
209 139
@@ -439,18 +369,3 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque · 229 unmodified lines
439 return 0;369 return 0;
440}370}
441 371
442int *avfilter_make_format_list(int len, ...)
443{
444 int *ret, i;
445 va_list vl;
446
447 ret = av_malloc(sizeof(int) * (len + 1));
448 va_start(vl, len);
449 for(i = 0; i < len; i ++)
450 ret[i] = va_arg(vl, int);
451 va_end(vl);
452 ret[len] = -1;
453
454 return ret;
455}
456

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