INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: SDR to HDR (Inverse Tone Mapping)  (Read 3010 times)

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
SDR to HDR (Inverse Tone Mapping)
« on: May 28, 2023, 04:40:15 am »

My only other wish, is for SDR to HDR conversion to bypass whatever Windows 11 is doing when in full time HDR Mode.  Not that Win11 is doing a "bad" SDR --> HDR conversion but, I presume that JRVR would be better. 
Logged
JRiver CEO Elect

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10945
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #1 on: May 28, 2023, 05:01:12 am »

There is really no ambiguity when doing a naive SDR to HDR conversion, because you are not converting the image to HDR, you are just fitting the image into a larger box. There is a perfect answer to this task, and its not so hard to achieve it.
Logged
~ nevcairiel
~ Author of LAV Filters

bogdanbz

  • World Citizen
  • ***
  • Posts: 208
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #2 on: May 28, 2023, 01:04:57 pm »

Regarding the "SDR to HDR conversion that Windows is doing".

Windows is doing a sRGB color space with a sRGB gamma function conversion to BT2020 colorspace with ST2084 transfer function. Which means Windows considers the sRGB content to have the sRGB "gamma" function applied, and then maps it to ST2084 absolute luminance values, with the white in the sRGB content reaching the value you configure with the slider in the "Windows HD color settings", where the slider at zero means a sRGB white mapped to 80 nits.

Mapping the sRGB "gamma' to ST2084 is correct for PC content (SDR PC displays are supposed to be used in their sRGB mode for accurate display, which is not the same as a "2.2 gamma mode").

But this mapping will not give the expected results for video content, which is encoded with a 2.4 or 2.2 gamma function instead of the sRGB gamma. The end result of the Windows mapping is that lower luminance values in video content will appear brighter than they should be, giving a washed out appearance.
Logged

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #3 on: May 28, 2023, 04:32:41 pm »

There seems to be two main ways to do SDR-->HDR and the following is from Dolby on the approaches.  I presume that Windows is doing the first, but I'm more interested in the 2nd (Inverse DRT with White Point Adaptation).  I use this method in Resolved when combining 709 and LOG footage on a single HDR project and it works really well.

Quote
Up-mapping SDR Archive Content to HDR

There are two fundamentally different ways to approach this issue:

The accurate (mathematical) conversion from the SDR to HDR format is defined in the document “MovieLabs Best Practices for Mapping BT.709 Content to HDR10 for Consumer Distribution” https://www.movielabs.com/ngvideo/MovieLabs_Mapping_BT.709_to_HDR10_v1.0.pdf
This preserves the original look of the SDR image within HDR. This means that the resulting HDR watched on an HDR display should look identical to the original SDR watched on an SDR display.  However, it does not change the look of the image and therefore may not blend well with other native HDR content. Such conversions are also referred to as direct mapping conversions, a terminology used in the Ultra HD Forum Guidelines.
 
To perform an inverse tone-mapping of the SDR content to create an “HDR look”.  The Ultra HD Forum refers to this type of conversion as up-mapping. This is often the desired approach as it will enable SDR clips to more seamlessly blend into an HDR production, or in the case of a complete SDR archive production creating this “HDR look” is often the primary reason for performing the remastering.
Logged
JRiver CEO Elect

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #4 on: May 28, 2023, 04:50:34 pm »

If I'm reading some of the libplacebo notes correctly, looks like hassn has already implemented RTM.

Quote
haasn commented on Feb 19, 2022
This was added in libplacebo v4.192, using the BT.2446A curves (among some others)
Logged
JRiver CEO Elect

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10945
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #5 on: May 28, 2023, 05:13:01 pm »

Inverse tone mapping is not something JRVR will ever offer, because a simple one-size-fits-all value for something like that is never going to yield any reasonable results. Converting SDR to a reasonable HDR requires a proper mastering step, not setting some value and hoping it comes out ok.

Enabling "direct mapping" would be relatively easy in comparison, but its not something i'm looking to do right this time.
Logged
~ nevcairiel
~ Author of LAV Filters

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #6 on: May 28, 2023, 05:30:02 pm »

Fair enough, as I have no idea how well (or not) a general ITM approach would work for playback.  My only experience with ITM is in Resolve and it certainly works well there.  Also, if the "direct mapping" method is what Windows is doing, then adding it to JRVR probably not needed.
Logged
JRiver CEO Elect

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #7 on: May 29, 2023, 01:51:42 am »

OK... I could leave well enough alone!  So here is a test of Inverse Tone Mapping to take SDR to HDR10
- It's the 1min trailer clip from the FHD BD version of Avatar
- Remuxed it to MKV and called it "Avatar SDR.mkv" - this is the "control".
- I then took "Avatar SDR.mkv" into Resolve and rendered it out as HDR10 using their "Inverse DRT for SDR to HDR" and "White point adaptation".  It was also scaled to UHD resolution.  No grading was done.

(woops made a mistake - will post a new link shortly)

I'd be interested in what people think of the two versions when played back on an HDR display using JRVR.
Logged
JRiver CEO Elect

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #8 on: May 29, 2023, 02:32:18 am »

So there are three 1min files now in this folder - you will need to download them and play in MC not in a web browser.
- SDR - The control, just as it was off the BD
- HDR - Luminance Mapping : Inverse Tone Mapping with Luminance Mapping
- HDR - Saturation Preserving : Inverse Tone Mapping with Saturation Preservation

My first sample (which I removed) used Davinci Resolve's own also which would not be available to JRVR. 
Logged
JRiver CEO Elect

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #9 on: May 29, 2023, 06:02:34 pm »

I'd be interested in what people think of the two versions when played back on an HDR display using JRVR.

Anyone had a chance to have a look yet?
Logged
JRiver CEO Elect

bogdanbz

  • World Citizen
  • ***
  • Posts: 208
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #10 on: June 01, 2023, 02:19:41 am »

Inverse tone mapping is not something JRVR will ever offer, because a simple one-size-fits-all value for something like that is never going to yield any reasonable results. Converting SDR to a reasonable HDR requires a proper mastering step, not setting some value and hoping it comes out ok.

Enabling "direct mapping" would be relatively easy in comparison, but its not something i'm looking to do right this time.
My main issue with the SDR to HDR conversion is viewing SDR extras on UHD BluRays, to be honest.

I have Windows HDR turned off by default in Windows, and when I start playback of a UHD BluRay JRVR automatically turns Windows HDR mode on, which is great!

But when I start playback of a SDR extra on that BluRay from the BluRay menu, JRVR does not turn Windows HDR mode off, it stays on, and the Windows sRGB to HDR10 PQ conversion takes place as far as I can see.

Would it be possible to turn off Windows HDR when playback of a SDR extra starts? This would allow the TV display to switch to its SDR mode and the video content would be rendered just as it should, and without any conversion done by Windows as well.

@jmone, most research done on how to mix SDR and HDR content to look fine together is done by those in broadcast, as they have streams shot both ways. There's info in the UltraHD Forum Guidelines (https://ultrahdforum.org/guidelines/) - check the Indigo Book, there are conversion LUTs defined for such workflows - and in the various ITU reports (https://www.itu.int/pub/R-REP).

The conversion LUTs from the NBC Universal workflows are hosted on GitHub here.
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10945
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #11 on: June 01, 2023, 02:35:52 am »

I think it should actually attempt to do that right now, as it follows the stream metadata. But I don't believe I have tested with a Blu-ray.

I can also add direct mapping in the near future, as its basically just yet another brightness slider for the reference white (or get the desired level from windows, but being able to configure that for video is probably better). I forgot that what MS calls G22 is actually treated like sRGB.
Logged
~ nevcairiel
~ Author of LAV Filters

bogdanbz

  • World Citizen
  • ***
  • Posts: 208
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #12 on: June 01, 2023, 02:39:45 am »

It's indeed not switching Windows HDR mode off when watching a SDR extra on a UHD HDR BluRay.
Logged

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #13 on: June 01, 2023, 02:46:47 am »

Thanks - FWIW, I do mix both SDR and LOG captured footage to create combined HDR footage using Resolves "Inverse DRT for SDR to HDR conversion" which does not require a LUT.  I'm more in the ICT/OCT than the LUT camp for converting between colour spaces (thanks to Daria Fissoun, who literally wrong the manual on color mgt for Davinci). 

I'm not sure if you have had a chance to look at the 3 samples I linked a couple posts back, but that shows what the "Inverse DRT for SDR to HDR conversion" process can do (warts and all).

The focus on Tone and Gamut Mapping has always been on scaling down HDR material to work well on SDR Displays.  JRVR does a great job of this.  I think as more and more displays are HDR there will be a desire to expand legacy SDR content to (faux) HDR.  Just like we now scale lower resolution legacy material to (faux) UHD.
Logged
JRiver CEO Elect

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10945
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #14 on: June 01, 2023, 03:55:42 am »

I think as more and more displays are HDR there will be a desire to expand legacy SDR content to (faux) HDR.  Just like we now scale lower resolution legacy material to (faux) UHD.

But there is the rub - upscaling video, similar to upsampling audio, you don't really expect "new" high-frequency detail to be created when you upscale, rather just reproduce the original faithfully. The same could be said about creating new brightness levels that never existed. Is this a lamp thats supposed to have 10000 nits, or just a white piece of paper?

Maybe AI stuff can do that more reasonably in the future, but "naive" algorithms will always produce weirdness all around.
Logged
~ nevcairiel
~ Author of LAV Filters

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #15 on: June 01, 2023, 04:16:18 am »

All good points which is why I created the 1min samples for review.  I'd value your opinion of what you thought of them TBH - even if it was "I told you so, they are rubbish". 

Edit: FYI - the two re-encode examples took FHD SDR to UHD HDR P3D65 in 2020 - so upscaling res, gamut (well I limited gamut to P3), as well as SDR to HDR (well I limited to 1000nits).  I was trying to replicate what it might look like if done in a renderer that did all of this using the most common UHD BD Spec.
Logged
JRiver CEO Elect

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4231
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #16 on: June 01, 2023, 06:10:30 am »

Anyone had a chance to have a look yet?
I'm not sure that viewing on a projector (so not tonemapped back down a fair bit) is going to be too revealing but my take....

* i find it slightly hard to judge content like this because it's literally an alien planet, i.e. I have no built in frame of reference for "that looks normal/weird"
* I didn't see anything obnoxious in either version
* both HDR versions looked a bit like they've just been run through some colour enhancing filter which operates particularly strongly on certain content but does v little to other content (which I guess it how that process works?)

FWIW the scene of them swimming through water was, subjectively to my eyes, the one scene where the difference was immediately obvious

I'll take a look on an OLED later to see if it looks any different there
Logged

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #17 on: June 01, 2023, 06:31:27 am »

Thanks! I've not tried viewing these on a PJ, but on a HDR1000 P3 Display to keep additional tone/gamut mapping to a minimum.  I'd expect that they should look similar on a PJ but should look different on the OLED.  I picked this example as Avatar is pretty well known and the demo clip should not get me in trouble!  Trouble with this choice is it is all a very blue canvas. 

A couple of good comparisons frames for me are:
- 14 sec mark for overall gamut / PQ changes
- 25 sec mark for the highlights of the white floating thingie and also the waterfall at 41 sec
- 33 & 39 sec mark for skin tones

I also don't see anything weird per say, but I think my order of preference on these samples would be:
- HDR - Saturation Preserving, then
- HDR - Luminance Mapping (don't like the extra blue/purple shadows on the tip of his nose at 10 sec), then
- SDR
Logged
JRiver CEO Elect

mattkhan

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 4231
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #18 on: June 04, 2023, 05:07:54 am »

Checked them out on a LG C1, luminance mapping is definitely rather intense to my eyes, like a vibrance filter.

Saturation preserving seems to blow the highlights a little bit.

SDR probably the best of them for me, quite small difference though tbh, not sure I would have a preference blind tested
Logged

jmone

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 14465
  • I won! I won!
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #19 on: June 04, 2023, 07:07:47 am »

Thanks for the feedback.  Interesting!
Logged
JRiver CEO Elect

bogdanbz

  • World Citizen
  • ***
  • Posts: 208
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #20 on: June 12, 2023, 03:56:06 pm »

It's indeed not switching Windows HDR mode off when watching a SDR extra on a UHD HDR BluRay.
I noticed to day that when I started playback of a SDR extra on a UHD BluRay, JRVR turned Windows HDR off before starting the playback of the extra feature, and turned it back on after the feature ended. This was with MC 31.0.17.

I don't remember this working before, so I guess this is something new. Thank you for implementing this change!
Logged

Hendrik

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 10945
Re: SDR to HDR (Inverse Tone Mapping)
« Reply #21 on: June 12, 2023, 03:56:54 pm »

There was no recent change in this area. This functionality was supposed to be working for quite a while now.
Logged
~ nevcairiel
~ Author of LAV Filters
Pages: [1]   Go Up