mac-virtualcam: Fix frame sharing and colourspace issues #7403
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes an issue with empty IOSurface references on Intel-based Macs and also broken output when OBS is set to deliver full colour range output.
Motivation and Context
The plugin was missing necessary IOSurface locks to ensure that modifications to the underlying memory reference made by the OS do not occur when client code accesses the image data.
On machines without unified memory this can lead to IOSurfaces pointing to GPU memory even though the data has been moved to CPU memory by the OS (to avoid unnecessarily large copy operations) and a PixelBuffer created from the IOSurface won't contain data.
In addition to the issue above, FFmpeg's
swscale
seems to have issues with converting images with full colour ranges to limited colour ranges, resulting in mangled frame data inside OBS.As macOS natively supports partial range as well as as full ranges for pixel buffers, use these directly, avoiding costly colour space conversions for even more use cases than before - as this skips swscale entirely, the issue doesn't occur anymore.
Fixes #7333
Possibly fixes #7171
How Has This Been Tested?
Tested with macOS 12.6 on Intel-based and Apple-Silicon-based Macs.
Types of changes
Checklist: