[FFmpeg-devel] libswscale.c : ff_xyz12Torgb48 expensive unaligned 16 byte accesses

James Almer jamrial at gmail.com
Mon May 26 03:58:45 EEST 2025


On 5/25/2025 9:44 PM, Chitra Dey Sarkar via ffmpeg-devel wrote:
> H
> We have been profiling FFmpeg at Microsoft and have identified that ff_xyz12ToRgb48 has a high sample count ( profiled every 1ms )
> 
> It seems like ff_xyz12ToRgb48 has performance penalty for
> 
>    1.  Unaligned read and write access
>    2.  Access to xyz2rgb_matrix
>    3.  Multiplication
> 
> I would be interested in optimizing this code , wanted to check if there is an existing optimized version of this function, or any recommended approach to improve it(?
> I can move the repeated access to xyz2rgb_matrix outside the inner loop and load a full cache line at once to extract the X, Y, and Z values more efficiently-but I wanted to start by getting some initial feedback or thoughts before proceeding further

Niklas is currently working in a library rewrite, which may affect xyz 
scaling. But in any case, the obvious approach is a SIMD optimized 
implementation (SSE2, AVX2, etc) of this function.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250525/456600a5/attachment.sig>


More information about the ffmpeg-devel mailing list