Re: [FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring

2022-08-04 Thread Michael Niedermayer
On Tue, Aug 02, 2022 at 06:54:20PM +0200, Nicolas George wrote:
> Signed-off-by: Nicolas George 
> ---
>  libavutil/pixdesc.c | 6 ++
>  1 file changed, 6 insertions(+)

probably ok

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The smallest minority on earth is the individual. Those who deny 
individual rights cannot claim to be defenders of minorities. - Ayn Rand


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 6/7] lavi/pixdesc: add comments about pixel format scoring

2022-08-02 Thread Nicolas George
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-requ...@ffmpeg.org with subject "unsubscribe".