[FFmpeg-devel] [PATCH] avfilter/delogo: Check that logo area is inside the picture

Jean Delvare jdelvare at suse.de
Tue May 10 14:50:38 CEST 2016


We can only remove the logo if it is inside the picture. We need at
least one pixel around the logo area for interpolation.

Fixes ticket #5527 (Delogo crash with x=0 and/or y=0).

Signed-off-by: Jean Delvare <jdelvare at suse.com>
---
 libavfilter/vf_delogo.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

--- ffmpeg.orig/libavfilter/vf_delogo.c	2016-05-10 13:44:01.569842931 +0200
+++ ffmpeg/libavfilter/vf_delogo.c	2016-05-10 13:47:58.754333920 +0200
@@ -225,6 +225,20 @@ static av_cold int init(AVFilterContext
     return 0;
 }
 
+static int config_input(AVFilterLink *inlink)
+{
+    DelogoContext *s = inlink->dst->priv;
+
+    /* Check whether the logo area fits in the frame */
+    if (s->x + (s->band - 1) < 0 || s->x + s->w - (s->band*2 - 2) > inlink->w ||
+        s->y + (s->band - 1) < 0 || s->y + s->h - (s->band*2 - 2) > inlink->h) {
+        av_log(s, AV_LOG_ERROR, "Logo area is outside of the frame.\n");
+        return AVERROR(EINVAL);
+    }
+
+    return 0;
+}
+
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
     DelogoContext *s = inlink->dst->priv;
@@ -283,6 +297,7 @@ static const AVFilterPad avfilter_vf_del
         .name         = "default",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
+        .config_props = config_input,
     },
     { NULL }
 };


-- 
Jean Delvare
SUSE L3 Support


More information about the ffmpeg-devel mailing list