From patchwork Mon Jun 12 05:51:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Mark X-Patchwork-Id: 3921 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.195 with SMTP id 186csp745580vsk; Sun, 11 Jun 2017 23:01:11 -0700 (PDT) X-Received: by 10.223.176.154 with SMTP id i26mr5742550wra.81.1497247271170; Sun, 11 Jun 2017 23:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497247271; cv=none; d=google.com; s=arc-20160816; b=Sige45zHeptbw/IwffdE3gX0v2RmUfUxbROtISDNkdmZwuk/1d47ArEYcZn9S8RZN/ cWsC1G7RmxgMSFPepv4wVL34zBGEGsJ5dTlhBweVoxI2mB6+Y+xVRnbfR3N2CojcEVYn JWJfF7pRxkqlrNPYVYIDsx5bxQsJqOTcUYtAtalTXgFcrZVLcF9cP75cbOvWdk18J0kM eAi89LbDQi1cN0FaXeIMzqR2ac37E/WCRlpsPMPKyXnj+bZ00G3tgW9zQ5bdSlZFuPRN CqvlQzenfEjL32ZkIVCr4ZyR2rsL2VNc6OjZ4Z2uPjMgp5M2AvBPfMxOaejkOdYMm/4E o60A== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=hInq2fqKH4C552W8zJlKD5asRFen6gta3nMdiaNTMHg=; b=WINsHNqviHgQ4CS2p+zcrVgZIU6PV5XhWEzcd79Y3IJyJZjbgXB6mpV2lOa0SYJPvj oXTGprGn7GDEwnoT+iNMKmpawGsanjPaKOs5Ox2RCdWUHzOw85YY3kM2J4MQ2ujDt/w4 aNRIo7aLxmYb/UaVi2XEauZ2PYZby+S+OX+e8W+Tdfjyrc1Az5rTtw4tC3/LaRxdxZjD JkyjZcwGACOfMnMThc9GcUugNaFk+UQODIX2ekh+IsRYLqxWxEDDz1XegI1ngPAxmip1 WGyY8g52yVLW9CFufIwZQPtDEBAd3JXBJMsg8msDMma/l8BN28ufQDYXNErzAVEiWG93 izeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=NHn76rGR; 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 s4si4339842wma.128.2017.06.11.23.01.10; Sun, 11 Jun 2017 23:01:11 -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.b=NHn76rGR; 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 D4D4868830E; Mon, 12 Jun 2017 09:01:06 +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 61765680BE4 for ; Mon, 12 Jun 2017 09:01:00 +0300 (EEST) Received: by mail-qt0-f196.google.com with SMTP id o21so24478744qtb.1 for ; Sun, 11 Jun 2017 23:01:02 -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:in-reply-to:references; bh=cko8uyU22qmuRQxnYFJ1uRA1i7mpuXWR+TO2cIdvGYg=; b=NHn76rGRKIVyHpeJWcJnkotcwskh4f9ngRj8r6FG+quYT4kU6O9ge2jT0o9IU1cPhX TuQ/ky7x48kQ3ahTr8FqkGqw4bli6fKbFL9wVzK0a0WKegmJqpAu83U2JNZXuR+c/NZp 1QITI8OlOb8KwT1qQLLnq+MA50/Gw9oRyo57uSIkqMPXy+j+ysFpawCJWIDiCYpCwGJf BL/JJt1SUfNeB9YfZZpGdov4xl5lnfDH95KMnM9tPoR1DuUvQp03cRVZi1htJzN9v5lA vEjqOThM14MOQ0iZJXYGdodhhHi+2flkm72aEw5QB+CCoaxt81O1ME4KKHP9tm90lR6+ lVUw== 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:in-reply-to :references; bh=cko8uyU22qmuRQxnYFJ1uRA1i7mpuXWR+TO2cIdvGYg=; b=hLfP4EW2Uo5xCuHfhC5vZoqnnqJAOrB4ix69OJksVQOS8bXi2NtBxnWx7Y6l45P47j baWAu1MQETUxowou9olXStvx2+eiSNs5CNAYjFoDNV82tmM30ovqzmHyhmyIF5TyqHyk JmyFrR3QiWLwi0hCsh95a3CM3Zv8mZ4T5lYAvLVK0TgjtnWAU9vLUWr288cTnYM0NN3H zixVR1dOMUx4ljmKl1cLLh4PJdYRlOppFBCsARLHOuZXaKErFKWD89bliqn/AtxV5JwN I7xsYxm447KFxyZDtN4OwPefSYYZKv08X4q68jFvZW5eHc3hS7xWmp6jclCOL0uWM021 +psA== X-Gm-Message-State: AKS2vOy3kc+Mqhokvvosw6TsqrlkaiXLyZF+mpbRbpQXfx4ajc1u8JaD RtwnuZJoG+xEfZe5QtA= X-Received: by 10.55.181.135 with SMTP id e129mr23794842qkf.203.1497246778421; Sun, 11 Jun 2017 22:52:58 -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 h64sm5859849qke.62.2017.06.11.22.52.57 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 11 Jun 2017 22:52:57 -0700 (PDT) From: Kevin Mark To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Jun 2017 01:51:48 -0400 Message-Id: <20170612055148.41979-1-kmark937@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: References: 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..a6c32e3978 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] = (int) res == 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] = (int) res == 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 = (int) res == 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