Aleksoid1978 / VideoRenderer

Внешний видео-рендерер
GNU General Public License v3.0
1.03k stars 115 forks source link

HDR/SDR display color mode switching BT.2020/709 #57

Closed Tronic closed 2 years ago

Tronic commented 2 years ago

I am running my desktop in HDR BT.2020 at all times, on LG OLED TV. When starting up the video player with SDR content, it switches the desktop to HDR BT.709 (i.e. sRGB primaries) instead, giving washed out colors in the video and on the desktop and other players such as Youtube. I notice that BT.2020 is enabled again once MPC-BE is closed, making Youtube's SDR content and all desktop graphics display more vibrant again. The mode switching also causes the screen to go blank for a while, which is annoying. I note that the resolution, Hz or HDR aren't being switched, only the color space.

When a HDR movie is opened in MPC-BE, no mode switching occurs, and it stays in HDR BT.2020 as is expected. The screen does not blank out when opening or closing the player.

I am aware that SDR formats, JPEG images etc. are supposed to be displayed in BT.709 by the standards but since this color space is very limited, it fails to display natural colors in any decent manner, and it would seem that most (digital) cameras do actually use BT.2020 primaries even if the material is then marked as BT.709, and uncalibrated "natural gamut" displays / TVs for a long time have used something wider than sRGB anyway. Thus, in general I find that SDR is much better watched in BT.2020 although it goes against the spec. Only in rare cases this produces annoyingly over-saturated image if the source material is already very saturated up to clipping.

How I'd expect it to work

There should be an option to treat SDR material as having BT.2020 primaries. An option, because there are people who prefer standards compliance. MadVR has such an option.

Ideally the renderer would also always use an HDR 10-bit (or 16 bit float) surface for display and convert SDR video into HDR10 as MadVR does. This gives more fidelity in processing and avoids Windows doing the conversion as happens with 8-bit SDR video surfaces. Such a renderer could add quantization noise in 10 bits to help hide the 8 bit quantization, and also allows precise control of color conversion.

Aleksoid1978 commented 2 years ago

If you don't need HDR on/off switching - disable it in MPC VR options: Auto display HDR On/Off -> not used.

About convert SDR to HDR10 - it's not supported and there will be no such functionality.

Tronic commented 2 years ago

I confirm that disabling that setting got rid of the problems on this setup, now SDR plays in 8 bit (which is suboptimal) but with BT.2020 primaries. Thanks!

Tronic commented 2 years ago

Some clarification on why I think that SDR playback of SDR content may be suboptimal, other than simply because it has more apparent quantization artifacts with 8-bit YUV and 8-bit RGB mixed:

I notice with many SDR movies that conversion from YUV to RGB commonly yields values ranging from negative to 1.6, instead of the expected RGB range [0, 1] (rounding errors would not extend much past that). Presumably the YUV mastering has preserved highly saturated colors even though not supported by SDR RGB without clipping. If that is the case, then clipping to 1.0 makes the color less luminous, less saturated and of a different hue than intended.

As an example YUV 170/240/16 yields RGB 0.00/0.88/1.58, which is supposedly a bright blue color but after clipping it turns into cyan #00E1FF (i.e. YUV 154/174/27). If I am not mistaken, the correct hue/saturation in sRGB, only less luminous, would be #008AFF (i.e. YUV 111/200/59).

I would like to try this on a proper HDR display to see if it really works or whether clipping the values is better, but my quickly hacked testing code is in Python and I haven't found any reasonable way to spawn HDR windows or to encode HDR video from there.