From patchwork Fri Nov 18 14:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 39326 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp356027pzb; Fri, 18 Nov 2022 06:25:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7cn7f4nyvdyy0Cb8KnUM+H9aMTui0SonFjVX9APegeulkCUEWCNYXSBK8bkFeoKaLAECP3 X-Received: by 2002:a17:906:28c4:b0:78d:b8b3:f027 with SMTP id p4-20020a17090628c400b0078db8b3f027mr6119393ejd.439.1668781542656; Fri, 18 Nov 2022 06:25:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668781542; cv=none; d=google.com; s=arc-20160816; b=mg8E1pbJ7D6jdRiTzIrmatlze7wqukm2M50Fe+o+qSYnLxVYv2DGVkE3PALSOF8j7X UDhIKSFJi1M3yWclRwVH+xZI9RRRV3ikbOrh2w5NT/utLtOLfChZ7CaHDa0emd/CAAKa mYWaN755FWCfHS+NNAyjQrAYNN0hDu+PFQTX8xeyqrP1IdC14swZrgv275MW33mvZe7e VOTHp72HtjT3Osy6Q4HUpMBj2uys1zwzKyPovfOd5cS/NvNNpvO+lejpPw/RVKuJDqGn uN14FN4PyETUYH6rhemfQnZIgjGaHsWn9E/ohdjdTZXAKjqafWeXqDoKoccRKP/URq9d SMQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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=cuu+TP37CjLmyftjdSYJL0xC9qMyJV73QaCIj4Inq08=; b=rSXkTQWSbHuId8GGr78ksRaoEqNqJazQcn5OB6roFwSC8y1Cb7XdITF7+utHtEnEzV N8NjOkMiPFbJ8QIGPplkHd98jljNArKaYRq32y6sJ/zoxOLCzguZV0+slT2YtdAZuo5U 2sbC+UmYmYTCoDHxmz/VjXFl5ACCqnc9/DRIxijC4hcKFmY6xDVAkZPK/s+5eShTBfC7 +iR4vFgjfvdylb3VWL3pOhoNvYCFan2PXDB+dLlbnuLlXxGZmCa0OOPoFYAe3ez+MhEb VwPdAQYcFbWhYlHE+9XdxwgPZRAKILyhDU6S9d6NCXWHqTr3qpO6GQC3i/6HbjD/Mtyp iU4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=gDv9XyWC; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id xh1-20020a170906da8100b00779e6c93108si3653817ejb.598.2022.11.18.06.25.41; Fri, 18 Nov 2022 06:25:42 -0800 (PST) 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=@haasn.xyz header.s=mail header.b=gDv9XyWC; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1EAE068BBF4; Fri, 18 Nov 2022 16:25:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B4D268B9E8 for ; Fri, 18 Nov 2022 16:25:30 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id A216247801; Fri, 18 Nov 2022 15:25:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1668781529; bh=Y05SccME0J6BBPPvZOnpmJPHIYntrhHcmZoCMSCQPdk=; h=From:To:Cc:Subject:Date:From; b=gDv9XyWCcwFMXUlNmghGcUbLPduYDqV1KxHQgNrWXho3tlzD5GxF2raFFc3j2M6Kn +Q3Dhq4XLMs5dOWH/3WdQkFuZbHNxu2K8FWN7M9JNAMFwi9InxgoG8gSDqBmPMjuLT DvKMDrsU/uUSItHKH4sQqZvcYda3/eYGTcTtKv78= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Nov 2022 15:25:11 +0100 Message-Id: <20221118142512.72413-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_libplacebo: default to normalize_sar=0 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 03aig2BC/v0W From: Niklas Haas As a result of a typo in the source code, this option was completely non-functional. In order to fix it, without breaking the current default (and, upon reconsideration, probably preferred) behavior, explicitly change this default to 0. --- doc/filters.texi | 7 ++++--- libavfilter/version.h | 2 +- libavfilter/vf_libplacebo.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index e4da63cf48..d576e46d79 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -15581,9 +15581,10 @@ will be performed. Work the same as the identical @ref{scale} filter options. @item normalize_sar -If enabled (the default), output frames will always have a pixel aspect ratio -of 1:1. If disabled, any aspect ratio mismatches, including those from e.g. -anamorphic video sources, are forwarded to the output pixel aspect ratio. +If enabled, output frames will always have a pixel aspect ratio of 1:1. This +will introduce padding/cropping as necessary. If disabled (the default), any +aspect ratio mismatches, including those from e.g. anamorphic video sources, +are forwarded to the output pixel aspect ratio. @item pad_crop_ratio Specifies a ratio (between @code{0.0} and @code{1.0}) between padding and diff --git a/libavfilter/version.h b/libavfilter/version.h index 436c2b8b17..1553e7fecf 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -32,7 +32,7 @@ #include "version_major.h" #define LIBAVFILTER_VERSION_MINOR 50 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index fa9a7675d1..d52833263d 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -626,7 +626,7 @@ static const AVOption libplacebo_options[] = { { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, STATIC, "force_oar" }, { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, STATIC, "force_oar" }, { "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, 256, STATIC }, - { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, STATIC }, + { "normalize_sar", "force SAR normalization to 1:1", OFFSET(normalize_sar), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, STATIC }, { "pad_crop_ratio", "ratio between padding and cropping when normalizing SAR (0=pad, 1=crop)", OFFSET(pad_crop_ratio), AV_OPT_TYPE_FLOAT, {.dbl=0.0}, 0.0, 1.0, DYNAMIC }, {"colorspace", "select colorspace", OFFSET(colorspace), AV_OPT_TYPE_INT, {.i64=-1}, -1, AVCOL_SPC_NB-1, DYNAMIC, "colorspace"}, From patchwork Fri Nov 18 14:25:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 39327 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp356118pzb; Fri, 18 Nov 2022 06:25:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf7aHm8lckkZk11kOPBypdlI+v9vd2U0OnQcWJgB5T4MyhEqRT/3INCrFXJxfpiOUbrWxOA8 X-Received: by 2002:a05:6402:4289:b0:467:9864:9463 with SMTP id g9-20020a056402428900b0046798649463mr6365320edc.360.1668781551843; Fri, 18 Nov 2022 06:25:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668781551; cv=none; d=google.com; s=arc-20160816; b=ijmbhUouYoe2tFijOz8bs68dR0bRTA12Jixp0gAQXaOIvy6wgvbI4tbCG2Y5jHtfc6 q2VrEpkxdr2BOZt6Hv+MXlF+2cbphNxj/c7jaVdbR1NJomOpQOTNZ8TcuSMqd6horVyf C2WIOUFa/RN5xlgrA9B5dFKUht5k6U8i3IE8ERj48KmNF9hlQ30FtxS33QnEKK1xKll+ TSyr3qIsnROLwXwF1bh3qHDy8v0diLBiic2imiNet1NyrR/yMKl5EEA/a15/fgDCM+xo 5VeHLXXQDi7spmcjWSjuxpuYd52JKn1P8SONfUnQx9VAXwM7wnFIXXQ50NE+aXnEgRYZ DKXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=bmPMv+XZEPTWpFuSlDhmP5L0+Gw96jOPwz2yPHMZ67M=; b=dlx/52FZGIOCqxqApmTDheM8O/X2P2oQQ5Og6PsQ5vfj+yOmdWCzTjCIca/Y3+DQjt XrQNLG+0kZemuJpGB2PYaixocb9CTqcIRx7f7JK807BZtBhCNsVVUh1RFB8xehs2SzmX X5ixvjPRVMGIdp3X1HfgsFHBmXVXCLJ+KTUEm2sXM/s6dBxW7bxZNbg1X39x7S5PFb9Y UaTEAg+6/oVytN97NWIQgKbb1u3GfQwnSwCk5uiS/6/nGCvp31dV7ohsvgitFTHKXux3 pm/JUke2trbaJaQmnRekaXjNVJ085pJl4828Sar4hptXKDAxB0yEyFT8Ur2TDnBcLv1w TF+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="m7C/dy9/"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ty13-20020a170907c70d00b007ae87dde2c7si1006899ejc.830.2022.11.18.06.25.51; Fri, 18 Nov 2022 06:25:51 -0800 (PST) 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=@haasn.xyz header.s=mail header.b="m7C/dy9/"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 45D7A68B8AF; Fri, 18 Nov 2022 16:25:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6920D68B8F2 for ; Fri, 18 Nov 2022 16:25:30 +0200 (EET) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id E334A483A1; Fri, 18 Nov 2022 15:25:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1668781530; bh=w90KTo/sBkfgVORqJNMMtrMs58IbX2sf3umyISyn1vI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m7C/dy9/mFvULAgBmaQ5Bas3wqfwfAUyTU0WkNiTpWbSCrTdDFDONo77i1aK9aeNb akk3pZ5QkjCgK+wlgDYn5YgoRmDdknxFStaPIbXHnbh7k/wstUbD+4HZURQgjE9VCW MvJT+vcNnE7pHL2RKp6r7QmTWIuWoUI74Yl/VDjI= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Nov 2022 15:25:12 +0100 Message-Id: <20221118142512.72413-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118142512.72413-1-ffmpeg@haasn.xyz> References: <20221118142512.72413-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_libplacebo: fix normalize_sar calculation 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: SA4nXDrH6Xq6 From: Niklas Haas This previous expression multiplied a constant (outlink->h) that was guaranteed to be 0 at this point, thus making it always a no-op. Fix the calculation, and also properly reset the SAR to 1:1 as is now necessary (the failure to do so previously hid this bug's existence). --- libavfilter/vf_libplacebo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index d52833263d..921cdb36fd 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -576,12 +576,13 @@ static int libplacebo_config_output(AVFilterLink *outlink) s->force_original_aspect_ratio, s->force_divisible_by); - scale_sar = (AVRational){outlink->h * inlink->w, *out_w * *out_h}; + scale_sar = (AVRational){*out_h * inlink->w, *out_w * inlink->h}; if (inlink->sample_aspect_ratio.num) scale_sar = av_mul_q(scale_sar, inlink->sample_aspect_ratio); if (s->normalize_sar) { /* Apply all SAR during scaling, so we don't need to set the out SAR */ + outlink->sample_aspect_ratio = (AVRational){ 1, 1 }; s->target_sar = scale_sar; } else { /* This is consistent with other scale_* filters, which only