def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src ref = hvf.SMDegrain(out, thSAD=300) denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref) out = denoise crop = core.std.Crop(out, left=12) crop = awf.bbmod(crop, left=2, thresh=20 << 8) resize = core.resize.Bicubic(crop, 1920) out = lvf.rfs(out, resize, [(78, 89)]) y = get_y(out) lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate() fkrescale = fake_rescale( y, 882, 0, 1, deringer=lambda x: gf.MaskedDHA(x, rx=1.85, ry=1.85, darkstr=0.25, brightstr=1.0, maskpull=100, maskpush=200), antialiser=lambda c: lvf.sraa(c, 2, 13, downscaler=core.resize.Bicubic) ) merged = core.std.MaskedMerge(y, fkrescale, lineart) out = vdf.merge_chroma(merged, out) dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True) out = dering out = lvf.rfs( out, denoise, [(0, 11), (38, 77), (115, 133), (316, 395), (441, 460), (606, 779), (825, 844), (990, 1127)] ) detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000) deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0)) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333) out = grain decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8) out = decz return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src edstart1, edend1 = 37428, 37428 + 2160 edstart2, edend2 = edend1 + 12, edend1 + 2160 ref = hvf.SMDegrain(out, thSAD=300) denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref) out = denoise y = get_y(out) lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate() fkrescale = fake_rescale( y, 882, 0, 1, deringer=lambda x: gf.MaskedDHA(x, rx=1.85, ry=1.85, darkstr=0.25, brightstr=1.0, maskpull=100, maskpush=200), antialiser=lambda c: lvf.sraa(c, 2, 13, downscaler=core.resize.Bicubic) ) merged = core.std.MaskedMerge(y, fkrescale, lineart) out = vdf.merge_chroma(merged, out) dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True) out = dering out = lvf.rfs(out, denoise, [(edstart1, src.num_frames - 1)]) detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000) deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0)) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333) out = grain decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8) out = decz ref = depth(src, 16) src_c, src_nced1, src_nced2 = [ depth(x, 16).std.Convolution( [1, 2, 1, 2, 4, 2, 1, 2, 1] ) for x in [src, JPBD_NCED1.src_cut, JPBD_NCED2.src_cut] ] ending_mask1 = vdf.dcm(out, src_c[edstart1:edend1 + 1], src_nced1[:edend1 - edstart1 + 1], edstart1, edend1, 2, 2) ending_mask2 = vdf.dcm(out, src_c[edstart2:edend2 + 1], src_nced2[:edend2 - edstart2 + 1], edstart2, edend2, 2, 2) ending_mask = core.std.Expr([ending_mask1, ending_mask2], 'x y +') ending_mask = iterate(ending_mask, core.std.Inflate, 4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, ending_mask), [(edstart1, edend2)]) credit = lvf.rfs(credit, ref, [(21594, 21737), (39589, 39599), (41744, src.num_frames - 1)]) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src edstart, edend = 31888, src.num_frames-1 shift = core.resize.Point(out, src_left=1).edgefixer.ContinuityFixer([2, 1, 1], 0, 0, 0) out = lvf.rfs(out, shift, [(235, 318)]) ref = hvf.SMDegrain(out, tr=1, thSAD=300, plane=4) denoise = mvf.BM3D(out, [1.5, 1], 1, profile1='lc', ref=ref) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', scale_value(0.065, 32, 16), (1, 1)).std.Median().std.BoxBlur(0, 1, 1, 1, 1) rescale = fake_rescale(y, 837.5, 1/3, 1/3, coef_dering=0.1, coef_dark=1.25, coef_warp=1.15, coef_sharp=0.75, coef_finalsharp=0.85) rescale = core.std.MaskedMerge(y, rescale, lineart) out = vdf.merge_chroma(rescale, out) preden = core.dfttest.DFTTest(get_y(out), ftype=0, sigma=0.5, sbsize=16, sosize=12, tbsize=1) detail_dark_mask = detail_dark_mask_func(preden, brz_a=6000, brz_b=5000) detail_light_mask = lvf.denoise.detail_mask(preden, brz_a=2500, brz_b=1200) detail_mask = core.std.Expr([detail_dark_mask, detail_light_mask], 'x y +').std.Median() detail_mask_grow = iterate(detail_mask, core.std.Maximum, 2) detail_mask_grow = iterate(detail_mask_grow, core.std.Inflate, 2).std.BoxBlur(0, 1, 1, 1, 1) detail_mask = core.std.Expr([preden, detail_mask_grow, detail_mask], f'x {40<<8} < y z ?') pf = vdf.merge_chroma(preden, out) deband = dumb3kdb(pf, 17, 40) deband_b = dumb3kdb(pf, 20, 80) deband = lvf.rfs(deband, deband_b, [(2194, 2216), (2283, 2306)]) deband = core.std.MergeDiff(deband, out.std.MakeDiff(pf)) deband = core.std.MaskedMerge(deband, out, detail_light_mask) out = deband grain = kgf.adaptive_grain(out, 0.35) out = grain ref = depth(src, 16) src_c, src_nced = [depth(x, 16) for x in [src, JPBD_NCED.src_cut[13:]]] ending_mask = vdf.dcm(out, src_c[edstart:edend+1], src_nced[:edend-edstart+1], edstart, edend, 2, 2).std.BoxBlur(0, 2, 2, 2, 2) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, ending_mask), [(31900, src.num_frames-1)]) out = credit return depth(out, 10).std.Limiter(16<<2, [235<<2, 240<<2], [0, 1, 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src opstart, opend = 2712, 4869 ref = hvf.SMDegrain(out, thSAD=300) denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref) out = denoise crop = core.std.Crop(out, left=12) crop = awf.bbmod(crop, left=2, thresh=20 << 8) resize = core.resize.Bicubic(crop, 1920) out = lvf.rfs(out, resize, [(86, 201)]) y = get_y(out) lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate() fkrescale = fake_rescale(y, 882, 0, 1, deringer=lambda x: gf.MaskedDHA(x, rx=1.85, ry=1.85, darkstr=0.25, brightstr=1.0, maskpull=100, maskpush=200), antialiser=lambda c: lvf.sraa( c, 2, 13, downscaler=core.resize.Bicubic)) merged = core.std.MaskedMerge(y, fkrescale, lineart) out = vdf.merge_chroma(merged, out) dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True) out = dering detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000) deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0)) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333) out = grain decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8) out = decz ref = depth(src, 16) src_c, src_ncop = [ depth(x, 16).std.Convolution([1, 2, 1, 2, 4, 2, 1, 2, 1]) for x in [src, JPBD_NCOP.src_cut] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], src_ncop[:opend - opstart + 1], opstart, opend, 2, 2) opening_mask = iterate(opening_mask, core.std.Inflate, 4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, opening_mask), [(opstart, opend)]) credit = lvf.rfs(credit, ref, [(17985, 18128)]) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])