mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.04k stars 2.88k forks source link

vo=gpu_next HDR passthrough settings #10158

Closed Obegg closed 2 years ago

Obegg commented 2 years ago

libplacebo last PR d3d11/swapchain: add support for configuring swap chain color space Is supposed to trigger the HDR to the TV using gpu-api=d3d11, but it's only working with gpu-api=vulkan

I have a few questions. 1) Why isn't HDR triggered when using gpu-api=d3d11? (MPV version is mpv 0.34.0-287-g90d291dce7 and built on Tue May 3 01:22:54 UTC 2022, also Initialized libplacebo v4.204.0 (API v204)) 2) Should I enable HDR mode in Windows before opening MPV? (It may be more accurate? Buggy?) 3) Should I use any settings for HDR, because till now I used the following:

[HDR]
profile-cond=p["video-params/primaries"] == "bt.2020"
profile-restore=copy
target-trc=pq
target-prim=bt.2020
tone-mapping=bt.2390
d3d11-output-csp=pq
gamut-mapping-mode=auto
jeeb commented 2 years ago

So, after my MR got merged in libplacebo, --vo=gpu-next --target-colorspace-hint=yes should now work with d3d11.

With HDR content the swap chain should be flagged as HDR, and with SDR content the swap chain should get flagged as SDR. d3d11-output-csp and d3d11-output-format will effectively get overridden by libplacebo after this. You can think of swap chain as the window, effectively. As long as this happens, everything is as expected.

Now, then regarding what people tend to often expect, which is display output reconfiguration. About a year or two ago MS started making sure that at least with d3d the swap chain color space would not affect how the display output is configured. The only way a user is supposed to configure it, is through the Windows settings application. Before that various driver vendors did reconfiguration based on fullscreen window's swap chain configuration, and thus if people expected that to happen - it would no longer do so as they updated their drivers. MS also does not provide official API to switch the configuration, so the application has no official way of requesting a reconfiguration. If you want HDR, you should always have your display configured as HDR through Windows settings. This issue with users' wishes not matching MS's wishes has also popped elsewhere, such as madVR's issue tracker.

This does not seem to affect other graphics APIs, such as Vulkan, though. MS seems to have much less say on what the driver vendors can or cannot do on that side. So if you do the same, but with --gpu-api=vulkan - at least on nvidia you will get the display configuration switching to HDR with HDR content.

I hope this clarifies what the current expectation is with regards to HDR swap chains on Windows.

jeeb commented 2 years ago

As for vo=gpu, in that case just d3d11-output-csp=pq will trigger the swap chain color space, and the default behavior (without manually setting any options) follows the configuration of the display the window was created on, irrespective of the input content (since I did not have a convenient location to get that information from during initialization when initially implementing the output color space setting).

In other words, if your display was set to HDR, it would get configured as HDR. If it was set to SDR, it would get configured as SDR.

For gpu-next, now that the d3d11 MR is merged, my plan is to add an auto option to target-colorspace-hint. This would basically enable automagic behavior based on each graphics API/OS. In case of d3d11 it would do the decision based on the display output configuration. If content is HDR and the display is configured as HDR - let the color space hint through. Otherwise tell it to keep to SDR. Of course you would still be able to force it, but since this is how MS wants applications to behave and there are no generic APIs to cause display output reconfiguration, this IMHO should be the default behavior.

Obegg commented 2 years ago

Great explanation! Love it! Wow! I really appreciate it! I really don't want to close this "issue" because of this explanation, I want more people (if and when) to know this, so I don't know if I should close it or not.

So on Windows, which one should I use? --vo=gpu-next --target-colorspace-hint=yes --gpu-api=vulkan Or --vo=gpu-next --target-colorspace-hint=yes --gpu-api=d3d11 and set the display to HDR? (which is more steps) I understand that Vulkan does set the display to HDR when needed but I have no idea if the video will be displayed better (color accuracy and etc) or worse compared to d3d11, which is the native API for Windows. (Native usually means better optimized, but since Vulkan seems to trigger the HDR on the display that means Vulkan is the better choice?)

jeeb commented 2 years ago

The output of either graphics API should be the same. d3d11 just has better co-operation with other d3d11 based things, such as d3d11va hardware decoding.

Doofussy2 commented 2 years ago

Awwww, my very bad. Please accept my apologies. I re-read the above posts and discovered I missed a vital piece of information, target-colorspace-hint=yes. That appears to work as expected. Sometimes I need a slap around the head.

Dolby Vision is still far too bright, but that's a separate issue.

Feel free to delete my earlier rubbish.

Doofussy2 commented 2 years ago

And for the DV stuff, as it's read as bt.709, I added a target-peak value to my SDR auto profile. That appears to correct the over brightness issue.

jeeb commented 2 years ago

Awwww, my very bad. Please accept my apologies. I re-read the above posts and discovered I missed a vital piece of information, target-colorspace-hint=yes. That appears to work as expected. Sometimes I need a slap around the head.

To be honest during the working week it went like this:

  1. You see a person yelling vaguely that everything is broken.
  2. You check that things still work as you expect in the two cases that were recently changed with my libplacebo MR (SDR and HDR with hint passing enabled).
  3. You decide that your mental power isn't enough to start arguing, and ignore responding to the comments for now.

This is why it's important to list the specifics of things when you say something is not working. You may notice during that time such things that you have since noticed, as well as you give actual things - as opposed to just generic "everything's broken".

Dolby Vision is still far too bright, but that's a separate issue.

Feel free to delete my earlier rubbish.

You can yourself click the three dots on the top right of posts and select to hide them, I can at least do the same on my issue comments in glfw, where I do not have any special rights, so I would expect the same to work here as well.

Obegg commented 2 years ago

@jeeb can you please delete all of their messages here and lock the issue? they ruined the beauty of your explanation, I want to restore that beauty so other people will know it.

Doofussy2 commented 2 years ago

@jeeb can you please delete all of their messages here and lock the issue? they ruined the beauty of your explanation, I want to restore that beauty so other people will know it.

I deleted them. I'm very sorry.

For the record. My confusion was in thinking that it would be automated, and would be enabled by default. Not needing to manually apply the command. The documentation was unclear, and I assumed incorrectly.