[FFmpeg-devel] [PATCH] avfilter/pad: improve error check for w and h

Gyan ffmpeg at gyani.pro
Sat Jan 18 08:51:04 EET 2020



On 15-01-2020 09:25 pm, Gyan Doshi wrote:
> Target dimensions have to cover entire input.
> ---
>   libavfilter/vf_pad.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
> index 186d3f028d..e86292eaa2 100644
> --- a/libavfilter/vf_pad.c
> +++ b/libavfilter/vf_pad.c
> @@ -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);

Will push in a day.

Gyan


More information about the ffmpeg-devel mailing list