Skip to content

Conversation

@squelart
Copy link
Contributor

@squelart squelart commented Feb 25, 2025

8f3d426

Apply dynamic-range-limit to videos
https://bugs.webkit.org/show_bug.cgi?id=288248
rdar://145326880

Reviewed by Jer Noble.

HTMLMediaElement now forwards the `dynamic-range-limit` value
from RenderMedia to MediaPlayer/content to MediaPlayer/GPU to
MediaPlayerPrivate, with the implementation in ObjC derived
classes updating the video layer's preferred dynamic range as
needed.

* LayoutTests/media/video-dynamic-range-limit-expected.html: Added.
* LayoutTests/media/video-dynamic-range-limit.html: Added.
Minimal test to exercise the new code paths, but it doesn't verify
the actual rendering of HDR un/constrained videos.

* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dynamicRangeLimitDidChange):
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/MediaPlayer.h:
* Source/WebCore/platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::layersAreInitialized):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/ca/cocoa/PlatformDynamicRangeLimitCocoa.h: Added.
(WebCore::platformDynamicRangeLimitString):
* Source/WebCore/rendering/RenderMedia.cpp:
(WebCore::RenderMedia::styleDidChange):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
(WebKit::RemoteMediaPlayerProxy::setPlatformDynamicRangeLimit):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h:
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
(WebKit::MediaPlayerPrivateRemote::setPlatformDynamicRangeLimit):
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:

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

3db96ae

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@squelart squelart self-assigned this Feb 25, 2025
@squelart squelart added the Media Bugs related to the HTML 5 Media elements. label Feb 25, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this function just be:

    if (RefPtr player = m_player)
        player->setPlatformDynamicRangeLimit(platformDynamicRangeLimit);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but I was copying the style of the ones above. Happy to be inconsistent in this case. 😄

Copy link
Contributor

@shallawa shallawa Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we store this property here? I do not see it is used in HTMLMediaElement.

Copy link
Contributor Author

@squelart squelart Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good eyes!
I need it in the next patch where it will be combined with an external notification.
But I suppose I could move this to the other patch, just in case we change tactics there...
[edit: we're both wrong! See next comment.]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's used at line 7951, when a player is created after this call here, so that we can give the new player the correct DRLimit.

Copy link
Contributor

@shallawa shallawa Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function should be renamed something like setPlayerDynamicRangeLimit() or dynamicRangeLimitDidChange().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll go with dynamicRangeLimitDidChange(), it matches the one call from RenderMedia::styleDidChange().

@squelart squelart force-pushed the eng/apply-dynamic-range-limit-to-video-layers branch from f8d0c4d to 0a3f1be Compare February 25, 2025 23:43
@squelart squelart force-pushed the eng/apply-dynamic-range-limit-to-video-layers branch from 0a3f1be to 3db96ae Compare February 27, 2025 01:13
@squelart squelart added the merge-queue Applied to send a pull request to merge-queue label Feb 27, 2025
https://bugs.webkit.org/show_bug.cgi?id=288248
rdar://145326880

Reviewed by Jer Noble.

HTMLMediaElement now forwards the `dynamic-range-limit` value
from RenderMedia to MediaPlayer/content to MediaPlayer/GPU to
MediaPlayerPrivate, with the implementation in ObjC derived
classes updating the video layer's preferred dynamic range as
needed.

* LayoutTests/media/video-dynamic-range-limit-expected.html: Added.
* LayoutTests/media/video-dynamic-range-limit.html: Added.
Minimal test to exercise the new code paths, but it doesn't verify
the actual rendering of HDR un/constrained videos.

* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dynamicRangeLimitDidChange):
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/MediaPlayer.h:
* Source/WebCore/platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::ensureLayer):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::layersAreInitialized):
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::setPlatformDynamicRangeLimit):
* Source/WebCore/platform/graphics/ca/cocoa/PlatformDynamicRangeLimitCocoa.h: Added.
(WebCore::platformDynamicRangeLimitString):
* Source/WebCore/rendering/RenderMedia.cpp:
(WebCore::RenderMedia::styleDidChange):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::prepareForPlayback):
(WebKit::RemoteMediaPlayerProxy::setPlatformDynamicRangeLimit):
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h:
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in:
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::prepareForPlayback):
(WebKit::MediaPlayerPrivateRemote::setPlatformDynamicRangeLimit):
* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:

Canonical link: https://commits.webkit.org/291217@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/apply-dynamic-range-limit-to-video-layers branch from 3db96ae to 8f3d426 Compare February 27, 2025 13:13
@webkit-commit-queue
Copy link
Collaborator

Committed 291217@main (8f3d426): https://commits.webkit.org/291217@main

Reviewed commits have been landed. Closing PR #41266 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 8f3d426 into WebKit:main Feb 27, 2025
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Media Bugs related to the HTML 5 Media elements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants