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') 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) # 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 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""" src = JPBD.src_cut src = depth(src, 32) ed = (30089, 32247) denoise = kgf.hybriddenoise(src, 0.45, 2) out = denoise h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('mitchell') luma = get_y(out) line_mask = shf.edge_mask_simple(luma, 'FDOG', 0.08, (1, 1)) descale = core.descale.Debicubic(luma, w, h, b, c) upscale = shf.fsrcnnx_upscale(descale, src.height, 'shaders/FSRCNNX_x2_56-16-4-1.glsl', partial(SSIM_downsample, kernel='Bicubic')) rescale = core.std.MaskedMerge(luma, upscale, line_mask) merged = vdf.merge_chroma(rescale, denoise) out = depth(merged, 16) mask = shf.detail_mask(out, (10000, 4000), (12000, 3500), [(2, 2), (2, 2)], sigma=[50, 250, 400], upper_thr=0.005) deband = dbs.f3kpf(out, 17, 42, 48, thrc=0.4) deband = core.std.MaskedMerge(deband, out, mask) deband_b = placebo.deband(out, 27, 8, 3, 0) deband = lvf.rfs(deband, deband_b, [(3404, 3450)]) deband_c = shf.deband_stonks(out, 20, 8, 3, shf.edge_mask_simple(out, 'prewitt', 2500, (8, 1))) deband = lvf.rfs(deband, deband_c, [(5642, 5784), (6222, 6479), (7798, 8073), (8133, 8256), (9699, 9817)]) deband_d = placebo.deband(out, 17, 7.5, 1, 0) deband_d = core.std.MaskedMerge(deband_d, out, mask) deband = lvf.rfs(deband, deband_d, [(8074, 8132), (8711, 8766), (12267, 12433), (28468, 28507)]) grain = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = grain grain = adptvgrnMod(out, 0.3, size=4/3, sharp=55, luma_scaling=14, grain_chroma=False) out = grain ending = shinyori_ed01.filtering(src, *ed) final = lvf.rfs(out, ending, [ed]) return depth(final, 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 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 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""" # 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""" def _single_rate_aa(clip): nnargs = dict(nsize=0, nns=2, qual=1) eeargs = dict(alpha=0.2, beta=0.4, gamma=250, nrad=3, mdis=20) clip = core.eedi3m.EEDI3(clip, 0, 0, 0, sclip=core.nnedi3.nnedi3( clip, 0, 0, 0, **nnargs), **eeargs).std.Transpose() clip = core.eedi3m.EEDI3(clip, 0, 0, 0, sclip=core.nnedi3.nnedi3( clip, 0, 0, 0, **nnargs), **eeargs).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, height=540, 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, [(3368, 3451)]) # Regular filterchain op, ed, eyec = (1200, 3356), (18989, 19108), (31888, 34046) opstart = op[0] denoise = CoolDegrain(src, tr=1, thsad=36, blksize=8, overlap=4, plane=4) h = 846 w = get_w(h) b, c = vdf.get_bicubic_params('mitchell') luma = get_y(denoise) descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c) upscale = vdf.fsrcnnx_upscale(depth(descale, 16), descale.height * 2, "Shaders/FSRCNNX_x2_56-16-4-1.glsl", core.resize.Point) sraa = _single_rate_aa(upscale) rescaled = core.resize.Bicubic(sraa, src.width, src.height, filter_param_a=0, filter_param_b=0) dering = core.std.MaskedMerge( rescaled, core.bilateral.Gaussian(rescaled, 0.3), hvf.HQDeringmod(rescaled, incedge=True, show=True)) rescaled = lvf.rfs(rescaled, dering, [(opstart, opstart + 498)]) merged = vdf.merge_chroma(rescaled, src) out = merged dehalo = fine_dehalo(out, rx=2.2, darkstr=0, brightstr=1, contra=True, useMtEdge=True) out = dehalo 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, [eyec, ed]) out = credit thr = 7000 line_mask = gf.EdgeDetect( out, 'FDOG').std.Median().std.Expr(f'x {thr} < x x 3 * ?') deband = dbs.f3kpf(out, 17, 36, 36) deband_b = dbs.f3kbilateral(out, 20, 64, 64) deband = lvf.rfs(deband, deband_b, [(14775, 14846)]) deband = core.std.MaskedMerge(deband, out, line_mask) out = deband dedimm = gf.Tweak(out, sat=1.1, cont=1.1) dedimm = lvf.rfs(out, dedimm, [(12957, 13061)]) out = dedimm grain = core.grain.Add(out, 0.1) out = grain return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 32) h = 720 w = get_w(h) # getnative script returns 0.2 0.5 as best combo but it introduces too much halos. # I think it's plain mitchell but robidoux is good too and very slightly sharp. b, c = vdf.get_bicubic_params('robidoux') opstart = 0 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, show=False) 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') 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, 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 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 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 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""" def _rescale(clip: vs.VideoNode, dx: int, dy: int): eeargs = dict(pscrn=2, alpha=0.3, beta=0.4, gamma=500, nrad=3, mdis=18) ux = clip.width * 2 uy = clip.height * 2 clip = iaa.eedi3_instance(clip.std.Transpose(), nnedi3Mode='opencl', **eeargs) clip = core.resize.Bicubic(clip, height=dx, src_top=-0.5, src_height=ux, filter_param_a=0, filter_param_b=0) clip = iaa.eedi3_instance(clip.std.Transpose(), nnedi3Mode='opencl', **eeargs) return core.resize.Bicubic(clip, height=dy, src_top=-0.5, src_height=uy, filter_param_a=0, filter_param_b=0) # 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 + src_wkn[-1] # Dehardsubbing # comp = lvf.comparison.stack_compare(src_funi, src_wkn, height=720, 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, [(4018, 4138)]) # Regular filterchain op, ed, eyec = (1534, 3692), (16280, 16399), (31888, 34046) opstart = op[0] h = 846 w = get_w(h) b, c = vdf.get_bicubic_params('mitchell') 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 = _rescale(depth(descale, 16), src.width, src.height) rescaled = core.std.MaskedMerge(luma, rescaled, line_mask) dering = core.std.MaskedMerge( rescaled, core.bilateral.Gaussian(rescaled, 0.3), hvf.HQDeringmod(rescaled, incedge=True, show=True)) rescaled = lvf.rfs(rescaled, dering, [(opstart, opstart + 498)]) 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, [eyec, ed]) out = credit deband = dbs.f3kpf(out, 17, 36, 36) deband = core.std.MaskedMerge(deband, out, line_mask) dedimm = gf.Tweak(deband, sat=1.28, cont=1.28) dedimm = lvf.rfs(deband, dedimm, [(1112, 1159), (7764, 7780), (9436, 9514), (20607, 20755), (26972, 27006)]) grain = core.grain.Add(dedimm, 0.1) return depth(grain, 10)
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 = 744, 3140 opstart_ep10, opend_ep10 = 768, 3164 full_stuff = [(3145, 3269), (18289, 18444), (29158, 33410)] border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 2), right=1212) fixstudioshit = lvf.rfs(src, border, [31759]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1212) fixstudioshit = lvf.rfs(fixstudioshit, border, [31760]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1274) fixstudioshit = lvf.rfs(fixstudioshit, border, [(31761, 31762)]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1300) fixstudioshit = lvf.rfs(fixstudioshit, border, [31763]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1322) fixstudioshit = lvf.rfs(fixstudioshit, border, [31764]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1342) fixstudioshit = lvf.rfs(fixstudioshit, border, [31765]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1356) fixstudioshit = lvf.rfs(fixstudioshit, border, [31766]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1368) fixstudioshit = lvf.rfs(fixstudioshit, border, [31767]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1376) fixstudioshit = lvf.rfs(fixstudioshit, border, [31768]) border = rkt.rekt_fast(src, lambda x: core.fb.FillBorders(x, 0, 0, 0, 6), right=1382) fixstudioshit = lvf.rfs(fixstudioshit, border, [(31769, 31793)]) src = fixstudioshit # 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(out, 17, 6, 3) deband = lvf.rfs(deband, deband_c, [(12529, 12615)]) deband_d = placebo.deband(out, 10, 3, 1) deband = lvf.rfs(deband, deband_d, [(21077, 21304), (22141, 22278), (22861, 22944), (29354, 29425), (33555, 33614)]) 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 = [ depth(x, 16) for x in [denoise, rescale_mask, src, JPBD_NCOP.src_cut] ] credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask), full_stuff) 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 return depth(out, 10)
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 ep11 = JPBD_11.src_cut opstart = 0 opstart_ep11, opend_ep11 = 744, 3140 h = 720 w = get_w(h) b, c = vdf.get_bicubic_params('robidoux') # Fix compositing error in the OP ncop, op_11 = src, ep11[opstart_ep11:opend_ep11 + 1] fix = lvf.rfs(ncop, op_11, [(0, 79), (1035, 1037)]) src = depth(fix, 32) def denoise_and_rescale(clip): denoise = hybrid_denoise(clip, 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) return depth(merged, 16) out = denoise_and_rescale(src) to_zoom = denoise_and_rescale(depth(JPBD_11.src_cut[8590:8605], 32)) zoom = core.std.FrameEval(to_zoom, partial(_zoom_prog, clip=to_zoom)) out = insert_clip(out, zoom, 1685) 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, show=False) 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') 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, 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 return depth(out, 10)
def do_filter(): """Vapoursynth filtering""" # Source and dithering src = JPBD.src_cut src = depth(src, 16) out = src # Variables 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 # 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 # Regraining grain = adptvgrnMod(out, 0.25, 0.15, size=out.height / h, sharp=80, luma_scaling=10, static=True) out = grain 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, 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""" def _nnedi3(clip: vs.VideoNode, factor: float, args: dict) -> vs.VideoNode: upscale = clip.std.Transpose().nnedi3cl.NNEDI3CL(0, True, **args) \ .std.Transpose().nnedi3cl.NNEDI3CL(0, True, **args) sraa = _sraa(upscale, dict(nsize=3, nns=3, qual=1, pscrn=1), dict(alpha=0.3, beta=0.4, gamma=500, nrad=3, mdis=18)) 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) def _sraa(clip: vs.VideoNode, nnargs: dict, eeargs: dict) -> vs.VideoNode: def _nnedi3(clip): return clip.nnedi3.nnedi3(0, False, **nnargs) def _eedi3(clip, sclip): return clip.eedi3m.EEDI3(0, False, **eeargs, sclip=sclip) clip = _eedi3(clip, _nnedi3(clip)).std.Transpose() clip = _eedi3(clip, _nnedi3(clip)).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, height=720, 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, [(3796, 3892)]) # Regular filterchain op, ed, eyec = (1630, 3788), (31888, 34046), (16400, 16519) 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, [eyec, ed]) out = credit deband = dbs.f3kpf(out, 17, 36, 36) deband = core.std.MaskedMerge(deband, out, line_mask) dedimm = gf.Tweak(deband, sat=1.15, cont=1.15) dedimm = lvf.rfs(deband, dedimm, [(21093, 21211)]) grain = core.grain.Add(dedimm, 0.2) return depth(grain, 10)