[FFmpeg-devel] [PATCH v3 3/7] swscale/range_convert: fix mpeg ranges in yuv range conversion for non-8-bit pixel formats

Michael Niedermayer michael at niedermayer.cc
Sun Dec 1 03:29:13 EET 2024


Hi

On Sat, Nov 30, 2024 at 04:23:38PM +0100, Ramiro Polla wrote:
> There is an issue with the constants used in YUV to YUV range conversion,
> where the upper bound is not respected when converting to mpeg range.
> 
> With this commit, the constants are calculated at runtime, depending on
> the bit depth. This approach also allows us to more easily understand how
> the constants are derived.
> 
> For bit depths <= 14, the number of fixed point bits has been set to 14
> for all conversions, to simplify the code.
> For bit depths > 14, the number of fixed points bits has been raised and
> set to 18, to allow for the conversion to be accurate enough for the mpeg
> range to be respected.
> 
> The convert functions now take the conversion constants (coeff and offset)
> as function arguments.
> For bit depths <= 14, coeff is unsigned 16-bit and offset is 32-bit.
> For bit depths > 14, coeff is unsigned 32-bit and offset is 64-bit.
> 
> x86_64:
> chrRangeFromJpeg8_1920_c:    5804.5  5845.2 ( 0.99x)
> chrRangeFromJpeg16_1920_c:   5792.8  5809.1 ( 1.00x)
> chrRangeToJpeg8_1920_c:      9388.6  9462.2 ( 0.99x)
> chrRangeToJpeg16_1920_c:     5796.5  9261.5 ( 0.63x)
> lumRangeFromJpeg8_1920_c:    4147.9  4191.4 ( 0.99x)
> lumRangeFromJpeg16_1920_c:   4529.0  4143.4 ( 1.09x)
> lumRangeToJpeg8_1920_c:      5694.1  5720.5 ( 1.00x)
> lumRangeToJpeg16_1920_c:     5334.2  5139.5 ( 1.04x)
> 
> aarch64 A55:
> chrRangeFromJpeg8_1920_c:   28833.8 28834.8 ( 1.00x)
> chrRangeFromJpeg16_1920_c:  28842.8 28840.6 ( 1.00x)
> chrRangeToJpeg8_1920_c:     23070.6 23072.5 ( 1.00x)
> chrRangeToJpeg16_1920_c:    17313.8 23075.1 ( 0.75x)
> lumRangeFromJpeg8_1920_c:   15388.1 15386.7 ( 1.00x)
> lumRangeFromJpeg16_1920_c:  15388.0 15383.8 ( 1.00x)
> lumRangeToJpeg8_1920_c:     19226.2 19223.6 ( 1.00x)
> lumRangeToJpeg16_1920_c:    19225.5 19225.5 ( 1.00x)
> 
> aarch64 A76:
> chrRangeFromJpeg8_1920_c:    6317.8  6318.5 ( 1.00x)
> chrRangeFromJpeg16_1920_c:   6322.9  6323.5 ( 1.00x)
> chrRangeToJpeg8_1920_c:      9287.1  9170.0 ( 1.01x)
> chrRangeToJpeg16_1920_c:     6104.9  9195.6 ( 0.66x)
> lumRangeFromJpeg8_1920_c:    4359.1  4425.5 ( 0.98x)
> lumRangeFromJpeg16_1920_c:   4358.8  4436.8 ( 0.98x)
> lumRangeToJpeg8_1920_c:      5957.2  6017.2 ( 0.99x)
> lumRangeToJpeg16_1920_c:     6072.5  6017.2 ( 1.01x)
> 
> NOTE: all simd optimizations for range_convert have been disabled.
>       they will be re-enabled when they are fixed for each architecture.
> 
> NOTE2: the same issue still exists in rgb2yuv conversions, which is not
>        addressed in this commit.

this (as expected) changes a lot of files, i looked at some and
could not find any vissual problems, i dont think i can test this
further than that

thx

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

It is a danger to trust the dream we wish for rather than
the science we have, -- Dr. Kenneth Brown
-------------- 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/20241201/1f93a5a1/attachment.sig>


More information about the ffmpeg-devel mailing list