lavfi: remove default config_props() callback and refactor avfilter_config_links()
Link properties have to be checked after config_props() is called to make sure everything is sane, so the default config_props() for output links was redundant. Also remove channel_layout check as it is now negotiated. Signed-off-by: Stefano Sabatini <stefano.sabatini-lala@poste.it>
This commit is contained in:
parent
4b7889453e
commit
5f68a91be2
@ -251,24 +251,51 @@ int avfilter_config_links(AVFilterContext *filter)
|
||||
if ((ret = avfilter_config_links(link->src)) < 0)
|
||||
return ret;
|
||||
|
||||
if (!(config_link = link->srcpad->config_props))
|
||||
config_link = avfilter_default_config_output_link;
|
||||
if ((ret = config_link(link)) < 0)
|
||||
if (!(config_link = link->srcpad->config_props)) {
|
||||
if (link->src->input_count != 1) {
|
||||
av_log(link->src, AV_LOG_ERROR, "Source filters and filters "
|
||||
"with more than one input "
|
||||
"must set config_props() "
|
||||
"callbacks on all outputs\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
} else if ((ret = config_link(link)) < 0)
|
||||
return ret;
|
||||
|
||||
if (link->time_base.num == 0 && link->time_base.den == 0)
|
||||
link->time_base = link->src && link->src->input_count ?
|
||||
link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
|
||||
switch (link->type) {
|
||||
case AVMEDIA_TYPE_VIDEO:
|
||||
if (!link->time_base.num && !link->time_base.den)
|
||||
link->time_base = link->src->input_count ?
|
||||
link->src->inputs[0]->time_base : AV_TIME_BASE_Q;
|
||||
|
||||
if (link->sample_aspect_ratio.num == 0 && link->sample_aspect_ratio.den == 0)
|
||||
link->sample_aspect_ratio = link->src->input_count ?
|
||||
link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
|
||||
if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den)
|
||||
link->sample_aspect_ratio = link->src->input_count ?
|
||||
link->src->inputs[0]->sample_aspect_ratio : (AVRational){1,1};
|
||||
|
||||
if (link->sample_rate == 0 && link->src && link->src->input_count)
|
||||
link->sample_rate = link->src->inputs[0]->sample_rate;
|
||||
if (link->src->input_count) {
|
||||
if (!link->w)
|
||||
link->w = link->src->inputs[0]->w;
|
||||
if (!link->h)
|
||||
link->h = link->src->inputs[0]->h;
|
||||
} else if (!link->w || !link->h) {
|
||||
av_log(link->src, AV_LOG_ERROR,
|
||||
"Video source filters must set their output link's "
|
||||
"width and height\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
break;
|
||||
|
||||
if (link->channel_layout == 0 && link->src && link->src->input_count)
|
||||
link->channel_layout = link->src->inputs[0]->channel_layout;
|
||||
case AVMEDIA_TYPE_AUDIO:
|
||||
if (link->src->input_count) {
|
||||
if (!link->sample_rate)
|
||||
link->sample_rate = link->src->inputs[0]->sample_rate;
|
||||
} else if (!link->sample_rate) {
|
||||
av_log(link->src, AV_LOG_ERROR,
|
||||
"Audio source filters must set their output link's "
|
||||
"sample_rate\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
if ((config_link = link->dstpad->config_props))
|
||||
if ((ret = config_link(link)) < 0)
|
||||
|
@ -464,9 +464,6 @@ void avfilter_default_end_frame(AVFilterLink *link);
|
||||
/** default handler for filter_samples() for audio inputs */
|
||||
void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref);
|
||||
|
||||
/** default handler for config_props() for audio/video outputs */
|
||||
int avfilter_default_config_output_link(AVFilterLink *link);
|
||||
|
||||
/** default handler for get_video_buffer() for video inputs */
|
||||
AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
|
||||
int perms, int w, int h);
|
||||
|
@ -174,29 +174,6 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
|
||||
inlink->cur_buf = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* default config_link() implementation for output video links to simplify
|
||||
* the implementation of one input one output video filters */
|
||||
int avfilter_default_config_output_link(AVFilterLink *link)
|
||||
{
|
||||
if (link->src->input_count && link->src->inputs[0]) {
|
||||
if (link->type == AVMEDIA_TYPE_VIDEO) {
|
||||
link->w = link->src->inputs[0]->w;
|
||||
link->h = link->src->inputs[0]->h;
|
||||
link->time_base = link->src->inputs[0]->time_base;
|
||||
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
|
||||
link->channel_layout = link->src->inputs[0]->channel_layout;
|
||||
link->sample_rate = link->src->inputs[0]->sample_rate;
|
||||
}
|
||||
} else {
|
||||
/* XXX: any non-simple filter which would cause this branch to be taken
|
||||
* really should implement its own config_props() for this link. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts,
|
||||
enum AVMediaType type, int offin, int offout)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user