feat: Add explicit yuv-420-8-bit-video/yuv-420-8-bit-full target pixel formats#4022
feat: Add explicit yuv-420-8-bit-video/yuv-420-8-bit-full target pixel formats#4022wcandillon wants to merge 2 commits into
yuv-420-8-bit-video/yuv-420-8-bit-full target pixel formats#4022Conversation
…pixel formats The `'yuv'` target resolves to `kCVPixelFormatType_420YpCbCr8BiPlanarFullRange` on iOS. Full-range YUV IOSurfaces cannot be imported by some GPU video pipelines; for example WebGPU (Dawn) only supports video-range YUV formats for external textures (`kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange`). This adds two explicit `TargetVideoPixelFormat` values, reusing the naming of the existing `VideoPixelFormat` type: - `'yuv-420-8-bit-full'`: explicitly full-range (same as `'yuv'` today) - `'yuv-420-8-bit-video'`: explicitly video-range, required for zero-copy WebGPU/Dawn external texture import On Android both resolve to `YUV_420_888` (same as `'yuv'`), as the color range of the Camera output cannot be configured there. The `'yuv'` target is unchanged, so existing behavior is not affected. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@wcandillon is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
|
Are you sure Dawn only supports I think it can be good to have control over which format it should be, but the fact that changing from Technically that would make a big difference and could break assumptions based on Pixel Data. But I guess since the |
What
Adds two explicit values to
TargetVideoPixelFormat(used byFrameOutputOptions.pixelFormat), reusing the naming of the existingVideoPixelFormattype:'yuv-420-8-bit-full': explicitly YUV 4:2:0 8-bit full-range (kCVPixelFormatType_420YpCbCr8BiPlanarFullRangeon iOS, same as'yuv'today)'yuv-420-8-bit-video': explicitly YUV 4:2:0 8-bit video-range (kCVPixelFormatType_420YpCbCr8BiPlanarVideoRangeon iOS)The
'yuv'target is unchanged, so existing behavior is not affected.Why
The
'yuv'target resolves tokCVPixelFormatType_420YpCbCr8BiPlanarFullRange(420f) on iOS. Some GPU video pipelines can only import video-range YUV buffers. Concretely, WebGPU (Dawn) only maps video-range formats towgpu::TextureFormatfor external texture import on Metal; full-range420ffails validation with "Unsupported IOSurface format". SeeGetFormatEquivalentToIOSurfaceFormatin Dawn'sSharedTextureMemoryMTL.mm, which supportskCVPixelFormatType_420YpCbCr8BiPlanarVideoRange(mapped toR8BG8Biplanar420Unorm) but not the full-range variant.With this change, react-native-webgpu users can request
pixelFormat: 'yuv-420-8-bit-video'on aCameraFrameOutputand import the resultingFrames zero-copy as WebGPU external textures.Notes
YUV_420_888(same as'yuv'), as CameraX/Camera2 do not allow configuring the color range of the output. This is documented on the type and in the docs page.bun camera specs.🤖 Generated with Claude Code