Skip to content

feat: Support 10-bit YUV, and properly handle colorspaces (YCbCr transform matrix)#3710

Merged
wcandillon merged 3 commits intoShopify:mainfrom
mrousavy:fix/support-422-yuv
Feb 18, 2026
Merged

feat: Support 10-bit YUV, and properly handle colorspaces (YCbCr transform matrix)#3710
wcandillon merged 3 commits intoShopify:mainfrom
mrousavy:fix/support-422-yuv

Conversation

@mrousavy
Copy link
Contributor

@mrousavy mrousavy commented Feb 13, 2026

We had support for 10-bit YUV, but it rendered wrong colors (yellow/purple-ish pixels).

This PR fixes this by actually getting the color transform matrix from the buffer (which is stored as kCVImageBufferYCbCrMatrixKey), which tells us the Skia Color Space to use (SkYUVColorSpace);

  • Rec709 (full or limited)
  • Rec601 (limited) <- super rare
  • BT2020 8-bit (full or limited)
  • BT2020 10-bit (full or limited)
  • JPEG full <- rare
  • SMPTE240 (full or limited) <- super duper rare

This is now safe, since before we just kinda assumed colorspace based on format, now we actually know the transform function.

Before

YUV 4:2:0 8-bit YUV 4:2:0 10-bit YUV 4:2:2 10-bit
YUV 4:2:0 8-bit YUV 4:2:0 10-bit YUV 4:2:2 10-bit

After

YUV 4:2:0 8-bit YUV 4:2:0 10-bit YUV 4:2:2 10-bit
YUV 4:2:0 8-bit YUV 4:2:0 10-bit YUV 4:2:2 10-bit

@mrousavy mrousavy changed the title feat: Support YUV 4:2:2 feat: Support 10-bit YUV, and properly handle colorspaces (YCbCr transform matrix) Feb 13, 2026
@mrousavy mrousavy marked this pull request as ready for review February 13, 2026 14:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds proper support for 10-bit YUV video formats and implements correct colorspace handling by reading the YCbCr transform matrix from CVPixelBuffer metadata. Previously, the code made assumptions about colorspace based solely on pixel format, which resulted in incorrect colors (yellow/purple-ish pixels) for 10-bit YUV content.

Changes:

  • Refactored colorspace detection to read the actual YCbCr matrix from CVPixelBuffer attachments (kCVImageBufferYCbCrMatrixKey)
  • Added support for 422 and 444 chroma subsampling variants (8-bit and 10-bit)
  • Improved Metal pixel format detection with explicit format handling instead of heuristics
  • Enhanced validation and error messages for plane index bounds checking

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/skia/apple/SkiaCVPixelBufferUtils.h Updated imports from CoreMedia to CoreVideo, changed getColorspace to accept CVPixelBufferRef instead of OSType, added helper method signatures
packages/skia/apple/SkiaCVPixelBufferUtils.mm Implemented colorspace matrix reading from buffer metadata, added 422/444 format support, refactored Metal pixel format detection with explicit handling, improved validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@wcandillon wcandillon merged commit f143f3d into Shopify:main Feb 18, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants