From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B9FFD438B4 for ; Tue, 2 Aug 2022 16:55:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 55D4D68BAEB; Tue, 2 Aug 2022 19:54:38 +0300 (EEST) Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9052D68BA71 for ; Tue, 2 Aug 2022 19:54:29 +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 272GsSx7017581 for ; Tue, 2 Aug 2022 18:54:29 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id CBB4BEB5BC; Tue, 2 Aug 2022 18:54:28 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Aug 2022 18:54:20 +0200 Message-Id: <20220802165421.137563-6-george@nsup.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220802165421.137563-1-george@nsup.org> References: <20220802165421.137563-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 02 Aug 2022 18:54:29 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Nicolas George --- libavutil/pixdesc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 6e57a82cb6..923a61b0ab 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2866,6 +2866,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, else nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components); + // Penalty for losing depth for (i = 0; i < nb_components; i++) { int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : (dst_desc->comp[i].depth - 1); if (src_desc->comp[i].depth - 1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) { @@ -2874,6 +2875,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, } } + // Penalty for subsampling if (consider & FF_LOSS_RESOLUTION) { if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) { loss |= FF_LOSS_RESOLUTION; @@ -2890,6 +2892,7 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, } } + // Penalty for changing colorspace if(consider & FF_LOSS_COLORSPACE) switch(dst_color) { case FF_COLOR_RGB: @@ -2920,15 +2923,18 @@ static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, if(loss & FF_LOSS_COLORSPACE) score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth - 1, src_desc->comp[0].depth - 1); + // Penalty for changing chroma if (dst_color == FF_COLOR_GRAY && src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) { loss |= FF_LOSS_CHROMA; score -= 2 * 65536; } + // Penalty for losing alpha if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) { loss |= FF_LOSS_ALPHA; score -= 65536; } + // Penalty for using a palette if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) && (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) { loss |= FF_LOSS_COLORQUANT; -- 2.35.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".