Fix #120077: Video output artifacts due to threaded YUV conversion #120168
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120168
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "aras_p/blender:swscale_align"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ffmpeg AVFrame objects should use correct alignment between image
rows, or otherwise bad things might happen. In this particular
case, multi-threaded libswscale RGB->YUV conversion was trampling
over 4 bytes of V plane, for each thread boundary.
@blender-bot build
It is a bit hard to do a proper review here, as it seems i can't reproduce the issue on my macOS arm64. The code and explanation looks clear though.
What is not clear is the relation of the issue with the previous refactor. it does not seem we ever passed proper alignment to
av_image_get_buffer_size
/av_image_fill_arrays
, so not really clear why422dd9404f
introduced the issue?From what I can tell, what happens is that each "slice" of image processed by sws_scale overwrites 4 bytes past the "image portion", at least on my machine for this video resolution. Without alignment, and with multiple threads, this actually adds "number of threads" artifacts right exactly where each thread slice ends, i.e. first 4 pixels of the next slice. With just one thread (as previously), I don't know if it actually overwrites past the array, or whether there is no overwriting happening. It could have been the former, just memory allocation / page granularity happens to be good enough that it was not triggering an actual crash.
And btw with most typical video resolutions the issue would not be showing up, since e.g. 1920x1080 has linesize that is already multiple of 16. But the repro video resolution has width 1080, which is not multiple of 16.
@aras_p Ah, I see. Thanks for the explanation.
it seems that on my computer (EndeavourOS) this change will generate strange output video (but in the preview windows it seems fine)
In the code above, the rgb_frame's linesize is after aligning (which is 4352 in this case(my computer's align size is 64)), however, the data in "pixels" is generated in RE_render_result_rect_to_ibuf and hasn't been aligned, (so it's linesize is 1080*4=4320 in this case), so when copying the data, they should use different linesize.
I've changed the code to this and it works fine on my computer.
my pr here: #120184