DGTonemap 1.2 ------------- DGTonemap provides filters for Reinhard and Hable tonemapping operators. This is a starting point to make available a full HDR->SDR process for Avisynth+. In the future, I will likely add other operators. Suggestions in this regard will be appreciated. I will also port it to CUDA. Requirements ------------ 1. Avisynth+ MT recent version 2. avsresize (https://forum.doom9.org/showthread.php?t=173986) (be sure to get the latest high-performance version r1d) Reinhard Usage -------------- DGReinhard(clip, float contrast, float bright) contrast default: 0.3 bright default: 5.0 Input must be CS_RGBPS, see z_ConvertFormat() in the script below. If 'clip' is omitted, then as usual implicit last is used. Higher numbers for bright reduce brightness, you can even go to bright=1000 and beyond, but it stops having an effect up there. Hable Usage -------------- DGHable(clip, float exposure, float a, float b, float c, float d, float e, float f, float w) exposure default: 2.0 a default: 0.15 b default: 0.50 c default: 0.10 d default: 0.20 e default: 0.02 f default: 0.30 w default: 11.2 Input must be CS_RGBPS, see z_ConvertFormat() in the script below. If 'clip' is omitted, then as usual implicit last is used. Meaning of Hable coefficients: exposure: Gain to apply. a: Shoulder strength b: Linear strength c: Linear angle d: Toe strength e: Toe numerator f: Toe denominator w: Linear white point hable(x) = ((x*(a*x+c*b)+d*e) / (x*(a*x+b)+d*f)) - e/f output_pixel = hable(exposure * input_pixel) / hable(w) Sample Script ------------- Following is a sample script for the full HDR->SDR process. The source UHD video is tonemapped, converted to rec709 colorspace, and downsampled to 8 bits. To leave it in 16 bits, set pixel_type=YUV420P16 in the second z_ConvertFormat() call. loadplugin("DGDecodeNV.dll") loadplugin("DGTonemap.dll") loadplugin("avsresize.dll") SetFilterMTMode("z_ConvertFormat", MT_MULTI_INSTANCE) # May not be needed. DGSource("THE GREAT WALL.dgi",fulldepth=true) ConvertBits(10) # Use 12 for 12-bit z_ConvertFormat(pixel_type="RGBPS",colorspace_op="2020ncl:st2084:2020:l=>rgb:linear:2020:l", dither_type="none") # Choose one of these: DGReinhard() #DGHable() z_ConvertFormat(pixel_type="YV12",colorspace_op="rgb:linear:2020:l=>709:709:709:l",dither_type="ordered") prefetch(4) Copyright (c) 2018 Donald A. Graft, All rights reserved