Skip to content

Clarify color space handling across decoding, encoding, and rendering - #954

Open
dalecurtis wants to merge 1 commit into
mainfrom
color_pr
Open

dalecurtis wants to merge 1 commit into
mainfrom
color_pr

Conversation

@dalecurtis

@dalecurtis dalecurtis commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #940.

  • Define an internal color space on the underlying media resource (which may represent H.273 code points beyond the WebIDL enums), exposing unspecified or unrecognized components as null on VideoFrame.colorSpace.

  • In Output VideoFrames: use the decoder-emitted color space if decoding transforms the color space; otherwise select the most specified color space between [[active decoder config]].colorSpace and the bitstream color space (breaking ties in favor of [[active decoder config]].colorSpace), falling back to a codec-specific default or sRGB (RGB formats) / REC709 (YUV formats) only when not fully specified and the media pipeline requires a fully specified color space.

  • In Output EncodedVideoChunks: allow encoders to modify the input frame's internal color space matrix and range to satisfy codec requirements (assuming full-range rgb for RGB formats and limited-range bt709 otherwise when unspecified), and populate outputConfig.colorSpace from the encoder-emitted color space if specified or else the frame's internal color space after any modifications.

  • Remove the heuristic guessing allowance from Pick Color Space and specify fallback to sRGB (RGB formats) or REC709 (other formats) during rendering when the internal color space is not fully specified.


Preview | Diff

Fixes #940.

- Define an internal color space on the underlying media resource (which may represent H.273 code points beyond the WebIDL enums), exposing unspecified or unrecognized components as null on VideoFrame.colorSpace.

- In Output VideoFrames: use the decoder-emitted color space if decoding transforms the color space; otherwise select the most specified color space between [[active decoder config]].colorSpace and the bitstream color space (breaking ties in favor of [[active decoder config]].colorSpace), falling back to a codec-specific default or sRGB (RGB formats) / REC709 (other formats) only when not fully specified and the decoder requires a fully specified color space.

- In Output EncodedVideoChunks: allow encoders to modify the input frame's internal color space matrix and range to satisfy codec requirements (assuming full-range rgb for RGB formats and limited-range bt709 otherwise when unspecified), and populate outputConfig.colorSpace from the encoder-emitted color space if specified or else the frame's internal color space after any modifications.

- Remove the heuristic guessing allowance from Pick Color Space and specify fallback to sRGB (RGB formats) or REC709 (other formats) during rendering when the internal color space is not fully specified.

This branch has not been deployed

No deployments
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.

ColorSpace override is not well defined

1 participant