Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 Doom9's Forum HDR10 to SDR with Hable tone-mapping
 User Name Remember Me? Password
 Register FAQ Calendar Search Today's Posts Mark Forums Read

 Thread Tools Search this Thread Display Modes
 25th January 2018, 17:25 #41  |  Link age Registered User   Join Date: Oct 2015 Posts: 50 I've taken the formula for decomposing rgb to luma and come back(it gives different result from a classic rgb->yuv->rgb and it is faster) from here:https://www.google.it/amp/s/imdoingi...-blacks-3/amp/ The jhon hable tonemapping from here:http://filmicworlds.com/blog/filmic-...ing-operators/
 25th January 2018, 19:36 #42  |  Link jpsdr Registered User   Join Date: Oct 2002 Location: France Posts: 1,835 ... I'm still unable to see the whole mathematical formula path . I also don't see any formula with exposed_bias in your links... I have no idea what is the mathematical results of such things Code: ```tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)#12=1200 nits / 100 nits w = core.std.Expr(c, expr="{exposure_bias} 0.15 {exposure_bias} * 0.05 + * 0.004 + {exposure_bias} 0.15 {exposure_bias} * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)# c = core.std.Expr(clips=[tm,w], expr=" x 1 y / * ",format=vs.RGBS)``` This is why, a "unrolled" explicit mathematical formula would be wonderfull... I mean... Your script result in several mathematic formulas apllied step by step. Is it possible to have the formula of each step ? Last edited by jpsdr; 25th January 2018 at 19:42.
25th January 2018, 21:56   #43  |  Link
ifb
Registered User

Join Date: Dec 2009
Posts: 66
Quote:
 Originally Posted by jpsdr ... I'm still unable to see the whole mathematical formula path . I also don't see any formula with exposed_bias in your links... I have no idea what is the mathematical results of such things Code: ```tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)#12=1200 nits / 100 nits w = core.std.Expr(c, expr="{exposure_bias} 0.15 {exposure_bias} * 0.05 + * 0.004 + {exposure_bias} 0.15 {exposure_bias} * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias),format=vs.RGBS)# c = core.std.Expr(clips=[tm,w], expr=" x 1 y / * ",format=vs.RGBS)``` This is why, a "unrolled" explicit mathematical formula would be wonderfull... I mean... Your script result in several mathematic formulas apllied step by step. Is it possible to have the formula of each step ?
I haven't looked at his script, but what you've quoted is the Hable operator from earlier in the thread. You can look at the VS plugin or ffmpeg if you want to see a C version.

https://github.com/ifb/vapoursynth-t.../tonemap.c#L44

 26th January 2018, 09:55 #44  |  Link jpsdr Registered User   Join Date: Oct 2002 Location: France Posts: 1,835 Ok, i'll try to figure out things with all i have for now.
 27th January 2018, 10:40 #45  |  Link jpsdr Registered User   Join Date: Oct 2002 Location: France Posts: 1,835 I've tried to read again the BT.2100 and BT.2390. I'm still confused. I'm unable to relate the formulas of OETF, EOTF, OOTF functions with the formulas of the tonemap functions you've all provided in your links. Where from the BT.2100 and BT.2390 did you get the formulas of the tonemap functions (what page, chapter ) ? I'm still unable to figure out where the "white max" information is involved in the OETF, EOTF, OOTF functions...
 27th January 2018, 19:40 #46  |  Link age Registered User   Join Date: Oct 2015 Posts: 50 EOTF and tonemapping are two different things, you could read about the st2084 formula in the official documentation or in the zimg code or elsewhere. I've founded an interesting pdf about hdr and tonemapping http://www.eusipco2016.org/documents...R_tutorial.pdf at page 119 the EOTF formula. At pages 100-107 some methods for the correction of the saturation. From the first one I've done a vapoursynth function with only two parameters,(clip and source_peak)it's simple but at my eyes is better then my previous attempt https://filebin.net/7c6kocrmxxnat1cp Code: ```import vapoursynth as vs import tmsimple core = vs.get_core() c = core.ffms2.Source(source = 'C:/.../testhdr.mkv') c=core.resize.Bicubic(clip=c, format=vs.RGBS,filter_param_a=0.0,filter_param_b=0.75, range_in_s="limited", matrix_in_s="2020ncl", primaries_in_s="2020", primaries_s="2020", transfer_in_s="st2084", transfer_s="linear",dither_type="none", nominal_luminance=1000) c=tmsimple.tm(clip=c,source_peak=1000) c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, filter_param_a=0.0, filter_param_b=0.75, matrix_s="709", primaries_in_s="2020", primaries_s="709", transfer_in_s="linear", transfer_s="709",dither_type="ordered") c.set_output()```
 28th January 2018, 14:18 #47  |  Link jpsdr Registered User   Join Date: Oct 2002 Location: France Posts: 1,835 Ok thanks, i'll read it.
14th April 2018, 22:59   #48  |  Link
jkilez
Registered User

Join Date: May 2014
Posts: 33
Quote:
 Originally Posted by Magik Mark Is there a way to convert this to avisynth+?
There is now a tone-mapping plug-in for avisynth+: http://rationalqm.us/DGTonemap.rar

It supports both Hable and Reinhard methods.

Last edited by jkilez; 14th April 2018 at 23:01.

 16th April 2018, 20:32 #49  |  Link MonoS Registered User   Join Date: Aug 2012 Posts: 183 Some times ago i wrote a c++ implementation of the hable implementation in tmap, i don't remeber how much faster it is, but IIRC about 2x . It only works for float input with mod8 resolution video and AVX CPU, i didn't bother writing an SSE implementation due to the high amount of FMAD instruction used. The static buffer optimization only work on windows right now. If i see any interest in this i'll try to add some functionality like the debug views, non mod8 support, etc Here the repo https://github.com/MonoS/tmap-vapoursynth/tree/V1
 2nd January 2019, 06:31 #50  |  Link lansing Registered User   Join Date: Sep 2006 Posts: 1,273 Japanese television recently launched their 4k/8k broadcasting last month, here's a same frame comparison between a 1080p HD version and the 4k HDR version: 1080p: 4K HDR: note: delete the last letter ("h") on the image name to get the original size. None of the three methods in the tonemap plugin I've tested can map the 4k one to look like 1080 one. They all failed on the color mapping.
 2nd January 2019, 07:27 #51  |  Link poisondeathray Registered User   Join Date: Sep 2007 Posts: 4,277 @lansing - does the original stream have metadata and parameters listed ? That can help guide what settings to use (or at least as a starting point)
2nd January 2019, 07:30   #52  |  Link
HolyWu
Registered User

Join Date: Aug 2006
Location: Taiwan
Posts: 755
Quote:
 Originally Posted by lansing None of the three methods in the tonemap plugin I've tested can map the 4k one to look like 1080 one. They all failed on the color mapping.
The exact script you used and maybe a 3 seconds sample (if you could cut it losslessly) is probably better than just screenshots.

 2nd January 2019, 08:58 #53  |  Link lansing Registered User   Join Date: Sep 2006 Posts: 1,273 Here's the sample clip, there's no metadata with the stream. script I've tested: Code: ```rgb_clip = core.resize.Bicubic(clip, height=1080, width=1920, matrix_in_s="709", format=vs.RGBS) # hable tonemap_clip = core.tonemap.Hable(rgb_clip, exposure=7.0, a=0.10, b=0.50, c=0.10, d=0.20, e=0.01, f=0.08, w=5.2) # mobius tonemap_clip = core.tonemap.Mobius(rgb_clip, exposure=1.5, transition=0.9, peak=1.0) #reinhard tonemap_clip = core.tonemap.Reinhard(rgb_clip, exposure=1.5, contrast=0.5, peak=1.0)``` The hable method is the only one that came close, but color are still off. The other two failed completely, as they have nothing to tweak.
2nd January 2019, 10:18   #54  |  Link
HolyWu
Registered User

Join Date: Aug 2006
Location: Taiwan
Posts: 755
Quote:
 Originally Posted by lansing Here's the sample clip, there's no metadata with the stream.
It seems that the stream is actually SDR rather than HDR even though the resolution is 4K. By definition, HDR video should have at least 10-bit color depth. And the stream is encoded in AVC, not HEVC. AVC-encoded HDR video is very uncommon.

Last edited by HolyWu; 2nd January 2019 at 11:31.

7th January 2019, 20:19   #55  |  Link
ifb
Registered User

Join Date: Dec 2009
Posts: 66
Quote:
 Originally Posted by lansing The hable method is the only one that came close, but color are still off. The other two failed completely, as they have nothing to tweak.
tonemap requires linear input and you still need to convert from 2020 to 709.

<edit>
I'm pretty sure it's HLG but with Rec.709 color, which is weird but I suppose they are worried about backward compatibility.

This is with zero tweaking, just copied from the tonemap examples:
Code:
```c = core.ffms2.Source(source  = "4kbs_trim.mp4")
c = core.resize.Lanczos(clip=c, format=vs.RGBS,
width=1920, height=1080,
matrix_in_s="709",
transfer_in_s="std-b67", transfer_s="linear",
nominal_luminance=1000)
c = core.tonemap.Mobius(clip=c, exposure=4)
c = core.resize.Lanczos(clip=c, format=vs.YUV420P10, matrix_s="709",
primaries_in_s="709",  primaries_s="709",
transfer_in_s="linear", transfer_s="709")```

Last edited by ifb; 7th January 2019 at 20:51.

8th January 2019, 03:44   #56  |  Link
poisondeathray
Registered User

Join Date: Sep 2007
Posts: 4,277
Quote:
 Originally Posted by HolyWu It seems that the stream is actually SDR rather than HDR even though the resolution is 4K. By definition, HDR video should have at least 10-bit color depth. And the stream is encoded in AVC, not HEVC. AVC-encoded HDR video is very uncommon.

^ this

If the goal was to "match" the other version, I'd probably just use normal color manipulation filters .

 8th January 2019, 17:59 #57  |  Link age Registered User   Join Date: Oct 2015 Posts: 50 Hi :-) I would like to use normal color manipulation filters too for this video. I've made a.cube file for the sdr match. https://filebin.net/uu8l2zh4xso2gqd2 Code: ```import vapoursynth as vs core = vs.get_core() c = core.lsmas.LibavSMASHSource(source= "C:/Users/..../4kbs_trim.mp4") c=core.resize.Bicubic(clip=c, format=vs.RGB48, chromaloc_in_s="left", chromaloc_s="center", filter_param_a=0.0, filter_param_b=0.75, matrix_in_s="2020ncl", range_in_s="limited",dither_type="none") c=core.timecube.Cube(c, cube="C:/..../Videos/4kbshdr.cube") c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, chromaloc_in_s="center", chromaloc_s="left",matrix_s="709", filter_param_a=0.0, filter_param_b=0.75, range_in_s="full", range_s="limited",dither_type="none") c.set_output()``` Last edited by age; 8th January 2019 at 19:02.
 8th January 2019, 21:05 #58  |  Link ifb Registered User   Join Date: Dec 2009 Posts: 66 HLG has a different look ("natural" to use BBC/BT.2408 terminology) versus the "traditional" look of SDR. To convert, you need to do a scene-referred conversion, which is not exposed in z.lib/vapoursynth. You can patch z.lib and build your own custom vapoursynth.dll, but really you're just better off using a LUT like shown. The BBC has some official .cube files they provide for doing this sort of thing.
 8th January 2019, 22:11 #59  |  Link age Registered User   Join Date: Oct 2015 Posts: 50 That video doesn't look hdr, but more like an hdr video converted to rec709 without tonemapping for example with hable tonemapping for 1000 nits Code: ```import vapoursynth as vs core = vs.get_core() c = core.lsmas.LibavSMASHSource(source= "C:/Users//Desktop/4kbs_trim.mp4") c=core.resize.Bicubic(clip=c, format=vs.RGBS,filter_param_a=0.0,filter_param_b=0.75, range_in_s="limited", matrix_in_s="2020ncl", chromaloc_in_s="left", chromaloc_s="center", transfer_in_s="709", transfer_s="linear",dither_type="none") #insert here tonemapping 1000nits #exposure_bias=10 #tm = core.std.Expr(c, expr="x {exposure_bias} * 0.15 x {exposure_bias} * * 0.05 + * 0.004 + x {exposure_bias} * 0.15 x {exposure_bias} * * 0.50 + * 0.06 + / 0.02 0.30 / - ".format(exposure_bias=exposure_bias)) #w=((exposure_bias*(0.15*exposure_bias+0.10*0.50)+0.20*0.02)/(exposure_bias*(0.15*exposure_bias+0.50)+0.20*0.30))-0.02/0.30 #tm = core.std.Expr(clips=[tm,c], expr="x 1 {w} / * ".format(exposure_bias=exposure_bias,w=w)) c=core.resize.Bicubic(clip=c, format=vs.RGBS, transfer_in_s="linear", transfer_s="709",dither_type="none") c=core.resize.Bicubic(clip=c, format=vs.YUV420P8, chromaloc_in_s="center", chromaloc_s="left", filter_param_a=0.0, filter_param_b=0.75, range_in_s="full", range_s="limited", matrix_s="709",dither_type="none") c.set_output()``` it gives me this
9th January 2019, 09:05   #60  |  Link
lansing
Registered User

Join Date: Sep 2006
Posts: 1,273
Quote:
 Originally Posted by age That video doesn't look hdr, but more like an hdr video converted to rec709 without tonemapping
I think you're right, it turns out that the recorder has an older model 4K TV that doesn't support HDR, and the tv just converted it into something else.

 Tags hdr, sdr

 Thread Tools Search this Thread Search this Thread: Advanced Search Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements and Chat     General Discussion     News     Forum / Site Suggestions & Help General     Decrypting     Newbies     DVD2AVI / DGIndex     Audio encoding     Subtitles     Linux, Mac OS X, & Co Capturing and Editing Video     Avisynth Usage     Avisynth Development     VapourSynth     Capturing Video     DV     HDTV / DVB / TiVo     NLE - Non Linear Editing     VirtualDub, VDubMod & AviDemux     New and alternative a/v containers Video Encoding     (Auto) Gordian Knot     MPEG-4 ASP     MPEG-4 Encoder GUIs     MPEG-4 AVC / H.264     High Efficiency Video Coding (HEVC)     New and alternative video codecs     MPEG-2 Encoding     VP9 and AV1 (HD) DVD, Blu-ray & (S)VCD     One click suites for DVD backup and DVD creation     DVD & BD Rebuilder     (HD) DVD & Blu-ray authoring     Advanced authoring     IFO/VOB Editors     DVD burning Hardware & Software     Software players     Hardware players     PC Hard & Software Programming and Hacking     Development     Translations

All times are GMT +1. The time now is 17:00.

 Doom9.org - Archive - Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.