def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) h = 882 w = get_w(h) kernel = 'lanczos' taps = 5 denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise luma = get_y(out) descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h) upscale = vdf.fsrcnnx_upscale( depth(descale, 16), src.width, src.height, '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0)) out = upscale unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5) sharp = hvf.LSFmod(unwarp, strength=90, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) stabilize = stabilization(out, sharp, 2, 1, 8, 16) out = vdf.merge_chroma(stabilize, denoise) antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic) out = antialias deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 42, 36) deband = core.std.MaskedMerge(deband, out, deband_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=18, keep_tv_range=True) out = deband grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14) out = grain rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask, 0), [(0, 647), (29954, 34046)]) credit = lvf.rfs(credit, src, [(0, 1)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" def _nnedi3(clip: vs.VideoNode, factor: float, args: dict)-> vs.VideoNode: upscale = clip.std.Transpose().nnedi3.nnedi3(0, True, **args) \ .std.Transpose().nnedi3.nnedi3(0, True, **args) sraa = _sraa(upscale, dict(nsize=3, nns=3, qual=1, pscrn=1)) return core.resize.Bicubic(sraa, clip.width*factor, clip.height*factor, src_top=.5, src_left=.5, filter_param_a=0, filter_param_b=0.25) # My GPU’s dying on it def _sraa(clip: vs.VideoNode, nnargs: dict)-> vs.VideoNode: clip = clip.nnedi3cl.NNEDI3CL(0, False, **nnargs).std.Transpose() clip = clip.nnedi3cl.NNEDI3CL(0, False, **nnargs).std.Transpose() return clip # Fun part / Cutting src_funi, src_wkn = [depth(c, 16) for c in CLIPS_SRC] src_funi, src_wkn = src_funi[744:], src_wkn[0] + src_wkn # Dehardsubbing # comp = lvf.comparison.stack_compare(src_funi, src_wkn, make_diff=True) src = core.std.MaskedMerge(src_wkn, src_funi, kgf.hardsubmask(src_wkn, src_funi)) hardsub_rem = core.std.MaskedMerge(src, src_funi, kgf.hardsubmask_fades(src, src_funi, 8, 2000)) src = lvf.rfs(src, hardsub_rem, [(3917, 4024)]) # Regular filterchain op, ed = (17238, 19468), (31889, 34045) h = 846 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') luma = get_y(src) thr = 8000 line_mask = gf.EdgeDetect(luma, 'FDOG').std.Median().std.Expr(f'x {thr} < x x 3 * ?') descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c) rescaled = _nnedi3(depth(descale, 16), src.height/h, dict(nsize=0, nns=4, qual=2, pscrn=2)) rescaled = core.std.MaskedMerge(luma, rescaled, line_mask) merged = vdf.merge_chroma(rescaled, src) out = merged cred_m = vdf.drm(src, h, b=b, c=c, mthr=80, mode='ellipse') credit = lvf.rfs(out, core.std.MaskedMerge(out, src, cred_m), [op]) credit = lvf.rfs(credit, src, [ed]) out = credit deband = dbs.f3kpf(out, 17, 36, 36) deband = core.std.MaskedMerge(deband, out, line_mask) grain = core.grain.Add(deband, 0.25) return depth(grain, 10)
def do_filter(): """Vapoursynth filtering""" def _fsrcnnx(clip: vs.VideoNode) -> vs.VideoNode: blank = core.std.BlankClip(clip, format=vs.GRAY16, color=128 << 8) clip = join([clip, blank, blank]) # The chroma is upscaled with box AKA nearest but we don't care since we only need the luma. # It's especially faster and speed is the key :^) clip = core.placebo.Shader(clip, 'Shaders/FSRCNNX_x2_56-16-4-1.glsl', clip.width*2, clip.height*2, filter='box') return get_y(clip) def _nnedi(clip: vs.VideoNode) -> vs.VideoNode: args = dict(nsize=4, nns=4, qual=2, pscrn=2) clip = clip.std.Transpose().nnedi3.nnedi3(0, True, **args) \ .std.Transpose().nnedi3.nnedi3(0, True, **args) return core.resize.Spline36(clip, src_top=.5, src_left=.5) def _rescale(clip: vs.VideoNode, thr: int, downscaler: Callable[[vs.VideoNode], vs.VideoNode]) -> vs.VideoNode: return downscaler(core.std.Merge(_nnedi(clip), _fsrcnnx(clip), thr)) src = SRC_CUT fixedges = lvf.ef(src, [1, 1, 1]) denoise = CoolDegrain(depth(fixedges, 16), tr=1, thsad=48, thsadc=84, blksize=8, overlap=4, plane=4) w, h = 1280, 720 b, c = vdf.get_bicubic_params('robidoux') luma = get_y(denoise) descale = depth(core.descale.Debicubic(depth(luma, 32), w, h, b, c), 16) rescale = _rescale(descale, 0.55, lambda c: core.resize.Bicubic(c, src.width, src.height, filter_param_a=0, filter_param_b=0)) line_mask = lvf.denoise.detail_mask(rescale, brz_a=7000, brz_b=2000) rescale = core.std.MaskedMerge(luma, rescale, line_mask) credit_mask = vdf.drm(luma, b=b, c=c, mode='ellipse', sw=3, sh=3) credit = core.std.MaskedMerge(rescale, luma, credit_mask) merged = vdf.merge_chroma(credit, denoise) deband_mask = lvf.denoise.detail_mask(merged, brz_a=3000, brz_b=1500) deband = dbs.f3kpf(merged, 17, 36, 36) deband = core.std.MaskedMerge(deband, merged, deband_mask) grain = core.neo_f3kdb.Deband(deband, preset='depth', grainy=32, output_depth=10, dither_algo=3, keep_tv_range=True) return grain
def filtering(clip: vs.VideoNode, edstart: int, edend: int)-> vs.VideoNode: """Main function""" clip = depth(clip, 32) denoise = CoolDegrainSF(clip, tr=1, thsad=36, blksize=8, overlap=4) out = denoise luma = get_y(out) descale = core.descale.Debicubic(luma, w, h, b, c) out = descale upscale = shf.nnedi3_upscale(out, clip.height/h, dict(nsize=4, nns=4, qual=2, pscrn=1)) out = upscale antialias = _antialias_stonk(descale, 128) mask = core.std.Sobel(antialias).std.Maximum().std.Maximum() antialias = lvf.rfs(out, core.std.MaskedMerge(out, antialias, mask), [(edstart+683, edstart+730)]) merged = vdf.merge_chroma(antialias, denoise) out = depth(merged, 16) sharp = lvf.rfs(out, _unblur(descale, denoise), [(edstart+501, edstart+617)]) out = sharp ref = core.resize.Point(luma, format=vs.YUV420P16) credit = core.std.MaskedMerge(out, ref, vdf.drm(ref, h, b=b, c=c), 0) out = credit deband_a = shf.deband_stonks(out, 24, 8, 1, shf.edge_mask_simple(out, 'prewitt', 2500, (2, 0))) deband_b = shf.deband_stonks(out, 31, 16, 3, shf.edge_mask_simple(out, 'prewitt', 2500, (6, 0))) deband_c = dbs.f3kpf(out, 17, 36, 36) deband = lvf.rfs(out, deband_a, [(edstart+44, edstart+69), (edstart+94, edstart+165), (edstart+190, edstart+213), (edstart+320, edstart+375), (edstart+683, edstart+730)]) deband = lvf.rfs(deband, deband_b, [(edstart+166, edstart+189)]) deband = lvf.rfs(deband, deband_c, [(edstart+376, edstart+682), (edstart+731, edend)]) out = deband grain = core.neo_f3kdb.Deband(out, preset='depth', grainy=24, grainc=24) out = grain return out
def do_filter(): """Vapoursynth filtering""" def _eedi3_instance(clip, eeargs, nnargs) -> vs.VideoNode: return core.eedi3m.EEDI3(clip, 0, True, **eeargs, sclip=_nnedi3_sclip(clip, nnargs)) def _nnedi3_sclip(clip, nnargs) -> vs.VideoNode: return core.nnedi3.nnedi3(clip, 0, True, **nnargs) def _rescale(clip, width, height, eeargs, nnargs) -> vs.VideoNode: clip = _eedi3_instance(clip, eeargs, nnargs).std.Transpose() clip = _eedi3_instance(clip, eeargs, nnargs).std.Transpose() return core.resize.Bicubic(clip, width, height, src_left=.5, src_top=.5) src = SRC_CUT denoise = mdf.hybriddenoise_mod(src, 0.5, 1.5, depth=32) h = 806 w = get_w(h) b, c = 0.3782, 0.3109 eedi3_args = dict(alpha=.2, beta=.3, gamma=1000, mdis=20, vcheck=3) nnedi3_args = dict(nns=4, nsize=0, qual=2, pscrn=1) luma = get_y(denoise) descale = core.descale.Debicubic(luma, w, h, b, c) scaled = _rescale(descale, src.width, src.height, eedi3_args, nnedi3_args) credit_m = vrf.drm(denoise, h, b=b, c=c, sw=4, sh=4) scaled = lvf.rfs(scaled, core.std.MaskedMerge(scaled, luma, credit_m), [(47, 134)]) merged = core.std.ShufflePlanes([scaled, denoise], [0, 1, 2], vs.YUV) merged = depth(merged, 16) deband_mask = lvf.denoise.detail_mask(merged, brz_a=2500, brz_b=1000) deband_a = dbs.f3kpf(merged, 17, 48, 48) deband_b = core.placebo.Deband(merged, radius=19, threshold=5, iterations=1, grain=2, planes=1|2|4) deband = lvf.rfs(deband_a, deband_b, [(2684, 2743)]) deband = core.std.MaskedMerge(deband, merged, deband_mask) deband = core.placebo.Deband(deband, iterations=0, grain=5, planes=1) grain = mdf.adptvgrnMod_mod(deband, 0.3, size=1.25, sharp=60, static=False, luma_scaling=6) final = lvf.rfs(grain, depth(src, 16), [(2904, src.num_frames-1)]) final = depth(final, 10) return final
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut ep10 = JPBD_10.src_cut h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') opstart, opend = 672, 3068 edstart, edend = 31888, src.num_frames - 1 opstart_ep10, opend_ep10 = 768, 3164 full_stuff = [(3853, 3984), (16130, 16279)] # Fix borders of the henshin start, end = 26596, 27387 white_clip = core.std.BlankClip(src, color=[235, 128, 128]) # Good length for the three henshins hibiki = TRANSFOS.src_cut[912:1716] hibiki = core.std.DeleteFrames(hibiki, [203, 204]) hibiki = core.std.DeleteFrames(hibiki, range(316, 320)) hibiki = core.std.DeleteFrames(hibiki, range(391, 394)) tsubasa = TRANSFOS.src_cut[2178:2738] tsubasa = core.std.DuplicateFrames(white_clip[:8] + tsubasa, range(10, 20)) tsubasa = core.std.DuplicateFrames(tsubasa, range(196, 203)) tsubasa = core.std.DuplicateFrames(tsubasa, [443, 443, 443]) yukine = TRANSFOS.src_cut[3240:3828] # The intro intro = 203 new_tranfos = hibiki[:intro] # Adjust croppings hibiki_crop_a = core.std.Crop(hibiki[intro:], src.width / 3, src.width / 3, 0, 0) dev = -150 hibiki_crop_b = core.std.Crop(hibiki[intro:], src.width / 3 + dev, src.width / 3 - dev, 0, 0) dev = -270 hibiki_crop_c = core.std.Crop(hibiki[intro:], src.width / 3 + dev, src.width / 3 - dev, 0, 0) hibiki_crop = lvf.rfs(hibiki_crop_a, hibiki_crop_b, [(391 - intro, 471 - intro)]) hibiki_crop = lvf.rfs(hibiki_crop, hibiki_crop_c, [(472 - intro, 552 - intro)]) tsubasa_crop_a = core.std.Crop(tsubasa, src.width / 3, src.width / 3, 0, 0) dev = -400 tsubasa_crop_b = core.std.Crop(tsubasa, src.width / 3 + dev, src.width / 3 - dev, 0, 0) tsubasa_crop = lvf.rfs(tsubasa_crop_a, tsubasa_crop_b, [(445 - intro, 460 - intro)]) tsubasa_crop = (tsubasa_crop[:461 - intro] + core.std.FrameEval( tsubasa_crop[461 - intro:478 - intro], partial(_prog_crop, clip=tsubasa[461 - intro:478 - intro], dev=dev)) + tsubasa_crop[478 - intro:]) yukine_crop = core.std.Crop(yukine, src.width / 3, src.width / 3, 0, 0) # Stack & merge new_tranfos += core.std.StackHorizontal( [tsubasa_crop, hibiki_crop, yukine_crop]) src = insert_clip(src, new_tranfos[:end - start], start) # Fix compositing error in the OP op_src, op_10 = src[opstart:opend + 1], ep10[opstart_ep10:opend_ep10 + 1] fix = lvf.rfs(op_src, op_10, [(0, 79), (1035, 1037)]) fix_src = insert_clip(src, fix, opstart) src = depth(fix_src, 32) denoise = hybrid_denoise(src, 0.5, 2) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1) upscale = vdf.fade_filter(upscale, upscale, upscale_smooth, 18018, 18068) upscale = lvf.rfs(upscale, upscale_smooth, [(18068, 18134)]) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) antialias = lvf.rfs( out, lvf.sraa(out, 1.65, 9, alpha=0.3, beta=0.45, gamma=240, nrad=3, mdis=25), [(opstart + 840, opstart + 881)]) antialias_a = lvf.sraa(out, 1.3, 3, alpha=0.3, beta=0.45, gamma=40, nrad=3, mdis=25) antialias_b = lvf.sraa(out, 1.85, 13, alpha=0.3, beta=0.6, gamma=400, nrad=2, mdis=15) antialias = vdf.fade_filter(antialias, antialias_a, antialias_b, 12718, 12861) antialias = lvf.rfs(antialias, antialias_b, [(24063, 24149)]) out = antialias # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband_b = placebo.deband(out, 22, 6, 2) deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)]) deband_c = placebo.deband(out, 10, 3, 1) deband = lvf.rfs(deband, deband_c, [(241, 300), (11076, 11183)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) out = grain rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src, src_ncop, src_nced = [ depth(x, 16) for x in [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) out = credit src_c, src_ncop, src_nced = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_ncop, src_nced] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], src_ncop[:opend - opstart + 1], opstart, opend, 4, 4).std.Inflate() ending_mask = vdf.dcm(out, src_c[edstart:edend + 1], src_nced[:edend - edstart + 1], edstart, edend, 4, 4).std.Inflate() credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +') credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask), [(opstart, opend), (edstart, edend)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) h = 882 w = get_w(h) kernel = 'lanczos' taps = 5 opstart, opend = 1918, 4076 edstart, edend = 31768, 33925 denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise luma = get_y(out) descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h) upscale = vdf.fsrcnnx_upscale( depth(descale, 16), src.width, src.height, '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0)) out = upscale import G41Fun as gf from vsTAAmbk import TAAmbk dehalo = gf.MaskedDHA(out, rx=2.8, ry=2.8, darkstr=0.4, brightstr=1.4, maskpull=48, maskpush=140) aaa = TAAmbk(dehalo, 'Eedi3SangNom', cycle=4, mtype=0) aaa = lvf.rfs(out, aaa, [(16052, 16105)]) out = aaa unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5) sharp = hvf.LSFmod(unwarp, strength=90, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) stabilize = stabilization(out, sharp, 2, 1, 8, 16) out = vdf.merge_chroma(stabilize, denoise) antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic) out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise), [(edstart, edend)]) deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 36, 36) deband = core.std.MaskedMerge(deband, out, deband_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=18, keep_tv_range=True) out = deband grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14) out = grain rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4) creditless_mask = core.std.Expr([ vdf.dcm(src, src[opstart:opend + 1], JPBD_NCOP.src_cut[:opend - opstart + 1], opstart, opend, 2, 2).std.Deflate(), vdf.dcm(src, src[edstart:edend + 1], JPBD_NCED.src_cut[:edend - edstart + 1], edstart, edend, 2, 2).std.Deflate() ], 'x y +') credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask, 0), [(opstart + 425, opstart + 698), (33972, src.num_frames - 1), (21962, 22009)]) credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, creditless_mask, 0), [(opstart, opend), (edstart, edend)]) credit = lvf.rfs(credit, src, [(5057, 5104), (12371, 12418)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) h = 882 w = get_w(h) kernel = 'lanczos' taps = 5 opstart, opend = 936, 3092 edstart, edend = 31769, 33926 clip_in = depth(src, 32) dedimm = gf.Tweak(clip_in, sat=1.65, cont=1.65) dedimm = vdf.fade_filter(clip_in, clip_in, dedimm, 26133, 26183) out = depth(dedimm, 16) denoise = CoolDegrain(out, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise luma = get_y(out) descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h) upscale = vdf.fsrcnnx_upscale( depth(descale, 16), src.width, src.height, '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0)) out = upscale unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5) sharp = hvf.LSFmod(unwarp, strength=90, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) stabilize = stabilization(out, sharp, 2, 1, 8, 16) out = vdf.merge_chroma(stabilize, denoise) antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic) out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise), [(edstart, edend)]) deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 30, 30) deband = core.std.MaskedMerge(deband, out, deband_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=18, keep_tv_range=True) out = deband grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14) out = grain rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4) creditless_mask = core.std.Expr([ vdf.dcm(src, src[opstart:opend + 1], JPBD_NCOP.src_cut[:opend - opstart + 1], opstart, opend, 2, 2).std.Deflate(), vdf.dcm(src, src[edstart:edend + 1], JPBD_NCED.src_cut[:edend - edstart + 1], edstart, edend, 2, 2).std.Deflate() ], 'x y +') credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask, 0), [(opstart + 425, opstart + 698), (33973, src.num_frames - 1)]) credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, creditless_mask, 0), [(opstart, opend), (edstart, edend)]) credit = lvf.rfs(credit, src, [(16911, 16970), (24486, 24533)]) out = credit return depth(out, 10)
def do_filter(): src = JPBD.src_cut fixedges = lvf.ef(src, [2, 1, 1]) fixedges = depth(fixedges, 16) out = fixedges h = 720 w = get_w(h) kernel = 'bilinear' denoise = CoolDegrain(out, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = kgf.get_descale_filter(kernel)(depth(luma, 32), w, h) rescale = vdf.fsrcnnx_upscale(depth(descale, 16), None, src.height, 'shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(muvf.SSIM_downsample, kernel='Bicubic')) rescale = core.std.MaskedMerge(luma, rescale, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=95, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=36, depth=6) out = warp deband_mask = lvf.denoise.detail_mask(out, brz_a=2500, brz_b=1500) deband = dbs.f3kpf(out, 17, 36, 36) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband grain = placebo.deband(out, iterations=0, grain=6, chroma=False) grain_mask = core.adg.Mask(out.std.PlaneStats(), 14).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.std.MaskedMerge(out, grain, grain_mask) out = grain rescale_mask = vdf.drm(luma, h, kernel, sw=4, sh=4) ref = fixedges credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask, 0), [(12805, src.num_frames-1)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) src += src[-1] h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') full_stuff = [(313, 1993), (15602, 15757), (19240, 19295)] denoise = hybrid_denoise(src, 0.5, 2) denoise_b = hybrid_denoise(src, 0.6, 7.5, bm3d_args=dict(profile1='high')) deband = lvf.rfs(denoise, denoise_b, [(4002, 4061)]) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) antialias = lvf.rfs(out, _aa_extra(depth(denoise, 16)), [(2794, 2949)]) out = antialias # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband = core.std.MaskedMerge(deband, out, deband_mask) deband_b = rkt.rekt_fast( deband, lambda x: core.neo_f3kdb.Deband( x, 8, 96, 96, 96, sample_mode=1, keep_tv_range=True), 1112, 264, 184, 0) deband = lvf.rfs(deband, deband_b, [(4002, 4061)]) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) grain_b = adptvgrnMod(grain, 0.6, size=1.85, static=False, luma_scaling=4, grain_chroma=False) grain = lvf.rfs(grain, grain_b, [(204, 2049)]) out = grain rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src = [ depth(x, 16) for x in [denoise, rescale_mask, src] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) credit = lvf.rfs( credit, core.std.MaskedMerge(credit, ref, vdf.region_mask(rescale_mask, 1450, 0, 947, 0)), [(33860, 33925)]) credit = lvf.rfs(credit, src, [(0, 203), (2049, 2229), (31768, 33839)]) out = credit smooth = gf.JohnFPS(out[31888:33840], 60000, 1001) clips = [out[:31888], smooth, out[33840:]] vfr = muvf.VFRSplice(clips, 'symphogearg_01_timecode.txt') cfr = core.std.AssumeFPS(vfr, src) out = cfr return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut # Variables opstart, opend = 6161, 8319 eptitle_s, eptitle_e = 8320, 8439 edstart, edend = 31170, 33326 preview_s, preview_e = 33687, src.num_frames - 1 h = 720 w = get_w(h) edges = core.edgefixer.ContinuityFixer(src, *[[2, 1, 1]] * 4) out = depth(edges, 32) ref = hvf.SMDegrain(depth(get_y(out), 16), thSAD=450) denoise = hybrid_denoise(out, 0.35, 1.75, dict(a=2, d=1), dict(ref=depth(ref, 32))) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', 0.055, (1, 1)).std.Median().std.Convolution([*[1] * 9]) descale = core.descale.Debilinear(y, w, h) upscale = vdf.fsrcnnx_upscale( descale, height=h * 2, shader_file=r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='slow', strength=85) antialias = sraa_eedi3(upscale, 9) downscale = muvf.SSIM_downsample(antialias, src.width, src.height, filter_param_a=0, filter_param_b=0) downscale = core.std.MaskedMerge(y, downscale, lineart) merged = vdf.merge_chroma(downscale, out) merged = lvf.rfs(merged, out, [(opstart, opend), (eptitle_s, eptitle_e), (preview_s, preview_e)]) out = depth(merged, 16) detail_dark_mask = detail_dark_mask_func(get_y(out), brz_a=8000, brz_b=6000) detail_light_mask = lvf.denoise.detail_mask(out, 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.Convolution([*[1] * 9]) detail_mask = core.std.Expr([get_y(out), detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') deband = dumb3kdbv2(out, 22, 24) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.1, 0.05, 1.05, sharp=80) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.2, 0.05, 1.15, sharp=80, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = depth(src, 16) rescale_mask = vdf.drm(ref, 720, 'bilinear', mthr=30, sw=0, sh=0) rescale_mask = vdf.region_mask(rescale_mask, *[10] * 4) rescale_mask = hvf.mt_expand_multi(rescale_mask, mode='ellipse', sw=4, sh=4) rescale_mask = rescale_mask.std.Binarize(scale_value( 100, 8, 16)).std.Inflate().std.Convolution([*[1] * 9]) dehalo_ref = gf.MaskedDHA(ref, rx=1.65, ry=1.65, darkstr=0.15, brightstr=1.0, maskpull=48, maskpush=140) dehalo_mask_a = vdf.region_mask(rescale_mask, top=650) dehalo_mask_b = vdf.region_mask(rescale_mask, right=400) credit = out dehalo_range_a = [(25, 205), (518, 612), (2090, 2172), (14449, 14537)] dehalo_range_b = [(3893, 3981)] credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(2197, 2252), (4072, 4129), (4409, 4527), (5390, 5484), (8473, 8603), (8610, 8669), (9826, 9909), (10666, 10713), (12088, 12507), (14943, 15052), (17988, 18136), (18897, 18976), (edstart, edend)] + dehalo_range_a + dehalo_range_b) credit = lvf.rfs( credit, core.std.MaskedMerge(credit, dehalo_ref, dehalo_mask_a, 0), dehalo_range_a) credit = lvf.rfs( credit, core.std.MaskedMerge(credit, dehalo_ref, dehalo_mask_b, 0), dehalo_range_b) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') full_stuff = [(0, 1310), (15484, 15639)] denoise = hybrid_denoise(src, 0.5, 2) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1) upscale = lvf.rfs(upscale, upscale_smooth, [(5534, 5598)]) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) out = grain rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src = [ depth(x, 16) for x in [denoise, rescale_mask, src] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) credit = lvf.rfs(credit, src, [(31707, 33937)]) out = credit smooth = gf.JohnFPS(out[31707:33937 + 1], 60000, 1001) clips = [out[:31707], smooth, out[33937 + 1:]] vfr = muvf.VFRSplice(clips, 'symphogearg_13_timecode.txt') cfr = core.std.AssumeFPS(vfr, src) out = cfr return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src dbzone = (14775, 14846) opstart, opend = 1200, 3356 edstart, edend = 31888, src.num_frames - 1 h = 846 w = get_w(h) cubic_filters = ['catrom', 'mitchell', 'robidoux', 'robidoux sharp'] cubic_filters = [vdf.get_bicubic_params(cf) for cf in cubic_filters] degrain = hybrid_denoise(out, 0.35, 1.2, dict(a=2, d=1)) degrain_b = hybrid_denoise(out, 0.55, 3, dict(a=2, d=1)) degrain = lvf.rfs(degrain, degrain_b, [dbzone]) out = degrain y = get_y(out) y32 = depth(y, 32) lineart = vdf.edge_detect(y32, 'kirsch', 0.055, (1, 1)).std.Median().std.Inflate() descale_clips = [ core.descale.Debicubic(y32, w, h, b, c) for b, c in cubic_filters ] descale = core.std.Expr(descale_clips, 'x y z a min min min x y z max max min') conv = core.std.Convolution(descale, [1, 2, 1, 2, 0, 2, 1, 2, 1]) thr, coef = 0.013, 3 descale_fix = core.std.Expr([descale, conv], f'x y - abs {thr} < y x ?').std.PlaneStats() adapt_mask = core.adg.Mask( descale_fix, 12).std.Invert().std.Expr(f'x 0.5 - {coef} * 0.5 + 0 max 1 min') descale = core.std.MaskedMerge(descale, descale_fix, adapt_mask) upscale = vdf.fsrcnnx_upscale(descale, w * 2, h * 2, r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='zastin', sharpener=partial(gf.DetailSharpen, sstr=1.25, power=4)) aa_strong = sraa_eedi3(upscale, 13, alpha=0.3, beta=0.5, gamma=40) aa = aa_strong down = muvf.SSIM_downsample(aa, src.width, src.height, filter_param_a=0, filter_param_b=0) upscale = depth(core.std.MaskedMerge(y32, down, lineart), 16) merged = vdf.merge_chroma(upscale, out) out = merged # Very bad halo dehalo_a = gf.MaskedDHA(out, rx=2.75, ry=2.75, darkstr=0.25, brightstr=1.0, maskpull=48, maskpush=140) dehalo_a = core.std.MaskedMerge(out, dehalo_a, lvf.src('lapis_05_halomask_1.png', out)) dehalo_b = gf.MaskedDHA(out, rx=2.25, ry=2.25, darkstr=0.25, brightstr=1.0, maskpull=48, maskpush=140) dehalo = lvf.rfs(out, dehalo_a, [(11677, 11765)]) dehalo = lvf.rfs(dehalo, dehalo_b, [(20509, 20690), (21242, 21276), (25834, 25856), (26614, 26648), (26682, 26761), (27685, 27719), (27861, 27895), (27955, 28025)]) out = dehalo y = get_y(out) detail_light_mask = lvf.denoise.detail_mask(y, brz_a=2500, brz_b=1200) pf = iterate(out, core.std.Maximum, 2).std.Convolution([10] * 9, planes=0) diff = core.std.MakeDiff(out, pf) deband = core.f3kdb.Deband(pf, 17, 36, 36, 36, 12, 12, 2, keep_tv_range=True, output_depth=16) deband_b = core.f3kdb.Deband(pf, 17, 48, 48, 48, 12, 12, 2, keep_tv_range=True, output_depth=16) deband = lvf.rfs(deband, deband_b, [dbzone]) deband = core.std.MergeDiff(deband, diff) deband = core.std.MaskedMerge(deband, out, detail_light_mask) out = deband ref = degrain pfed = ref.std.Median().std.Convolution([1] * 9, planes=0) diff_ed = core.std.MakeDiff(ref, pfed) deband_ed = core.f3kdb.Deband(pfed, 22, 30, 30, 30, 32, 32, 2, keep_tv_range=True, output_depth=16) deband_ed = core.std.MergeDiff(deband_ed, diff_ed) out = lvf.rfs(out, deband_ed, [(edstart, edend)]) grain = adptvgrnMod(out, 0.25, 0.15, size=out.height / h, sharp=80, luma_scaling=10, static=True) out = grain # # Restore 1080p stuff ref = src rescale_mask = vdf.drm(ref, h, mthr=65, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(opstart, opend), (3369, 3451)]) credit = lvf.rfs(credit, ref, [(18989, 19108)]) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut h = 720 w = get_w(h) edgesfix = awf.bbmod(src, 1, 1, 1, 1, 48, 500) out = edgesfix clip = depth(out, 32) denoise = hybrid_denoise(clip, 0.45, 1.5) out = denoise luma = get_y(out) line_mask = line_mask_func(luma) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, pscrn=1) antialias = single_rate_antialiasing(upscale, 13, alpha=0.4, beta=0.3, gamma=400, mdis=15).resize.Bilinear( src.width, src.height) rescale = core.std.MaskedMerge(luma, antialias, depth(line_mask, 32)) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) preden = core.knlm.KNLMeansCL(get_y(out), h=0.75, a=2, d=3, device_type='gpu', device_id=0) detail_dark_mask = detail_dark_mask_func(preden, brz_a=8000, brz_b=6000) 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.Convolution([1, 1, 1, 1, 1, 1, 1, 1, 1]) detail_mask = core.std.Expr([preden, detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') custom_mask_a = lvf.src('rezeros2_07_25374-25642.png', detail_mask) custom_mask_a = core.std.Expr([custom_mask_a, detail_mask], 'x y +') deband_a = dbs.f3kpf(out, 17, 36, 42, thr=0.5, elast=2, thrc=0.2) deband_b = placebo.deband(out, 18, 5.5, 2, 0) deband_d = core.neo_f3kdb.Deband(out, 20, 30, 30, 30, 0, 0, 4) deband_e = placebo.deband(out, 18, 8, 2, 0) deband = core.std.MaskedMerge(deband_a, deband_b, preden) deband = lvf.rfs(deband, deband_d, [(1457, 1677), (8414, 8684), (8788, 8915), (9348, 10179), (11325, 11459), (12647, 12857), (13025, 13574), (13874, 13987), (20809, 21076), (23936, 25063), (25219, 25373), (26231, 26530), (26668, 26800), (26818, 27048), (27174, 27454), (27503, 27943), (28492, 28622), (29948, 30563), (30965, 31498), (31624, 32005), (32107, 32325), (32451, 35407), (37171, 37955)]) deband = lvf.rfs(deband, deband_e, [(22116, 22173), (22454, 22459), (38028, 38035)]) deband = core.std.MaskedMerge(deband, out, detail_mask) deband = lvf.rfs(deband, core.std.MaskedMerge(deband_e, deband, custom_mask_a), [(25374, 25642), (25708, 25889)]) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = deband ref, src, src_nced = [ depth(x, 16) for x in [denoise, src, JPBD_NCED.src_cut[221:]] ] credit_mask = vdf.drm(ref, kernel='bilinear', mthr=65) credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask, 0), [(113, 3315), (37171, src.num_frames - 1)]) credit = lvf.rfs(credit, ref, [(3316, 3435), (35408, 35485)]) out = credit src_c, src_nced = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_nced] ] ending_mask = vdf.dcm(out, src_c[EDSTART:EDEND + 1], src_nced[:EDEND - EDSTART + 1], EDSTART, EDEND, 4, 4).std.Inflate() credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, ending_mask), [(EDSTART, EDEND)]) out = credit grain = adptvgrnMod(out, 0.3, 0.15, 1.25, luma_scaling=8, sharp=80, static=False, lo=19) out = grain return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut h = 720 w = get_w(h) edgesfix = awf.bbmod(src, 1, 1, 1, 1, 48, 500) out = edgesfix clip = depth(out, 32) denoise = hybrid_denoise(clip, 0.45, 1.5) out = denoise luma = get_y(out) line_mask = line_mask_func(luma) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, pscrn=1) antialias = single_rate_antialiasing(upscale, 13, alpha=0.2, beta=0.5, gamma=600, mdis=15) scaled = core.resize.Bicubic(antialias, src.width, src.height) rescale = core.std.MaskedMerge(luma, scaled, depth(line_mask, 32)) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) preden = core.knlm.KNLMeansCL(get_y(out), h=0.75, a=2, d=3, device_type='gpu', device_id=0) detail_dark_mask = detail_dark_mask_func(preden, brz_a=8000, brz_b=6000) 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.Convolution([1, 1, 1, 1, 1, 1, 1, 1, 1]) detail_mask = core.std.Expr([preden, detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') custom_mask_a = lvf.src('rezeros2_01_4186-4400.png', detail_mask) custom_mask_a = core.std.Expr([custom_mask_a, detail_mask], 'x y +') deband_a = dbs.f3kpf(out, 17, 36, 42, thr=0.5, elast=2, thrc=0.2) deband_b = placebo.deband(out, 18, 5.5, 2, 0) deband = core.std.MaskedMerge(deband_a, deband_b, preden) deband = lvf.rfs(deband, deband_b, [(4920, 4961), (11027, 11055), (15377, 15596)]) deband = core.std.MaskedMerge(deband, out, detail_mask) deband = lvf.rfs(deband, core.std.MaskedMerge(deband_b, deband, custom_mask_a), [(4186, 4400)]) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = deband ref = depth(denoise, 16) credit_mask = vdf.drm(ref, kernel='bilinear', mthr=65) credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask, 0), [(327, 6130), (34757, 39693), (41102, 41167)]) credit = lvf.rfs(credit, ref, [(8320, 8439), (41168, 41239)]) out = credit grain = adptvgrnMod(out, 0.3, 0.15, 1.25, luma_scaling=8, sharp=80, static=False, lo=19) out = grain return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" def _fsrcnnx(clip: vs.VideoNode, width: int, height: int) -> vs.VideoNode: blank = core.std.BlankClip(clip, format=vs.GRAY16, color=128 << 8) clip = join([clip, blank, blank]) clip = core.placebo.Shader(clip, 'FSRCNNX_x2_56-16-4-1.glsl', clip.width * 2, clip.height * 2) return core.resize.Spline36(get_y(clip), width, height) src = SRC_CUT fe = lvf.ef(src, [1, 1, 1]) fe = depth(fe, 16) h = 864 w = get_w(864) b, c = 0, 1 / 2 luma = get_y(fe) descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c) descale = depth(descale, 16) rescale_a = nnedi3_rpow2(descale, 2, src.width, src.height, nns=4, qual=2, pscrn=2) rescale_b = _fsrcnnx(descale, src.width, src.height) rescale = core.std.Merge(rescale_a, rescale_b, 0.75) rescale_mask = vrf.drm(fe, 864, b=b, c=c, mthr=80, sw=4, sh=4) rescale = core.std.MaskedMerge(rescale, luma, rescale_mask) rescale = lvf.rfs(rescale, luma, [(OPSTART + 483, OPSTART + 721), (OPSTART + 822, OPSTART + 1083)]) merge = core.std.ShufflePlanes([rescale, fe], [0, 1, 2], vs.YUV) antialias = join([lvf.sraa(plane) for plane in split(merge)]) antialias = lvf.rfs(merge, antialias, [(2836, 2870)]) denoise = core.knlm.KNLMeansCL(antialias, a=2, h=0.65, d=0, device_type='gpu', channels='UV') preden = CoolDegrain(denoise, tr=2, thsad=60, blksize=8, overlap=4, plane=4) diff = core.std.MakeDiff(denoise, preden) deband_mask = lvf.denoise.detail_mask(preden, brz_a=3000, brz_b=1500) deband_a = dbs.f3kpf(preden, 17, 42, 42) deband_b = core.placebo.Deband(preden, radius=17, threshold=6, iterations=1, grain=0, planes=1 | 2 | 4) deband = lvf.rfs(deband_a, deband_b, [(2081, 2216), (2450, 2550), (3418, 3452), (3926, 3926)]) deband = core.std.MaskedMerge(deband, preden, deband_mask) deband = core.std.MergeDiff(deband, diff) grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=8) final = depth(grain, 10) return final
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut out = depth(src, 32) # Variables h = 900 w = get_w(h) ref = hvf.SMDegrain(depth(out, 16), thSAD=250) denoise = mvf.BM3D(out, [1, 0.75], radius2=1, ref=depth(ref, 32)) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', 0.085, (1, 2)).std.Median().std.Convolution([*[1]*9]) descale = core.descale.Despline36(y, w, h) upscale = eedi3_upscale(descale) antialias = sraa_eedi3(upscale, 9) downscale = muvf.SSIM_downsample(antialias, src.width, src.height, filter_param_a=-0.5, filter_param_b=0.25) downscale = core.std.MaskedMerge(y, downscale, lineart) merged = vdf.merge_chroma(downscale, out) out = depth(merged, 16) sharp = hvf.LSFmod(out, strength=40, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp detail_light_mask = lvf.denoise.detail_mask(out, brz_a=2500, brz_b=1200) deband = dumb3kdb(out, 17, 36) deband_b = dumb3kdb(out, 24, 64) deband = lvf.rfs(deband, deband_b, [(25600, 25691), (30867, 30938)]) deband = core.std.MaskedMerge(deband, out, detail_light_mask) out = deband ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.125, 0.075, 1.15, sharp=80) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.3, 0.15, 1.2, sharp=80, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = depth(src, 16) rescale_mask = vdf.drm(ref, h, 'spline36', mthr=50, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(3032, 4101), (4290, 5284), (35677, 37282)]) credit = lvf.rfs(credit, ref, [(17688, 17783), (37695, src.num_frames-1)]) out = credit return depth(out, 10).std.Limiter(16<<2, [235<<2, 240<<2])
def do_filter(): """Vapoursynth filtering""" # Source and dithering src = JPBD.src_cut src = depth(src, 16) out = src # Variables opstart, opend = 17310, 19468 edstart, edend = 31889, src.num_frames - 1 h = 846 w = get_w(h) cubic_filters = ['catrom', 'mitchell', 'robidoux', 'robidoux sharp'] cubic_filters = [vdf.get_bicubic_params(cf) for cf in cubic_filters] # Remove the dynamic grain degrain = hybrid_denoise(out, 0.35, 1.2, dict(a=2, d=1)) out = degrain y = get_y(out) y32 = depth(y, 32) lineart = vdf.edge_detect(y32, 'kirsch', 0.055, (1, 1)).std.Median().std.Inflate() # Use multiple descaling kernel for a sharper result descale_clips = [ core.descale.Debicubic(y32, w, h, b, c) for b, c in cubic_filters ] descale = core.std.Expr(descale_clips, 'x y z a min min min x y z max max min') # Fix descaling artifacts (yes even for catrom there's still artifacts) conv = core.std.Convolution(descale, [1, 2, 1, 2, 0, 2, 1, 2, 1]) thr, coef = 0.013, 3.2 descale_fix = core.std.Expr([descale, conv], f'x y - abs {thr} < y x ?').std.PlaneStats() adapt_mask = core.adg.Mask( descale_fix, 12).std.Invert().std.Expr(f'x 0.80 - {coef} * 0.20 + 0 max 1 min') descale = core.std.MaskedMerge(descale, descale_fix, adapt_mask) # Double using eedi3+nnedi, fsrcnnx and a sharpener upscale = vdf.fsrcnnx_upscale(descale, w * 2, h * 2, r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='zastin', sharpener=partial(gf.DetailSharpen, sstr=1.25, power=4)) # Antialiasing by eedi3 aa_strong = sraa_eedi3(upscale, 13, alpha=0.3, beta=0.5, gamma=40) aa = aa_strong # Rescale to 1080p with Bicubic b=0, c=0 AKA Hermite down = muvf.SSIM_downsample(aa, src.width, src.height, filter_param_a=0, filter_param_b=0) upscale = depth(core.std.MaskedMerge(y32, down, lineart), 16) merged = vdf.merge_chroma(upscale, out) out = merged # Very bad halo dehalo = rkt.rekt_fast(out, lambda x: gf.MaskedDHA(x, rx=4.5, ry=4.5, darkstr=0.05, brightstr=1.0, maskpull=48, maskpush=140), left=620, right=440, top=200, bottom=176) mask_halo = get_y(out.std.MakeDiff(dehalo, 0)).rgvs.RemoveGrain(2).std.Median() mask_halo = core.hist.Luma(mask_halo).std.Binarize( 33000).std.Maximum().std.Inflate() mask_halo = vdf.region_mask(mask_halo, left=630, right=440, top=200, bottom=176) blur_dehalo = core.std.BoxBlur(dehalo, hradius=1, vradius=1) dehalo = core.std.MaskedMerge(dehalo, blur_dehalo, mask_halo) out = lvf.rfs(out, dehalo, [(15936, 15973)]) # Deband with prefilter y = get_y(out) detail_light_mask = lvf.denoise.detail_mask(y, brz_a=2500, brz_b=1200) pf = iterate(out, core.std.Maximum, 2).std.Convolution([10] * 9, planes=0) diff = core.std.MakeDiff(out, pf) deband = core.f3kdb.Deband(pf, 17, 36, 36, 36, 12, 12, 2, keep_tv_range=True, output_depth=16) deband = core.std.MergeDiff(deband, diff) deband = core.std.MaskedMerge(deband, out, detail_light_mask) out = deband # Ending part ref = degrain pfed = ref.std.Median().std.Convolution([1] * 9, planes=0) diff_ed = core.std.MakeDiff(ref, pfed) deband_ed = core.f3kdb.Deband(pfed, 22, 30, 30, 30, 32, 32, 2, keep_tv_range=True, output_depth=16) deband_ed = core.std.MergeDiff(deband_ed, diff_ed) out = lvf.rfs(out, deband_ed, [(edstart, edend)]) # Regraining grain = adptvgrnMod(out, 0.25, 0.15, size=out.height / h, sharp=80, luma_scaling=10, static=True) out = grain # Restore 1080p stuff ref = src rescale_mask = vdf.drm(ref, h, mthr=65, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(opstart, opend), (3917, 4024)]) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') opstart, opend = 1392, 3788 edstart, edend = 31889, src.num_frames - 1 full_stuff = [(3801, 3908), (16203, 16358)] denoise = hybrid_denoise(src, 0.5, 2) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1) upscale = lvf.rfs(upscale, upscale_smooth, [(18547, 18586)]) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) antialias = lvf.rfs( out, lvf.sraa(out, 1.65, 9, alpha=0.3, beta=0.45, gamma=240, nrad=3, mdis=25), [(opstart + 840, opstart + 881)]) out = antialias # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband_b = placebo.deband(out, 22, 6, 2) deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)]) deband_c = placebo.deband(out, 17, 8, 3) import kagefunc deband_mask_c = kagefunc.retinex_edgemask(preden) deband_mask_c = iterate(deband_mask_c, core.std.Maximum, 3).std.Binarize(15000).std.Deflate() deband = lvf.rfs(deband, core.std.MaskedMerge(deband_c, deband, deband_mask_c), [(7409, 7600), (7960, 8055)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) out = grain rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src, src_ncop, src_nced = [ depth(x, 16) for x in [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) out = credit src_c, src_ncop, src_nced = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_ncop, src_nced] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], src_ncop[:opend - opstart + 1], opstart, opend, 4, 4).std.Inflate() ending_mask = vdf.dcm(out, src_c[edstart:edend + 1], src_nced[:edend - edstart + 1], edstart, edend, 4, 4).std.Inflate() credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +') credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask), [(opstart, opend), (edstart, edend)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) src += src[-1] src = core.std.FreezeFrames(src, 3130, 3153, 3129) black = src.std.BlankClip().grain.Add(0.2) src = vdf.fade_filter(src, src, black, 3130, 3154) src = depth(src, 16) h = 882 w = get_w(h) kernel = 'lanczos' taps = 5 opstart, opend = 264, 2421 edstart, edend = 31767, 33924 denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise luma = get_y(out) descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h) upscale = vdf.fsrcnnx_upscale(depth(descale, 16), src.width, src.height, '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0)) out = upscale unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5) sharp = hvf.LSFmod(unwarp, strength=90, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) stabilize = stabilization(out, sharp, 2, 1, 8, 16) out = vdf.merge_chroma(stabilize, denoise) antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic) out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise), [(edstart, edend)]) deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 36, 36) deband_b = dbs.f3kpf(out, 17, 56, 56) deband = lvf.rfs(deband, out, [(3149, 3153)]) deband = lvf.rfs(deband, deband_b, [(30213, 30422)]) deband = core.std.MaskedMerge(deband, out, deband_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=18, keep_tv_range=True) out = deband grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14) out = grain rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4) creditless_mask = core.std.Expr([ vdf.dcm(src, src[opstart:opend+1], JPBD_NCOP.src_cut[:opend-opstart+1], opstart, opend, 2, 2).std.Deflate(), vdf.dcm(src, src[edstart:edend+1], JPBD_NCED.src_cut[:edend-edstart+1], edstart, edend, 2, 2).std.Deflate()], 'x y +') credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask, 0), [(opstart+425, opstart+698), (33971, src.num_frames-1)]) credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, creditless_mask, 0), [(opstart, opend), (edstart, edend)]) credit = lvf.rfs(credit, src, [(7670, 7717), (20824, 20871), (26581, 26628)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src += src[-1] ep10 = JPBD_10.src_cut h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') opstart, opend = 2973, 5370 edstart, edend = 31887, src.num_frames - 1 opstart_ep10, opend_ep10 = 768, 3164 full_stuff = [(5449, 5580), (16465, 16620)] # Fix compositing error in the OP op_src, op_10 = src[opstart:opend + 1], ep10[opstart_ep10:opend_ep10 + 1] fix = lvf.rfs(op_src, op_10, [(0, 79), (1035, 1037)]) fix_src = insert_clip(src, fix, opstart) src = depth(fix_src, 32) denoise = hybrid_denoise(src, 0.5, 2) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) antialias = lvf.rfs( out, lvf.sraa(out, 1.65, 9, alpha=0.3, beta=0.45, gamma=240, nrad=3, mdis=25), [(opstart + 840, opstart + 881)]) out = antialias # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband_b = placebo.deband(out, 22, 6, 2) deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)]) deband_c = placebo.deband(deband, 17, 5, 1) deband_c = dbs.f3kbilateral(deband_c, 22, 64, 64) deband = lvf.rfs(deband, deband_c, [(15612, 15695)]) deband_mask2 = vdf.edge_detect( out.knlm.KNLMeansCL(d=2, a=2, h=0.4, device_type='GPU', channels='Y'), 'FDOG', 1100, (8, 1)) deband_mask2 = iterate(deband_mask2, core.std.Deflate, 4) deband_d = placebo.deband(out, 16, 12, 3) deband_d = core.std.MaskedMerge(deband_d, out, deband_mask2) deband = lvf.rfs(deband, deband_d, [(16339, 16542)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) out = grain rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src, src_ncop, src_nced = [ depth(x, 16) for x in [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) out = credit src_c, src_ncop, src_nced = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_ncop, src_nced] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], src_ncop[:opend - opstart + 1], opstart, opend, 4, 4).std.Inflate() ending_mask = vdf.dcm(out, src_c[edstart:edend + 1], src_nced[:edend - edstart + 1], edstart, edend, 4, 4).std.Inflate() credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +') credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask), [(opstart, opend), (edstart, edend)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src h = 900 w = get_w(h) # Remove the grain ref = hvf.SMDegrain(out, tr=1, thSAD=300, plane=4) degrain = mvf.BM3D(out, sigma=[1.5, 1], radius1=1, ref=ref) degrain = insert_clip(degrain, smhdegrain(out[5539:5670], 2, 280), 5539) degrain = insert_clip(degrain, smhdegrain(out[5933:5992], 2, 200), 5933) degrain = insert_clip(degrain, smhdegrain(out[6115:6180], 2, 200), 6115) degrain = insert_clip(degrain, smhdegrain(out[6180:6281], 2, 200), 6180) degrain = insert_clip(degrain, smhdegrain(out[39303:39482], 2, 280), 39303) degrain = insert_clip(degrain, smhdegrain(out[40391:40837], 2, 200), 40391) degrain = insert_clip(degrain, smhdegrain(out[40908:41087], 2, 280), 40908) degrain = insert_clip(degrain, smhdegrain(out[41671:41791], 2, 280), 41671) degrain = insert_clip(degrain, smhdegrain(out[41791:41977], 2, 280), 41791) degrain = insert_clip(degrain, smhdegrain(out[41977:42073], 2, 280), 41977) degrain = insert_clip(degrain, smhdegrain(out[43083:44462], 2, 350), 43083) degrain = lvf.rfs(degrain, out, [(51749, 52387)]) out = depth(degrain, 32) luma = get_y(out) line_mask = vdf.edge_detect(luma, 'kirsch', 0.075, (1, 1)).std.Median().std.Inflate() descale = core.descale.Debilinear(luma, w, h) upscale = eedi3_upscale(descale) antialias = single_rate_antialiasing(upscale, 13, alpha=0.2, beta=0.6, gamma=300, mdis=15).resize.Bicubic( src.width, src.height) rescale = core.std.MaskedMerge(luma, antialias, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) y = get_y(out) detail_light_mask = lvf.denoise.detail_mask(y.std.Median(), brz_a=2500, brz_b=1200) pf = out.std.Convolution([1] * 9).std.Merge(out, 0.45) diffdb = core.std.MakeDiff(out, pf) deband = dumb3kdb(pf, 16, 30) deband_b = dbs.f3kbilateral(pf, 20, 100) deband = lvf.rfs(deband, deband_b, [(43083, 44461)]) deband = core.std.MergeDiff(deband, diffdb) deband = core.std.MaskedMerge(deband, out, detail_light_mask) deband = lvf.rfs(deband, out, [(51749, 52387)]) out = deband sharp = hvf.LSFmod(out, strength=65, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.1, 0.05, 1.00) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.2, 0.05, 1.05, sharp=60, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = src rescale_mask = vdf.drm(ref, h, mthr=65, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(0, 2956), (43104, 45749)]) credit = lvf.rfs(credit, ref, [(45824, 50401), (52388, src.num_frames - 1)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut # Variables opstart, opend = 2038, 4196 eptitle_s, eptitle_e = 4197, 4316 edstart, edend = 31530, 33687 preview_s, preview_e = 33688, src.num_frames - 1 h = 720 w = get_w(h) edges = core.edgefixer.ContinuityFixer(src, *[[2, 1, 1]] * 4) out = depth(edges, 32) ref = hvf.SMDegrain(depth(get_y(out), 16), thSAD=450) denoise = hybrid_denoise(out, 0.35, 1.75, dict(a=2, d=1), dict(ref=depth(ref, 32))) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', 0.055, (1, 1)).std.Median().std.Convolution([*[1] * 9]) descale = core.descale.Debilinear(y, w, h) upscale = vdf.fsrcnnx_upscale( descale, height=h * 2, shader_file=r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='slow', strength=85) antialias = sraa_eedi3(upscale, 9) downscale = muvf.SSIM_downsample(antialias, src.width, src.height, filter_param_a=0, filter_param_b=0) downscale = core.std.MaskedMerge(y, downscale, lineart) merged = vdf.merge_chroma(downscale, out) merged = lvf.rfs(merged, out, [(opstart, opend), (eptitle_s, eptitle_e), (preview_s, preview_e)]) out = depth(merged, 16) detail_dark_mask = detail_dark_mask_func(get_y(out), brz_a=8000, brz_b=6000) detail_light_mask = lvf.denoise.detail_mask(out, 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.Convolution([*[1] * 9]) detail_mask = core.std.Expr([get_y(out), detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') deband = dumb3kdbv2(out, 22, 24) deband = core.std.MaskedMerge(deband, out, detail_mask) deband_b = dumb3kdbv2(out, 24, 64) deband_b = core.std.MaskedMerge(deband_b, out, detail_light_mask) deband = lvf.rfs(deband, deband_b, [(opstart + 414, opstart + 496)]) out = deband ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.1, 0.05, 1.05, sharp=80) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.2, 0.05, 1.15, sharp=80, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = depth(src, 16) rescale_mask = vdf.drm(ref, 720, 'bilinear', mthr=30, sw=0, sh=0) rescale_mask = vdf.region_mask(rescale_mask, *[10] * 4) rescale_mask = hvf.mt_expand_multi(rescale_mask, mode='ellipse', sw=4, sh=4) rescale_mask = rescale_mask.std.Binarize(scale_value( 100, 8, 16)).std.Inflate().std.Convolution([*[1] * 9]) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(8993, 9066), (20104, 20223), (edstart, edend)]) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src += src[-1] # Variables opstart, opend = 8296, 10452 eptitle_s, eptitle_e = 10453, 10572 edstart, edend = 31528, 33685 preview_s, preview_e = 33686, src.num_frames - 1 h = 720 w = get_w(h) edges = core.edgefixer.ContinuityFixer(src, *[[2, 1, 1]] * 4) out = depth(edges, 32) ref = hvf.SMDegrain(depth(get_y(out), 16), thSAD=450) denoise = hybrid_denoise(out, 0.35, 1.75, dict(a=2, d=1), dict(ref=depth(ref, 32))) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', 0.055, (1, 1)).std.Median().std.Convolution([*[1] * 9]) descale = core.descale.Debilinear(y, w, h) upscale = vdf.fsrcnnx_upscale( descale, height=h * 2, shader_file=r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='slow', strength=85) antialias = sraa_eedi3(upscale, 9) downscale = muvf.SSIM_downsample(antialias, src.width, src.height, filter_param_a=0, filter_param_b=0) downscale = core.std.MaskedMerge(y, downscale, lineart) merged = vdf.merge_chroma(downscale, out) merged = lvf.rfs(merged, out, [(opstart, opend), (eptitle_s, eptitle_e), (preview_s, preview_e)]) out = depth(merged, 16) detail_dark_mask = detail_dark_mask_func(get_y(out), brz_a=8000, brz_b=6000) detail_light_mask = lvf.denoise.detail_mask(out, 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.Convolution([*[1] * 9]) detail_mask = core.std.Expr([get_y(out), detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') deband = dumb3kdbv2(out, 22, 24) deband = core.std.MaskedMerge(deband, out, detail_mask) deband_b = dumb3kdbv2(out, 24, 64) deband_b = core.std.MaskedMerge(deband_b, out, detail_light_mask) deband = lvf.rfs(deband, deband_b, [(opstart + 414, opstart + 496)]) out = deband ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.1, 0.05, 1.05, sharp=80) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.2, 0.05, 1.15, sharp=80, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = depth(src, 16) rescale_mask = vdf.drm(ref, 720, 'bilinear', mthr=30, sw=0, sh=0) rescale_mask = vdf.region_mask(rescale_mask, *[10] * 4) rescale_mask = hvf.mt_expand_multi(rescale_mask, mode='ellipse', sw=4, sh=4) rescale_mask = rescale_mask.std.Binarize(scale_value( 100, 8, 16)).std.Inflate().std.Convolution([*[1] * 9]) dehalo_ref = gf.MaskedDHA(ref, rx=1.65, ry=1.65, darkstr=0.15, brightstr=1.0, maskpull=48, maskpush=140) dehalo_mask_a = vdf.region_mask(rescale_mask, top=650, right=200) credit = out dehalo_range_a = [(18, 130), (1291, 1355), (14691, 14846), (15126, 15189)] credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(131, 220), (400, 505), (817, 899), (1766, 1809), (1925, 2041), (4033, 4116), (4342, 4453), (4964, 5031), (6422, 6515), (7848, 7978), (10606, 10728), (11619, 11701), (15339, 15457), (edstart, edend)] + dehalo_range_a) credit = lvf.rfs( credit, core.std.MaskedMerge(credit, dehalo_ref, dehalo_mask_a, 0), dehalo_range_a) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src += src[-1] # Variables opstart, opend = 2206, 4362 eptitle_s, eptitle_e = 4363, 4482 edstart, edend = 31528, 33685 preview_s, preview_e = 33686, src.num_frames - 1 h = 720 w = get_w(h) edges = core.edgefixer.ContinuityFixer(src, *[[2, 1, 1]] * 4) out = depth(edges, 32) ref = hvf.SMDegrain(depth(get_y(out), 16), thSAD=450) denoise = hybrid_denoise(out, 0.35, 1.75, dict(a=2, d=1), dict(ref=depth(ref, 32))) out = denoise y = get_y(out) lineart = vdf.edge_detect(y, 'FDOG', 0.055, (1, 1)).std.Median().std.Convolution([*[1] * 9]) descale = core.descale.Debilinear(y, w, h) upscale = vdf.fsrcnnx_upscale( descale, height=h * 2, shader_file=r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='slow', strength=85) antialias = sraa_eedi3(upscale, 9) downscale = muvf.SSIM_downsample(antialias, src.width, src.height, filter_param_a=0, filter_param_b=0) downscale = core.std.MaskedMerge(y, downscale, lineart) merged = vdf.merge_chroma(downscale, out) merged = lvf.rfs(merged, out, [(opstart, opend), (eptitle_s, eptitle_e), (preview_s, preview_e)]) out = depth(merged, 16) detail_dark_mask = detail_dark_mask_func(get_y(out), brz_a=8000, brz_b=6000) detail_light_mask = lvf.denoise.detail_mask(out, 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.Convolution([*[1] * 9]) detail_mask = core.std.Expr([get_y(out), detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') deband = dumb3kdbv2(out, 22, 24) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband ref = get_y(out).std.PlaneStats() adgmask_a = core.adg.Mask(ref, 30) adgmask_b = core.adg.Mask(ref, 12) stgrain = sizedgrn(out, 0.1, 0.05, 1.05, sharp=80) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b) stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert()) dygrain = sizedgrn(out, 0.2, 0.05, 1.15, sharp=80, static=False) dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a) grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain)) out = grain ref = depth(src, 16) rescale_mask = vdf.drm(ref, 720, 'bilinear', mthr=30, sw=0, sh=0) rescale_mask = vdf.region_mask(rescale_mask, *[10] * 4) rescale_mask = hvf.mt_expand_multi(rescale_mask, mode='ellipse', sw=4, sh=4) rescale_mask = rescale_mask.std.Binarize(scale_value( 100, 8, 16)).std.Inflate().std.Convolution([*[1] * 9]) dehalo_ref = gf.MaskedDHA(ref, rx=1.65, ry=1.65, darkstr=0.15, brightstr=1.0, maskpull=48, maskpush=140) dehalo_mask_b = vdf.region_mask(rescale_mask, right=400) credit = out dehalo_range_b = [(18, 101), (16853, 16917)] credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(126, 160), (1722, 1761), (7749, 7795), (8189, 8232), (8445, 8504), (9020, 9067), (9727, 9768), (12430, 12520), (12876, 12971), (13608, 13646), (15833, 15879), (20526, 20586), (20783, 20823), (21193, 21239), (23812, 23854), (24018, 24059), (edstart, edend)] + dehalo_range_b) credit = lvf.rfs( credit, core.std.MaskedMerge(credit, dehalo_ref, dehalo_mask_b, 0), dehalo_range_b) out = credit return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') opstart, opend = 768, 3164 edstart, edend = 30571, 32728 full_stuff = [(3189, 3296), (13806, 13961)] denoise = hybrid_denoise(src, 0.5, 2) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point) upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1) upscale = lvf.rfs(upscale, upscale_smooth, [(5534, 5598)]) antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18) scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic') rescale = core.std.MaskedMerge(luma, scaled, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) antialias = lvf.rfs( out, lvf.sraa(out, 1.65, 9, alpha=0.3, beta=0.45, gamma=240, nrad=3, mdis=25), [(opstart + 840, opstart + 881)]) out = antialias # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp dering = gf.HQDeringmod(out, thr=16, darkthr=0.1) out = dering warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8) out = warp preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y') deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4) deband = dbs.f3kpf(out, 17, 42, 42) deband_b = placebo.deband(out, 22, 6, 2) deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +') grain = core.grain.Add(out, 0.2, constant=True) grain = core.std.MaskedMerge(out, grain, adg_mask, 0) out = grain # Fix random productions errors # AAAAAAAAAAAAARGHHHHHHHHHHHHHHH WHYYYY THE STUDIO DID THIS ncop = JPBD_NCOP.src_cut ncop = lvf.rfs(ncop, depth(src, 8)[opstart:opend + 1], [(0, 79), (1035, 1037)]) rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4) ref, rescale_mask, src, src_ncop, src_nced = [ depth(x, 16) for x in [denoise, rescale_mask, src, ncop, JPBD_NCED.src_cut] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) out = credit src_c, src_ncop, src_nced = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_ncop, src_nced] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], src_ncop[:opend - opstart + 1], opstart, opend, 4, 4).std.Inflate() ending_mask = vdf.dcm(out, src_c[edstart:edend + 1], src_nced[:edend - edstart + 1], edstart, edend, 4, 4).std.Inflate() credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +') credit_mask = core.std.FreezeFrames(credit_mask, opstart + 1685, opstart + 1699, opstart + 1684) credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask), [(opstart, opend), (edstart, edend)]) out = credit return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) out = src opstart, opend = 59, 1630 edstart, edend = 30776, src.num_frames-1 h = 846 w = get_w(h) cubic_filters = ['catrom', 'mitchell', 'robidoux', 'robidoux sharp'] cubic_filters = [vdf.get_bicubic_params(cf) for cf in cubic_filters] degrain = hybrid_denoise(out, 0.35, 1.2, dict(a=2, d=1)) out = degrain y = get_y(out) y32 = depth(y, 32) lineart = vdf.edge_detect(y32, 'kirsch', 0.055, (1, 1)).std.Median().std.Inflate() descale_clips = [core.descale.Debicubic(y32, w, h, b, c) for b, c in cubic_filters] descale = core.std.Expr(descale_clips, 'x y z a min min min x y z max max min') conv = core.std.Convolution(descale, [1, 2, 1, 2, 0, 2, 1, 2, 1]) thr, coef = 0.013, 3 descale_fix = core.std.Expr([descale, conv], f'x y - abs {thr} < y x ?').std.PlaneStats() adapt_mask = core.adg.Mask(descale_fix, 12).std.Invert().std.Expr(f'x 0.5 - {coef} * 0.5 + 0 max 1 min') descale = core.std.MaskedMerge(descale, descale_fix, adapt_mask) upscale = vdf.fsrcnnx_upscale(descale, w*2, h*2, r'shaders\FSRCNNX_x2_56-16-4-1.glsl', upscaler_smooth=eedi3_upscale, profile='zastin', sharpener=partial(gf.DetailSharpen, sstr=1.25, power=4)) aa_strong = sraa_eedi3(upscale, 13, alpha=0.3, beta=0.5, gamma=40) aa = aa_strong down = muvf.SSIM_downsample(aa, src.width, src.height, filter_param_a=0, filter_param_b=0) upscale = depth( core.std.MaskedMerge(y32, down, lineart), 16 ) merged = vdf.merge_chroma(upscale, out) out = merged y = get_y(out) detail_light_mask = lvf.denoise.detail_mask(y, brz_a=2500, brz_b=1200) pf = iterate(out, core.std.Maximum, 2).std.Convolution([10] * 9, planes=0) diff = core.std.MakeDiff(out, pf) deband = core.f3kdb.Deband(pf, 17, 36, 36, 36, 12, 12, 2, keep_tv_range=True, output_depth=16) deband = core.std.MergeDiff(deband, diff) deband = core.std.MaskedMerge(deband, out, detail_light_mask) out = deband grain = adptvgrnMod(out, 0.25, 0.15, size=out.height/h, sharp=80, luma_scaling=10, static=True) out = grain # # Restore 1080p stuff ref = src rescale_mask = vdf.drm(ref, h, mthr=65, sw=4, sh=4) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask, 0), [(opstart, opend), (1634, 1728), (edstart, edend)]) credit = lvf.rfs(credit, ref, [(15200, 15271)]) out = credit return depth(out, 10).std.Limiter(16<<2, [235<<2, 240<<2])
def do_filter(): """Vapoursynth filtering""" src = WEB.src_cut src = src.std.AssumeFPS(src) src = depth(src, 16) out = src denoise = hvf.SMDegrain(out, tr=3, thSAD=150, thSADC=150) out = denoise dering = hvf.EdgeCleaner(out, 20, smode=1, hot=True) out = dering y = get_y(out) taps = 5 w, h = 1600, 900 descale = core.descale.Delanczos(depth(y, 32), w, h, taps) upscale = vdf.nnedi3_upscale(descale, pscrn=1, correct_shift=False) rescale = core.resize.Bicubic(upscale, 1920, 1080, src_left=.5, src_top=.5, filter_param_a=-.5, filter_param_b=.25) out = depth(rescale, 16) sharp = hvf.LSFmod(out, strength=90, Smode=3, edgemode=0, source=get_y(denoise)) out = sharp merge = vdf.merge_chroma(out, denoise) out = merge detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1200) pref = out.std.Convolution([1, 2, 1, 2, 4, 2, 1, 2, 1]).std.Convolution([1] * 9) deband1 = vdf.dumb3kdb(pref, 17, 45, grain=16, seed=333) deband2 = vdf.dumb3kdb(pref, 15, 49, grain=16, sample_mode=4, use_neo=True, blur_first=False, seed=333) th_lo, th_hi = 20 << 8, 26 << 8 strength = '{1} x - {1} {0} - /'.format(th_lo, th_hi) deband = core.std.Expr([pref, deband1, deband2], [ f'x {th_lo} > x {th_hi} < and z ' + strength + ' * y 1 ' + strength + f' - * + x {th_lo} <= z y ? ?', 'y' ]) deband = core.std.MergeDiff(deband, out.std.MakeDiff(pref)) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband grain = adptvgrnMod(out, 0.3, 0.15, size=1.2, luma_scaling=16, hi=[128, 240], protect_neutral=False, seed=333) out = grain ref = denoise rescale_mask = vdf.drm(src, h, 'spline36', mthr=80).std.Maximum() credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask), [(2374, 4530), (4544, 4648), (4701, 4762), (30070, 30210), (31266, 33422)]) credit = lvf.rfs(credit, ref, [(33423, 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 += src[-1] * 2 h = 720 w = get_w(h) edgesfix = awf.bbmod(src, 1, 1, 1, 1, 48, 500) out = edgesfix clip = depth(out, 32) denoise = hybrid_denoise(clip, 0.45, 1.5) out = denoise luma = get_y(out) line_mask = line_mask_func(luma) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, pscrn=1) antialias = single_rate_antialiasing(upscale, 13, alpha=0.4, beta=0.3, gamma=400, mdis=15).resize.Bilinear( src.width, src.height) rescale = core.std.MaskedMerge(luma, antialias, depth(line_mask, 32)) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) preden = core.knlm.KNLMeansCL(get_y(out), h=0.75, a=2, d=3, device_type='gpu', device_id=0) detail_dark_mask = detail_dark_mask_func(preden, brz_a=8000, brz_b=6000) 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.Convolution([1, 1, 1, 1, 1, 1, 1, 1, 1]) detail_mask = core.std.Expr([preden, detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') deband_a = dbs.f3kpf(out, 17, 36, 42, thr=0.5, elast=2, thrc=0.2) deband_b = placebo.deband(out, 18, 5.5, 2, 0) deband = core.std.MaskedMerge(deband_a, deband_b, preden) deband = core.std.MaskedMerge(deband, out, detail_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = deband ref, src = [depth(x, 16) for x in [denoise, src]] credit_mask = vdf.drm(ref, kernel='bilinear', mthr=65) credit = out credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, credit_mask, 0), [(0, 1380), (36437, 38719)]) credit = lvf.rfs(credit, ref, [(20810, 20881), (38720, src.num_frames - 1)]) out = credit grain = adptvgrnMod(out, 0.3, 0.15, 1.25, luma_scaling=8, sharp=80, static=False, lo=19) out = grain return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut h = 720 w = get_w(h) edgesfix = awf.bbmod(src, 1, 1, 1, 1, 48, 500) out = edgesfix clip = depth(out, 32) denoise = hybrid_denoise(clip, 0.45, 1.5) out = denoise luma = get_y(out) line_mask = line_mask_func(luma) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, pscrn=1) antialias = single_rate_antialiasing(upscale, 13, alpha=0.2, beta=0.5, gamma=600, mdis=15) scaled = core.resize.Bicubic(antialias, src.width, src.height) rescale = core.std.MaskedMerge(luma, scaled, depth(line_mask, 32)) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) preden = core.knlm.KNLMeansCL(get_y(out), h=0.75, a=2, d=3, device_type='gpu', device_id=0) detail_dark_mask = detail_dark_mask_func(preden, brz_a=8000, brz_b=6000) 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.Convolution([1, 1, 1, 1, 1, 1, 1, 1, 1]) detail_mask = core.std.Expr([preden, detail_mask_grow, detail_mask], f'x {32<<8} < y z ?') op_mask = mask_opening(out) op_mask = iterate(op_mask, core.std.Deflate, 2) deband_a = dbs.f3kpf(out, 17, 36, 42, thr=0.5, elast=2, thrc=0.2) deband_b = placebo.deband(out, 18, 5.5, 2, 0) deband_c = placebo.deband(out, 22, 10, 3, 0) deband = core.std.MaskedMerge(deband_a, deband_b, preden) deband = core.std.MaskedMerge(deband, out, detail_mask) deband = lvf.rfs(deband, core.std.MaskedMerge(deband_c, deband, op_mask), [(OPSTART + 0, OPSTART + 38)]) deband = lvf.rfs(deband, deband_b, [(OPSTART + 236, OPSTART + 284)]) deband = lvf.rfs(deband, deband_c, [(OPSTART + 1934, OPSTART + 1944)]) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = deband ref, src, src_ncop = [ depth(x, 16) for x in [denoise, src, JPBD_NCOP.src_cut] ] credit_mask = vdf.drm(ref, kernel='bilinear', mthr=65) credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask, 0), [(0, 3164)]) credit = lvf.rfs(credit, ref, [(34693, 34764)]) out = credit src_c, src_ncop = [ c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu') for c in [src, src_ncop] ] opening_mask = vdf.dcm(out, src_c[OPSTART:OPEND + 1], src_ncop[:OPEND - OPSTART + 1], OPSTART, OPEND, 4, 4).std.Inflate() credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, opening_mask), [(OPSTART, OPEND)]) out = credit grain = adptvgrnMod(out, 0.3, 0.15, 1.25, luma_scaling=8, sharp=80, static=False, lo=19) out = grain return depth(out, 10)