HDR PQ to HLG

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

HDR PQ to HLG

Post by admin » Sun Jul 01, 2018 7:59 pm

I have the basic HDR PQ to HLG chain working fine. It's currently outputting the HLG to YV12 (because I had the code from DGHDRtoSDR) so it acts as a form of HDR->SDR conversion, showing the property people talk about of HLG looking OK when played as SDR 709. Honestly, though, I think that property is overblown because it seems some gamut mapping and tone mapping can still be beneficial for display on a SDR device and the result is clearly worse without those.

So I'm adding full depth YUV420P16 output (have to make a 10-bit 2020 RGB->YUV conversion) so that it can act as a pure PQ->HLG transcode, outputting 2020 HDR HLG in 16 bits. YV12 versus YUV420P16 output will be selectable via a parameter. Then everything over to CUDA and Bob's your uncle.

gonca
Distinguished Member
Distinguished Member
Posts: 607
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR PQ to HLG

Post by gonca » Sun Jul 01, 2018 8:15 pm

Looks like you have been busy,
and who is this Bob guy? ;)

User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR PQ to HLG

Post by admin » Sun Jul 01, 2018 8:30 pm

gonca wrote:
Sun Jul 01, 2018 8:15 pm
who is this Bob guy?
Bob's your uncle.

https://en.wikipedia.org/wiki/Bob%27s_your_uncle

User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR PQ to HLG

Post by admin » Mon Jul 02, 2018 10:16 am

Here's a first version for y'all. Feedback appreciated. It implements the process given in the BBC white paper with a fix to avoid divide by zero when applying gamma to RGB = 0,0,0. Why didn't they mention that? ;)

http://rationalqm.us/misc/DGPQtoHLG_1.0.rar

It runs at 96 fps on my i7 7700K 1080 Ti system for 3840x2160. That's a bit slower than DGHDRtoSDR because it outputs P16 so the GPU transfer load is increased. For these large frames the GPU transfer bandwidth is a much more significant factor than the kernel execution.

I decided not to have an option for outputting YV12 because it is so easy to add ConvertBits(8) in your script. And anyway, HDR->SDR using that process is a poor way to convert to SDR. Use DGHDRtoSDR for that.

gonca
Distinguished Member
Distinguished Member
Posts: 607
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR PQ to HLG

Post by gonca » Mon Jul 02, 2018 3:19 pm

Your plugin does a good job, when video is played back in either SDR or HDR
I guess that with this plugin people can make one single backup for playback on SDR or HDR devices
Well done

User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR PQ to HLG

Post by admin » Mon Jul 02, 2018 4:07 pm

Thanks for the positive assessment but I repeat again that it is suboptimal for HDR->SDR and I discourage that. The real purpose is to transcode from PQ to HLG for use in HLG displays and ecosystems.

PQ and HLG are two very different approaches. PQ is absolute with respect to brightness (display-referred) while HLG is relative (scene-referred). HLG is better suited for broadcasting and it can be argued that PQ has shot itself in the foot for the days when we have really bright displays (content will have to be remastered). HLG also does not require metadata. There will be competition between the two and we will see which prevails. In the meantime, it can't be bad to have a way to go PQ->HLG. Nobody seems to be asking for the reverse. ;)

gonca
Distinguished Member
Distinguished Member
Posts: 607
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR PQ to HLG

Post by gonca » Mon Jul 02, 2018 4:32 pm

Agreed, HDR PQ to HLG is a "poor mans version" of HDRtoSDR
HLG was developed for broadcasting with backward compatibility in mind, a single stream can be used by HDR or SDR displays.
For streaming, or local playback, HDR is the way to go

User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR PQ to HLG

Post by admin » Mon Jul 02, 2018 4:46 pm

gonca wrote:
Mon Jul 02, 2018 4:32 pm
HLG was developed for broadcasting with backward compatibility in mind, a single stream can be used by HDR or SDR displays.
OK, but only if you qualify the SDR as BT.2020 10-bit. When one says "SDR" one usually means BT.709 8-bit HD displays.

The BBC page best describes what the "backward compatibility" is all about. That things seem to look "OK" on a BT.709 8-bit display is a coincidence, not a design goal of the HLG system.

https://www.bbc.co.uk/rd/projects/high-dynamic-range

gonca
Distinguished Member
Distinguished Member
Posts: 607
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR PQ to HLG

Post by gonca » Mon Jul 02, 2018 4:57 pm

OK, but only if you qualify SDR here as BT.2020. When one says "SDR" one usually means BT.709 HD displays.
You are quite correct on this
The correct wording should have been
HLG was designed to be compatible with HDR and SDR displays

Didn't mean to imply that it displays HDR on HDR displays and SDR on SDR displays
It is a bandwidth reduced format for broadcasting
Either way
a proper hdr to sdr is still better quality

User avatar
admin
Site Admin
Posts: 4002
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR PQ to HLG

Post by admin » Mon Jul 02, 2018 9:44 pm

You know me, always a stickler for precision. You had it right, but I had to pick nits. Nits, get it? :twisted:

Post Reply