Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Nicolas George <george@nsup.org>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring
Date: Tue,  2 Aug 2022 18:54:20 +0200
Message-ID: <20220802165421.137563-6-george@nsup.org> (raw)
In-Reply-To: <20220802165421.137563-1-george@nsup.org>

Signed-off-by: Nicolas George <george@nsup.org>
---
 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".

  parent reply	other threads:[~2022-08-02 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-02 16:54 [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 2/7] lavfi/graphdump: add plain listing output Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 3/7] fftools: add -lavfi_dump option Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 4/7] lavfi/(a)format: factor finding the delimiter Nicolas George
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 5/7] lavfi/(a)format: support slash as a delimiter Nicolas George
2022-08-02 16:54 ` Nicolas George [this message]
2022-08-04 13:52   ` [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring Michael Niedermayer
2022-08-02 16:54 ` [FFmpeg-devel] [PATCH 7/7] tests: add coverage for libavfilter's format negotiation Nicolas George
2022-08-04 13:49 ` [FFmpeg-devel] [PATCH 1/7] lavu/pixfmt: summarize yuv naming conventions Michael Niedermayer
2022-08-04 13:57   ` Nicolas George
2022-08-04 15:04     ` Michael Niedermayer
2022-08-06 10:36       ` Nicolas George

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220802165421.137563-6-george@nsup.org \
    --to=george@nsup.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git