MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / PickColorSpace

Function PickColorSpace

src/video_frame.ts:862–880  ·  view source on GitHub ↗
(
	overrideColorSpace: VideoColorSpaceInit | undefined,
	format: VideoPixelFormat | null,
)

Source from the content-addressed store, hash-verified

860};
861
862const PickColorSpace = (
863 overrideColorSpace: VideoColorSpaceInit | undefined,
864 format: VideoPixelFormat | null,
865): VideoColorSpace => {
866 // 1. If overrideColorSpace is provided, return a new VideoColorSpace constructed with overrideColorSpace.
867 if (overrideColorSpace) {
868 return new VideoColorSpacePolyfill(overrideColorSpace);
869 }
870 // 2. Otherwise, if [[format]] is an RGB format return a new instance of the sRGB Color Space.
871 if (format && isRGBFormat(format)) {
872 return new VideoColorSpacePolyfill(
873 { primaries: 'bt709', transfer: 'iec61966-2-1', matrix: 'rgb', fullRange: true },
874 );
875 }
876 // 3. Otherwise, return a new instance of the REC709 Color Space.
877 return new VideoColorSpacePolyfill(
878 { primaries: 'bt709', transfer: 'bt709', matrix: 'bt709', fullRange: false },
879 );
880};
881
882const InitializeFrameFromOtherFrame = (
883 init: VideoFrameInit,

Callers 1

constructorMethod · 0.85

Calls 1

isRGBFormatFunction · 0.85

Tested by

no test coverage detected