From 5389e5884e8748be21a0d1f2db64d76f208cebbd Mon Sep 17 00:00:00 2001 From: louis Date: Thu, 29 Jul 2021 10:43:47 -0400 Subject: [PATCH] tensura: s2: tv: 16 --- .../S2 [TV]/16/16.vpy | 100 ++++++++++++++++++ .../tensura_common/tv.py | 14 ++- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 Tensei Shitara Slime Datta Ken/S2 [TV]/16/16.vpy diff --git a/Tensei Shitara Slime Datta Ken/S2 [TV]/16/16.vpy b/Tensei Shitara Slime Datta Ken/S2 [TV]/16/16.vpy new file mode 100644 index 0000000..a18be78 --- /dev/null +++ b/Tensei Shitara Slime Datta Ken/S2 [TV]/16/16.vpy @@ -0,0 +1,100 @@ +import vapoursynth as vs + +from tensura_common import (TenSuraS2Config, TenSuraS2AODSource, antialias, cr_prefilter, + deband, dehalo, denoise, edgefix, finalize, regrain) + +from yt_common.automation import SelfRunner +from yt_common.chapters import Chapter +from yt_common.video import Zone + +from lvsfunc.mask import BoundingBox +from lvsfunc.dehardsub import HardsubASS, HardsubMask, bounded_dehardsub +from lvsfunc.types import Range +from lvsfunc.util import replace_ranges, normalize_ranges + +from typing import List, Optional, Tuple + +import os + +DESC: str = os.path.basename(os.path.splitext(__file__)[0]) +CONFIG: TenSuraS2Config = TenSuraS2Config(DESC) +SOURCE: TenSuraS2AODSource = TenSuraS2AODSource(CONFIG, [(24, -24)]) + +OP: Optional[int] = 2446 + +CHAPTERS: List[Chapter] = [ + Chapter("Intro", 0), + Chapter("OP", 2446), + Chapter("Part A", 4603), + Chapter("Part B", 16855), + Chapter("ED", 31767), + Chapter("Next", 33925), +] + +DEHARDSUB: List[HardsubMask] = [ + HardsubASS("./ger.ass"), +] + +NOD3: List[Range] = [ +] + +if OP is not None: + NOD3 += [ + (OP+1520, OP+1576) + ] + +NODEN: List[Range] = [ + (28026, 28135), + (28655, 29052), + (30509, 30661), + (30686, 30907), + (33925, None), +] + +if OP is not None: + NODEN += [ + (OP+1385, OP+1519) + ] + +ZONES: List[Zone] = [ +] + +ZONES += [Zone(r, 0.75) for r in normalize_ranges(SOURCE.source(), NOD3 + NODEN)] + +AA_STRONG: List[Range] = [ +] + +SANGNOM: List[Tuple[Range, List[BoundingBox]]] = [ +] + +core = vs.core + + +def filter_basic() -> vs.VideoNode: + aod, ref = SOURCE.dhs_source() + return finalize(bounded_dehardsub(aod[0], ref, DEHARDSUB)) + + +def filter() -> vs.VideoNode: + aod, ref = SOURCE.dhs_source() + pre = cr_prefilter(ref) + src = bounded_dehardsub(aod[0], pre, DEHARDSUB) + ef = edgefix(src) + den = denoise(ef) + den = replace_ranges(den, src, NODEN) + deb = deband(den) + deb = replace_ranges(deb, src, NOD3) + aa = antialias(deb, strong=AA_STRONG, sangnom=SANGNOM) + dh = dehalo(aa) + dh = replace_ranges(dh, aa, NOD3 + NODEN) + grain = regrain(dh) + final = finalize(grain) + src.set_output(1) + final.set_output(0) + return final + + +if __name__ == "__main__": + SelfRunner(CONFIG, SOURCE, filter, filter_basic, chapters=CHAPTERS, zones=ZONES) +else: + filter() diff --git a/Tensei Shitara Slime Datta Ken/tensura_common/tv.py b/Tensei Shitara Slime Datta Ken/tensura_common/tv.py index 6c6c458..f5d723a 100644 --- a/Tensei Shitara Slime Datta Ken/tensura_common/tv.py +++ b/Tensei Shitara Slime Datta Ken/tensura_common/tv.py @@ -8,11 +8,23 @@ from vardefunc.deband import dumb3kdb from vsutil import depth +from typing import Any, Dict + core = vs.core +def _nnedi3_rescale(clip: vs.VideoNode, width: int, height: int) -> vs.VideoNode: + nnargs: Dict[str, Any] = dict(field=0, dh=True, nsize=4, nns=4, qual=2, pscrn=2) + nn = clip.resize.Point(1440, 810, format=vs.GRAY16).std.Transpose() \ + .nnedi3.nnedi3(**nnargs) \ + .std.Transpose() \ + .nnedi3.nnedi3(**nnargs) + return nn.resize.Bicubic(width, height, filter_param_a=0, filter_param_b=1/2, + src_top=0.5, src_left=0.5, format=vs.GRAYS) + + def cr_prefilter(clip: vs.VideoNode) -> vs.VideoNode: - rescaled = depth(descale(clip, height=810, kernel=Bicubic(b=0, c=1/2)), 16) + rescaled = depth(descale(clip, height=810, kernel=Bicubic(b=0, c=1/2), upscaler=_nnedi3_rescale), 16) return rescaled