[FFmpeg-cvslog] lavfi: check links properties after configuring them.
Nicolas George
git at videolan.org
Thu Nov 2 13:24:00 EET 2017
ffmpeg | branch: master | Nicolas George <george at nsup.org> | Wed Nov 1 21:15:00 2017 +0100| [345e7072ab867ee1e56cbf857dbc93d37f168294] | committer: Nicolas George
lavfi: check links properties after configuring them.
For now, check the image size.
Inspired by a patch from Paul B Mahol.
Invalid sizes would be detected later by allocation failures,
detecting problems earlier is cleaner.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=345e7072ab867ee1e56cbf857dbc93d37f168294
---
libavfilter/avfiltergraph.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 69cf26896d..a009e0a760 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
+#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
@@ -263,6 +264,27 @@ static int graph_config_links(AVFilterGraph *graph, AVClass *log_ctx)
return 0;
}
+static int graph_check_links(AVFilterGraph *graph, AVClass *log_ctx)
+{
+ AVFilterContext *f;
+ AVFilterLink *l;
+ unsigned i, j;
+ int ret;
+
+ for (i = 0; i < graph->nb_filters; i++) {
+ f = graph->filters[i];
+ for (j = 0; j < f->nb_outputs; j++) {
+ l = f->outputs[j];
+ if (l->type == AVMEDIA_TYPE_VIDEO) {
+ ret = av_image_check_size2(l->w, l->h, INT64_MAX, l->format, 0, f);
+ if (ret < 0)
+ return ret;
+ }
+ }
+ }
+ return 0;
+}
+
AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *name)
{
int i;
@@ -1256,6 +1278,8 @@ int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
return ret;
if ((ret = graph_config_links(graphctx, log_ctx)))
return ret;
+ if ((ret = graph_check_links(graphctx, log_ctx)))
+ return ret;
if ((ret = graph_config_pointers(graphctx, log_ctx)))
return ret;
More information about the ffmpeg-cvslog
mailing list