Skip to content

feat(android): decoded frames take the stream's color space where the config has none - #12

Merged
andreialecu merged 1 commit into
mainfrom
feat/android-stream-color-space
Nov 26, 2026
Merged

andreialecu merged 1 commit into
mainfrom
feat/android-stream-color-space

Conversation

@andreialecu

Copy link
Copy Markdown
Owner

Stacked on #11 (it needs react-native-webgpu 0.26.0 to build and test). Retarget to main once #11 is merged.

What

A VideoDecoder configured without a colorSpace (used without Mediabunny, which passes the track's) gave its frames BT.709 limited range, whatever the stream said. frame.nativeBufferColorSpace then passed that to WebGPU, so a BT.601 or full-range stream was read with the wrong matrix or range on Android.

  • Android: the decoder reads the color aspects of its output format (color-standard, color-transfer, color-range: the stream's VUI) when the format changes, and sends them with each frame (NativeDecodedFrame.colorSpace, new and optional in the Nitro spec).
  • JS: the frame's colorSpace is the config's members, and for those the config leaves out, the stream's, as WebCodecs has it. BT.709 still fills what neither says. A config with a full colorSpace (Mediabunny's case) behaves as before.
  • iOS: unchanged, still the config's (colorSpace: nil from the decoder).

Tests

Written test first: the new e2e test, "gives decoded frames the stream's color space when the config has none (Android)", decodes a BT.601 (smpte170m), full-range H.264 clip.

  • With no colorSpace in the config, it expects smpte170m / full range.
  • With only matrix: "bt709" in the config, it expects the config's matrix and the stream's other members.

The test failed before the change (every member came out BT.709, limited range) and passes after.

  • Android emulator (API 35): the whole e2e suite passes, 60/60.
  • tsc, lint and unit tests (70/70) are clean.
  • Not built or run on iOS here. The Swift change is the one-argument call to the regenerated initializer.

@andreialecu
andreialecu changed the base branch from chore/drop-upstream-patches to main November 26, 2026 09:23
… config has none

A VideoDecoder configured without a colorSpace (used without Mediabunny)
gave its frames BT.709 limited range, whatever the stream said. The Android
decoder now reads the color aspects of its output format (the stream's VUI)
and sends them with each frame; the config's members win over them, as in
WebCodecs, and BT.709 fills what neither says. iOS still takes the config's.

The new e2e test decodes a BT.601 full-range H.264 clip without a colorSpace,
then with only a matrix in the config.
@andreialecu
andreialecu force-pushed the feat/android-stream-color-space branch from b6de3b2 to 68f8e5b Compare November 26, 2026 09:24
@andreialecu
andreialecu merged commit 495663e into main Nov 26, 2026
3 of 4 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant