[FFmpeg-devel] [PATCH] vf_colorspace: Forbid odd dimensions

Vittorio Giovara vittorio.giovara at gmail.com
Thu Nov 17 22:53:19 EET 2016


This prevents writing past bounds.

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
---
Any opinions about this?
Cheers,
Vittorio
(please cc)

 doc/filters.texi            | 1 +
 libavfilter/vf_colorspace.c | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 208be42..aee43a8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -5278,6 +5278,7 @@ colormatrix=bt601:smpte240m
 @section colorspace
 
 Convert colorspace, transfer characteristics or color primaries.
+Input video needs to have an even size.
 
 The filter accepts the following options:
 
diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index c7a2286..5bc7b3c 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -168,7 +168,6 @@ typedef struct ColorSpaceContext {
     int did_warn_range;
 } ColorSpaceContext;
 
-// FIXME deal with odd width/heights (or just forbid it)
 // FIXME faster linearize/delinearize implementation (integer pow)
 // FIXME bt2020cl support (linearization between yuv/rgb step instead of between rgb/xyz)
 // FIXME test that the values in (de)lin_lut don't exceed their container storage
@@ -1031,8 +1030,15 @@ static int query_formats(AVFilterContext *ctx)
 
 static int config_props(AVFilterLink *outlink)
 {
+    AVFilterContext *ctx = outlink->dst;
     AVFilterLink *inlink = outlink->src->inputs[0];
 
+    if (inlink->w % 2 || inlink->h % 2) {
+        av_log(ctx, AV_LOG_ERROR, "Invalid odd size (%dx%d)\n",
+               inlink->w, inlink->h);
+        return AVERROR(EINVAL);
+    }
+
     outlink->w = inlink->w;
     outlink->h = inlink->h;
     outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
-- 
2.10.0



More information about the ffmpeg-devel mailing list