I've recently done a new script based always on the hale tone mapping , it works mainly in linear rgb with bt2020 primaries and the luma channel, it has an option for the desaturation of the super bright colors and for linearize the first part of the tonemapper curve.
There's only few parameters:
source_peak = max brightness expressed in nits
desat = how much desaturate the bright regions, it goes from 0 to 100, with 0 there isn't any desaturation and with 100 it desaturate totally the bright colors, default is 50
lin= True or False, with True it linearize the first part of the curve
show_satmask=True or False, with true it show the mask used for the reduction of the saturation
show_clipped=True or False, show the image with clipped highlights
hable only in rgb
(sorry for the horrible compression)
new script
show_satmask=True
show_clipped=True
HLG with rec709 primaries
HLG tonemapped
example of usage with HLG content(convert always to linear with 2020 primaries)
Code:
import vapoursynth as vs
import tmap
core = vs.get_core()
c = core.ffms2.Source(source = 'C:/..../TravelXP 4K HDR HLG Demo.ts')
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="std-b67", transfer_s="linear",dither_type="none", nominal_luminance=1000)
c=tmap.tm(c,source_peak=1000,desat=50,show_satmask=False,lin=True,show_clipped=False)
c=core.resize.Bicubic(clip=c, format=vs.YUV422P10, 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="none")
c.set_output()
I don't have tested it much but I think sometimes it gives acceptable results :-)
Here's the script