Open Bug 1642854 (hdr-video-linux) Opened 5 years ago Updated 31 minutes ago

HDR video support for Linux

Categories

(Core :: Audio/Video: Playback, enhancement)

76 Branch
Desktop
Linux
enhancement

Tracking

()

UNCONFIRMED

People

(Reporter: romulasry, Assigned: stransky)

References

(Depends on 14 open bugs, Blocks 1 open bug)

Details

Attachments

(5 obsolete files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0

Steps to reproduce:

Go to https://www.youtube.com/channel/UCve7_yAZHFNipzeAGBI5t9g/ and view a video on Linux.

Actual results:

VIdeos were in SDR

Expected results:

Been in HDR

Depends on: 1576020
Hardware: Unspecified → Desktop

(In reply to romulasry from comment #0)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0

Steps to reproduce:

Go to https://www.youtube.com/channel/UCve7_yAZHFNipzeAGBI5t9g/ and view a video on Linux.

Actual results:

VIdeos were in SDR

Expected results:

Been in HDR

OS: Unspecified → Linux

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core
Alias: hdr-video-linux
No longer depends on: 1576020
Summary: HDR Linux support for video → HDR video support for Linux

To have a roadmap here let's point out some tasks we need to finish to have HDR support on Linux:

  • Extend existing NativeLayerWayland() to support external images (that's how video frames are injected to renderer). MacOS variant is here: https://phabricator.services.mozilla.com/D84638
  • Extend DMABufSurfaces to hold HDR YUV surfaces (10-bit formats)
  • Extend DMABufSurfaces to hold HDR color data
  • Pass HDR data from FFmpeg decoder via DMABufSurfaces to MozContainer (or something else) and apply them during wl_surface_commit
  • Propagate Linux/HDR support so web playes can serve us HDR content (i.e. clips in bt.2020 color space with yuv420p10 bit planes)
  • Optionally update NativeLayerRootWayland to do local composition (by GL?) and send to Wayland compositor as less subsurfaces as possible.
Depends on: 1711461, 1743631
Attached patch hdr-wip-2.patch (obsolete) — Splinter Review

WIP v.2 patch, mostly contains unification for layer and multi buffer code.

Assignee: nobody → stransky
Attachment #9435843 - Attachment is obsolete: true
Attached file Bug 1642854 [Wayland] hdr patch (obsolete) —
Attachment #9435927 - Attachment description: WIP: Bug 1642854 [Wayland] hdr patch → Bug 1642854 [Wayland] hdr patch
Attachment #9435927 - Attachment is obsolete: true
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.7 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.8
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.8 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.9
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.9 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.10
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.10 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.11
See Also: → 1761927
Depends on: 1934130
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.11 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.12 - compositor crashes, divided scale
Depends on: 1934324
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.12 - compositor crashes, divided scale → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.13 - viewport scale

A new patch which uses viewport scale instead of buffer scale. It should fix all the "wrong buffer size" bugs when Firefox is moved between screens with different scales. We can also remove all the stuff we use to stop compositor rendering during scale changes at nsWindow.

Depends on: 1934497
Attachment #9438943 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.13 - viewport scale → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.14 - viewport scale
Depends on: 1935002
Depends on: 1938033
Depends on: 1938240
Attachment #9438943 - Attachment is obsolete: true
Attachment #9444846 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.15 → Bug 1642854 [WIP][Wayland] hdr patch v.16
Depends on: 1940037
Attachment #9444846 - Attachment is obsolete: true
Attachment #9445861 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.18 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.19

The patch here implements very experimental HDR playback. As it's missing correct wl_buffer format negotiation (Bug 1743631) and trows whatever it has to compositor it tends to crash due to unsupported modifiers. It needs further work on stabilization, layers rendering optimization and some layers fixes (D&D is broken due to missing layer screenshotter and there are rendering errors on scrolling).

I have tried 135beta1, 135beta2, trunk from yesterday morning - where fixes for wayland surfaces applied.

Everywhere notice a power consumption regression on idle. Same pages opened in 134 consumes 5 watts average on idle, 135 and trunk - 8 watts.
When playing videos on youtube the difference is not so big but still seems to be there - around 10 watts 134 and 11-12 135 and higher.

The FF processes in 135 and 134 seems to consume about the same CPU but with 135 version and higher compositor always runs at 10-13% CPU even when nothing is happening in FF. With 134 version at the same condition compositor is somewhere at the end of process list using abut 1%.

I understand that this is a very early WIP stage and such things is normal at this moment, just want to make early warning that there is something wrong in new wayland code related to the idle CPU/battery usage.

Use wayfire compositor based on wlroots 18.2.

(In reply to s.zharkoff from comment #12)

I have tried 135beta1, 135beta2, trunk from yesterday morning - where fixes for wayland surfaces applied.

Everywhere notice a power consumption regression on idle. Same pages opened in 134 consumes 5 watts average on idle, 135 and trunk - 8 watts.
When playing videos on youtube the difference is not so big but still seems to be there - around 10 watts 134 and 11-12 135 and higher.

The FF processes in 135 and 134 seems to consume about the same CPU but with 135 version and higher compositor always runs at 10-13% CPU even when nothing is happening in FF. With 134 version at the same condition compositor is somewhere at the end of process list using abut 1%.

I understand that this is a very early WIP stage and such things is normal at this moment, just want to make early warning that there is something wrong in new wayland code related to the idle CPU/battery usage.

Use wayfire compositor based on wlroots 18.2.

Do you mean with the WIP: Bug 1642854 [WIP][Wayland] hdr patch v.19 patch applied or without it?
Thanks.

Flags: needinfo?(s.zharkoff)

Do you mean with the WIP: Bug 1642854 [WIP][Wayland] hdr patch v.19 patch applied or without it?
Thanks.

It was before applying this patch. As I understand this patch will not be in 135 - but 135 is already broken. Is this patch supposed to fix the idle issue?

wlroots is not yet capable of HDR signalling, so I do not expect to get HDR on my display and just view regular SDR videos, so in fact the issue is not because of sdr but because of some changes how ff talks with compositor, and those changes already landed in 135. So I guess my coments are not for thos patch but for the whole big wayland rework being done to allow HDR to happen.

Flags: needinfo?(s.zharkoff)

(In reply to s.zharkoff from comment #14)

Do you mean with the WIP: Bug 1642854 [WIP][Wayland] hdr patch v.19 patch applied or without it?
Thanks.

It was before applying this patch. As I understand this patch will not be in 135 - but 135 is already broken. Is this patch supposed to fix the idle issue?

wlroots is not yet capable of HDR signalling, so I do not expect to get HDR on my display and just view regular SDR videos, so in fact the issue is not because of sdr but because of some changes how ff talks with compositor, and those changes already landed in 135. So I guess my coments are not for thos patch but for the whole big wayland rework being done to allow HDR to happen.

Okay, please file a new bug for it, I'll look at it. Please attach your about:support there.
Thanks.

Attachment #9445861 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.19 → Bug 1642854 [WIP][Wayland] hdr patch v.20
Attachment #9445861 - Attachment description: Bug 1642854 [WIP][Wayland] hdr patch v.20 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.20
Attachment #9445861 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.20 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.21

With the v.21 patch HDR is supposed to work. It includes dmabuf feedback and direct composition from external dmabuf surfaces (WebGL/VA-API). SW HDR rendering is not supported yet so you need VA-API decode of VP9 Profile 2 to decode P10 formats. It's under gfx.wayland.hdr pref.

There are still some bugs remaining - D&D doesn't work due to missing snapshotter and there are rendering artifacts like missing tiles during scrolling.

Depends on: 1941671

With the latest patch Firefox crashes for me upon starting a HDR video with this error:
GFX1-]: (kde) Wayland protocol error: zwp_linux_buffer_params_v1#857: error 7: importing the supplied dmabufs failed.

Attachment #9445861 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.21 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.22
Attachment #9445861 - Attachment description: WIP: Bug 1642854 [WIP][Wayland] hdr patch v.22 → WIP: Bug 1642854 [WIP][Wayland] hdr patch v.23
Depends on: 1942232

I'm also running into https://bugzilla.mozilla.org/show_bug.cgi?id=1732051 trying to test this. Once vsync is disabled, seeing the same error as Amine. Fedora 41 KDE, on an AMD card.

No longer blocks: 1942668
Depends on: 1942668
Depends on: 1945226

FTR., for fully correct playback we'll also need to implement the color representation protocol - which is getting ready as well.

It mainly needed to tell the compositor whether to use BT601, BT709 or BT2020 matrix coefficients (and limited or full range) in the YCbCr->RGB conversion. Without that compositors like Mutter and KMS drivers will usually default to BT709 while one wants BT2020 for HDR10. The visual impact is not too bad, but visible once you compare directly next to each other.

See also my MR for Gstreamer as example.

Hello Robert,
we use xx_color_manager_v4 to set surface colorspace:
https://searchfox.org/mozilla-central/rev/d1fbe983fb7720f0a4aca0e748817af11c1a374e/widget/gtk/WaylandSurface.cpp#1356
isn't that enough?
Thanks.

Flags: needinfo?(robert.mader)

Only for RGB content like games. For YCbCr/YUV content, which is what we're aiming for here, you additionally need the matrix coefficients and range (and in theory chroma location) as specified in ITU-T Rec. 273 - i.e. for HDR10 you want the PQ curve (XX_COLOR_MANAGER_V4_TRANSFER_FUNCTION_ST2084_PQ) and the BT2020 primaries (XX_COLOR_MANAGER_V4_PRIMARIES_BT2020) from the color protocol in combination with BT2020 coefficients/limited range (WP_COLOR_REPRESENTATION_V1_COEFFICIENTS_BT2020/WP_COLOR_REPRESENTATION_V1_RANGE_LIMITED) from the color representation protocol.

But the color representation protocol won't make it into Gnome 48 anyways (I only added some initial plumbing for the KMS properties here) and the error is not too bad. Once the protocol lands - likely in 49 - it should be an easy addition. I just wanted to give you a heads-up.

Some context:

Flags: needinfo?(robert.mader)
Depends on: 1946374
Depends on: 1946654

Hello,
Just tried latest nightly and now it run correctly on sway with gfx.webrender.compositor.force-enabled
but I got crashes after randomly navigation

Should I create new issues for that ?

(In reply to GreyXor from comment #25)

Hello,
Just tried latest nightly and now it run correctly on sway with gfx.webrender.compositor.force-enabled
but I got crashes after randomly navigation

Should I create new issues for that ?

Yes please, you can file as blocking this one.

Depends on: 1949362
Depends on: 1949363

Btw we still have some color management issues even in SDR mode, which really needs paying attention on:
https://bugzilla.mozilla.org/show_bug.cgi?id=1939259
https://bugzilla.mozilla.org/show_bug.cgi?id=1834978

Depends on: 1949726
Depends on: 1949739

Latest build : https://hg.mozilla.org/mozilla-central/rev/54c1adbab9fb0376a3a0521762af1e52070bb2a5
Cannot see video anymore

tested https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4
I can hear the sound, but the image remains black
with gfx.webrender.compositor.force-enabled

Depends on: 1949769

There a regression with VRR with compositor.force-enabled VRR is not working anymore.

I'm using vbltest to check the actual real refresh rate of my output.

Doing nothing: 32fps
Open nautilus and doing nothing: 32fps
Moving mouse anywhere: 60fps
Open firefox: 60fps
doing nothing in firefox: 60fps
open firefox (without compositor.fore-enabled): 32fps

If I disable compositor.force-enabled then vrr is working as expected again

Depends on: 1948007

(In reply to GreyXor from comment #29)

There a regression with VRR with compositor.force-enabled VRR is not working anymore.

I'm using vbltest to check the actual real refresh rate of my output.

Doing nothing: 32fps
Open nautilus and doing nothing: 32fps
Moving mouse anywhere: 60fps
Open firefox: 60fps
doing nothing in firefox: 60fps
open firefox (without compositor.fore-enabled): 32fps

If I disable compositor.force-enabled then vrr is working as expected again

That's possible, please file a new bug for it.
Thanks.

Attachment #9445861 - Attachment is obsolete: true
Depends on: 1950039
Depends on: 1950066
Depends on: 1950458
Depends on: 1950464
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: