Opened 3 months ago
Closed 3 months ago
#11116 closed defect (fixed)
av_frame_get_buffer automatic alignment is incorrect for AVX512 CPUs
Reported by: | Aras Pranckevicius | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avutil |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
av_frame_get_buffer with "automatic" (align=0) alignment ends up picking 32 alignment, even if on an AVX512 CPU it should have picked 64.
Actual get_video_buffer function implementation, in the original commit that added automatic alignment (2017 Feb) https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/4de220d2e3751c4?hp=f44ec22e095 used av_cpu_max_align. However, a later merge of that commit (2017 Sep) https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/7aa6b8a68fce93d84?hp=24ee1b8c6343f replaced usage of av_cpu_max_align with hardcoded value of 32, with a comment saying that it should really be av_cpu_max_align.
The repro case is a bit involved, currently I don't have a clean one, only an indirect one through investigating a Blender bug report (https://projects.blender.org/blender/blender/issues/125446). Where it ends up being a problem, is when a video frame is decoded through ffmpeg, and then YUV -> RGBA conversion is done through libswscale. On an AVX512 CPU, where video width is not multiple of 16 pixels (i.e. RGBA image stride is not multiple of 64 bytes), the swscale conversion ends up emitting "wrapping artifacts" on the left side of the image.
Should be fixed in 210740b4ed4ac0329652aa4f16c0166e96a7e112