Repository navigation
Conversation
|
cc @mahkoh |
|
AIUI libplacebo assumes that the reference luminance is 203. That was the reason for doing the transformation. Has this changed? Or do you use some other method for telling libplacebo about the luminance to tonemap to? |
It does it only as the default for SDR content. libplacebo did not change, mpv now tells it the reference white.
Pass-through did not change. Hint mode One known limitation. Without |
|
The important consideration is this: Ignoring minimum luminances for a moment, if mpv receives either of the following descriptions
the values it stores in the pixel buffer it gives to the compositor should be exactly the same. IOW, the tone mapping operations should be identical. If mpv telling libplacebo the reference white ensures that, then I guess it's fine. |
That holds for SDR content. It does not hold for HDR content, and that is the intended change.
The two descriptions are only equivalent for a relative signal. PQ content and its metadata are absolute, and scaling the result after we tone mapped it gives a different picture than the one we made. #18857 is that case, HDR at 46 % with KDE's SDR brightness at 94. Additionally, we no longer lie about the capabilities of the monitor. KWin, for example, reports the HDR values from its calibration in nits. For my monitor that is 465 nits, as expected, and not the 307 nits that current master reports. |
If libplacebo hard codes 203 anywhere instead of using the reference white you pass in, then this patch is not correct. |
I don't consider this case particularly important, it's not really a "HDR". I can improve it separately, but for now anything < 203 is SDR and rendered at reference luminance. |
|
If apps start ignoring the reference luminance like this, I will have to fix it on the compositor side by not telling apps about the real reference luminance anymore. That would be incredibly stupid and annoying, but if apps can't be trusted to follow the absolute basics of the color management protocol, I can't see another choice. Maybe Apple wasn't so wrong with their "EDR" concept. While it's more limiting in what you can do for meaningful color management, it also helps prevent apps from pulling stunts like this. |
I don't know why you need to improve anything. The current code (without this PR) is the result of days of discussions and already works. |
set_mastering_luminance belongs to the set_mastering_display_primaries feature.
Both are optional and stay undefined unless they are set. A 0 is a set value, and version 1 of the protocol requires a set value to be above the minimum of the mastering luminance range.
So it matches mastering luminance which is also rounded.
Use effective reference white, instead of hardcoded one.
It tells if the params are made for the target device or are those of the source. The distinction is unfortunatelly needed, becasue Wayland has HDR10 reference white scaling, which we have to undo.
It tells if the params are made for the output or are those of the source, as for set_color. vo_dmabuf_wayland and vo_wlshm pass the params of the source through.
So that it can be made optional.
An SDR or linear signal was declared with 203 nits as its reference white, also where it peaks below that, as with --target-peak=100. By the protocol a reference white above the maximum needs the extended_target_volume feature, and Mutter raises a protocol error for it. The white of such a signal is at its peak.
The luminances of the preferred image description are converted to the scale of 203 nits and the surface declares 203 as its reference white. The compositor then shows all of it brighter or darker by the ratio of its own reference white to 203, which is the model of the protocol and stays the default. With the option the luminances of the output are used as they are, and the surface declares the reference white of the compositor, which shows it as it is. HDR content keeps its luminance. SDR content, the OSD and subtitles are at the reference white of the compositor in both cases. A signal of the source, as with vo_dmabuf_wayland or --target-colorspace-hint-mode=source, stays in the scale of 203 nits.
vo_gpu_next encodes HLG for the black and the peak of its target, while an image description without luminances stands for a display of 1000 nits with the reference white at 203. Declare the range of the signal with its reference white, as for PQ. HLG of the source keeps the defaults.
Two places take the target as HDR by its transfer function. scRGB ends at the reference white on a target that is not HDR, and inverse tone mapping takes the transfer function and the luminances of one that is. A Wayland compositor can prefer an SDR transfer function with a peak above the reference white for an HDR output, KWin does. That was hidden as long as such a transfer function is replaced by PQ.
With --wayland-respect-pq-scale an SDR or linear signal was declared with its reference white at the peak, which is where vo_gpu_next matches. An HDR output also shows such a signal above its reference white. Gamma 2.2 with the white at 400 nits and the peak at 1000 nits is the description that KWin prefers there. Report that through sdr_above_ref_luma and declare the reference white of the output for such a signal, capped at its peak. Note that I don't endorse using Gamma 2.2 transfer for HDR signals, but this is what Wayland forces on us, and undoing it causes more pain that it's worth.
The peak of an SDR target is set to the reference white once the system reports one. Windows needs that, it shows the peak of an SDR swapchain at its SDR white level. A Wayland compositor shows an SDR signal with the white where the image description has it, so --target-trc=gamma2.2 on an HDR output can go up to the peak of the output, as it did before the reference white was reported there.
Now that we plug the reference white into the SDR transfers, we can try to match the descriptors directly. For better or for worse. It's on Wayland then to provide sane luminance ranges. They say everything is relative, but the HDR10 metadata is not. We just follow what the compositor says, let's see how it ends up.
With the hint off the hint mode has no meaning, the frame is rendered for the target in every mode.
It tells if the signal is made for the target device or is the one of the source, as for set_color. Wayland anchors a signal of the source at its own reference white, so the one of the output doesn't apply to it.
The compositor anchors a signal of the source at its own reference white, so the one of the output doesn't apply to what the renderer draws into it. With --wayland-respect-pq-scale the OSD and subtitles on a passed through HDR video were off by the ratio of the two.
It was not ignored, but I see the point about the default, so I changed the PR.
The option is there because a movie carries no reference white. There is no metadata, and the protocol itself calls the 203 for PQ "a protocol addition" that is "not part of ST 2084 or BT.2100". With the scaling a movie is shown as mastered only while the slider sits at exactly 203. Whoever lowers it for the desktop, as in #18857, dims every movie with it. Some users want that and some don't, it is a choice. I don't think it's on compositor to impose such choice and force users to manually move slider to some magic position to have their movies rendered correctly. At the same time 203 is often to bright for SDR/UI content, so it's unrealistic to make users use it by default.
That was about your 80 / 160 case. With the default back in the scale of 203 it works as on master. Only the option needs help from libplacebo there, and I have that as a patch.
It stays the default. What the PR still changes by default is that the preferred transfer function is used as it is, so KWin gets its extended range gamma 2.2 instead of forced PQ, with the same luminances as before. The rest are fixes, like a reference white above the maximum of an SDR signal, which Mutter throws protocol error. To show what the option is for, take my display. KWin's preferred description has a peak of 465 and a reference white of 265, and 465 is what the panel really reaches. The table shows where things land on screen, in nits.
It's generally not expected to ignore PQ curve and many purist may prefer movies to be rendered as mastered. |
f2253b8 to
1f3d7bc
Compare
No description provided.