From: Mina Nagy Zaki <[email protected]>

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.

Signed-off-by: Anton Khirnov <[email protected]>
---
 libavfilter/avfilter.c |   32 ++++++++++++++++++++++++++------
 libavfilter/defaults.c |   20 --------------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9dacf70..5d79de5 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -210,18 +210,38 @@ 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->type == AVMEDIA_TYPE_VIDEO) {
+                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);
+                }
+            }
 
             if ((config_link = link->dstpad->config_props))
                 if ((ret = config_link(link)) < 0)
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 7230da0..9ea336a 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -35,23 +35,3 @@ void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr)
     av_free(ptr->data[0]);
     av_free(ptr);
 }
-
-/**
- * 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 {
-        /* 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;
-}
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to