From: Philip Langdale <philipl@overt.org>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH] lavu/pixdesc: favour formats where bit depth exactly matches
Date: Sat, 10 Sep 2022 09:59:54 -0700
Message-ID: <20220910095954.62c8fcd1@fido7> (raw)
In-Reply-To: <20220910150432.GH2088045@pb2>
On Sat, 10 Sep 2022 17:04:32 +0200
Michael Niedermayer <michael@niedermayer.cc> wrote:
> >
> > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> > index d7c6ebfdc4..412e257a30 100644
> > --- a/libavutil/pixdesc.c
> > +++ b/libavutil/pixdesc.c
> > @@ -3004,6 +3004,11 @@ static int get_pix_fmt_score(enum
> > AVPixelFormat dst_pix_fmt, if ((ret =
> > get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) <
> > 0) return -3;
> > + // Favour formats where bit depth exactly matches. If all
> > other scoring is
> > + // equal, we'd rather use a lower bit depth that matches the
> > source.
> > + if (src_min_depth != dst_min_depth || src_max_depth !=
> > dst_max_depth)
> > + score -= 64;
>
> This adds a penalty for decreasing the depth, that is under
> FF_LOSS_DEPTH
>
> more so if we decreas depth from 16 to 15 bit, that gives a penalty
> of 2 but increasing from 15 to 16 a penalty of 64. This needs an
> adjustment also are we intentionally treating a increase from 14 to
> 15 like 14 to 16 ? or do we want to prefer the closer ?
>
> a FF_LOSS_EQUAL_DEPTH / DIFFERENT_DEPTH could be added to keep this
> more in line with existing code
Good point. I was thinking about this in binary terms, but you are
right that the penalty should scale with the divergence, in the same
way that it does for other mismatches.
>
> > +
> > src_color = get_color_type(src_desc);
> > dst_color = get_color_type(dst_desc);
> > if (dst_pix_fmt == AV_PIX_FMT_PAL8)
> > @@ -3020,14 +3025,21 @@ static int get_pix_fmt_score(enum
> > AVPixelFormat dst_pix_fmt, }
> >
> > if (consider & FF_LOSS_RESOLUTION) {
> > + // Apply a large penalty if there's a loss of resolution,
> > but also apply
> > + // a small penalty of the dst resolution is higher so that
> > we favour
> > + // exactly matching formats.
> > if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) {
> > loss |= FF_LOSS_RESOLUTION;
> > score -= 256 << dst_desc->log2_chroma_w;
> > - }
> > + } else if (dst_desc->log2_chroma_w <
> > src_desc->log2_chroma_w)
> > + score -= 32;
> > +
> > if (dst_desc->log2_chroma_h > src_desc->log2_chroma_h) {
> > loss |= FF_LOSS_RESOLUTION;
> > score -= 256 << dst_desc->log2_chroma_h;
> > - }
> > + } else if (dst_desc->log2_chroma_h <
> > src_desc->log2_chroma_h)
> > + score -= 32;
>
> this would favor 410 -> 411 over 410 -> 420, i dont think that choice
> is correct in that specific case
True. I'll need to make it scale here as well.
> i do agree though with the basic idea behind this patch
Thanks for taking a look!
--phil
_______________________________________________
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".
prev parent reply other threads:[~2022-09-10 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 3:46 Philip Langdale
2022-09-09 6:31 ` Xiang, Haihao
2022-09-10 15:04 ` Michael Niedermayer
2022-09-10 16:59 ` Philip Langdale [this message]
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=20220910095954.62c8fcd1@fido7 \
--to=philipl@overt.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