mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-11 17:20:00 +00:00
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
This commit is contained in:
parent
52362e9dc1
commit
75ce65468f
@ -96,18 +96,6 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int common_format(int *fmts0, int *fmts1)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for(i = 0; fmts0[i] != -1; i ++)
|
||||
for(j = 0; fmts1[j] != -1; j ++)
|
||||
if(fmts0[i] == fmts1[j])
|
||||
return fmts0[i];
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
|
||||
unsigned in, unsigned out)
|
||||
{
|
||||
@ -131,57 +119,11 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
|
||||
|
||||
int avfilter_config_link(AVFilterLink *link)
|
||||
{
|
||||
int *fmts[3] = {NULL,NULL,NULL};
|
||||
int (*config_link)(AVFilterLink *);
|
||||
int *(*query_formats)(AVFilterLink *link);
|
||||
|
||||
AVFilterContext *scale;
|
||||
AVFilterLink *link2 = NULL;
|
||||
|
||||
if(!link)
|
||||
return 0;
|
||||
|
||||
/* find a format both filters support */
|
||||
if(!(query_formats = link_spad(link).query_formats))
|
||||
query_formats = avfilter_default_query_output_formats;
|
||||
fmts[0] = query_formats(link);
|
||||
fmts[1] = link_dpad(link).query_formats(link);
|
||||
if((link->format = common_format(fmts[0], fmts[1])) == -1) {
|
||||
/* no common format found. insert scale filter to convert */
|
||||
if(!(scale = avfilter_open(&avfilter_vf_scale, NULL)))
|
||||
goto format_done;
|
||||
if(scale->filter->init(scale, NULL, NULL)) {
|
||||
avfilter_destroy(scale);
|
||||
goto format_done;
|
||||
}
|
||||
if(avfilter_insert_filter(link, scale, 0, 0))
|
||||
goto format_done;
|
||||
link2 = scale->outputs[0];
|
||||
|
||||
/* now try again to find working colorspaces.
|
||||
* XXX: is it safe to assume that the scale filter always supports the
|
||||
* same input and output colorspaces? */
|
||||
fmts[2] = scale->input_pads[0].query_formats(link);
|
||||
link->format = common_format(fmts[0], fmts[2]);
|
||||
link2->format = common_format(fmts[1], fmts[2]);
|
||||
}
|
||||
|
||||
format_done:
|
||||
av_free(fmts[0]);
|
||||
av_free(fmts[1]);
|
||||
av_free(fmts[2]);
|
||||
if(link->format == -1 || (link2 && link2->format == -1)) {
|
||||
if(link2) {
|
||||
link->dst = link2->dst;
|
||||
link->dstpad = link2->dstpad;
|
||||
link->dst->inputs[link->dstpad] = link;
|
||||
link->format = -1;
|
||||
avfilter_destroy(scale);
|
||||
av_free(link2);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!(config_link = link_spad(link).config_props))
|
||||
config_link = avfilter_default_config_output_link;
|
||||
if(config_link(link))
|
||||
@ -192,18 +134,6 @@ format_done:
|
||||
if(config_link(link))
|
||||
return -1;
|
||||
|
||||
if(link2) {
|
||||
if(!(config_link = link_spad(link2).config_props))
|
||||
config_link = avfilter_default_config_output_link;
|
||||
if(config_link(link2))
|
||||
return -1;
|
||||
|
||||
if(!(config_link = link_dpad(link2).config_props))
|
||||
config_link = avfilter_default_config_input_link;
|
||||
if(config_link(link2))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -439,18 +369,3 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque
|
||||
return 0;
|
||||
}
|
||||
|
||||
int *avfilter_make_format_list(int len, ...)
|
||||
{
|
||||
int *ret, i;
|
||||
va_list vl;
|
||||
|
||||
ret = av_malloc(sizeof(int) * (len + 1));
|
||||
va_start(vl, len);
|
||||
for(i = 0; i < len; i ++)
|
||||
ret[i] = va_arg(vl, int);
|
||||
va_end(vl);
|
||||
ret[len] = -1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user