iina / iina

The modern video player for macOS.
https://iina.io
GNU General Public License v3.0
37.1k stars 2.53k forks source link

Map SDR -> HDR #4781

Open Rozzemak opened 5 months ago

Rozzemak commented 5 months ago

Well, turns out you can map SDR into HDR colorspace with amazing results. Works well on windows binaries of mpv. And only mpv.conf edits are needed:

mpv.conf:

profile=gpu-hq vo=gpu-next gpu-api=d3d11 gpu-context=d3d11 d3d11-output-format=rgb10_a2 d3d11-output-csp=pq tone-mapping=bt.2446a target-colorspace-hint=yes dither-depth=10 target-trc=pq target-prim=bt.2020 target-peak=750 #set this according to your display's max nits hdr-compute-peak=yes

[dynamically_enable_inverse-tone-mapping_for_SDR] profile-restore=copy profile-cond=get("video-params/colormatrix") ~= "bt.2020-ncl" and get("target-trc") == "pq" inverse-tone-mapping=yes


source: SpecialK discord - hdr section

image

Maybe integrate this into hdr toggle, so it will automatically enhance SDR videos ? Also needs default behavior option

Or just add another toggle like we have with HDR

Rozzemak commented 5 months ago

just a quick followup: I did some experimenting and there are currently unsupported options on macos in mpv config file that are needed:

image

Seems SDR->HDR tone mapping trickery needs vo=gpu-next renderer. Well, till then, this issue feature cannot be implemented I think. Unless there are alternative ways to do this directly in iina rather than mpv.

Using newest production build of mpv on brew.

low-batt commented 5 months ago

Your analysis is correct. Some mpv HDR related functionality such as the bt.2446a tone-mapping algorithm require use of gpu-next.

From the mpv Wiki post GPU Next vs GPU:

There is currently no support for the libmpv / render API in vo_gpu_next.

IINA uses the render API, so we are waiting for GPU Next to support the API. Last I heard the mpv project was struggling with some technical issues.

Evertt commented 5 months ago

I don't know exactly how to apply these options on my mac, but I have a question about them.

So I have the latest macbook pro with the micro-led backlight zones, so it can in theory go to perfect black values when the zones are just turned off. Which is great for HDR movies, but for some reason, when playing SDR movies, black isn't purely black, and I don't understand why. Would these options also allow IINA to display black in SDR movies as pure black with backlight turned off?

If not then I'll open a separate issue for that.

low-batt commented 5 months ago

This issue is about a different problem, expanding the dynamic range of a SDR video to HDR. Of course you would not want to apply the configuration shown because it does not work with IINA. And it does not address the problem of SDR displaying proper blacks.

For the record here is some information about using mpv options…

For audio/video support IINA uses a library from the mpv project. As a result many of the options listed in the mpv manual can be used with IINA. Select Settings… under the IINA menu and click on the Advanced tab. You will see an Additional mpv options setting. Individual mpv options can be set in that table. Another way to set mpv options is to check the Use config directory setting at the bottom of the panel and add a mpv.conf file to the ~/.config/mpv/ directory.

One set of mpv options that can not be used with IINA is those that have a note that indicates the option is only usable with gpu-next. Many of those have to do with new HDR related support.

On SDR blacks being too light…

In IINA's settings under the Audio/Video tab there is a setting Load ICC profile that is enabled by default. You might try disabling that setting and see if that makes a difference. Otherwise I suggest searching for advice on how to solve this with the mpv player.