HDR -> SDR conversion

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
DAE avatar
dmcs
Posts: 36
Joined: Sat Oct 21, 2017 9:40 pm

Re: HDR -> SDR tonemapping

Post by dmcs »

admin wrote:
Mon Jul 09, 2018 12:32 pm
@dmcs

Is this sample known to be Dolby Vision?
I'm not sure what you meant. m2ts has Dolby Vision metadata. mkv sample file doesn't.
Here's the full mediainfo of the m2ts file.
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Yes, I meant the m2ts. Thank you.
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Another cause of blockiness! I apply tonemapping individually to R, G, and B. This causes hue shifts depending on how the individual components are mapped. I have to apply it to the lightness L. So I am going to redesign everything to work in CIELAB space and apply tonemapping to the L of darks and lights to bring them into range of 709. If there are any out-of-gamut colors left then I'll decide what to do with them. If they are sparse I can just clip them. If not, maybe desaturate them. We'll see.

Finally thinking I might be understanding things. :lol:
DAE avatar
dmcs
Posts: 36
Joined: Sat Oct 21, 2017 9:40 pm

Re: HDR -> SDR tonemapping

Post by dmcs »

:salute: :salute:
DAE avatar
Narkyy
Posts: 51
Joined: Thu May 25, 2017 11:51 pm

Re: HDR -> SDR tonemapping

Post by Narkyy »

That would cause issues like this as well right? Not just in highlights

Image

Thank you for the hard work :hat:
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

You're welcome. But please, whenever you say "issues like this" don't assume we know what you are talking about. Tell it in words too. I look at your last image and think "umm, OK, what issue?". Context is completely lacking.

I'll try to guess. You are thinking there are hue shifts there leading to a blocking effect. Hard to say without the source. But, yes, it can happen to any RGB color if the individual channels get different scalings from the tonemapping.
DAE avatar
Narkyy
Posts: 51
Joined: Thu May 25, 2017 11:51 pm

Re: HDR -> SDR tonemapping

Post by Narkyy »

Yes sorry, there's mostly visible blocking around vivid/deep colors.
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Got it, thanks. Keep that sample, I'm going to ask you for it later. ;)
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Ha, I don't even have to go to CIELAB and back (which is expensive). I can do it directly in linear RGB space. Find the max of R, G, and B. Then tonemap that max one and apply the resulting scaling to all three. It's also faster than tonemapping all three individually, although for CUDA the actual kernel time is small compared to the frame transfer time, so it's a moot point.
User avatar
gonca
Curly Approved/Moose Approved
Posts: 970
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR -> SDR tonemapping

Post by gonca »

Sounds like you are just flying thru it now
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

It's working in my head. :lol:

Actually, I tested that one frame by just multiplying the RGB by 0.2 for the whole frame (because the largest RGB component is ~5.0) and the bright area looks great with no blocking or hue shift and more detail than madVR. So when I put the proper nonlinear function in place everything should look great. However, many a drop is spilt twixt cup and mouth. Or:

But, Mousie, thou art no thy lane,
In proving foresight may be vain;
The best laid schemes o' Mice an' Men,
Gang aft agley,
An' lea'e us nought but grief an' pain,
For promis'd joy!

-- "To A Mouse" by Robert Burns
User avatar
gonca
Curly Approved/Moose Approved
Posts: 970
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR -> SDR tonemapping

Post by gonca »

So, what you are so eloquently saying is that poop happens
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Or, maybe, don't count the chickens before they hatch.
DAE avatar
Beta
Posts: 10
Joined: Tue Jul 10, 2018 7:54 am

Re: HDR -> SDR tonemapping

Post by Beta »

Hi guys!

Is anyone here who can help to me fix this issue?
The source is HEVC
Thank You!

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

Re: HDR -> SDR tonemapping

Post by admin »

Looks like an AVSPMOD issue (AVSPMOD not using Avisynth+?). Try to open your script in VirtualDub2 and report the result. Note that these filters require Avisynth+.
DAE avatar
Beta
Posts: 10
Joined: Tue Jul 10, 2018 7:54 am

Re: HDR -> SDR tonemapping

Post by Beta »

admin wrote:
Tue Jul 10, 2018 10:08 am
Looks like an AVSPMOD issue (AVSPMOD not using Avisynth+?). Try to open your script in VirtualDub2 and report the result. Note that these filters require Avisynth+.
Thank You!!

I forgot that avisynth+ has two versions!!

We need for this:

https://github.com/pinterf/AviSynthPlus/releases

Now its all fine!!

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

Re: HDR -> SDR tonemapping

Post by admin »

Following is my latest result for mobius applied to the lightness rather than individual color channels (frame 2467 of the sample). Specifically, using this script:

dghdrtosdr(light=200,tm="mobius",trans=0.3,peak=2.1)

Even at fairly bright light=200 there is better detail than in the madVR result, and at the same time there is no severe artifacting or hue shifting. I'm pretty happy with this. One interesting thing is that as you raise the peak past 2.1 more strong whites coming in causes the compression to increase and hue changes start to appear. I don't see a need for higher peaks but I will investigate if it is possible to include them without hue shifts, possibly by going to a more constant hue color space like ICtCp.

https://www.dolby.com/us/en/technologie ... -paper.pdf

What do y'all think of this result? If you like it I'll make a release.

latest.jpg
User avatar
gonca
Curly Approved/Moose Approved
Posts: 970
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR -> SDR tonemapping

Post by gonca »

+1
Like
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Surely you count for more than 1? ;)

I tested it on the previous problematic stream (the one with the heater bars that disappeared). The bars remain intact with all light levels. I also tried it on the The Great Wall scene with the riders kicking up dust in the sun and it gives way better detail in the clouds to the left of the riders than anything before. So it's looking good. I have one little thing to fix up and then I'll give a release. Still 110 fps with my i7-7700K + 1080 Ti.
User avatar
gonca
Curly Approved/Moose Approved
Posts: 970
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR -> SDR tonemapping

Post by gonca »

"The color contouring" issue seems to be gone, which was the problem so it looks good
Me, I am just 1
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

Beta wrote:
Tue Jul 10, 2018 11:29 am
Thank You!!
You're welcome, Beta, and welcome to the forum! Look out for the next release, it will handle highlights way better.
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

gonca wrote:
Tue Jul 10, 2018 3:33 pm
Me, I am just 1
I count you double. Get over it. :twisted:
User avatar
admin
Site Admin
Posts: 4450
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR tonemapping

Post by admin »

OK, I fixed the last little wrinkle and all the previous streams look great, IMHO.

Now, as things are looking so good with mobius, and as mobius has simple and easy-to-understand parameters, I want to ditch hable. Hable has a boatload of non-intuitive parameters and I never did figure out how to set it up right. So I give y'all an opportunity to object before I remove it. If you can make a strong case for it maybe I'll leave it there. I'm going to decide later tonight.

Another thing I noticed (and which is described in the literature) is that the approach I have taken can produce highly saturated colors that can sometimes look like too much. The sat parameter is there so you can desaturate the result. My question is should I leave the default sat at 1.0, or reduce it to (say) 0.8?
User avatar
gonca
Curly Approved/Moose Approved
Posts: 970
Joined: Sun Apr 08, 2012 6:12 pm

Re: HDR -> SDR tonemapping

Post by gonca »

I would say, go for one approach and ditch Hable
The saturation thingy, drop it to 0.8 and then adjust the default, if needed, in the future based on feedback
DAE avatar
Narkyy
Posts: 51
Joined: Thu May 25, 2017 11:51 pm

Re: HDR -> SDR tonemapping

Post by Narkyy »

Ideally saturation should only be adjusted for around highlights that cause these very saturated colors, as overall the default saturation is good.
I don't think anyone cares for Hable anymore :salute:
Post Reply