def deband( clip: vs.VideoNode, lineart: vs.VideoNode, heavy: Optional[Union[int, Tuple[int, int]]] = None) -> vs.VideoNode: detail_mask = lvf.mask.detail_mask(clip, brz_a=0.03) deband_lo = dumb3kdb(clip, radius=16, threshold=36) deband_hi = dumb3kdb(clip, radius=18, threshold=72) deband_replace = lvf.rfs(deband_lo, deband_hi, ranges=heavy) deband = core.std.MaskedMerge(deband_replace, lineart, detail_mask) return deband
def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]: """Main filterchain""" import debandshit as dbs import lvsfunc as lvf from adptvgrnMod import adptvgrnMod from vsutil import depth src = JP_TV.clip_cut vfm = core.vivtc.VFM(src, order=1) vdec = core.vivtc.VDecimate(vfm) src = depth(vdec, 16) stretch = lvf.kernels.Catrom().scale(src, 1920, 1080) debl = lvf.deblock.autodb_dpir(stretch, strs=[15, 20, 35], matrix=1, cuda=True) deband = dbs.dumb3kdb(debl, radius=18, threshold=[24, 16]) grain: vs.VideoNode = adptvgrnMod(deband, strength=0.3, size=1.3, sharp=80, grain_chroma=False, static=False, seed=42069, luma_scaling=8) return grain
def debanding(clip: vs.VideoNode) -> vs.VideoNode: from debandshit import dumb3kdb bits, clip = _get_bits(clip) deband_mask = detail_mask(clip, brz=(750, 1750)) deband = dumb3kdb(clip, radius=18, threshold=[32, 56], grain=24) # Heavy chroma banding deband_masked = core.std.MaskedMerge(deband, clip, deband_mask) return deband_masked if bits == 16 else depth(deband_masked, bits)
def masked_f3kdb(clip: vs.VideoNode, rad: int = 16, thr: Union[int, List[int]] = 24, grain: Union[int, List[int]] = [12, 0], mask_args: Dict[str, Any] = {}) -> vs.VideoNode: """Basic f3kdb debanding with detail mask """ from debandshit import dumb3kdb deb_mask_args: Dict[str, Any] = dict(detail_brz=1500, lines_brz=1000) deb_mask_args |= mask_args bits, clip = _get_bits(clip) deband_mask = detail_mask(clip, **deb_mask_args) deband = dumb3kdb(clip, radius=rad, threshold=thr, grain=grain) deband_masked = core.std.MaskedMerge(deband, clip, deband_mask) deband_masked = deband_masked if bits == 16 else depth(deband_masked, bits) return deband_masked
def filterchain() -> Union[vs.VideoNode, Tuple[vs.VideoNode, ...]]: """Main filterchain""" import debandshit as dbs import havsfunc as haf import lvsfunc as lvf import vardefunc as vdf from adptvgrnMod import adptvgrnMod from vsutil import depth src = JP_BD.clip_cut src = depth(src, 16) up = vdf.scale.to_444(src, src.width, src.height, join_planes=True) cbl = haf.FixChromaBleedingMod(up, cx=-0.35, cy=0, thr=4, strength=1, blur=False) debl = lvf.deblock.vsdpir(cbl, matrix=1, strength=25, mode='deblock', i444=True) aa = lvf.aa.nneedi3_clamp(debl, strength=1.5) aa = lvf.rfs(debl, aa, aliasing_ranges) aa = depth(aa, 16).std.Limiter(16 >> 8, [235 << 8, 240 << 8], [0, 1, 2]) dehalo = lvf.dehalo.masked_dha(aa, brightstr=0.35) dehalo = lvf.rfs(aa, dehalo, haloing_ranges) deband = dbs.dumb3kdb(dehalo, threshold=[16, 12]) grain: vs.VideoNode = adptvgrnMod(deband, strength=0.15, size=1.15, sharp=70, grain_chroma=False, static=False, seed=42069, luma_scaling=10) return grain
dpir = core.std.Merge(haf.FineDehalo(dpir, rx=1.8, ry=1.8, brightstr=1.8, darkstr=0), dpir, weight=[0.4, 0.6]) aa = core.std.Expr([lvf.aa.upscaled_sraa(dpir, rfactor=1.8), dpir], "x y min") aa = core.std.Merge(lvf.aa.upscaled_sraa(aa, rfactor=2.2), aa, weight=[0.9, 0.1]) dpir = debandshit.dumb3kdb(aa.resize.Bicubic(format=YUV420P10, matrix_s="170m", dither_type="error_diffusion"), threshold=40, output_depth=10) # freeze framing to frame +1 dpir = awf.ReplaceFrames( dpir, dpir[1:], "1154 1262 1341 1441 1522 1573 1609 1835 2357 2405 2477 2525 2530 2633 2688 3235 3283 3499 3978 4170 4174 4176 4207 4363 4425 4477 4645 4764 4773 4812 4849 5124 5143 5233 5285" ) # 3978 is questionable # freeze framing to frame +2 dpir = awf.ReplaceFrames( dpir, dpir[2:], "1153 1261 1608 1834 2356 2404 2476 2524 2632 3234 3282 3498 4169 4173 4206 4362 4476 4644 4848 5142 5232" ) # freeze framing to frame -1 dpir = awf.ReplaceFrames(