Compare commits
2 Commits
53aa19530f
...
1d7cb04c1e
Author | SHA1 | Date | |
---|---|---|---|
1d7cb04c1e | |||
6864290f26 |
87
Vivy/09/09.vpy
Normal file
87
Vivy/09/09.vpy
Normal file
@ -0,0 +1,87 @@
|
||||
import vapoursynth as vs
|
||||
|
||||
from vivy_common import (VivyConfig, VivySource, antialias, deband, denoise,
|
||||
finalize, fsrcnnx_rescale, letterbox_edgefix, letterbox_refix, regrain)
|
||||
|
||||
from yt_common.automation import SelfRunner
|
||||
from yt_common.source import waka_replace
|
||||
|
||||
from lvsfunc.types import Range
|
||||
from lvsfunc.dehardsub import HardsubLine, HardsubSign, HardsubSignFade, HardsubMask, bounded_dehardsub
|
||||
|
||||
from typing import List
|
||||
|
||||
import os
|
||||
|
||||
core = vs.core
|
||||
|
||||
|
||||
EPNUM: int = int(os.path.basename(os.path.splitext(__file__)[0]))
|
||||
CONFIG: VivyConfig = VivyConfig(EPNUM)
|
||||
SOURCE: VivySource = VivySource(CONFIG)
|
||||
|
||||
WAKA_REPLACE: List[List[Range]] = [
|
||||
[(31528, 32331)],
|
||||
[],
|
||||
]
|
||||
SIGNS_RU: List[HardsubMask] = [
|
||||
HardsubLine([
|
||||
(222, 2336),
|
||||
(27065, 30404),
|
||||
], ((283, 844), (1349, 204))),
|
||||
HardsubSignFade([
|
||||
(5508, 5587),
|
||||
(33950, 34045),
|
||||
], refframe=1),
|
||||
HardsubSignFade([
|
||||
(2385, 2505),
|
||||
], expand=10),
|
||||
HardsubSignFade([
|
||||
(8501, 8513),
|
||||
(11701, 11716),
|
||||
(24242, 24295),
|
||||
]),
|
||||
HardsubSign([
|
||||
(17049, 17084),
|
||||
]),
|
||||
]
|
||||
NOSCALE: List[Range] = [
|
||||
]
|
||||
AA_NONE: List[Range] = [
|
||||
]
|
||||
AA_STRONGER: List[Range] = [
|
||||
]
|
||||
LETTERBOX: List[Range] = [
|
||||
(2853, 3737),
|
||||
(6084, 6974),
|
||||
]
|
||||
|
||||
|
||||
def filter_basic() -> vs.VideoNode:
|
||||
wakas, ref = SOURCE.dhs_source()
|
||||
wakas = [w[:11220] + w[11221:] 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)
|
||||
rescale = fsrcnnx_rescale(den, NOSCALE)
|
||||
edgefix = letterbox_edgefix(rescale, LETTERBOX)
|
||||
deb = deband(edgefix)
|
||||
aa = antialias(deb, stronger=AA_STRONGER, noaa=AA_NONE)
|
||||
refix = letterbox_refix(aa, deb, LETTERBOX)
|
||||
grain = regrain(refix)
|
||||
final = finalize(grain)
|
||||
final.set_output()
|
||||
return final
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
SelfRunner(CONFIG, SOURCE, filter, filter_basic)
|
||||
else:
|
||||
filter()
|
@ -1,2 +1,3 @@
|
||||
from .filter import antialias, deband, denoise, finalize, fsrcnnx_rescale, letterbox_edgefix, regrain # noqa: F401
|
||||
from .filter import (antialias, deband, denoise, finalize, fsrcnnx_rescale, # noqa: F401
|
||||
letterbox_edgefix, letterbox_refix, regrain)
|
||||
from .config import VivyConfig, VivySource # noqa: F401
|
||||
|
@ -10,7 +10,7 @@ from lvsfunc.denoise import bm3d
|
||||
from lvsfunc.kernels import Bicubic
|
||||
from lvsfunc.misc import replace_ranges
|
||||
from lvsfunc.types import Range
|
||||
from typing import List, Optional, Union
|
||||
from typing import List, Optional
|
||||
|
||||
from yt_common import antialiasing
|
||||
from yt_common.data import FSRCNNX
|
||||
@ -36,13 +36,35 @@ def fsrcnnx_rescale(src: vs.VideoNode, noscale: Optional[List[Range]] = None,
|
||||
return lvf.misc.replace_ranges(descale, src, noscale) if noscale else descale
|
||||
|
||||
|
||||
def _fixplane(clip: vs.VideoNode, top: int, bottom: int,
|
||||
bbt: int, bbb: int, chroma: bool = False, blur: int = 20) -> vs.VideoNode:
|
||||
return core.std.StackVertical([bbmod(clip.std.Crop(bottom=clip.height-top), bottom=1 if not chroma else 0),
|
||||
bbmod(clip.std.Crop(top=top, bottom=bottom), top=bbt, bottom=bbb, blur=blur),
|
||||
bbmod(clip.std.Crop(top=clip.height-bottom), top=1 if not chroma else 0)])
|
||||
|
||||
|
||||
def letterbox_edgefix(clip: vs.VideoNode, ranges: List[Range]) -> vs.VideoNode:
|
||||
edgefix = bbmod(clip.std.Crop(top=132, bottom=132), top=2, bottom=2, blur=500).std.AddBorders(top=132, bottom=132)
|
||||
return lvf.misc.replace_ranges(clip, edgefix, ranges)
|
||||
fy = _fixplane(clip.std.ShufflePlanes(planes=0, colorfamily=vs.GRAY), top=132, bottom=131, bbt=3, bbb=3)
|
||||
fu = _fixplane(clip.std.ShufflePlanes(planes=1, colorfamily=vs.GRAY), top=66, bottom=65, bbt=2, bbb=2, chroma=True)
|
||||
fv = _fixplane(clip.std.ShufflePlanes(planes=2, colorfamily=vs.GRAY), top=66, bottom=65, bbt=2, bbb=2, chroma=True)
|
||||
return replace_ranges(clip, core.std.ShufflePlanes([fy, fu, fv], planes=[0, 0, 0], colorfamily=vs.YUV), ranges)
|
||||
|
||||
|
||||
def denoise(clip: vs.VideoNode, sigma: Union[float, List[float]] = 1.5) -> vs.VideoNode:
|
||||
return bm3d(clip, sigma=sigma)
|
||||
def letterbox_refix(aa: vs.VideoNode, noaa: vs.VideoNode, ranges: List[Range]) -> vs.VideoNode:
|
||||
return replace_ranges(aa, core.std.StackVertical([
|
||||
aa.std.Crop(bottom=aa.height-130),
|
||||
noaa.std.Crop(top=130, bottom=aa.height-134),
|
||||
aa.std.Crop(top=134, bottom=132),
|
||||
noaa.std.Crop(top=aa.height-132, bottom=130),
|
||||
aa.std.Crop(top=aa.height-130)
|
||||
]), ranges)
|
||||
|
||||
|
||||
def denoise(clip: vs.VideoNode, sigma: float = 1.5, h: float = 0.7) -> vs.VideoNode:
|
||||
return core.std.ShufflePlanes([
|
||||
bm3d(clip.std.ShufflePlanes(planes=0, colorfamily=vs.GRAY), sigma=sigma, radius=1),
|
||||
clip.knlm.KNLMeansCL(d=3, a=1, h=h, channels="UV"),
|
||||
], planes=[0, 1, 2], colorfamily=vs.YUV)
|
||||
|
||||
|
||||
def deband(clip: vs.VideoNode) -> vs.VideoNode:
|
||||
|
Loading…
x
Reference in New Issue
Block a user