def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) h = 828 w = get_w(h) kernel = 'bilinear' 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)(depth(luma, 32), w, h) upscale = vdf.nnedi3_upscale(depth(descale, 16), correct_shift=False, pscrn=4) \ .resize.Bicubic(src.width, src.height, src_left=.5, src_top=.5, filter_param_a=0, filter_param_b=0) out = vdf.merge_chroma(upscale, out) deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 24, 24) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14) out = grain 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 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 mark_descale( clip: vs.VideoNode, height: int, kernel: str = "bicubic", b: float = 1 / 3, c: float = 1 / 3, taps: int = 5, debug: bool = False, ) -> vs.VideoNode: """ Evaluates PlaneStats for a rescaled clip vs the original only operates on luma for now """ y = vsutil.get_y(clip) descale = get_descale_filter(kernel, b=b, c=c, taps=taps)(y, vsutil.get_w(height), height) rescale = get_scale_filter(kernel, b=b, c=c, taps=taps)(descale, clip.width, clip.height, format=y.format) mask = core.std.Expr([y, rescale], "x y - abs dup 0.015 > swap 0 ?") mask = mask.std.PlaneStats() def copy_scale_error(n, f): f_out = f[0].copy() f_out.props["ScaleError"] = f[1].props.PlaneStatsAverage return f_out descale = core.std.ModifyFrame(clip=descale, clips=[descale, mask], selector=copy_scale_error) def write_scale_error(n, f, clip): return clip.text.Text(f"{f.props.ScaleError:.2e}") if debug: descale = core.std.FrameEval(descale, partial(write_scale_error, clip=descale), prop_src=descale) return descale
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 = vdf.merge_chroma(upscale, out) 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 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 = 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)