]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/pad: improve error check for w and h
authorGyan Doshi <ffmpeg@gyani.pro>
Wed, 15 Jan 2020 15:39:38 +0000 (21:09 +0530)
committerGyan Doshi <ffmpeg@gyani.pro>
Sun, 19 Jan 2020 05:47:53 +0000 (11:17 +0530)
Target dimensions have to cover entire input.

libavfilter/vf_pad.c

index 186d3f028d787e651f6f3b82a8cd855d9f128ce0..e86292eaa2700a62ca7e3155d9d98542e5ffe37b 100644 (file)
@@ -178,14 +178,14 @@ static int config_input(AVFilterLink *inlink)
     if (s->y < 0 || s->y + inlink->h > s->h)
         s->y = var_values[VAR_Y] = (s->h - inlink->h) / 2;
 
+    s->w    = ff_draw_round_to_sub(&s->draw, 0, -1, s->w);
+    s->h    = ff_draw_round_to_sub(&s->draw, 1, -1, s->h);
     /* sanity check params */
-    if (s->w < 0 || s->h < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Negative values are not acceptable.\n");
+    if (s->w < inlink->w || s->h < inlink->h) {
+        av_log(ctx, AV_LOG_ERROR, "Padded dimensions cannot be smaller than input dimensions.\n");
         return AVERROR(EINVAL);
     }
 
-    s->w    = ff_draw_round_to_sub(&s->draw, 0, -1, s->w);
-    s->h    = ff_draw_round_to_sub(&s->draw, 1, -1, s->h);
     s->x    = ff_draw_round_to_sub(&s->draw, 0, -1, s->x);
     s->y    = ff_draw_round_to_sub(&s->draw, 1, -1, s->y);
     s->in_w = ff_draw_round_to_sub(&s->draw, 0, -1, inlink->w);