Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5bc2af81b6e52dc80eb98505f7346066130d7c00
      
https://github.com/WebKit/WebKit/commit/5bc2af81b6e52dc80eb98505f7346066130d7c00
  Author: Youenn Fablet <[email protected]>
  Date:   2026-06-10 (Wed, 10 Jun 2026)

  Changed paths:
    A LayoutTests/http/tests/webcodecs/av1-sdr-expected.txt
    A LayoutTests/http/tests/webcodecs/av1-sdr.bin
    A LayoutTests/http/tests/webcodecs/av1-sdr.html
    M LayoutTests/http/tests/webcodecs/vp9-hdr-expected.txt
    M LayoutTests/http/tests/webcodecs/vp9-hdr.html
    M LayoutTests/platform/glib/TestExpectations
    M Source/WebCore/platform/graphics/AV1Utilities.cpp
    M Source/WebCore/platform/graphics/AV1Utilities.h
    M Source/WebCore/platform/graphics/PlatformVideoColorSpace.cpp
    M Source/WebCore/platform/graphics/PlatformVideoColorSpace.h
    M Source/WebCore/platform/graphics/VP9Utilities.cpp
    M Source/WebCore/platform/graphics/VP9Utilities.h
    M Source/WebCore/platform/graphics/cocoa/CMUtilities.mm
    M Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h
    M Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm
    M Source/WebCore/platform/libwebrtc/LibWebRTCVPXVideoDecoder.cpp
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoder.h
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoder.mm
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBAV1.h
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBAV1.mm
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBVP9.h
    M Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBVP9.mm
    M Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h
    M Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.messages.in
    M Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm
    M Source/WebKit/WebProcess/GPU/media/RemoteVideoCodecFactory.cpp
    M Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.cpp
    M Source/WebKit/WebProcess/GPU/webrtc/LibWebRTCCodecs.h

  Log Message:
  -----------
  [WebCodecs] Add support for overriding color space for HW video decoders
rdar://178717498
https://bugs.webkit.org/show_bug.cgi?id=316301

Reviewed by Jean-Yves Avenard.

The WebCodecs spec says VideoDecoderConfig.colorSpace takes precedence over 
in-band color signaling, but WebKit was ignoring it for VP9 and AV1.
The bitstream's primaries/transfer/matrix/range surfaced unchanged on the 
decoded VideoFrame — leaving JS no way to retag e.g. a stream signaling BT.2020 
SDR transfer as PQ for HDR rendering.
We plumb the optional PlatformVideoColorSpace from the WebCodecs config all the 
way to the decoder for both SW and HW paths.

For HW path, RemoteVideoCodecFactory takes config.colorSpace, LibWebRTCCodecs 
stores it on Decoder.
The LibWebRTCCodecsProxy CreateDecoder IPC message carries it to the GPU 
process.
The proxy hands it to WebRTCVideoDecoder::create, which forwards it to 
WebRTCVideoDecoderVTBVP9 / WebRTCVideoDecoderVTBAV1 constructors.
Each decoder applies the override when building the CMVideoFormatDescription so 
the resulting CVPixelBuffer carries the overridden color tags.

For SW, we update LibWebRTCVPXVideoDecoder to use a VideoInfo at parse time.
This allows to compute the color space override properly.

LibWebRTCVPXInternalVideoDecoder now reparses every frame to search for VPCC 
info, while in the past, it was only doing so if there was no config provided.
This is more semantically correct as parameters come from the bitstream.

createVP9FormatDescriptionFromRecord and createVideoInfoFromAV1Stream gain the 
optional override parameter.
createVideoInfoFromVPCodecConfigurationRecord is exposed in VP9UtilitiesCocoa.h 
so the libwebrtc path can build a VideoInfo from a parsed record directly.

Test: http/tests/webcodecs/av1-sdr.html
* LayoutTests/http/tests/webcodecs/av1-sdr-expected.txt: Added.
* LayoutTests/http/tests/webcodecs/av1-sdr.bin: Added.
* LayoutTests/http/tests/webcodecs/av1-sdr.html: Added.
* Source/WebCore/platform/graphics/AV1Utilities.cpp:
(WebCore::createVideoInfoFromAV1CodecConfigurationRecord):
(WebCore::createVideoInfoFromAV1Stream):
* Source/WebCore/platform/graphics/AV1Utilities.h:
* Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h:
* Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm:
(WebCore::createVideoInfoFromVPCodecConfigurationRecord):
(WebCore::createVP9FormatDescriptionFromRecord):
* Source/WebCore/platform/libwebrtc/LibWebRTCVPXVideoDecoder.cpp:
(WebCore::LibWebRTCVPXInternalVideoDecoder::decode):
(WebCore::LibWebRTCVPXInternalVideoDecoder::LibWebRTCVPXInternalVideoDecoder):
(WebCore::LibWebRTCVPXInternalVideoDecoder::Decoded):
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoder.h:
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoder.mm:
(WebCore::WebRTCVideoDecoder::create):
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBAV1.h:
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBAV1.mm:
(WebCore::computeAV1InputFormat):
(WebCore::WebRTCVideoDecoderVTBAV1::WebRTCVideoDecoderVTBAV1):
(WebCore::WebRTCVideoDecoderVTBAV1::decodeFrame):
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBVP9.h:
* Source/WebCore/platform/video-codecs/cocoa/WebRTCVideoDecoderVTBVP9.mm:
(WebCore::createVP9FormatDescriptionFromData):
(WebCore::WebRTCVideoDecoderVTBVP9::WebRTCVideoDecoderVTBVP9):
(WebCore::WebRTCVideoDecoderVTBVP9::decodeFrame):

Canonical link: https://commits.webkit.org/314887@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to