From 974a11efb4656488f91353d205a36fe6f7a43fd6 Mon Sep 17 00:00:00 2001 From: louis Date: Fri, 7 May 2021 13:36:16 -0400 Subject: [PATCH] tanteidan: tv: 04 small deband scenefilter not like it fucking matters because mpv's debander destroys it anyway --- Bishounen Tanteidan/04/04.vpy | 10 ++++++++++ yt_common/yt_common/denoise.py | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Bishounen Tanteidan/04/04.vpy b/Bishounen Tanteidan/04/04.vpy index 8854d22..40c2b7f 100644 --- a/Bishounen Tanteidan/04/04.vpy +++ b/Bishounen Tanteidan/04/04.vpy @@ -5,11 +5,13 @@ from tanteidan_common import (PrettyConfig, PrettySource, antialias, deband, wd_scenefilter) from yt_common.automation import SelfRunner +from yt_common.denoise import bm3d from yt_common.source import waka_replace from typing import List, Optional from lvsfunc.dehardsub import HardsubSign, HardsubSignFade, HardsubMask, bounded_dehardsub +from lvsfunc.misc import replace_ranges from lvsfunc.types import Range import os @@ -86,6 +88,11 @@ AA_NONE: List[Range] = TITLECARDS + [ # chapter 2 title cards are insanely deta (20821, 21039), ] +STUPID_DENOISE: List[Range] = [ + (11435, 11626), + (12026, 12115), +] + def filter_basic() -> vs.VideoNode: wakas, ref = SOURCE.source() @@ -94,6 +101,8 @@ def filter_basic() -> vs.VideoNode: waka, wakas = waka_replace(waka, wakas[1:], WAKA_REPLACE) src = bounded_dehardsub(waka, ref, SIGNS_RU, wakas) src.set_output(1) + core.ffms2.Source("./tanteidan_04_premux.mkv").set_output(2) + core.ffms2.Source("./tanteidan_04_premux_nopatch1.mkv").set_output(3) return src @@ -101,6 +110,7 @@ def filter() -> vs.VideoNode: src = filter_basic() den = denoise(src) deb = deband(den) + deb = replace_ranges(deb, bm3d(src, sigma=4, radius=1), STUPID_DENOISE) aa = antialias(deb, stronger=AA_STRONGER, strong=AA_STRONG, weak=AA_WEAK, noaa=AA_NONE) scenefilter = stupid_op_scenefilter(aa, deb, OP) if WELCOMING_DAYS is not None: diff --git a/yt_common/yt_common/denoise.py b/yt_common/yt_common/denoise.py index 88ce4a5..65ace4d 100644 --- a/yt_common/yt_common/denoise.py +++ b/yt_common/yt_common/denoise.py @@ -22,12 +22,12 @@ def bm3d(clip: vs.VideoNode, matrix_s: str = "709", sigma: Union[float, List[flo def to_fullgray(clip: vs.VideoNode) -> vs.VideoNode: return get_y(clip).resize.Point(format=vs.GRAYS, range_in=Range.LIMITED, range=Range.FULL) - sigmal = [sigma] * 3 if isinstance(sigma, float) else sigma + [sigma[-1]]*(3-len(sigma)) + sigmal = [sigma] * 3 if not isinstance(sigma, list) else sigma + [sigma[-1]]*(3-len(sigma)) sigmal = [sigmal[0], 0, 0] if isGray else sigmal isGray = True if sigmal[1] == 0 and sigmal[2] == 0 else isGray if len(sigmal) != 3: raise ValueError("bm3d: 'invalid number of sigma parameters supplied'") - radiusl = [0, 0] if radius is None else [radius] * 2 if isinstance(radius, int) \ + radiusl = [0, 0] if radius is None else [radius] * 2 if not isinstance(radius, list) \ else radius + [radius[-1]]*(2-len(radius)) if len(radiusl) != 2: raise ValueError("bm3d: 'invalid number or radius parameters supplied'")