From patchwork Wed Jun 7 07:45:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Mark X-Patchwork-Id: 3863 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.10.2 with SMTP id 2csp2231396vsk; Wed, 7 Jun 2017 00:54:11 -0700 (PDT) X-Received: by 10.28.168.13 with SMTP id r13mr519917wme.0.1496822051829; Wed, 07 Jun 2017 00:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496822051; cv=none; d=google.com; s=arc-20160816; b=0s0qEotYNxDhSLtNO3gUsZS5bMgXuLh9+DV24eh+wWM5HbrOXq1K5yTIFuV/9ZvDbc TnNl7ZA09zw5oQGU1exUB3BR06pjv9ukz5oKPLArBldNjmQrjZjoJ1GadFpfbxMFW7t1 GLwfM8uJeLdVZZT30lX9RIZ9EHoXntAAexIWMlfeQiBizwFSXMDrxOARZRyjmAQTf1wE L3shDTHh5pYqEKx3iAQ56A/eaHfafDAXNhHPQdQejWTvHAXPCpiDGFYBf2wm7J+wVqIK Zq+W8DkJOGQv2yZKEeh+mwvbG1MuQ7S0wVOVfyt8tWiIS9yUqRxoqP8+iLicAwyIVGy4 YmZA== 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=pdMvMPmuo4han7YhBIytoUc2DFUemVud0m2MikZi+L4=; b=OMATNufG+3CYvWMPPAq9auNHFPKZlEj1iWg8o57myrFdoqN7z9XqnMtCDznFThg3/a zr3pjGP1WixB/DkYUKs5kXAfKNxS2+ewJ8YdvP2cPVr/4kU4ekJpZxanbSQd2Gl7N7/x UeG2RtlTKseSAIcmo6Z86tS0DZ7KtY1yL5FIeO1xt/m5rp6QGpHdNjlNI84+KXOCD0iO y72W4qs0tdio1dm/dycxpezGFrfDaRXQC0nC5xydUiFK//m81QfGJoVsfaEcbsSmgYlk Gk8gIZtNOe5+W662+TlZpcIHglXllQg6DHElxAtIO3LhFqgjcUcoazWD145TUhBs9UGO Qo3w== 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 p184si1514821wme.20.2017.06.07.00.54.11; Wed, 07 Jun 2017 00:54: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; 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 1259F689DE7; Wed, 7 Jun 2017 10:54:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C68AF680BEE for ; Wed, 7 Jun 2017 10:53:54 +0300 (EEST) Received: by mail-qk0-f194.google.com with SMTP id d14so579192qkb.1 for ; Wed, 07 Jun 2017 00:54: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=Sxbn+z7dtV5VLQkeNszESZJcjo165dGM2+KSBuAatAA=; b=oEKfME0q6sHLzw5YEZmjanlsgMZUoYs8URhbDyhZMSbghwbjKuZTbAUbVuRqcu5p6j daqDv7wLawqlHjc7xmpUGUXSBEmO/iaV1zdWNDJ1seFcrWQb2ez85ldepk9EVGaUntSl p+lnH0oGLrGzK2oOPbIt0XzAWsShJFfEQZqR+q/rWeY4Fc+KHB5dkPRTtWVHJ+7Rqgif JRx6mZu/cm0XVceLhh4TKOweBznKsuBGxg/1bUvji9/lDmY4WYchNkFjw+Lt2kHedVgG uAnYFxEyVBzFj94fQb2TDxgIYST+2YyYysllVW5IRUtLuHfiOpzk6fAA2SPOdP/XQBPz r2iQ== 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=Sxbn+z7dtV5VLQkeNszESZJcjo165dGM2+KSBuAatAA=; b=jQ9slyJSM7SSPDGK5AtV7dkct51KjwdW1kVzqSVlLimEoIwDul6h1LMipXw4QScMDj xfRyBXnHmvIEGa6+aYYXyCkeWHe3PQpQTrruLdHFmX9z33SBlUyePWl0JhKbcfLr3PAB SjbjfHf8vLMpEsJfuHm0oHzcDB+orPEbgK6xVSWNg+47VI5TGVFW73Zh+V4oOM0+PlRu J9pr1TiCspKMYykA/ylkcnFP23RIH3vqVJZQBfif0rJVUFgzBU7LXDldXFdVCRgvP5MF 0+yUC8BQ2+S3iIH3oFxt/IXqZ1sVRDncc8Q52N6N97RaiJsHShh/JRycaw9QhZKM5ez/ kVzQ== X-Gm-Message-State: AKS2vOxY3G/2ep50P/7ET9C43CWpYftSFJuJXr4Iq84M9p6VEfpdcAfv bTLfhSXWf+nohz6pszo= X-Received: by 10.55.138.71 with SMTP id m68mr16551057qkd.192.1496821562525; Wed, 07 Jun 2017 00:46:02 -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 x80sm529735qkb.63.2017.06.07.00.46.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 07 Jun 2017 00:46:01 -0700 (PDT) From: Kevin Mark To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Jun 2017 03:45:19 -0400 Message-Id: <20170607074519.13780-1-kmark937@gmail.com> X-Mailer: git-send-email 2.13.0 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