From patchwork Wed Oct 27 22:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 31238 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp487243ioa; Wed, 27 Oct 2021 15:21:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjMBc1LyMO8dcCOk+s0dxSxBT7QBS31jodnRqorKXwPQopmp0LcV8SyQeGHb5AdCwLkhoX X-Received: by 2002:a17:906:8a7b:: with SMTP id hy27mr421067ejc.308.1635373264729; Wed, 27 Oct 2021 15:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635373264; cv=none; d=google.com; s=arc-20160816; b=JkTO58Wl6+MDSXWMUeZwr4FLADqxnLvcB8WHPWdMfq7QNC1bUYi+1eFKiOXhChLHlt pizziDExFXc3MppcxbK9SDiGhnZEOAWDwktd4J2HheYWJ57FYeIrX+nYkHUnOA+bLADv yxQjRg7BsoPGMPQVyxDV+ESh8w7fk10CsI1YDPlT+Y1sozSe+HO7BOGRJltRNOsomf+8 W6WFrrWE/ZAGWnd3E0UZ62zt541Aeldvcq2RIRdrHBPXckWHG+VY2mqVPmDEuTIoEKsS DXDl8mbKrquOk0HEYYGJrC7iIWfimeyHPCRJOkPxSKWeel6yU/e3h/BtGqdANWlobCtT QoOQ== 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=mPYh7Jss7Zfl5+lkiY2Q1sKe+m+Xh7kry26tvpM8Hx4=; b=XftrUhSwL6siIeTev0cf+2ikkU4WgQq4TjwULxqhujKsaDVznxGDg+JmqaGI13JdOw uiNwfTGinF+K5g2Y/ZaORPRajhJMeAVb3Shh1lyDr+PNf5dO+KLJvgTLxKR1prFVGJmx Uz2V7l4AD+KDa6VB3UbK5RoCo9n6l28hc6vLRfqjNE4h+qvz/WUdUMs0IbqSnbRBp6fj DkXuwm9k8b8OLCy/ONzNo6eAVeJ914MohxUlB1+Gfqv4s2nOdj8qbtnZMe5xbd9tIJE2 uxOrQ0PZMxbJ8Kq2nMOJAzdKPNZDkvJRS2OWd9FTBs2x/Jk50hIuUDgrdNuIwN5TZzHF lssg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=NiZgCIQ1; 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 hc7si1460938ejc.170.2021.10.27.15.20.41; Wed, 27 Oct 2021 15:21:04 -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=NiZgCIQ1; 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 2AE1D68AA5C; Thu, 28 Oct 2021 01:20:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 640EC68A1CC for ; Thu, 28 Oct 2021 01:20:31 +0300 (EEST) Received: by mail-lf1-f43.google.com with SMTP id b32so6086434lfv.0 for ; Wed, 27 Oct 2021 15:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IFzVu+0BTQ2uWozgGpStkvKB0RIvlH0a94W1vZ8CMbI=; b=NiZgCIQ1zEeWQQ6wF16S4MCmPB7FhZHJQbVGXkW9nwMHVy3PNL2dbSsQ0BYTLlmqh2 qwr6g3Ux1dlzwSAhKDwGID+jxI8LJTdXTWtiGg6Y4sEz/JrfV55YvFeRPzj63GM1A9dB nHxKco3SGoKIqitqL23zPVfkkDuQ082R7kzRILW/ZgrcGmbMrRJsFuKSs+etMvsOWcmj NuB4iBE27k5EUqorV1A3RZtD7N9X/G5yCWdrCLQFX83vBnFHT/ZiTDhdC047OmitTDpH XDcCgNGvg9G1h5u1VEsd3fULxc13INLLgXvrR4XH7P0RVAc39t3hQhJomP4T3nf2Pv53 kAbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=IFzVu+0BTQ2uWozgGpStkvKB0RIvlH0a94W1vZ8CMbI=; b=Sa/gZSMQE4ENPVzNWeQRmE0LYXPIo2Tliq3NC+OVEEmIgrvr5xzcsOWoZZWVTu9CQI C6527CVMPX5oG0K2Vlu4d17aC7QFmn65vz56PpG4NppPH8IelPYgaJocwiIlye9C9iPA IhVrwlPvWMKkzlNhA1N/MIj+n+t3obz+/ltaH1LJfmMw5ELOOrx0qtxtPeahorVOSSkv +mKoph+YzwFiEYE7WOyKrIHAoyJmCAE1DbexNTAYdb4uglwBYKs+xo+wjaV6RuTURb7R 7Rc1mGvVUWSGOwon1z8wQps8NTvzbbksZbkfMcXPMqm81lsWVQKthyAthu/eaBl4cbTR Tppw== X-Gm-Message-State: AOAM532fqawo9xjm+5lihislaX/e10GbObsk7Hw2aAyl7wEEGFiWgE56 +B0MrJYuUno/pQ9eq+WI9w78V1cOS6Q= X-Received: by 2002:a05:6512:3401:: with SMTP id i1mr404865lfr.336.1635373229986; Wed, 27 Oct 2021 15:20:29 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id z6sm115692lfq.195.2021.10.27.15.20.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 15:20:29 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Oct 2021 01:20:23 +0300 Message-Id: <20211027222024.53018-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avfilter/vf_zscale: deduplicate output color information setting 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: nBlOSHVlxltH This way a piece of logic is not missed in one location or the other, such as the case with chroma location outside the if. --- libavfilter/vf_zscale.c | 45 ++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 3f7dba489a..439c0c8548 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -554,6 +554,24 @@ fail: return ret; } +static void update_output_color_information(ZScaleContext *s, AVFrame *frame) +{ + if (s->colorspace != -1) + frame->colorspace = (int)s->dst_format.matrix_coefficients; + + if (s->primaries != -1) + frame->color_primaries = (int)s->dst_format.color_primaries; + + if (s->range != -1) + frame->color_range = convert_range_from_zimg(s->dst_format.pixel_range); + + if (s->trc != -1) + frame->color_trc = (int)s->dst_format.transfer_characteristics; + + if (s->chromal != -1) + frame->chroma_location = (int)s->dst_format.chroma_location - 1; +} + static int filter_frame(AVFilterLink *link, AVFrame *in) { ZScaleContext *s = link->dst->priv; @@ -621,20 +639,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) format_init(&s->dst_format, out, odesc, s->colorspace, s->primaries, s->trc, s->range, s->chromal); - if (s->colorspace != -1) - out->colorspace = (int)s->dst_format.matrix_coefficients; - - if (s->primaries != -1) - out->color_primaries = (int)s->dst_format.color_primaries; - - if (s->range != -1) - out->color_range = convert_range_from_zimg(s->dst_format.pixel_range); - - if (s->trc != -1) - out->color_trc = (int)s->dst_format.transfer_characteristics; - - if (s->chromal != -1) - out->chroma_location = (int)s->dst_format.chroma_location - 1; + update_output_color_information(s, out); ret = graph_build(&s->graph, &s->params, &s->src_format, &s->dst_format, &s->tmp, &s->tmp_size); @@ -680,17 +685,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) } } - if (s->colorspace != -1) - out->colorspace = (int)s->dst_format.matrix_coefficients; - - if (s->primaries != -1) - out->color_primaries = (int)s->dst_format.color_primaries; - - if (s->range != -1) - out->color_range = convert_range_from_zimg(s->dst_format.pixel_range); - - if (s->trc != -1) - out->color_trc = (int)s->dst_format.transfer_characteristics; + update_output_color_information(s, out); av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den, (int64_t)in->sample_aspect_ratio.num * outlink->h * link->w, From patchwork Wed Oct 27 22:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 31239 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp487336ioa; Wed, 27 Oct 2021 15:21:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcWHKVnsUAlxVOG7GNhosS60W3ydSaacBHNahcyqdbwOiLBkPrsl73M5JOZzbhShz6Yd66 X-Received: by 2002:a05:6402:350a:: with SMTP id b10mr754758edd.345.1635373272745; Wed, 27 Oct 2021 15:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635373272; cv=none; d=google.com; s=arc-20160816; b=ZDyJiC7Um84H3KMXgwDlFBo6BO4oXfAyDEAywUpjtgLOb+9SE8GkYDOCOvsP074EmS T9R6zwuLCKvEqt1jJ85c3u/m/OvTdwo7hQIVJ+GiR+lnWutV6YxNrX5yQspSP2qbUKLa kwVlhN6g/p6PdDp+llNxj1gTnWf292Drda+hfGm09yDDFGfjIteHKBmwKttOQY/epvzW yyt0aNnYyl5bYlarX4tXr79GC/ns0wg5SB6qCiYDM4PP2LzIGUpfTKn5jqeQoZSJEic6 xcKmHPHFrfPYNNXiQbj0mRRh0Run/cSMHYpAX8BTurHKuzILN5ECc4Va4lA4ubKNlX4f /O5w== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=rUDUHVVb/hmkgYHoV1z4AY3hxJSAuc5zSElyTNc/h1Q=; b=X9Kx9Cv9GLoQiVxghACD2hdERrdG5nlbC9Pm5SSJj3/KgCfAXcgw58Ut1XD3w1mefX UQFH7z17Qz9BZsZXcMaIbrxf7KmrB8ZUhqUu+a6SOyGyptqA8CDctmhUba4kIRHHV3Xn 0JGUVDIsaZ6b5WN1pENB39lz2lYMKOB1Brk7RFHscXdHgcMaLZ5yXXEtlmvRqfdHzQti TD5/0r+wrQs+t+sP/qiIoBOW7fjRyl3Q3mfOGTGif0nSwfGpUOZUGa/CvE0UfAIhZZUe as0T9NlFxAiirN1r4kQAytbU48uDy1FanHRQiGQk7BxoyEbEWjpxLXLkIeQXZaVwpBoj aJaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=igGsXtNN; 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 qp24si1361837ejb.434.2021.10.27.15.20.52; Wed, 27 Oct 2021 15:21:12 -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=igGsXtNN; 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 5174A68A9C0; Thu, 28 Oct 2021 01:20:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 659D768AA36 for ; Thu, 28 Oct 2021 01:20:31 +0300 (EEST) Received: by mail-lf1-f41.google.com with SMTP id b32so6086455lfv.0 for ; Wed, 27 Oct 2021 15:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZeZZ+sWB/6viWcn2cRdVJOwSyqFSntyYP5JBOjscJGg=; b=igGsXtNNXz0ULY8IetQr8zobziO+dLjKQtPI/HnktP5AywB7Oyf/OD+e+M3Ou32jbW 6TUXo27kKEb4PZz5mWovDBTcEy7TSpednrm0Sv8m2izh0CbEJu4QEhYXQxmp25BB3fPu CA19XMIMNnuRCcTjXa/Oc+tLI38F378Cl13NlG9mUXJUJ/tqKSZ4v9k5H0IyTLBZMHnG j13pVpwb+RU69xj060YqRSBaKhxTjPayaVeLYb180G2bYSx8awnGPkp+1GQylx+BLQc+ LQk87XOeJmAhJWurkiMHz8gXwPWs68YTspouYbztn/Iu8Vm6wUx3pHvs/ISjL0B5wTwU oMsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZeZZ+sWB/6viWcn2cRdVJOwSyqFSntyYP5JBOjscJGg=; b=GWXhNdUBuW9/DdTwYOHY70mTth9uAoPToCORryRzSvZ+sbSdbEr/nZeup4ZamUA7K+ KVYtn6qs0NdzYTqtp5hMtOWrbIauFlUtpyahjIYpsAQvBmCu+onkJbgCehTKP6Dw8CUX toblOqpFfVncIC0Kl9h8QZFooD3JRHOeV2pvwyQh6oNLW5qfTdXzfsFGXVrsMAbywLI1 dX6NHXwm1Yh5YcnhLuyDXPENj4+jkQsvJpBDl305R/AfDd1M/MfnmnDgjl/4Oko9RQLb yDNahIft+rWC8ZyTD2KjfiPDI2UULnJryPdEXDb/oS2l5HTInVoZfzPuJqooBzYyAvwz NTJg== X-Gm-Message-State: AOAM5300+AgM6N1uLWFdvwCoF804GRejKcTUOezpUvtsYzj6qaeJeQCV 1nUmqXCWOGwLWtqNLH1byLYx8Mfmo1g= X-Received: by 2002:a19:ac44:: with SMTP id r4mr368462lfc.157.1635373230429; Wed, 27 Oct 2021 15:20:30 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id z6sm115692lfq.195.2021.10.27.15.20.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Oct 2021 15:20:30 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Oct 2021 01:20:24 +0300 Message-Id: <20211027222024.53018-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211027222024.53018-1-jeebjp@gmail.com> References: <20211027222024.53018-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_zscale: fix mapping of zimg_chroma_location_e to AVChromaLocation 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: 6SHwd889BgVT The AVChromaLocation values are one higher than zimg's, not one lower as the undefined value is set to zero (as opposed to zimg's -1). --- libavfilter/vf_zscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c index 439c0c8548..1288c5efc1 100644 --- a/libavfilter/vf_zscale.c +++ b/libavfilter/vf_zscale.c @@ -569,7 +569,7 @@ static void update_output_color_information(ZScaleContext *s, AVFrame *frame) frame->color_trc = (int)s->dst_format.transfer_characteristics; if (s->chromal != -1) - frame->chroma_location = (int)s->dst_format.chroma_location - 1; + frame->chroma_location = (int)s->dst_format.chroma_location + 1; } static int filter_frame(AVFilterLink *link, AVFrame *in)