[FFmpeg-devel] [PATCH] swscale/slice: fix init of 32 bpc planes
Michael Niedermayer
michael at niedermayer.cc
Tue Dec 17 00:39:40 EET 2024
Hi
On Mon, Dec 16, 2024 at 11:40:50AM +0100, Niklas Haas wrote:
> On Mon, 16 Dec 2024 01:50:20 +0100 Michael Niedermayer <michael at niedermayer.cc> wrote:
> > Hi Niklas
> >
> > On Wed, Dec 11, 2024 at 09:25:12AM +0100, Niklas Haas wrote:
> > > From: Niklas Haas <git at haasn.dev>
> > >
> > > In input.c and output.c and many other places, swscale follows the rule of using
> > > 15-bit intermediate if output bpc is <= 8, and 19-bit (inside int32_t)
> > > intermediate otherwise. See e.g. the comments on hyScale() on
> > > swscale_internal.h. These are also the coefficients that yuv2gbrpf32_full_X_c()
> > > is using.
> > >
> > > In contrast to this, the plane init code in slice.c (function fill_ones) is
> > > assuming that we use 35-bit intermediates (inside 64-bit integers) for this
> > > case, seemingly added by commit b4967fc71c63eae8cd96f9c46cd3e1fbd705bbf9 with
> > > no further justification.
> > >
> > > This causes a mismatch whenever the implicitly initialized plane contents leak
> > > out to the output, e.g. when converting from grayscale to RGB.
> > >
> > > Fixes: ticket #10716
> > > Signed-off-by: Niklas Haas <git at haasn.dev>
> > > Sponsored-by: Sovereign Tech Fund
> > > ---
> > > libswscale/slice.c | 6 +-----
> > > 1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > ultimately 32bit on teh input or output side require more than 32bit
> > internally to maintain precission.
> >
> > if this patch makes it all match up, its ok for now but 18bit dont seem
> > enough for 32bit data
>
> What exactly is the design goal here? As a point of reference, here is how many
Make the user happy :)
> bits you need to represent a signal to within an error that is substantially
> below the threshold of human perception in all but the most extreme synthetic
> test setups:
>
> - HDR before linearization: 14 bits
> - HDR after linearization: 35 bits
> - SDR before linearization: 12 bits
> - SDR after linearization: 26 bits
>
> If we relax this to the threshold that is required for visual transparency in
> (non-static) video playback, we get:
>
> - HDR before linearization: 12 bits
> - HDR after linearization: 30 bits
> - SDR before linearization: 10 bits
> - SDR after linearization: 22 bits
what about image material from scientific instruments ?
The question here is not if a human can see it with unadjusted contrast,
but the existing precission should still be preserved
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
z(9) = an object that transcends all computable functions describable
in finite terms. - ChatGPT in 2024
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241216/2baaaaa1/attachment.sig>
More information about the ffmpeg-devel
mailing list