WIP: macOS: map VideoToolbox frames before falling back to a CPU copy #818
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
stale
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-streetpea/chiaki-ng!818
Loading…
Reference in a new issue
No description provided.
Delete branch "latifv/codex/videotoolbox-direct-mapping"
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?
On macOS, VideoToolbox-decoded frames currently go through
av_hwframe_transfer_databefore presentation. That allocates a software frame and copies the decoded pixels even when FFmpeg can expose the CVPixelBuffer's CPU planes directly.This change first tries
av_hwframe_mapwithAV_HWFRAME_MAP_READ | AV_HWFRAME_MAP_DIRECTwhen the existing Zero-Copy setting is enabled. The mapped AVFrame retains the underlying surface and metadata. Mapping failure preserves the current transfer/copy fallback; disabling Zero-Copy and reconnecting also restores it.This is a read-only CPU mapping, not Metal texture import: renderer upload and presentation still happen. The production change is confined to the macOS frame-preparation path. No queue sizes, decoder options, renderer defaults, audio, or networking behavior are changed.
Validation
ctest --test-dir build-upstream --output-on-failure: 2/2 passed (existing unit suite and the new macOS mapping test).These timings include AVFrame allocation and metadata propagation, but exclude decoding, validation, unmapping/freeing, GPU upload, and presentation. They do not establish an end-to-end Remote Play latency improvement. Reproduction instructions are in
doc/videotoolbox-mapping.md.Remaining validation (draft)
This isolated upstream branch has not had a live PS5 session. Live renderer behavior, decoder-surface retention during a long session, and HDR display output still need testing. Intel Macs, older macOS releases, and Linux/Windows builds have not been tested locally. The local build used Homebrew libraries targeting newer macOS versions and emitted deployment-target warnings, so it does not establish macOS 13 compatibility. No Flatpak validation was performed on this macOS host.
Suggested live check: stream using VideoToolbox with Zero-Copy enabled, repeat with it disabled after reconnecting, and compare correctness, frame pacing, and memory use with H.264 and HEVC (including 10-bit where available).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.