import vapoursynth as vs from tanteidan_common import (PrettyConfig, PrettySource, antialias, deband, denoise, finalize, regrain) from yt_common.automation import SelfRunner from yt_common.source import waka_replace from typing import List from lvsfunc.dehardsub import HardsubLineFade, HardsubSignFade, HardsubMask, bounded_dehardsub from lvsfunc.types import Range import os core = vs.core EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0])) CONFIG: PrettyConfig = PrettyConfig(EPNUM) SOURCE: PrettySource = PrettySource(CONFIG) WAKA_REPLACE: List[List[Range]] = [ [(31864, 32652)], [], ] TITLECARDS: List[Range] = [ (0, 35), (2949, 2996), (6470, 6505), (8460, 8495), (8976, 9011), (11058, 11141), (13221, 13268), (15780, 15818), (19494, 19529), (21303, 21338), (24000, 24023), (25207, 25242), (26654, 26683), (30290, 30337), ] SIGNS_RU: List[HardsubMask] = [ HardsubLineFade([ ], ((449, 51), (1015, 127)), refframe=0.75), HardsubSignFade([ (318, 347), (4607, 4702), (6506, 6547), (31792, 31863), (3714, 3773), (3774, 3851), (4886, 4933), (5972, 6091), (12060, 12083), (12084, 12113), (18132, 18200), (19446, 19493), (24178, 24196), (24201, 24216), (26768, 26815), (26816, 26857), ]), ] SIGNS_RU += [HardsubSignFade(tc) for tc in TITLECARDS] AA_WEAK: List[Range] = [ (0, 35), (282, 347), (18069, 18440), ] AA_WEAK += TITLECARDS AA_NONE: List[Range] = [ (5972, 6091), # this is heavily stylized and i'm not touching it ] def filter_basic() -> vs.VideoNode: wakas, ref = SOURCE.source() wakas = [w[0] + w for w in wakas] waka = wakas[0] waka, wakas = waka_replace(waka, wakas[1:], WAKA_REPLACE) src = bounded_dehardsub(waka, ref, SIGNS_RU, wakas) src.set_output(1) return src def filter() -> vs.VideoNode: src = filter_basic() den = denoise(src) deb = deband(den) aa = antialias(deb, weak=AA_WEAK, noaa=AA_NONE) grain = regrain(aa) final = finalize(grain) final.set_output() return final if __name__ == "__main__": SelfRunner(CONFIG, filter, filter_basic) else: filter()