HDR -> SDR conversion

These CUDA filters are packaged into DGDecodeNV, which is part of DGDecNV.
DAE avatar
Dion
Posts: 28
Joined: Sun Dec 04, 2016 12:30 am

Re: HDR -> SDR conversion

Post by Dion »

https://www.dropbox.com/s/qiwo2v5j6b9c9 ... 2.mkv?dl=1

Make sure you have the latest Avisynth+ otherwise 16bit will error out and display nothing..
https://github.com/pinterf/AviSynthPlus ... /tag/r2728

16 Bit
DGSource("Annihilation-002.dgi", fulldepth=True)
z_Spline36Resize(1920, 1080)
DGHDRtoSDR
DGSource("Annihilation-002.dgi", fulldepth=True)
z_Spline36Resize(1920, 1080)
DGHDRtoSDR(tm="mobius", light=250)
8 Bit
DGSource("Annihilation-002.dgi", fulldepth=True)
z_Spline36Resize(1920, 1080)
ConvertBits(8)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

Thank you, Dion.

Here is build 1.8, which adds a fulldepth parameter to output 10-bit SDR stored in YUV420P16.

http://rationalqm.us/misc/DGHDRtoSDR_1.8.rar

BTW, you have tm="mobius". That is not valid syntax for build 1.7, so I suppose you used an earlier
version.
DAE avatar
Dion
Posts: 28
Joined: Sun Dec 04, 2016 12:30 am

Re: HDR -> SDR conversion

Post by Dion »

Thanks.. Looks to be working.. :salute:
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

You're welcome. Thank you for pushing for this addition.
DAE avatar
Nginx
Posts: 26
Joined: Fri Mar 23, 2018 12:48 am

Re: HDR -> SDR conversion

Post by Nginx »

Thank you very much ~
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

You're welcome, Nginx.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

DGHDRtoSDR 1.9 is released. It adds Vapoursynth native support.
DAE avatar
Guest

Re: HDR -> SDR conversion

Post by Guest »

Keeps getting better and better, thank you
DAE avatar
Dion
Posts: 28
Joined: Sun Dec 04, 2016 12:30 am

Re: HDR -> SDR conversion

Post by Dion »

Have you ever considered making an HDR to SDR app for the Nvidia Shield? It has an Nvidia GPU in it and one thing it lacks is an HDR to SDR app that can hook onto Plex or Kodi or some other popular video apps.

Could even charge for it an probably make some decent bank. :D
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

I'll look into it when current projects finish up. Thank you for the suggestion.
DAE avatar
Antikor
Posts: 1
Joined: Thu Sep 20, 2018 4:35 pm

Re: HDR -> SDR conversion

Post by Antikor »

DGTonemap DGHable green and human skin color is not correct, unfortunately, you can add parameters for this. respects
skin color turns green.

|Source
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
Image Image Image
DAE avatar
Dion
Posts: 28
Joined: Sun Dec 04, 2016 12:30 am

Re: HDR -> SDR conversion

Post by Dion »

Stark image is from the 1080p bluray.. Not the UHD..

UHD and 1080p BD's do not have the same color.

and on top of that you have never seen a UHD in it's native form.. So you have no idea what Tonemapping is correct. The quest for a perfect SDR tonemap is impossible right now.
DAE avatar
Guest

Re: HDR -> SDR conversion

Post by Guest »

Perfection is a highly improbable result at any time.
All we can hope for is good enough > good > real good > darn, that is good
DGHDRtoSDR is already in the real to darn range
User avatar
hydra3333
Posts: 394
Joined: Wed Oct 06, 2010 3:34 am
Contact:

Re: HDR -> SDR conversion

Post by hydra3333 »

Just a note about the .rar file not opening in 7zip commandline,

Per http://forum.doom9.org/showthread.php?p ... ost1853939 when I try to manually use standalone z7ip to even list the rar file, it fails.

Would it be possible to consider using .zip or something ?
I really do like it here.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

I'll look into it tomorrow. Thanks for pointing it out. I used to always use ZIP but then I saw lots of people using RAR.
User avatar
alexantr
Posts: 11
Joined: Mon Oct 15, 2018 4:24 pm

Re: HDR -> SDR conversion

Post by alexantr »

Why DGHDRtoSDR has so strange hue?

1. SDR version: https://i.imgur.com/8ns30OO.jpg
2. HDR to SDR with DGTonemap 1.2: https://i.imgur.com/B2jbxdf.jpg
3. HDR to SDR with DGHDRtoSDR 1.10: https://i.imgur.com/zGFdNzF.jpg

avs with DGTonemap:

Code: Select all

loadplugin("D:\Programs\DG\x64\DGDecodeNV.dll")
loadplugin("D:\Programs\DG\x64\DGTonemap.dll")
loadplugin("D:\Programs\DG\x64\avsresize.dll")
SetFilterMTMode("z_ConvertFormat", MT_MULTI_INSTANCE)
DGSource("e:\encode\Coco.dgi", fulldepth=true)
ConvertBits(10)
z_ConvertFormat(pixel_type="RGBPS", colorspace_op="2020ncl:st2084:2020:l=>rgb:linear:2020:l", dither_type="none")
DGReinhard()
z_ConvertFormat(pixel_type="YV12", colorspace_op="rgb:linear:2020:l=>709:709:709:l", dither_type="ordered")
Crop(0, 276, 0, -276)
Spline36Resize(1920, 804)
prefetch(4)
avs with DGHDRtoSDR:

Code: Select all

loadplugin("D:\Programs\DG\x64\DGDecodeNV.dll")
loadplugin("D:\Programs\DG\x64\DGHDRtoSDR.dll")
DGSource("e:\encode\Coco.dgi", fulldepth=true)
Crop(0, 276, 0, -276)
Spline36Resize(1920, 804)
DGHDRtoSDR()
prefetch(6)
Another video:

1. HDR with madVR: https://i.imgur.com/mTlruX1.jpg
2. HDR to SDR with DGTonemap 1.2: https://i.imgur.com/HArYxUt.jpg
3. HDR to SDR with DGHDRtoSDR 1.10: https://i.imgur.com/GaoQ2Go.jpg
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

"strange hue"

Not a really precise formulation but I can look into it if you provide me with an unprocessed source stream sample. I can't do much with JPGs.
User avatar
alexantr
Posts: 11
Joined: Mon Oct 15, 2018 4:24 pm

Re: HDR -> SDR conversion

Post by alexantr »

Please checkout source file: https://mega.nz/#!GsdHmazY!Vo6zfUcpm31E ... HOZbqerSlA

Resulting file after DGHDRtoSDR: https://mega.nz/#!z0MlgaDR!NJlZg76uyf0B ... hDBMeXAcow

Resulting file after DGTonemap: https://mega.nz/#!T8sRhQIZ!4IvY35zNQnwa ... ZK2QLIf7bw

Every my tested video has same problem. I can see almost similar result only after appending Tweak(hue=10).
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

Thanks, I'll look into it.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

Please try out this version:

http://rationalqm.us/hdr/DGHDRtoSDR_1.11.rar

I added some hue correction for the gamut mapping. We'll never exactly match other solutions. What I am aiming for is reasonable results for most streams and fast processing in CUDA mode.
DAE avatar
Guest 3
Posts: 67
Joined: Mon Mar 26, 2018 6:00 am

Re: HDR -> SDR conversion

Post by Guest 3 »

Image Image Image Image

I see similar problem with the colors. It is probably due to the Hable operator implemented with DGTonemap plugin with its dafaults.
At least, I’ve seen same results with ffmpeg tonemapping filters.
Three of above screens are results of Hable tonemapping. The fourth is from the source UHD .hevc.

Working with 240 frames cut from the source Gladiator 2000 UHD I've encountered two more problems:
  • DGDecNV(), when works, processes 236 frames.

Code: Select all

>avs2yuv64 -depth 10 -raw DGTonemap.avs - | x265-64bit-8bit-2018-10-08 - ...
yuv  [info]: 1920x1080 fps 24000/1001 i420p8 unknown frame count
raw  [info]: output file:
...
x265 [info]: HEVC encoder version 2.8+74-fd517ae68f93
...
x265 [info]: tools:
avisynth 16-bit hack enabled
DGTonemap.avs: 960x1080, YV12, 10-bits, progressive, 24000/1001 fps, 236 frames
encoded 236 frames in 293.53s (0.80 fps), 59210.41 kb/s, Avg QP:16.28
If I use FFMS2() as a source instead I have

Code: Select all

>avs2yuv64 -depth 10 -raw DGTonemapMod.avs - | 
...
DGTonemapMod.avs: 960x1080, YV12, 10-bits, progressive, 24 fps, 240 frames
encoded 240 frames in 314.47s (0.76 fps), 58830.89 kb/s, Avg QP:16.23
  • HDR2SDR plugin doesn't work properly.
It process more than 500 frames and I cancel it. Seems like a program loop.
The result seems as if color channels' frames are overlaid.

Working environment
Window 10 Pro v.1803 Build 17134.345
GeForce GTX 1050 Video driver v.398.82
User avatar
alexantr
Posts: 11
Joined: Mon Oct 15, 2018 4:24 pm

Re: HDR -> SDR conversion

Post by alexantr »

admin wrote:
Wed Oct 17, 2018 11:13 am
Please try out this version:

http://rationalqm.us/hdr/DGHDRtoSDR_1.11.rar

I added some hue correction for the gamut mapping. We'll never exactly match other solutions. What I am aiming for is reasonable results for most streams and fast processing in CUDA mode.
Awesome! Thanks!
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

@ alexantr

You're welcome, and thank you for your valuable report.

@Guest 3
Guest 3 wrote:
Wed Oct 17, 2018 11:49 am
Working with 240 frames cut from the source Gladiator 2000 UHD I've encountered two more problems:
DGDecNV(), when works, processes 236 frames.
There may be a good reason for that. If you link me to your cut stream I can look into it.
HDR2SDR plugin doesn't work properly.
I don't know that plugin.
DAE avatar
Guest 3
Posts: 67
Joined: Mon Mar 26, 2018 6:00 am

Re: HDR -> SDR conversion

Post by Guest 3 »

Tonemapping isn't a trivial task and the operators least at their defaults aren't universal.
I've just found a JOHN HABLE's publication at http://filmicworlds.com/blog/filmic-ton ... er-curves/
proposing Filmic Tonemapping with Piecewise Power Curves.
Here is his source code https://github.com/johnhable/fw-public
I think it would be nice if we had this model implemented as aa AviSynth.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: HDR -> SDR conversion

Post by admin »

@Guest 3

Are you going to ignore my request for your source file, etc.?
Post Reply