Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d51d4915931037416a1c6bebdf475d1d3df45379
https://github.com/WebKit/WebKit/commit/d51d4915931037416a1c6bebdf475d1d3df45379
Author: Jean-Yves Avenard <[email protected]>
Date: 2026-03-18 (Wed, 18 Mar 2026)
Changed paths:
M Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp
M Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h
M Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
M Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
M Source/WebCore/platform/graphics/PlatformVideoColorSpace.h
M
Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.cpp
M Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.h
M Source/WebCore/platform/graphics/cocoa/CMUtilities.mm
M Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.mm
M Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm
Log Message:
-----------
HDR content looks washed out with ToT MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=310174
rdar://172721079
Reviewed by Youenn Fablet.
Some of the video's colorspace information were lost
during the IPC serialisation from the CP to the GPUP.
The colorspace conversion relied on the colorSpaceFromFormatDescription
utility to convert information found in a CMFormatDescription into a
PlatformVideoColorSpace.
However, several enum values were left out.
Additionally, some of the soft-links used to access the CM or CV keys were
set as SOFT_LINK_CONSTANT_MAY_FAIL and they weren't actually loaded,
so the conversion of some cases were incorrect and failing due to nullptr
comparison.
PAL/WebCore: Fix soft-linking infrastructure for CoreMedia/CoreVideo color
space constants
Several kCMFormatDescription* constants are #defined in system headers as
aliases to kCVImageBuffer* equivalents.
We removed those in favour of CoreVideo constants so that we can use the more
elegant constant name
rather than get_##framework##_##variableName##Singleton()
Add API Test: Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm.
Manually verified on HDR screen that colours are sharp and vibrant.
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.cpp:
* Source/WebCore/PAL/pal/cf/CoreMediaSoftLink.h:
* Remove SOFT_LINK_CONSTANT entries for macro-alias constants:
kCMFormatDescriptionExtension_ColorPrimaries, ColorPrimaries_ITU_R_709_2,
ColorPrimaries_EBU_3213, ColorPrimaries_SMPTE_C, Extension_TransferFunction,
TransferFunction_ITU_R_709_2, Extension_YCbCrMatrix,
YCbCrMatrix_SMPTE_240M_1995, Extension_PixelAspectRatio,
Key_PixelAspectRatioHorizontalSpacing, Key_PixelAspectRatioVerticalSpacing
* Remove misplaced kCVImageBufferYCbCrMatrix_ITU_R_709_2 and
kCVImageBufferYCbCrMatrix_ITU_R_601_4 entries (CoreVideo symbols do not belong
in CoreMediaSoftLink)
* Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp:
* Source/WebCore/platform/cocoa/CoreVideoSoftLink.h:
* Add soft-link entries for kCVImageBufferPixelAspectRatioKey,
kCVImageBufferPixelAspectRatioHorizontalSpacingKey,
kCVImageBufferPixelAspectRatioVerticalSpacingKey
* Add soft-link entries for kCVImageBufferTransferFunction_UseGamma,
kCVImageBufferGammaLevelKey
* Add soft-link entries for kCVImageBufferColorPrimaries_P22,
kCVImageBufferColorPrimaries_DCI_P3, kCVImageBufferColorPrimaries_P3_D65,
kCVImageBufferColorPrimaries_ITU_R_2020
* Source/WebCore/platform/graphics/PlatformVideoColorSpace.h:
* Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.cpp:
(WebCore::colorSpaceFromFormatDescription):
* Replace all
PAL::kCMFormatDescriptionExtension_ColorPrimaries/TransferFunction/YCbCrMatrix
with the correct kCVImageBuffer*Key equivalents
in particular the missing bt20202 related components
* Replace PAL::kCMFormatDescriptionColorPrimaries_* comparisons with
kCVImageBufferColorPrimaries_*
* Replace PAL::kCMFormatDescriptionTransferFunction_ITU_R_709_2 with
kCVImageBufferTransferFunction_ITU_R_709_2
* Replace PAL::kCVImageBufferYCbCrMatrix_* (wrong namespace) with bare
kCVImageBufferYCbCrMatrix_*
* Add kCVImageBufferColorPrimaries_P22 → JedecP22Phosphors mapping
* Add kCVImageBufferTransferFunction_UseGamma handling: read
kCVImageBufferGammaLevelKey and map to Gamma22curve (< 2.5) or Gamma28curve (≥
2.5)
* Source/WebCore/platform/graphics/avfoundation/FormatDescriptionUtilities.h:
* Source/WebCore/platform/graphics/cocoa/CMUtilities.mm:
(WebCore::computeVideoFrameColorSpace):
* Fix PixelAspectRatio extension keys to use properly soft-linked
kCVImageBuffer* constants
* Add Gamma22curve/Gamma28curve → kCVImageBufferTransferFunction_UseGamma
to convertToCMTransferFunction
* In createFormatDescriptionFromTrackInfo and
attachColorSpaceToPixelBuffer, set kCVImageBufferGammaLevelKey to 2.2 or 2.8
when the transfer function is UseGamma
* In computeVideoFrameColorSpace, add missing mappings:
* Primaries: kCVImageBufferColorPrimaries_P22 → JedecP22Phosphors;
kCVImageBufferColorPrimaries_SMPTE_C → Smpte170m
* Transfer: kCMFormatDescriptionTransferFunction_ITU_R_2020 →
Bt2020_10bit; kCVImageBufferTransferFunction_UseGamma + gamma level →
Gamma22curve/Gamma28curve
* Matrix: kCVImageBufferYCbCrMatrix_ITU_R_601_4 → Bt470bg
* Source/WebCore/platform/graphics/cv/GraphicsContextGLCVCocoa.mm:
(WebCore::transferFunctionFromString):
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/CoreMediaUtilities.mm:
(TestWebKitAPI::makeColorSpaceFormatDescription):
(TestWebKitAPI::baselineColorSpace):
(TestWebKitAPI::TEST(CMUtilities, ColorPrimariesRoundTrip)):
(TestWebKitAPI::TEST(CMUtilities, TransferCharacteristicsRoundTrip)):
(TestWebKitAPI::TEST(CMUtilities, MatrixCoefficientsRoundTrip)):
Canonical link: https://commits.webkit.org/309502@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications