From patchwork Wed Jun 7 06:11:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Mark X-Patchwork-Id: 3862 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.2 with SMTP id 2csp2202352vsk; Tue, 6 Jun 2017 23:11:56 -0700 (PDT) X-Received: by 10.223.147.165 with SMTP id 34mr18928756wrp.175.1496815916685; Tue, 06 Jun 2017 23:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496815916; cv=none; d=google.com; s=arc-20160816; b=sJNUliz8BsmayLWuVxkV/QEA0d29UA+0tosPYs8vKsod5Rcr0VLcc1YZLpp4J5T1yX BCjv6Eb6O3ARvZliKzZOLv/aukbxgXUbKxL++ggFXqrrrmjPoekhy9t1Qr00uYuloyxr Vvymd3mPy8aoWpm2pZhxvCX23mqWN+7aUZsBDhP1lOq1Rs1Yh55DHjSjnmVul93UHRhP QocFPsP4BSRlp1C2F7TM9bGnr2QXRBm9Pxq/WKXExM+xr6tXrnCb7SinAcNY2r6ZaU5h dNrcGkD0jHp3O1zoZGNDWanb9hwMqscaQQUMTMGbnWNNRzbroAktyMQBNhFalgjJHNQt QWqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=Gn9vVNWxxlOO9WxgDzGaL26pHb6c8cnV6dgYKDi1GZk=; b=omy+/jsJCLq4Yxxwf5qtlWYraMU+DVbbBpyYVoPINxJVFSbuN4t8w6yKH23Srnepcg JIBand7mdOQiZfeX1oZPjt/XBRy3Q6NGXsK05fYb1jv+yJ/NQBWidMBKaYVBYLhPcxVm X4x+oY0E+WaiuIQhSixDxPcrEFlOyQcZIDOq7J3DtPkydQTGUUwSk2RGHZxSUuZBB1qw ZVYr1UrXKxVG1UVRIrhr/8Rl+V8Rhhoyso3pJjQw/BY5dEf4kSCFo8zjRQBb3ybD2Kmm ORXBml0f93iHVTZn57qeEBvt5/xKnYH2g5O0DX04K1EN+azJGLfE01ynS1ylRJ7efv2l 91Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; 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=NONE 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 j67si1262439wmg.92.2017.06.06.23.11.55; Tue, 06 Jun 2017 23:11:56 -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; 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=NONE 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 8472D689B0E; Wed, 7 Jun 2017 09:11:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B20E689A62 for ; Wed, 7 Jun 2017 09:11:38 +0300 (EEST) Received: by mail-qt0-f196.google.com with SMTP id w1so412959qtg.0 for ; Tue, 06 Jun 2017 23:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JNzUBH9XDHQxkN3KQUner7fXhLK2DOaPearM5rONG0s=; b=V2hY+yHSOzxUUZCgFVPUpQoVNxpPDPe0mVv0dQJx3wH80xvvthb16swDej6pDVjqcg hVIAq7cgH0xd1xSuYKFn4Hp/9l6Io8MK0qhivlsLRG9IJp++MY4zJTFantb5+3szjltA kC8bXyEYFqxBHJP8s7sxMX1psAmfp5W07u3WmLb7lnU5cTe1Yrhfpp2QmOgbcvsDaJ87 J/iE45/ug/Vm2uIVpWD+/jEQoe619naNLBxHu3940EJyQyZVKiu5l0nEyRkAUDZEJjEv N/puqx8tYDJ9SLSLJrVwBT83XG2d561zylDJgXhhEkSjXi6Lh/JqAI09zy2oxVSjiVZq Grhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JNzUBH9XDHQxkN3KQUner7fXhLK2DOaPearM5rONG0s=; b=rbDTyFx42hQtoMC0qe96Fr7K/tVl4obfQImDn5MbdF4iQrsTdTMB5eCqT9oBbgVqyS byFJMyfPCYL1EjhaB5r7C1PRE2fkckb6yKr+85xA1nuSiNTlP2E2MURVDATbwFILch7Z TPguVX564SU5m7NFqyRe2r5I1U+JhBsWm67P/OHd7QyS5T1arJfbJ2SDmjetJRViPKx5 gpeeIZnnHYAYwt68jRkSdnT6N54gATEiVh8SVCvlZTKvYWWfwf0IVnURYGS47lRnsb/2 KOtl19rs/NwMrAWJhUekeTXFKbIrZhOaFbdESPqxaiQCt37PMl9jKNp4jfUeEhRuTr1X tjIA== X-Gm-Message-State: AODbwcAPCpPlghguwgIlIQKUfF/4sol4xBYz6Eldt+Q/SBPuP1CteNIA nPS1FWC1FOLzNE+IJrQ= X-Received: by 10.200.3.97 with SMTP id w33mr33001323qtg.203.1496815903867; Tue, 06 Jun 2017 23:11:43 -0700 (PDT) Received: from Klingon.fios-router.home (pool-173-69-140-247.bltmmd.fios.verizon.net. [173.69.140.247]) by smtp.gmail.com with ESMTPSA id a203sm446680qkg.20.2017.06.06.23.11.42 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Jun 2017 23:11:43 -0700 (PDT) From: Kevin Mark To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Jun 2017 02:11:41 -0400 Message-Id: <20170607061141.2568-1-kmark937@gmail.com> X-Mailer: git-send-email 2.13.0 Subject: [FFmpeg-devel] [PATCH] libavfilter/scale: Populate ow/oh when using 0 as w/h X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Kevin Mark MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The input width and height is known at parse time so there's no reason ow/oh should not be usable when using 0 as the width or height expression. Previously in "scale=0:ow" ow would be set to "0" which works, conveniently, as "scale=0:0" is perfectly valid input but this breaks down when you do something like "scale=0:ow/4" which one could reasonably expect to work as well, but does not as ow is 0 not the real value. This change handles the 0 case for w/h immediately so the ow/oh variables work as expected. Consequently, the rest of the code does not need to handle 0 input. w/h will always be > 0 or < 0. Signed-off-by: Kevin Mark --- libavfilter/scale.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libavfilter/scale.c b/libavfilter/scale.c index 03745ddcb8..cc2bea5caf 100644 --- a/libavfilter/scale.c +++ b/libavfilter/scale.c @@ -158,19 +158,19 @@ int ff_scale_eval_dimensions(void *log_ctx, av_expr_parse_and_eval(&res, (expr = w_expr), names, var_values, NULL, NULL, NULL, NULL, NULL, 0, log_ctx); - eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; + eval_w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res == 0.0 ? inlink->w : res; if ((ret = av_expr_parse_and_eval(&res, (expr = h_expr), names, var_values, NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) goto fail; - eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; + eval_h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res == 0.0 ? inlink->h : res; /* evaluate again the width, as it may depend on the output height */ if ((ret = av_expr_parse_and_eval(&res, (expr = w_expr), names, var_values, NULL, NULL, NULL, NULL, NULL, 0, log_ctx)) < 0) goto fail; - eval_w = res; + eval_w = res == 0.0 ? inlink->w : res; w = eval_w; h = eval_h; @@ -186,13 +186,10 @@ int ff_scale_eval_dimensions(void *log_ctx, factor_h = -h; } - if (w < 0 && h < 0) - eval_w = eval_h = 0; - - if (!(w = eval_w)) + if (w < 0 && h < 0) { w = inlink->w; - if (!(h = eval_h)) h = inlink->h; + } /* Make sure that the result is divisible by the factor we determined * earlier. If no factor was set, it is nothing will happen as the default