From patchwork Mon Sep 5 02:55:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 37667 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp2368591pzh; Sun, 4 Sep 2022 19:56:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kz19N8dijpPH6x+Mj2MLik4ety28f8FiH/L6gaK4BbCEy9tfUzHXryRGwO3b8wJtXWmRi X-Received: by 2002:a05:6402:1911:b0:448:da24:5f23 with SMTP id e17-20020a056402191100b00448da245f23mr23715300edz.61.1662346594190; Sun, 04 Sep 2022 19:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662346594; cv=none; d=google.com; s=arc-20160816; b=i/mp3zqAm+tdoBWWKgJwpM2+EBCCGRL1zwycJ2criyVCBIo+0pTjuGXKF59AB6rGHF tdv/dZmGCIkr54zzb4piW5WuXkQkvzfxOMt3FWAfvbQepGosYPMP+WMzmRt+WEtlJKc2 GlqbaffwetAqQPqrMiss+yIzv+UKJhHlfX3iAP9yV7Y4tV60+zGpVE4ip8tOnWYgDyo+ eWRtbG9O6pbTJ0Ay/frp7nYrQs8wsKxsqt6biz9B13eVCAZqrJ40aU7fQGfYIy3a0TjT 8/JPIYndERgGA+dRuEmnJVT9HfaZZJegjttWp0UR1iuyo5gFGDHhqeWf5l9xeX9nDxtm SzSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=T1ZjkTPNrrUtTMMJqIglnnCl8ojxnkOU1itVO+Y/0s8=; b=ZTKfcOSacGq0sjqdJ1iVkf9vtApCkAgJJnG5xZtQwsqzC3vrDrqirwRcT5bWk+uiKH RudW0POT92dNS7+vN6u+UTyJlkY3J6IxbCe8B5Muakk7F3fjFeB2yzBITW5jmn2FJgOg 1n67HTCGj2iPmc1jqX+eDDxsMxIoMoSaAjUZ5SDhonJN93ey8YTvreiKtwkx+/8RdtTA /mDfhQPbQVBGOE4Y6RVdf0hXLAw9ic9Mo6JD6BpndT/BSbnt8AHoi6DhuY+se/gCe2QD GkjSR2UpXHHxyDc5xy6c00tyvX8XPDD+AwwqvplkI1O5Sgk0F0BS1i0rFJQzacgARZjH uqfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jm8rAwko; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b90-20020a509f63000000b0044619f71deesi7046221edf.277.2022.09.04.19.56.33; Sun, 04 Sep 2022 19:56:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jm8rAwko; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DA83B68B6B6; Mon, 5 Sep 2022 05:56:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C04C68B149 for ; Mon, 5 Sep 2022 05:56:25 +0300 (EEST) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-1272fc7f51aso5350679fac.12 for ; Sun, 04 Sep 2022 19:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=8YaKIAZaY1Bb1YHoA4RGF7KN1HiQZvYA3l3whgRM8D4=; b=Jm8rAwkoTIsWv1T8DhSadqywkvGdLUVUq+GxT+V4PHI6cbmCqa3wPse/ekQLidNzcN G0bEnlCWI9YGtegsnBXsRO0yYnLfzHCuZJAOkpE00Dl+xB/YEK2FQRZYEM4rFZG3D0qr QKaa3Uhvpj3mj5OD38DCE4CYiAb8Cen51FG+XzTVbccCrDvS7Ps83GdKjmPx0C9tQIBW ApD3o9dxfnvRNl/DEGaYtKu0kRjoXVQAwpHEsRDcgvBZX4pazYd5K+XavSqjkV7nnDAD kZjekGP6NaVBszN40flBeeDbQCOjVhqGVIKYujLYQtBmiwC0A0KD/fo77Hk/KB/4qgQQ Rg6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=8YaKIAZaY1Bb1YHoA4RGF7KN1HiQZvYA3l3whgRM8D4=; b=LhyyakzuvXFM93QIjLdAJmh6ClXO6XJk0pSoRje5HbuvFaBcRMY3ykSni5Yg68htx+ b/nMCf1P02rW/ADFNpEGuMoDcddQRmnOi2CbOKgnjrXFLOoPuj09A+S2Ndgb+U1oD0d8 be1XClOeFyfKldUNpnjtWC0rouWy4knybLgc/Cpzl3jt5kygSpnz2UctyiT+rPwCDe5a W8celjNu5rywoeVeQYfwbfZv013LBwAr5KBjvZCz7MxBDUb6FMm7h33vhDqDyBpgcg2l Kt+CDNzewYvdye/tQs03V0hGzf0s12Cqz+NvezNytjX6Df+a2/3EuYdyPj2/ZT47W/6j y0zA== X-Gm-Message-State: ACgBeo1lwXlc9zcDDCfAAGGQdp1IJFhBbyJ94qmoij3Canc3aHff2Nh7 yAPVF+kG0QjgI076k5rd6j6xoxlAACA= X-Received: by 2002:a05:6870:e308:b0:123:2825:84da with SMTP id z8-20020a056870e30800b00123282584damr7455713oad.254.1662346583513; Sun, 04 Sep 2022 19:56:23 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id 101-20020a9d086e000000b0063696cbb6bdsm4066719oty.62.2022.09.04.19.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Sep 2022 19:56:23 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Sep 2022 23:55:56 -0300 Message-Id: <20220905025556.552-1-jamrial@gmail.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_scale: overwrite the width and eight expressions with the original values X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: b1Fb1GS6UqHz Instead of the potentially adjusted ones. Otherwise, if config_props() is called again and if using force_original_aspect_ratio, the already adjusted values could be altered again. Example command line scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2 user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the very first frame. Signed-off-by: James Almer --- libavfilter/vf_scale.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 996f7aaa5b..2b12cf283c 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -491,19 +491,19 @@ static int config_props(AVFilterLink *outlink) if ((ret = scale_eval_dimensions(ctx)) < 0) goto fail; - ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h, + outlink->w = scale->w; + outlink->h = scale->h; + + ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h, scale->force_original_aspect_ratio, scale->force_divisible_by); - if (scale->w > INT_MAX || - scale->h > INT_MAX || - (scale->h * inlink->w) > INT_MAX || - (scale->w * inlink->h) > INT_MAX) + if (outlink->w > INT_MAX || + outlink->h > INT_MAX || + (outlink->h * inlink->w) > INT_MAX || + (outlink->w * inlink->h) > INT_MAX) av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); - outlink->w = scale->w; - outlink->h = scale->h; - /* TODO: make algorithm configurable */ scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL; @@ -718,9 +718,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) goto scale; if (scale->eval_mode == EVAL_MODE_INIT) { - snprintf(buf, sizeof(buf)-1, "%d", outlink->w); + snprintf(buf, sizeof(buf) - 1, "%d", scale->w); av_opt_set(scale, "w", buf, 0); - snprintf(buf, sizeof(buf)-1, "%d", outlink->h); + snprintf(buf, sizeof(buf) - 1, "%d", scale->h); av_opt_set(scale, "h", buf, 0); ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", scale->w_expr);