aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorMina Nagy Zaki <mnzaki@gmail.com>2011-08-04 15:47:00 +0300
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-08-06 12:13:18 +0200
commit5f68a91be242c05bdd5aeffd74b36a1e6c782dd5 (patch)
treec86a2387bee3a6553904d5cb1aaf6be803363e9c /libavfilter/avfilter.c
parent4b7889453e50a7fdfe079ddc62eaca04c4d742ee (diff)
downloadffmpeg-5f68a91be242c05bdd5aeffd74b36a1e6c782dd5.tar.gz
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>
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 7003cdda5c..23bb26cccc 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -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;
-
- 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_rate == 0 && link->src && link->src->input_count)
- link->sample_rate = link->src->inputs[0]->sample_rate;
-
- if (link->channel_layout == 0 && link->src && link->src->input_count)
- link->channel_layout = link->src->inputs[0]->channel_layout;
+ 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 && !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->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;
+
+ 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)