From patchwork Sun Aug 22 14:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29727 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1321846iov; Sun, 22 Aug 2021 07:54:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfPOp5X25253o+tub9CEpDUKAi+qSMHC9iEa6zyr+usf3PRWhIYBOl01Jj7Z2yraT7PXXE X-Received: by 2002:a05:6402:1d33:: with SMTP id dh19mr32851598edb.10.1629644064619; Sun, 22 Aug 2021 07:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629644064; cv=none; d=google.com; s=arc-20160816; b=C69oEM78AZPXiFMECz+9S7pj/u5/t6AgEVpFpOQk9b2oAHIoN4KFuIlWV5to5hjWzH 3QqppC3hkcMOEGYd7hXVHLYpibr23zrLxsfmcP1IJ7Ozk7Aw/c0YKz2IBvfhUEpVf19r OebIhFLKaw2S6k4m23yeWJm2EB/l7+O09pOz6wp2WshtNtHDQ843BxElvB8U5jKl7EGV 9JqFNvqjm48cSxIRZldIrWTM+cLP+VOtYuuh8gj3DZ4leVlebcBPmttxRHzM59dNRBWx ShTe/I2K6MgfCgou2RWidb+3Tj2QhksYrZHT74eN0nvitVYoL6gZPhcpsxy9BMx85oHe x2Yg== 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 :delivered-to; bh=WgEuraNC/TxW4AzJRRVeKbwW1X4ZQHzdylIPyz9GJhA=; b=YAwV9VP/nM1pnhXxT2ml7YZ2wxzuFskOj1KLI7DH3qSJjwjJHL7Ezq2oTx8j3qnar2 pyLJ17SYZB+rMH3T7DZ+ScD7J3Yw+npg9mH8AfuyTO9p5gw+dmVWmQRW7+Evi8n/ctH2 422K7+WxHQZJR6eUky8lcmmBToNZwDsmGs/Y9EqkqVcQK14OVdg5lZXDLd+vpGHCw3Cs +5teRwexHUvPJOGeq8HdQ1xjtCl5dajPd4Qm3xS4yKz182zGGw73uongUGzXe7TiGjss gq2kv1hkX7WiQrJPCPk0e3O9YZXMXh8FhC3fvziDkHT/0BSOC1h1nTfX0FzSh+Q3kY9d rfXg== ARC-Authentication-Results: i=1; mx.google.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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id du21si2810171ejc.221.2021.08.22.07.54.23; Sun, 22 Aug 2021 07:54:24 -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; 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 3D35F68A2BD; Sun, 22 Aug 2021 17:54:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C009689A52 for ; Sun, 22 Aug 2021 17:54:12 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 17MEsBkE017308 for ; Sun, 22 Aug 2021 16:54:11 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 2DB98EB5BC; Sun, 22 Aug 2021 16:54:11 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Aug 2021 16:54:08 +0200 Message-Id: <20210822145409.316517-1-george@nsup.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Sun, 22 Aug 2021 16:54:11 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/2] lavu/pixdesc: remove get_pix_fmt_depth(). 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: q9B83qRQzsS7 Apart from erroring when nb_components == 0, it is dead code. nb_components == 0 only for HW formats, and HW formats are handled earlier in get_pix_fmt_score(). Signed-off-by: Nicolas George --- libavutil/pixdesc.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) The strange thing is that it was dead code from the start. Maybe I a missing something. I will need to make the score function public to let libavfilter use it. These two patches were low-hanging fruits and make understanding the logic easier. diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 2346138d04..f1898a6a13 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2686,24 +2686,6 @@ static int get_color_type(const AVPixFmtDescriptor *desc) { return FF_COLOR_YUV; } -static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt) -{ - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); - int i; - - if (!desc || !desc->nb_components) { - *min = *max = 0; - return AVERROR(EINVAL); - } - - *min = INT_MAX, *max = -INT_MAX; - for (i = 0; i < desc->nb_components; i++) { - *min = FFMIN(desc->comp[i].depth, *min); - *max = FFMAX(desc->comp[i].depth, *max); - } - return 0; -} - static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, unsigned *lossp, unsigned consider) @@ -2711,8 +2693,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); int src_color, dst_color; - int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth; - int ret, loss, i, nb_components; + int loss, i, nb_components; int score = INT_MAX - 1; if (!src_desc || !dst_desc) @@ -2732,11 +2713,6 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, if (dst_pix_fmt == src_pix_fmt) return INT_MAX; - if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0) - return -3; - if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0) - return -3; - src_color = get_color_type(src_desc); dst_color = get_color_type(dst_desc); if (dst_pix_fmt == AV_PIX_FMT_PAL8)