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""" 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 ?') deband_a = dbs.f3kpf(out, 16, 30, 42, thr=0.5, elast=2, thrc=0.2) deband_b = placebo.deband(out, 18, 5.5, 2, 4) deband = core.std.MaskedMerge(deband_a, deband_b, preden) deband = core.std.MaskedMerge(deband_a, out, detail_mask) deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=24) out = deband grain = adptvgrnMod(out, 0.4, 0.3, 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 src = depth(src, 16) denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4) out = denoise deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 30, 30) deband_b = dbs.f3kpf(out, 17, 84, 84) deband_c = placebo.deband(out, 32, 12, 3, 4) deband = lvf.rfs(deband, deband_b, [(2090, 2107)]) deband = lvf.rfs(deband, deband_c, [(2108, src.num_frames - 1)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband 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 = 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 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""" src = JPBD.src_cut out = depth(src, 16) denoise = hvf.SMDegrain(out, thSAD=150, thSADC=75) out = denoise y = get_y(out) lineart = core.std.Sobel(y).std.Binarize( 75 << 8).std.Maximum().std.Inflate() antialias = lvf.sraa(y, 1.5, 9, downscaler=core.resize.Spline36, gamma=200, mdis=18) sharp = hvf.LSFmod(antialias, strength=95, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) minmax = core.std.Expr([y, sharp, antialias], 'x y z min max y z max min') merge = core.std.MaskedMerge(y, minmax, lineart) out = vdf.merge_chroma(merge, out) y = get_y(out) detail_dark_mask = detail_dark_mask_func(y, brz_a=10000, brz_b=9000) detail_light_mask = lvf.denoise.detail_mask(y, 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([y, detail_mask_grow, detail_mask], f'x {28<<8} < y z ?') deband = dbs.f3kpf(out, 17, 24, 24) deband = core.std.MaskedMerge(deband, out, detail_mask) import placebo deband_b = core.std.MaskedMerge(placebo.deband(deband, 20, 6, 2, 2), out, detail_light_mask) deband = lvf.rfs(deband, deband_b, [(31055, 31119)]) out = deband grain = adptvgrnMod(out, 0.2, 0.1, 1.25, luma_scaling=14, sharp=80, static=False, lo=19, hi=[192, 240]) out = grain return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
def do_filter(): """Vapoursynth filtering""" src = JPBD.src_cut src = depth(src, 16) 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, 30, 30) deband_b = placebo.deband(out, 24, 8, 5) deband_c = dbs.f3kpf(out, 17, 54, 48) deband = lvf.rfs(deband, deband_b, [(0, 105)]) deband = lvf.rfs(deband, deband_c, [(25188, 25220)]) 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 credit_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4) credit = lvf.rfs(out, core.std.MaskedMerge(out, src, credit_mask, 0), [(196, 2107), (11352, 11416), (30402, 30602), (31431, 33501), (33837, src.num_frames - 1)]) credit = lvf.rfs(credit, src, [(3856, 3897)]) 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) # 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(): 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 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""" src = JPBD.src_cut h = 720 w = get_w(h) fixedges = lvf.ef(src, [2, 1, 1]) out = depth(fixedges, 16) denoise = hybrid_denoise(out, 0.65, 3) denoise_b = hybrid_denoise(out, 0.3, 1) denoise_c = hvf.KNLMeansCL(out, 5, 3, 6, 2, device_type='gpu', device_id=0) denoise = lvf.rfs(denoise, denoise_b, [(75124, 82725)]) denoise = vdf.fade_filter(denoise, denoise, denoise_c, 82726, 82790) denoise = lvf.rfs(denoise, denoise_c, [(82791, src.num_frames - 1)]) diff = core.std.MakeDiff(out, denoise) out = denoise luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 7000, (1, 1)) line_mask = iterate(line_mask, core.std.Median, 4) # Not FSRCNNX this time )^: descale = depth(core.descale.Debilinear(depth(luma, 32), w, h), 16) upscale = lvf.sraa(descale, 2, 3, src.width, src.height, _ssim_downsample, alpha=0.2, beta=0.6, gamma=400, nrad=2, mdis=15) rescaled = core.std.MaskedMerge(luma, upscale, line_mask) out = vdf.merge_chroma(rescaled, out) # Slight sharp though CAS sharp = hvf.LSFmod(out, strength=75, Smode=3, Lmode=2, edgemode=1, edgemaskHQ=True) out = sharp deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1200) deband = dbs.f3kpf(out, 16, 30, 30) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband avg = out.std.PlaneStats() adg_mask16 = core.adg.Mask(avg, 16) grain_hi = core.std.MergeDiff(out, diff) grain_hi = core.std.Merge(grain_hi, out, [0, 0.5]) # Half the grain on chroma planes grain_hi = core.std.MaskedMerge(out, grain_hi, core.adg.Mask(avg, 6)) grain_lo = core.neo_f3kdb.Deband(out, preset='depth', grainy=24, keep_tv_range=True) grain_lo = core.std.MaskedMerge(grain_lo, grain_hi, core.adg.Mask(avg, 14)) grain_b = core.std.MaskedMerge(out, out.grain.Add(0.1, constant=True), adg_mask16) grain = lvf.rfs(grain_hi, grain_lo, [(0, 16168), (24078, 41084), (63274, 75123)]) grain = lvf.rfs(grain, grain_b, [(75124, 82725)]) # Credits deband_c = placebo.deband(sharp, 17, 6, 3, 0) grain_c = core.std.MaskedMerge(deband_c, deband_c.grain.Add(6.5, constant=True), adg_mask16) grain = lvf.rfs(grain, grain_c, [(82791, src.num_frames - 1)]) grain = vdf.fade_filter(grain, grain, grain_c, 82726, 82790) out = grain 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""" 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_clip src = depth(src, 16) src = src[:34016] + src[34016 + 24 * 2 + 22:-24] out = src h = 720 w = get_w(h) fixedges = awf.bbmod(out, 2, 2, 2, 2, 64 << 8, 999) out = fixedges decomb = hvf.Vinverse(out) decomb = lvf.rfs(out, decomb, [(756, 764)]) ref = decomb out = decomb from adptvgrnMod import adptvgrnMod first_denoise = hybrid_denoise(out, 0.35, 1.5) regrain = adptvgrnMod(first_denoise, 0.275, 0.175, 1.25, 45) regrain = lvf.rfs(out, regrain, [(23709, 23786), (30397, 30546)]) out = regrain clean = core.knlm.KNLMeansCL(out, h=0.55, a=2, d=3, device_type='gpu', device_id=0, channels='UV') clean = core.knlm.KNLMeansCL(clean, h=0.55, a=2, d=3, device_type='gpu', device_id=0, channels='Y') diff_den = core.std.MakeDiff(out, clean) out = depth(clean, 32) luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, correct_shift=False, pscrn=1).resize.Bicubic(src.width, src.height, src_left=.5, src_top=.5) rescale = core.std.MaskedMerge(luma, upscale, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) moozzi = warping(out, 0.4, 4) sharp = hvf.LSFmod(moozzi, strength=95, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 30, 30) deband_b = core.neo_f3kdb.Deband(out, 31, 18, 18, 18, 0, 0, 4) import placebo deband_c = placebo.deband(out, 18, 6, 1, 2) deband = lvf.rfs(deband, deband_b, [(16328, 16607), (17272, 17447)]) deband = lvf.rfs(deband, deband_c, [(23709, 23786), (30397, 30546), (31115, 31353)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband grain_org = core.std.MergeDiff(out, diff_den) out = grain_org credit_mask = vdf.diff_rescale_mask(ref, mthr=40, sw=5, sh=5) credit_mask = vdf.region_mask(credit_mask, 10, 10, 10, 10).std.Inflate().std.Inflate() credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask), [(0, 661), (26731, 34015)]) credit = lvf.rfs(credit, src, [(34016, src.num_frames - 1)]) out = credit 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.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 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 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)
def do_filter(): """Vapoursynth filtering""" scene_change = [] with open('k.log') as file: lines = file.readlines() for line in lines: line = line.split() scene_change.append(int(line[0])) src = CLIP_SRC # Lol? border = awf.bbmod(src, 4, thresh=128, blur=15, y=True, u=True, v=True) border = lvf.ef(border, [6, 3, 3], radius=[12, 6, 6]) border = lvf.rfs(src, border, scene_change) out = depth(border, 16) # joletb has stronk eyes planes = split(out) planes[1], planes[2] = [ core.resize.Spline16(plane, src_top=-0.25) for plane in planes[1:] ] out = join(planes) # qual=2 produces weird artefacts and a stronger alpha/beta/gamma smudges details. new_fields = core.eedi3m.EEDI3(out, 1, alpha=0.25, beta=0.3, gamma=400, nrad=3, mdis=20, vcheck=3, sclip=core.nnedi3.nnedi3(out, 1, nsize=3, nns=3, qual=1, pscrn=4)) out = new_fields # omegartifacted frames def freeze_frame_after(clip, frame): return core.std.FreezeFrames(clip, frame, frame, frame + 1) def freeze_frame_before(clip, frame): return core.std.FreezeFrames(clip, frame, frame, frame - 1) cursed_frames = [ 2326, 8907, 12211, 12551, 13990, 14403, 15462, 17673, 19382, 23099, 23738, 24031, 24802, 25083 ] for cursed_frame in cursed_frames: out = freeze_frame_after(out, cursed_frame) cursed_frames = [5695, 9115, 9116, 17671, 18432] for cursed_frame in cursed_frames: out = freeze_frame_before(out, cursed_frame) # omegartifacted frames ² denoise_li = hvf.SMDegrain(out, thSAD=200) denoise_hi = hvf.SMDegrain(out, thSAD=350) denoise = lvf.rfs(denoise_li, denoise_hi, scene_change) def hard_denoise(clip): clip = hvf.SMDegrain(clip, thSAD=500) clip = knlm_denoise(clip, (2, 2), dict(a=8)) return clip cursed_frames = [ 595, 1191, 2643, 2663, 2664, 2665, 2666, 2667, 2671, 2672, 2674, 2675, 2679, 3999, 4419, 6351, 6355, 6547, 8906, 11731, 14176, 14177, 14178, 14179, 18430, 18435, 18437, 18438, 18439, 27766 ] cursed_frames += range(10767, 10776) cursed_frames += range(25013, 25018) cursed_frames += range(27663, 27668) cursed_frames += range(29642, 29646) cursed_frames += range(31384, 31388) uncursed = hard_denoise(out) denoise = lvf.rfs(denoise, uncursed, cursed_frames) out = denoise # It helps to fix the the aliasing left antialias = lvf.sraa(out, rep=13) out = antialias # Compensative line darkening and sharpening luma = get_y(out) darken = hvf.Toon(luma, 0.20) darken_mask = core.std.Expr([ core.std.Convolution( luma, [5, 10, 5, 0, 0, 0, -5, -10, -5], divisor=4, saturate=False), core.std.Convolution( luma, [5, 0, -5, 10, 0, -10, 5, 0, -5], divisor=4, saturate=False) ], [ 'x y max {neutral} / 0.86 pow {peak} *'.format( neutral=1 << (luma.format.bits_per_sample - 1), peak=(1 << luma.format.bits_per_sample) - 1) ]) darken = core.std.MaskedMerge(luma, darken, darken_mask) # Slight sharp through CAS sharp = hvf.LSFmod(darken, strength=65, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = vdf.merge_chroma(sharp, out) # Chroma planes are pure crap chromableed = xvs.WarpFixChromaBlend(out, 96, depth=8) out = chromableed detail_mask = lvf.denoise.detail_mask(out, brz_a=2700, brz_b=1500) deband = placebo.deband(out, 17, 5.75, grain=4) deband_b = placebo.deband(out, 24, 8, 2, grain=4) deband_c = placebo.deband(out, 17, 8, grain=4) deband_d = placebo.deband(out, 20, 12, 3, grain=4) deband = lvf.rfs(deband, deband_b, [(4596, 4669), (23036, 23098)]) deband = lvf.rfs(deband, deband_c, [(1646, 1711), (29768, 29840), (29932, 30037), (30163, 30243)]) deband = lvf.rfs(deband, deband_d, [(1712, 1830)]) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband 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 if out.num_frames < 34046: while out.num_frames != 34046: out += out[-1] opstart, opend = 2230, 4386 edstart, edend = 31311, 33467 h = 720 w = get_w(h) fixedges = awf.bbmod(out, 2, 2, 2, 2, 64 << 8, 999) out = fixedges decomb = hvf.Vinverse(out) decomb = lvf.rfs(out, decomb, [(4391, 4399)]) ref = decomb out = decomb from adptvgrnMod import adptvgrnMod first_denoise = hybrid_denoise(out, 0.35, 1.5) regrain = adptvgrnMod(first_denoise, 0.275, 0.175, 1.25, 45) regrain = lvf.rfs(out, regrain, [(1551, 1580)]) out = regrain clean = core.knlm.KNLMeansCL(out, h=0.55, a=2, d=3, device_type='gpu', device_id=0, channels='UV') clean = core.knlm.KNLMeansCL(clean, h=0.55, a=2, d=3, device_type='gpu', device_id=0, channels='Y') diff_den = core.std.MakeDiff(out, clean) out = depth(clean, 32) luma = get_y(out) line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1)) descale = core.descale.Debilinear(luma, w, h) upscale = vdf.nnedi3_upscale(descale, correct_shift=False, pscrn=1).resize.Bicubic(src.width, src.height, src_left=.5, src_top=.5) rescale = core.std.MaskedMerge(luma, upscale, line_mask) merged = vdf.merge_chroma(rescale, out) out = depth(merged, 16) moozzi = warping(out, 0.4, 4) sharp = hvf.LSFmod(moozzi, strength=95, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True) out = sharp deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000) deband = dbs.f3kpf(out, 17, 30, 30) import placebo deband_b = placebo.deband(out, 18, 6, 2, 2) deband = lvf.rfs(deband, deband_b, [(1551, 1580)]) deband = core.std.MaskedMerge(deband, out, deband_mask) out = deband grain_org = core.std.MergeDiff(out, diff_den) out = grain_org credit_mask = vdf.diff_rescale_mask(ref, mthr=40, sw=5, sh=5) credit_mask = vdf.region_mask(credit_mask, 10, 10, 10, 10).std.Inflate().std.Inflate() antialias = lvf.sraa(ref, 2, 13, downscaler=core.resize.Bicubic) credit = lvf.rfs(out, core.std.MaskedMerge(out, antialias, credit_mask), [(4396, 4484), (33924, src.num_frames - 1), (11981, 12250), (12478, 12836)]) out = credit src_c, ncop, nced = [ clip.std.Median() for clip in [src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut] ] opening_mask = vdf.dcm(out, src_c[opstart:opend + 1], ncop[:opend - opstart + 1], opstart, opend, 3, 3) ending_mask = vdf.dcm(out, src_c[edstart:edend + 1], nced[:edend - edstart + 1], edstart, edend, 3, 3) credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +').std.Convolution([1] * 9) credit = lvf.rfs(out, core.std.MaskedMerge(out, src, credit_mask), [(opstart, opend), (edstart, edend)]) out = credit return depth(out, 10)
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 = CLIP_SRC out = depth(src, 16) clip = out clip = core.std.FreezeFrames(clip, 1432, 1433, 1434) clip = core.std.FreezeFrames(clip, 1503, 1514, 1515) out = clip planes = split(out) planes[1], planes[2] = [ core.resize.Spline16(plane, src_left=-0.25) for plane in planes[1:] ] out = join(planes) # qual=2 produces weird artefacts and a stronger alpha/beta/gamma smudges details. new_fields = core.eedi3m.EEDI3(out, 1, alpha=0.4, beta=0.5, gamma=300, nrad=3, mdis=20, vcheck=3, sclip=core.nnedi3.nnedi3(out, 1, nsize=3, nns=3, qual=1, pscrn=4)) out = new_fields denoise = gf.MCDegrainSharp( out, tr=3, bblur=0.65, csharp=lambda x: hvf.LSFmod( x, strength=85, Smode=3, Lmode=1, edgemode=0), thSAD=285, rec=True) out = denoise edge_cleaner = hvf.EdgeCleaner(out, 35, rmode=13, smode=1, hot=True) out = edge_cleaner antialias = lvf.sraa(out, 2, 13, downscaler=core.resize.Bicubic, alpha=0.25, beta=0.35, gamma=400) antialias_a = lvf.sraa(out, 1.4, 9, downscaler=core.resize.Bicubic) antialias = lvf.rfs(antialias, antialias_a, [(1223, 1229)]) out = antialias chromableed = xvs.WarpFixChromaBlend(out, 72, depth=8) out = chromableed detail_mask = lvf.denoise.detail_mask(out, brz_a=2300, brz_b=1000) deband = placebo.deband(out, 17, 4.25, grain=6) deband_a = placebo.deband(out, 17, 8, 2, grain=6) deband_b = placebo.deband(out, 17, 6, grain=6) deband = lvf.rfs(deband, deband_a, [(1230, 1330)]) deband = lvf.rfs(deband, deband_b, [(1678, 1889)]) deband = core.std.MaskedMerge(deband, out, detail_mask) out = deband return depth(out, 10)