コード例 #1
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    src = core.std.FreezeFrames(src, 45219, 45219, 45219 - 1)

    adg_mask = core.adg.Mask(src.std.PlaneStats(), 20)
    denoise_a = CoolDegrain(src, tr=1, thsad=48, blksize=8, overlap=4, plane=4)
    denoise_b = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    denoise = core.std.MaskedMerge(denoise_a, denoise_b, adg_mask)
    denoise = vdf.merge_chroma(denoise, denoise_a)
    out = denoise

    deband_mask = lvf.denoise.detail_mask(out.std.Median(),
                                          brz_a=3000,
                                          brz_b=1500)
    deband = dbs.f3kpf(out, 20, 24, 30)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    grain = kgf.adaptive_grain(out, 0.1, luma_scaling=16)
    out = grain

    return depth(out, 10)
コード例 #2
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)


    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise


    luma = get_y(out)
    antialias = vdf.nnedi3_upscale(luma, correct_shift=False, pscrn=4) \
        .resize.Bicubic(src.width, src.height, src_left=.5, src_top=.5,
                        filter_param_a=0, filter_param_b=1/2)
    out = vdf.merge_chroma(antialias, out)


    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 24, 24)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain


    return depth(out, 10)
コード例 #3
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1):
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        strong = TAAmbk(luma, aatype='Eedi3', alpha=0.4, beta=0.4)
        weak = TAAmbk(luma, aatype='Nnedi3')
        expr = 'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr)

        clip_aa = core.std.Expr([strong, weak, luma], expr)
        return core.std.ShufflePlanes([clip_aa, clip], [0, 1, 2], vs.YUV)

    src = SRC_CUT

    interpolate = core.resize.Bicubic(src, src_left=3)
    f_1 = 1006
    src = src[:EDSTART + f_1] + interpolate[EDSTART + f_1] + src[EDSTART +
                                                                 f_1:-1]

    src = depth(src, 16)

    blur = core.bilateral.Gaussian(src, [0.45, 0])
    den = CoolDegrain(blur, tr=1, thsad=60, blksize=8, overlap=4, plane=4)

    dering = core.std.MaskedMerge(den, hvf.YAHR(den, 2, 32),
                                  muvf.AnimeMask(den, 0.2), 0)

    aa_a = core.std.MaskedMerge(dering, _nneedi3_clamp(dering),
                                TAAmbk(dering, mtype=2, showmask=1))
    aa_b = TAAmbk(src, aatype='Nnedi3', mtype=1, nns=4, qual=2, nsize=6)
    aa = lvf.rfs(aa_a, aa_b, [(OPSTART, OPEND), (EDSTART, EDEND)])

    preden = core.knlm.KNLMeansCL(aa,
                                  a=2,
                                  h=2,
                                  d=0,
                                  device_type='gpu',
                                  channels='Y')
    diff = core.std.MakeDiff(aa, preden, 0)
    db_m = lvf.denoise.detail_mask(aa.std.Median(), brz_a=3000, brz_b=1500)

    db_a = dbs.f3kpf(aa, 17)
    db_b = core.placebo.Deband(preden,
                               radius=17,
                               threshold=5.5,
                               iterations=1,
                               grain=4,
                               planes=1 | 2 | 4)
    db_b = core.std.MergeDiff(db_b, diff, 0)
    db = lvf.rfs(db_a, db_b, [(9729, 9845), (13652, 14048)])
    db = core.std.MaskedMerge(db, aa, db_m)

    grain = mdf.adptvgrnMod_mod(db, 0.2, size=1.25, sharp=60, luma_scaling=8)

    final = depth(grain, 10)

    return final, src
コード例 #4
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    h = 882
    w = get_w(h)
    kernel = 'lanczos'
    taps = 5

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    luma = get_y(out)

    descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h)
    upscale = vdf.fsrcnnx_upscale(
        depth(descale, 16), src.width, src.height,
        '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl',
        partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0))
    out = upscale

    unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5)
    sharp = hvf.LSFmod(unwarp,
                       strength=90,
                       Smode=3,
                       Lmode=1,
                       edgemode=1,
                       edgemaskHQ=True)

    stabilize = stabilization(out, sharp, 2, 1, 8, 16)
    out = vdf.merge_chroma(stabilize, denoise)

    antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic)
    out = antialias

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 42, 36)

    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband = core.neo_f3kdb.Deband(deband,
                                   preset='depth',
                                   grainy=24,
                                   grainc=18,
                                   keep_tv_range=True)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain

    rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4)
    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask,
                                                  0), [(0, 647),
                                                       (29954, 34046)])
    credit = lvf.rfs(credit, src, [(0, 1)])
    out = credit

    return depth(out, 10)
コード例 #5
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1):
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        strong = TAAmbk(luma, aatype='Eedi3', alpha=0.4, beta=0.4)
        weak = TAAmbk(luma, aatype='Nnedi3')
        expr = 'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr)

        clip_aa = core.std.Expr([strong, weak, luma], expr)
        return core.std.ShufflePlanes([clip_aa, clip], [0, 1, 2], vs.YUV)

    src = SRC_CUT
    src += src[-1]*2

    interpolate = core.resize.Bicubic(src, src_left=3)
    f_1 = 1006
    src = src[:EDSTART+f_1] + interpolate[EDSTART+f_1] + src[EDSTART+f_1:-1]

    src = depth(src, 16)

    blur = core.bilateral.Gaussian(src, [0.45, 0])
    den = CoolDegrain(blur, tr=1, thsad=60, blksize=8, overlap=4, plane=4)



    dering = core.std.MaskedMerge(den, hvf.YAHR(den, 2, 32), muvf.AnimeMask(den, 0.2), 0)




    aa_a = core.std.MaskedMerge(dering, _nneedi3_clamp(dering), TAAmbk(dering, mtype=2, showmask=1))
    aa_b = TAAmbk(src, aatype='Nnedi3', mtype=1, nns=4, qual=2, nsize=6)
    aa_c = TAAmbk(dering, aatype='Eedi3SangNom', mtype=2, cycle=2)
    aa_d = TAAmbk(dering, aatype='Eedi3', cycle=2)
    aa = lvf.rfs(aa_a, aa_b, [(OPSTART, OPEND), (EDSTART, EDEND)])
    aa = lvf.rfs(aa, aa_c, [(6448, 6546)])
    aa = lvf.rfs(aa, aa_d, [(5467, 5550)])




    db_m = lvf.denoise.detail_mask(aa.std.Median(), brz_a=3000, brz_b=1500)

    db = dbs.f3kpf(aa, 17)
    db = core.std.MaskedMerge(db, aa, db_m)

    grain = mdf.adptvgrnMod_mod(db, 0.2, size=1.25, sharp=60, luma_scaling=8)

    final = depth(grain, 10)

    return final, src
コード例 #6
0
def do_filter():
    """Vapoursynth filtering"""

    def _fsrcnnx(clip: vs.VideoNode) -> vs.VideoNode:
        blank = core.std.BlankClip(clip, format=vs.GRAY16, color=128 << 8)
        clip = join([clip, blank, blank])
        # The chroma is upscaled with box AKA nearest but we don't care since we only need the luma.
        # It's especially faster and speed is the key :^)
        clip = core.placebo.Shader(clip, 'Shaders/FSRCNNX_x2_56-16-4-1.glsl', clip.width*2, clip.height*2, filter='box')
        return get_y(clip)

    def _nnedi(clip: vs.VideoNode) -> vs.VideoNode:
        args = dict(nsize=4, nns=4, qual=2, pscrn=2)
        clip = clip.std.Transpose().nnedi3.nnedi3(0, True, **args) \
            .std.Transpose().nnedi3.nnedi3(0, True, **args)
        return core.resize.Spline36(clip, src_top=.5, src_left=.5)

    def _rescale(clip: vs.VideoNode, thr: int, downscaler: Callable[[vs.VideoNode], vs.VideoNode]) -> vs.VideoNode:
        return downscaler(core.std.Merge(_nnedi(clip), _fsrcnnx(clip), thr))

    src = SRC_CUT

    fixedges = lvf.ef(src, [1, 1, 1])

    denoise = CoolDegrain(depth(fixedges, 16), tr=1, thsad=48, thsadc=84, blksize=8, overlap=4, plane=4)


    w, h = 1280, 720
    b, c = vdf.get_bicubic_params('robidoux')
    luma = get_y(denoise)
    descale = depth(core.descale.Debicubic(depth(luma, 32), w, h, b, c), 16)
    rescale = _rescale(descale, 0.55, lambda c: core.resize.Bicubic(c, src.width, src.height, filter_param_a=0, filter_param_b=0))

    line_mask = lvf.denoise.detail_mask(rescale, brz_a=7000, brz_b=2000)
    rescale = core.std.MaskedMerge(luma, rescale, line_mask)



    credit_mask = vdf.drm(luma, b=b, c=c, mode='ellipse', sw=3, sh=3)
    credit = core.std.MaskedMerge(rescale, luma, credit_mask)


    merged = vdf.merge_chroma(credit, denoise)


    deband_mask = lvf.denoise.detail_mask(merged, brz_a=3000, brz_b=1500)
    deband = dbs.f3kpf(merged, 17, 36, 36)
    deband = core.std.MaskedMerge(deband, merged, deband_mask)
    grain = core.neo_f3kdb.Deband(deband, preset='depth', grainy=32, output_depth=10,
                                  dither_algo=3, keep_tv_range=True)

    return grain
コード例 #7
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 16, 16)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    return depth(out, 10)
コード例 #8
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1)-> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode)-> vs.VideoNode:
            args = dict(alpha=0.25, beta=0.5, gamma=40, nrad=2, mdis=20, vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip, luma.width, luma.height, src_left=-.5, src_top=-.5)

        def _weak(clip: vs.VideoNode)-> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip, luma.width, luma.height, src_left=-.5, src_top=-.5)

        clip_aa = core.std.Expr([_strong(luma), _weak(luma), luma],
                                'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)

    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)


    antialias = _nneedi3_clamp(denoise)


    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise, rad=2, radc=2, brz_a=3250, brz_b=1250)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')


    deband = core.neo_f3kdb.Deband(antialias, 17, 42, 42, 42, 12, 0, sample_mode=4, keep_tv_range=True)
    deband = core.std.MaskedMerge(deband, antialias, line_mask)


    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)

    final = core.resize.Bicubic(grain, format=vs.YUV420P10, dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10)
コード例 #9
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 30, 30)
    deband_b = dbs.f3kpf(out, 17, 84, 84)
    deband_c = placebo.deband(out, 32, 12, 3, 4)
    deband = lvf.rfs(deband, deband_b, [(2090, 2107)])
    deband = lvf.rfs(deband, deband_c, [(2108, src.num_frames - 1)])
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    return depth(out, 10)
コード例 #10
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    radius = 2
    clip_in = depth(out, 32)
    y, u, v = split(clip_in)
    y_m = core.resize.Bicubic(y,
                              960,
                              540,
                              src_left=-.5,
                              filter_param_a=1 / 3,
                              filter_param_b=1 / 3)

    def demangle(clip):
        return core.resize.Bicubic(clip, 1920, 1080, src_left=.5)

    y_m, u, v = map(demangle, (y_m, u, v))

    y_fixup = core.std.MakeDiff(y, y_m)
    yu, yv = Regress(y_m, u, v, radius=radius)

    u_fixup = ReconstructMulti(y_fixup, yu, radius=radius)
    u_r = core.std.MergeDiff(u, u_fixup)

    v_fixup = ReconstructMulti(y_fixup, yv, radius=radius)
    v_r = core.std.MergeDiff(v, v_fixup)

    scaled = depth(join([y, u_r, v_r]), 16)
    out = scaled

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 24, 24)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain

    return depth(out, 10)
コード例 #11
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)
    deband = dbs.f3kpf(out, 17, 30, 30)
    deband_b = dbs.f3kpf(out, 17, 48, 48)
    deband = lvf.rfs(deband, deband_b, [(0, 89)])
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=8)
    grain = lvf.rfs(out, grain, [(0, 89)])
    out = grain

    return depth(out, 10)
コード例 #12
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    h = 882
    w = get_w(h)
    kernel = 'lanczos'
    taps = 5

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    luma = get_y(out)

    descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h)
    upscale = vdf.fsrcnnx_upscale(
        depth(descale, 16), src.width, src.height,
        '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl',
        partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0))
    out = vdf.merge_chroma(upscale, out)

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)

    deband = dbs.f3kpf(out, 17, 30, 30)

    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband = core.neo_f3kdb.Deband(deband,
                                   preset='depth',
                                   grainy=24,
                                   grainc=18,
                                   keep_tv_range=True)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain

    return depth(out, 10)
コード例 #13
0
def do_filter():
    src = JPBD.src_cut

    fixedges = lvf.ef(src, [2, 1, 1])
    fixedges = depth(fixedges, 16)
    out = fixedges


    h = 720
    w = get_w(h)
    kernel = 'bilinear'


    denoise = CoolDegrain(out, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise


    luma = get_y(out)

    line_mask = vdf.edge_detect(luma, 'FDOG', 0.05, (1, 1))

    descale = kgf.get_descale_filter(kernel)(depth(luma, 32), w, h)
    rescale = vdf.fsrcnnx_upscale(depth(descale, 16), None, src.height, 'shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  partial(muvf.SSIM_downsample, kernel='Bicubic'))
    rescale = core.std.MaskedMerge(luma, rescale, line_mask)


    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)


    # Slight sharp though CAS
    sharp = hvf.LSFmod(out, strength=95, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True)
    out = sharp

    dering = gf.HQDeringmod(out, thr=16, darkthr=0.1)
    out = dering

    warp = xvs.WarpFixChromaBlend(out, thresh=36, depth=6)
    out = warp



    deband_mask = lvf.denoise.detail_mask(out, brz_a=2500, brz_b=1500)
    deband = dbs.f3kpf(out, 17, 36, 36)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband


    grain = placebo.deband(out, iterations=0, grain=6, chroma=False)
    grain_mask = core.adg.Mask(out.std.PlaneStats(), 14).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.std.MaskedMerge(out, grain, grain_mask)
    out = grain

    rescale_mask = vdf.drm(luma, h, kernel, sw=4, sh=4)
    ref = fixedges
    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask, 0), [(12805, src.num_frames-1)])
    out = credit


    return depth(out, 10)
コード例 #14
0
def denoise(clip: vs.VideoNode) -> vs.VideoNode:
    adaptive_mask = adptvgrnMod(clip, luma_scaling=8, show_mask=True)
    denoise = CoolDegrain(clip, thsad=48, blksize=8, overlap=4)
    merge = core.std.MaskedMerge(denoise, clip, adaptive_mask)
    return merge
コード例 #15
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1) -> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(alpha=0.25,
                        beta=0.5,
                        gamma=40,
                        nrad=2,
                        mdis=20,
                        vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        def _weak(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        clip_aa = core.std.Expr(
            [_strong(luma), _weak(luma), luma],
            'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)

    def _perform_endcard(path: str, ref: vs.VideoNode) -> vs.VideoNode:
        endcard = lvf.src(path).std.AssumeFPS(ref)
        endcard = core.std.CropRel(endcard,
                                   left=14,
                                   top=12,
                                   right=18,
                                   bottom=23)
        endcard = core.resize.Bicubic(endcard,
                                      ref.width,
                                      ref.height,
                                      vs.RGBS,
                                      dither_type='error_diffusion')

        endcard = iterate(
            endcard, partial(core.w2xc.Waifu2x, noise=3, scale=1, photo=True),
            2)

        endcard = core.resize.Bicubic(endcard,
                                      format=vs.YUV444PS,
                                      matrix_s='709',
                                      dither_type='error_diffusion')

        return Tweak(endcard, sat=1.2, bright=-0.05, cont=1.2)

    src = JPBD.src_cut
    src = depth(src, 16)
    edstart = 32012

    denoise_a = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)
    denoise_b = CoolDegrain(src, tr=3, thsad=96, blksize=8, overlap=4, plane=4)
    denoise = lvf.rfs(denoise_a, denoise_b, [(edstart + 1870, edstart + 1900)])

    antialias_a = _nneedi3_clamp(denoise)
    antialias_b = lvf.sraa(denoise, 2, rep=13)
    antialias = lvf.rfs(antialias_a, antialias_b, [(14667, 14696)])

    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise,
                                          rad=2,
                                          radc=2,
                                          brz_a=3250,
                                          brz_b=1250)
    adapt_mask = core.adg.Mask(predenoise.std.PlaneStats(), 40)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(
        9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')

    deband_a = core.neo_f3kdb.Deband(antialias,
                                     17,
                                     42,
                                     42,
                                     42,
                                     12,
                                     0,
                                     sample_mode=4,
                                     keep_tv_range=True)
    deband_a = core.std.MaskedMerge(deband_a, antialias, line_mask)
    deband_b = core.neo_f3kdb.Deband(deband_a,
                                     18,
                                     48,
                                     48,
                                     48,
                                     0,
                                     0,
                                     sample_mode=2,
                                     keep_tv_range=True)
    deband_ca = dbs.f3kbilateral(deband_b, 8, 270, 270)
    deband_cb = dbs.f3kbilateral(deband_b, 12, 110, 110)
    deband_c = core.std.MaskedMerge(deband_ca, deband_cb, adapt_mask)

    deband = lvf.rfs(deband_a, deband_b, [(edstart + 1870, edstart + 1900),
                                          (13041, 13180), (13932, 13949),
                                          (14121, 14168), (14647, 14666)])
    deband = lvf.rfs(deband, deband_c, [(14667, 14669), (14673, 14674),
                                        (14676, 14677)])

    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)

    crop = core.std.Crop(grain, 0, 0, 132, 132)
    edgefixe = core.edgefixer.ContinuityFixer(crop, 0, [2, 1, 1], 0, [1, 1, 1])
    borders = core.std.AddBorders(edgefixe, 0, 0, 132, 132)
    borders = lvf.rfs(grain, borders, [(0, 2905)])

    endcard = _perform_endcard(
        '[BDMV][200304][Magia Record][Vol.1]/Scans/endcard3_front_descreen.png',
        src)
    endcard_length = 117
    final = core.std.Splice([borders, endcard * endcard_length], True)
    final = core.resize.Bicubic(final,
                                format=vs.YUV420P10,
                                dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10), endcard_length
コード例 #16
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    h = 882
    w = get_w(h)
    kernel = 'lanczos'
    taps = 5
    opstart, opend = 936, 3092
    edstart, edend = 31769, 33926

    clip_in = depth(src, 32)
    dedimm = gf.Tweak(clip_in, sat=1.65, cont=1.65)
    dedimm = vdf.fade_filter(clip_in, clip_in, dedimm, 26133, 26183)
    out = depth(dedimm, 16)

    denoise = CoolDegrain(out, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    luma = get_y(out)

    descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h)
    upscale = vdf.fsrcnnx_upscale(
        depth(descale, 16), src.width, src.height,
        '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl',
        partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0))
    out = upscale

    unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5)
    sharp = hvf.LSFmod(unwarp,
                       strength=90,
                       Smode=3,
                       Lmode=1,
                       edgemode=1,
                       edgemaskHQ=True)

    stabilize = stabilization(out, sharp, 2, 1, 8, 16)
    out = vdf.merge_chroma(stabilize, denoise)

    antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic)
    out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise),
                  [(edstart, edend)])

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)

    deband = dbs.f3kpf(out, 17, 30, 30)

    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband = core.neo_f3kdb.Deband(deband,
                                   preset='depth',
                                   grainy=24,
                                   grainc=18,
                                   keep_tv_range=True)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain

    rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4)
    creditless_mask = core.std.Expr([
        vdf.dcm(src, src[opstart:opend + 1],
                JPBD_NCOP.src_cut[:opend - opstart + 1], opstart, opend, 2,
                2).std.Deflate(),
        vdf.dcm(src, src[edstart:edend + 1],
                JPBD_NCED.src_cut[:edend - edstart + 1], edstart, edend, 2,
                2).std.Deflate()
    ], 'x y +')

    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask,
                                                  0),
                     [(opstart + 425, opstart + 698),
                      (33973, src.num_frames - 1)])
    credit = lvf.rfs(credit,
                     core.std.MaskedMerge(credit, src, creditless_mask, 0),
                     [(opstart, opend), (edstart, edend)])
    credit = lvf.rfs(credit, src, [(16911, 16970), (24486, 24533)])
    out = credit

    return depth(out, 10)
コード例 #17
0
def do_filter():
    """Vapoursynth filtering"""
    def _sraa(clip: vs.VideoNode, nnargs: dict, eeargs: dict) -> vs.VideoNode:
        def _nnedi3(clip):
            return clip.nnedi3.nnedi3(0, False, **nnargs)

        def _eedi3(clip, sclip):
            return clip.eedi3m.EEDI3(0, False, **eeargs, sclip=sclip)

        clip = _eedi3(clip, _nnedi3(clip)).std.Transpose()
        clip = _eedi3(clip, _nnedi3(clip)).std.Transpose()
        return clip

    def _nnedi3(clip: vs.VideoNode, factor: float, args: dict) -> vs.VideoNode:
        upscale = clip.std.Transpose().nnedi3.nnedi3(0, True, **args) \
            .std.Transpose().nnedi3.nnedi3(0, True, **args)
        return core.resize.Spline36(upscale,
                                    clip.width * factor,
                                    clip.height * factor,
                                    src_top=.5,
                                    src_left=.5)

    def area_resize(clip: vs.VideoNode, width: int,
                    height: int) -> vs.VideoNode:
        blank = core.std.BlankClip(clip, format=vs.GRAY16, color=128 << 8)
        clip = join([clip, blank, blank])
        clip = core.area.AreaResize(clip, width, height)
        return get_y(clip)

    src = JPBD.src_cut
    src = depth(src, 16)

    flashback = [(31665, 31987), (68524, 68569)]

    denoise = CoolDegrain(src, tr=1, thsad=48, blksize=8, overlap=4, plane=4)
    denoise = lvf.rfs(denoise, src, flashback)

    dering = hvf.EdgeCleaner(denoise, 10, rmode=3, smode=1, hot=True)

    luma = get_y(dering)
    line_mask = TAAmbk(luma, mtype=2, showmask=1).std.Inflate()
    upscale = _nnedi3(luma, 2, dict(nsize=4, nns=4, qual=2, pscrn=2))
    sraa = _sraa(upscale, dict(nsize=0, nns=3, qual=1, pscrn=1),
                 dict(alpha=0.2, beta=0.5, gamma=40, nrad=3, mdis=20))
    sraa = core.rgvs.Repair(sraa, upscale, 13)
    antialias = area_resize(sraa, src.width, src.height)
    antialias = lvf.rfs(core.std.MaskedMerge(luma, antialias, line_mask),
                        antialias, [(22503, 22789)])
    antialias_merged = vdf.merge_chroma(antialias, denoise)

    deband_mask_a = lvf.denoise.detail_mask(antialias_merged,
                                            brz_a=3000,
                                            brz_b=1200)
    deband_mask_b = kgf.retinex_edgemask(antialias_merged)
    deband_mask = core.std.Expr([deband_mask_a, deband_mask_b], 'x y +')
    deband = dbs.f3kpf(antialias_merged, 18, 30, 30)
    deband = core.std.MaskedMerge(deband, antialias_merged, deband_mask)
    deband = hvf.ContraSharpening(deband, antialias_merged)
    deband = lvf.rfs(deband, antialias_merged, flashback)

    grain = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24)
    grain_a = kgf.adaptive_grain(grain)
    grain_b = core.grain.Add(grain, 1, 0, constant=True)
    grain = lvf.rfs(grain_a, grain_b, flashback)

    mask_borders = core.std.BlankClip(grain,
                                      format=vs.GRAY16,
                                      color=(256 << 8) - 1)
    mask_borders = vdf.region_mask(mask_borders, 0, 0, 132, 132).std.Invert()
    final = lvf.rfs(grain, core.std.MaskedMerge(grain, src, mask_borders),
                    flashback + [(65388, 65413), (113621, 113763)])

    smooth = xvs.mvfrc(src[146178:src.num_frames], preset='slow')
    vfr = muvf.VFRSplice([final[:146178], smooth], 'sora_timecode.txt')

    return depth(vfr, 10)
コード例 #18
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1) -> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(alpha=0.25,
                        beta=0.5,
                        gamma=40,
                        nrad=2,
                        mdis=20,
                        vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        def _weak(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        clip_aa = core.std.Expr(
            [_strong(luma), _weak(luma), luma],
            'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)

    def _perform_endcard(path: str, ref: vs.VideoNode) -> vs.VideoNode:
        endcard = lvf.src(path).std.AssumeFPS(ref)
        endcard = core.std.CropRel(endcard, left=4, top=12, right=0, bottom=21)
        endcard = core.resize.Bicubic(endcard,
                                      ref.width,
                                      ref.height,
                                      vs.RGBS,
                                      dither_type='error_diffusion')

        endcard = iterate(
            endcard, partial(core.w2xc.Waifu2x, noise=3, scale=1, photo=True),
            2)

        endcard = core.resize.Bicubic(endcard,
                                      format=vs.YUV444PS,
                                      matrix_s='709',
                                      dither_type='error_diffusion')
        endcard = lvf.util.quick_resample(
            endcard,
            lambda c: core.neo_f3kdb.Deband(c, 15, 36, 36, 36, 24, 24, 4))

        return Tweak(endcard, sat=1.2, bright=-0.05, cont=1.2)

    def to_gray(clip: vs.VideoNode, ref: vs.VideoNode) -> vs.VideoNode:
        clip = core.std.AssumeFPS(clip, ref)
        return core.resize.Point(clip,
                                 format=vs.GRAY16,
                                 matrix_s=mvf.GetMatrix(ref))

    src = JPBD.src_cut
    src = depth(src, 16)
    edstart = 30618

    denoise_a = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)
    denoise_b = CoolDegrain(src, tr=3, thsad=96, blksize=8, overlap=4, plane=4)
    denoise = lvf.rfs(denoise_a, denoise_b, [(edstart + 1870, edstart + 1900)])

    antialias_a = _nneedi3_clamp(denoise)
    antialias_b = TAAmbk(denoise, aatype='Eedi3', mtype=1)
    antialias = lvf.rfs(antialias_a, antialias_b, [(9478, 9501)])

    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise,
                                          rad=2,
                                          radc=2,
                                          brz_a=3250,
                                          brz_b=1250)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(
        9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')

    deband_a = core.neo_f3kdb.Deband(antialias,
                                     17,
                                     42,
                                     42,
                                     42,
                                     12,
                                     0,
                                     sample_mode=4,
                                     keep_tv_range=True)
    deband_a = core.std.MaskedMerge(deband_a, antialias, line_mask)
    deband_b = core.neo_f3kdb.Deband(deband_a,
                                     18,
                                     48,
                                     48,
                                     48,
                                     0,
                                     0,
                                     sample_mode=2,
                                     keep_tv_range=True)
    deband_c = core.neo_f3kdb.Deband(deband_a,
                                     20,
                                     64,
                                     64,
                                     64,
                                     24,
                                     0,
                                     sample_mode=2,
                                     keep_tv_range=True)

    deband = lvf.rfs(deband_a, deband_b, [(edstart + 1870, edstart + 1900)])
    deband = lvf.rfs(
        deband,
        core.std.MaskedMerge(
            deband_c, deband_a,
            to_gray(lvf.src('masks/magia_07_mask_01.png'), src)),
        [(6729, 6865)])

    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)

    borders = vdf.region_mask(grain, 240, 240, 0, 0)
    borders = lvf.rfs(grain, borders, [(25623, 25670)])

    endcard = _perform_endcard(
        '[BDMV][200610][Magia Record][Vol.3]/Scans/endcard7_front_descreen.png',
        src)
    endcard_length = 119
    final = core.std.Splice([borders, endcard * endcard_length], True)
    final = core.resize.Bicubic(final,
                                format=vs.YUV420P10,
                                dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10), endcard_length
コード例 #19
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)

    h = 882
    w = get_w(h)
    kernel = 'lanczos'
    taps = 5
    opstart, opend = 1918, 4076
    edstart, edend = 31768, 33925

    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise

    luma = get_y(out)

    descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h)
    upscale = vdf.fsrcnnx_upscale(
        depth(descale, 16), src.width, src.height,
        '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl',
        partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0))
    out = upscale

    import G41Fun as gf
    from vsTAAmbk import TAAmbk
    dehalo = gf.MaskedDHA(out,
                          rx=2.8,
                          ry=2.8,
                          darkstr=0.4,
                          brightstr=1.4,
                          maskpull=48,
                          maskpush=140)
    aaa = TAAmbk(dehalo, 'Eedi3SangNom', cycle=4, mtype=0)
    aaa = lvf.rfs(out, aaa, [(16052, 16105)])
    out = aaa

    unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5)
    sharp = hvf.LSFmod(unwarp,
                       strength=90,
                       Smode=3,
                       Lmode=1,
                       edgemode=1,
                       edgemaskHQ=True)

    stabilize = stabilization(out, sharp, 2, 1, 8, 16)
    out = vdf.merge_chroma(stabilize, denoise)

    antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic)
    out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise),
                  [(edstart, edend)])

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)

    deband = dbs.f3kpf(out, 17, 36, 36)

    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband = core.neo_f3kdb.Deband(deband,
                                   preset='depth',
                                   grainy=24,
                                   grainc=18,
                                   keep_tv_range=True)
    out = deband

    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain

    rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4)
    creditless_mask = core.std.Expr([
        vdf.dcm(src, src[opstart:opend + 1],
                JPBD_NCOP.src_cut[:opend - opstart + 1], opstart, opend, 2,
                2).std.Deflate(),
        vdf.dcm(src, src[edstart:edend + 1],
                JPBD_NCED.src_cut[:edend - edstart + 1], edstart, edend, 2,
                2).std.Deflate()
    ], 'x y +')

    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask,
                                                  0),
                     [(opstart + 425, opstart + 698),
                      (33972, src.num_frames - 1), (21962, 22009)])
    credit = lvf.rfs(credit,
                     core.std.MaskedMerge(credit, src, creditless_mask, 0),
                     [(opstart, opend), (edstart, edend)])
    credit = lvf.rfs(credit, src, [(5057, 5104), (12371, 12418)])
    out = credit

    return depth(out, 10)
コード例 #20
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1)-> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode)-> vs.VideoNode:
            args = dict(alpha=0.25, beta=0.5, gamma=40, nrad=2, mdis=20, vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip, luma.width, luma.height, src_left=-.5, src_top=-.5)

        def _weak(clip: vs.VideoNode)-> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip, luma.width, luma.height, src_left=-.5, src_top=-.5)

        clip_aa = core.std.Expr([_strong(luma), _weak(luma), luma],
                                'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)


    def _perform_endcard(path: str, ref: vs.VideoNode)-> vs.VideoNode:
        endcard = lvf.src(path).std.AssumeFPS(ref)
        endcard = core.std.CropRel(endcard, left=7, top=0, right=11, bottom=22)
        endcard = core.resize.Bicubic(endcard, ref.width, ref.height, vs.RGBS, dither_type='error_diffusion')

        endcard = core.w2xc.Waifu2x(endcard, noise=3, scale=1, photo=True)

        endcard = core.resize.Bicubic(endcard, format=vs.YUV444PS, matrix_s='709', dither_type='error_diffusion')
        endcard = lvf.util.quick_resample(endcard, lambda c: core.neo_f3kdb.Deband(c, 15, 36, 36, 36, 24, 24, 4))

        return Tweak(endcard, sat=1.4, cont=1.2)


    def _perform_motion_mask(clip: vs.VideoNode, brz: int)-> vs.VideoNode:
        clip = depth(clip, 8)
        sup = core.hqdn3d.Hqdn3d(clip).neo_fft3d.FFT3D().mv.Super(sharp=1)
        fv1 = core.mv.Analyse(sup, isb=False, delta=1, truemotion=False, dct=2)
        fv2 = core.mv.Analyse(sup, isb=True, delta=1, truemotion=True, dct=2)

        momask1 = core.mv.Mask(clip, fv1, ml=2, kind=1)
        momask2 = core.mv.Mask(clip, fv2, ml=3, kind=1)
        momask = core.std.Merge(momask1, momask2).rgvs.RemoveGrain(3).std.Binarize(brz)
        momask = momask.std.Minimum().std.Minimum()

        return depth(get_y(momask), 16)


    src = JPBD.src_cut
    src = depth(src, 16)

    denoise_a = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)
    denoise = denoise_a


    antialias = _nneedi3_clamp(denoise)
    antialias_a = TAAmbk(antialias, aatype='Eedi3', cycle=3)
    antialias_b = lvf.sraa(denoise, 2, 13)

    motion_mask = _perform_motion_mask(denoise[16914:17001], 140).std.FreezeFrames([0, 18, 57], [2, 38, 86], [2, 38, 57])
    motion_mask = insert_clip(src.std.BlankClip(format=vs.GRAY16), motion_mask, 16914)


    antialias = lvf.rfs(antialias, core.std.MaskedMerge(antialias_a, antialias, motion_mask), [(16914, 17000)])
    antialias = lvf.rfs(antialias, antialias_b, [(18084, 18179)])


    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise, rad=2, radc=2, brz_a=3250, brz_b=1250)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')


    deband_a = core.neo_f3kdb.Deband(antialias, 17, 42, 42, 42, 12, 0, sample_mode=4, keep_tv_range=True)
    deband_a = core.std.MaskedMerge(deband_a, antialias, line_mask)
    deband = deband_a


    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)


    ending = lvf.rfs(grain, src, [(32079, 33098)])


    endcard = _perform_endcard(r'[BDMV][200902][Magia Record][Vol.5]\Scans\endcard13_front_descreen.png', src)
    endcard_length = 119
    final = core.std.Splice([ending, endcard * endcard_length], True)
    final = core.resize.Bicubic(final, format=vs.YUV420P10, dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10), endcard_length
コード例 #21
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1) -> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(alpha=0.25,
                        beta=0.5,
                        gamma=40,
                        nrad=2,
                        mdis=20,
                        vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        def _weak(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        clip_aa = core.std.Expr(
            [_strong(luma), _weak(luma), luma],
            'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)

    def _perform_endcard(path: str, ref: vs.VideoNode) -> vs.VideoNode:
        endcard = lvf.src(path).std.AssumeFPS(ref)
        endcard = core.std.CropRel(endcard, left=6, top=20, right=0, bottom=6)
        endcard = core.resize.Bicubic(endcard,
                                      ref.width,
                                      ref.height,
                                      vs.RGBS,
                                      dither_type='error_diffusion')

        endcard = iterate(
            endcard, partial(core.w2xc.Waifu2x, noise=3, scale=1, photo=True),
            2)

        endcard = core.resize.Bicubic(endcard,
                                      format=vs.YUV444PS,
                                      matrix_s='709',
                                      dither_type='error_diffusion')
        endcard = lvf.util.quick_resample(
            endcard,
            lambda c: core.neo_f3kdb.Deband(c, 15, 36, 36, 36, 24, 24, 4))

        return Tweak(endcard, sat=1.2, bright=-0.05, cont=1.2)

    src = JPBD.src_cut
    src = depth(src, 16)
    edstart = 31769

    denoise_a = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)
    denoise_b = CoolDegrain(src, tr=3, thsad=96, blksize=8, overlap=4, plane=4)
    denoise = lvf.rfs(denoise_a, denoise_b, [(edstart + 1870, edstart + 1900)])

    antialias_a = _nneedi3_clamp(denoise)
    downscaler = lambda c, w, h: core.fmtc.resample(
        c, w, h, kernel='gauss', invks=True, invkstaps=1, taps=1, a1=32)
    antialias_b = rekt_fast(
        denoise,
        lambda c: lvf.sraa(c, 1.45, rep=13, downscaler=downscaler),
        top=482)
    antialias = lvf.rfs(antialias_a, antialias_b, [(8185, 8280)])

    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise,
                                          rad=2,
                                          radc=2,
                                          brz_a=3250,
                                          brz_b=1250)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(
        9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')

    deband_a = core.neo_f3kdb.Deband(antialias,
                                     17,
                                     42,
                                     42,
                                     42,
                                     12,
                                     0,
                                     sample_mode=4,
                                     keep_tv_range=True)
    deband_a = core.std.MaskedMerge(deband_a, antialias, line_mask)
    deband_b = core.neo_f3kdb.Deband(deband_a,
                                     18,
                                     48,
                                     48,
                                     48,
                                     0,
                                     0,
                                     sample_mode=2,
                                     keep_tv_range=True)

    deband = lvf.rfs(deband_a, deband_b, [(edstart + 1870, edstart + 1900)])
    deband = lvf.rfs(deband, deband_b, [(13611, 13661), (20022, 20057)])

    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)

    endcard = _perform_endcard(
        '[BDMV][200610][Magia Record][Vol.3]/Scans/endcard6_front_descreen.png',
        src)
    endcard_length = 119
    final = core.std.Splice([grain, endcard * endcard_length], True)
    final = core.resize.Bicubic(final,
                                format=vs.YUV420P10,
                                dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10), endcard_length
コード例 #22
0
def do_filter():
    """Vapoursynth filtering"""
    def _fsrcnnx(clip: vs.VideoNode, width: int, height: int) -> vs.VideoNode:
        blank = core.std.BlankClip(clip, format=vs.GRAY16, color=128 << 8)
        clip = join([clip, blank, blank])
        clip = core.placebo.Shader(clip, 'FSRCNNX_x2_56-16-4-1.glsl',
                                   clip.width * 2, clip.height * 2)
        return core.resize.Spline36(get_y(clip), width, height)

    src = SRC_CUT

    fe = lvf.ef(src, [1, 1, 1])
    fe = depth(fe, 16)

    h = 864
    w = get_w(864)
    b, c = 0, 1 / 2
    luma = get_y(fe)
    descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c)
    descale = depth(descale, 16)

    rescale_a = nnedi3_rpow2(descale,
                             2,
                             src.width,
                             src.height,
                             nns=4,
                             qual=2,
                             pscrn=2)
    rescale_b = _fsrcnnx(descale, src.width, src.height)
    rescale = core.std.Merge(rescale_a, rescale_b, 0.75)

    rescale_mask = vrf.drm(fe, 864, b=b, c=c, mthr=80, sw=4, sh=4)
    rescale = core.std.MaskedMerge(rescale, luma, rescale_mask)

    rescale = lvf.rfs(rescale, luma, [(OPSTART + 483, OPSTART + 721),
                                      (OPSTART + 822, OPSTART + 1083)])
    merge = core.std.ShufflePlanes([rescale, fe], [0, 1, 2], vs.YUV)

    antialias = join([lvf.sraa(plane) for plane in split(merge)])
    antialias = lvf.rfs(merge, antialias, [(2836, 2870)])

    denoise = core.knlm.KNLMeansCL(antialias,
                                   a=2,
                                   h=0.65,
                                   d=0,
                                   device_type='gpu',
                                   channels='UV')

    preden = CoolDegrain(denoise,
                         tr=2,
                         thsad=60,
                         blksize=8,
                         overlap=4,
                         plane=4)
    diff = core.std.MakeDiff(denoise, preden)
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=3000, brz_b=1500)

    deband_a = dbs.f3kpf(preden, 17, 42, 42)
    deband_b = core.placebo.Deband(preden,
                                   radius=17,
                                   threshold=6,
                                   iterations=1,
                                   grain=0,
                                   planes=1 | 2 | 4)
    deband = lvf.rfs(deband_a, deband_b, [(2081, 2216), (2450, 2550),
                                          (3418, 3452), (3926, 3926)])

    deband = core.std.MaskedMerge(deband, preden, deband_mask)
    deband = core.std.MergeDiff(deband, diff)

    grain = kgf.adaptive_grain(deband, 0.25, luma_scaling=8)
    final = depth(grain, 10)

    return final
コード例 #23
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)
    src += src[-1]

    src = core.std.FreezeFrames(src, 3130, 3153, 3129)
    black = src.std.BlankClip().grain.Add(0.2)
    src = vdf.fade_filter(src, src, black, 3130, 3154)
    src = depth(src, 16)

    h = 882
    w = get_w(h)
    kernel = 'lanczos'
    taps = 5
    opstart, opend = 264, 2421
    edstart, edend = 31767, 33924


    denoise = CoolDegrain(src, tr=1, thsad=24, blksize=8, overlap=4, plane=4)
    out = denoise



    luma = get_y(out)

    descale = kgf.get_descale_filter(kernel, taps=taps)(depth(luma, 32), w, h)
    upscale = vdf.fsrcnnx_upscale(depth(descale, 16), src.width, src.height, '_assets/shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  partial(core.resize.Bicubic, filter_param_a=0, filter_param_b=0))
    out = upscale



    unwarp = line_darkening(out, 0.275).warp.AWarpSharp2(depth=-2.5)
    sharp = hvf.LSFmod(unwarp, strength=90, Smode=3, Lmode=1, edgemode=1, edgemaskHQ=True)

    stabilize = stabilization(out, sharp, 2, 1, 8, 16)
    out = vdf.merge_chroma(stabilize, denoise)



    antialias = lvf.sraa(out, 1.4, rep=7, downscaler=core.resize.Bicubic)
    out = lvf.rfs(antialias, vdf.merge_chroma(upscale, denoise), [(edstart, edend)])



    deband_mask = lvf.denoise.detail_mask(out, brz_a=2000, brz_b=1000)

    deband = dbs.f3kpf(out, 17, 36, 36)
    deband_b = dbs.f3kpf(out, 17, 56, 56)
    deband = lvf.rfs(deband, out, [(3149, 3153)])
    deband = lvf.rfs(deband, deband_b, [(30213, 30422)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband = core.neo_f3kdb.Deband(deband, preset='depth', grainy=24, grainc=18, keep_tv_range=True)
    out = deband




    grain = kgf.adaptive_grain(out, 0.2, luma_scaling=14)
    out = grain




    rescale_mask = vdf.drm(src, h, kernel, taps, mthr=40, sw=4, sh=4)
    creditless_mask = core.std.Expr([
        vdf.dcm(src, src[opstart:opend+1], JPBD_NCOP.src_cut[:opend-opstart+1],
                opstart, opend, 2, 2).std.Deflate(),
        vdf.dcm(src, src[edstart:edend+1], JPBD_NCED.src_cut[:edend-edstart+1],
                edstart, edend, 2, 2).std.Deflate()], 'x y +')

    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, rescale_mask, 0),
                     [(opstart+425, opstart+698), (33971, src.num_frames-1)])
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, src, creditless_mask, 0),
                     [(opstart, opend), (edstart, edend)])
    credit = lvf.rfs(credit, src, [(7670, 7717), (20824, 20871), (26581, 26628)])
    out = credit


    return depth(out, 10)
コード例 #24
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1) -> vs.VideoNode:
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        def _strong(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(alpha=0.25,
                        beta=0.5,
                        gamma=40,
                        nrad=2,
                        mdis=20,
                        vcheck=3)
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            clip = core.eedi3m.EEDI3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        def _weak(clip: vs.VideoNode) -> vs.VideoNode:
            args = dict(nsize=3, nns=2, qual=2)
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            clip = core.znedi3.nnedi3(clip, 1, True, **args).std.Transpose()
            return core.resize.Spline36(clip,
                                        luma.width,
                                        luma.height,
                                        src_left=-.5,
                                        src_top=-.5)

        clip_aa = core.std.Expr(
            [_strong(luma), _weak(luma), luma],
            'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr))
        return vdf.merge_chroma(clip_aa, clip)

    def _perform_endcard(path: str, ref: vs.VideoNode) -> vs.VideoNode:
        endcard = lvf.src(path).std.AssumeFPS(ref)
        endcard = core.std.CropRel(endcard,
                                   left=10,
                                   top=17,
                                   right=17,
                                   bottom=23)
        endcard = core.resize.Bicubic(endcard,
                                      ref.width,
                                      ref.height,
                                      vs.RGBS,
                                      dither_type='error_diffusion')

        endcard = iterate(
            endcard, partial(core.w2xc.Waifu2x, noise=3, scale=1, photo=True),
            2)

        endcard = core.resize.Bicubic(endcard,
                                      format=vs.YUV444PS,
                                      matrix_s='709',
                                      dither_type='error_diffusion')

        return Tweak(endcard, sat=1.2, bright=-0.05, cont=1.2)

    src = JPBD.src_cut
    src = depth(src, 16)

    denoise = CoolDegrain(src, tr=2, thsad=48, blksize=8, overlap=4, plane=4)

    antialias_a = _nneedi3_clamp(denoise)

    antialias_b = lvf.sraa(denoise, rep=6)
    antialias = lvf.rfs(antialias_a, antialias_b, [(29453, 29476),
                                                   (29510, 29532),
                                                   (29640, 29663),
                                                   (29775, 29798),
                                                   (29866, 29889),
                                                   (30011, 30034)])

    predenoise = mClean(antialias, thSAD=200, chroma=False)
    detail_mask = lvf.denoise.detail_mask(predenoise,
                                          rad=2,
                                          radc=2,
                                          brz_a=3250,
                                          brz_b=1250)
    ret_mask = kgf.retinex_edgemask(predenoise).std.Binarize(
        9250).std.Median().std.Inflate()
    line_mask = core.std.Expr([detail_mask, ret_mask], 'x y max')

    deband = core.neo_f3kdb.Deband(antialias,
                                   17,
                                   42,
                                   42,
                                   42,
                                   12,
                                   0,
                                   sample_mode=4,
                                   keep_tv_range=True)
    deband = core.std.MaskedMerge(deband, antialias, line_mask)

    grain_a = kgf.adaptive_grain(deband, 0.25, luma_scaling=10)
    grain_b = adptvgrnMod(deband,
                          2,
                          size=2,
                          luma_scaling=2,
                          static=False,
                          grain_chroma=False)
    grain = lvf.rfs(grain_a, grain_b, [(5149, 5598), (8691, 10137)])

    borders_mask = vdf.region_mask(
        src.std.BlankClip(format=vs.GRAY16, color=(256 << 8) - 1), 240 + 2,
        240 + 2, 0, 0)
    borders = core.std.MaskedMerge(src, grain, borders_mask)
    borders = lvf.rfs(grain, borders, [(5149, 5598)])

    endcard = _perform_endcard(
        '[BDMV][200304][Magia Record][Vol.1]/Scans/endcard1_front_descreen.png',
        src)
    endcard_length = 119
    final = core.std.Splice([borders, endcard * endcard_length], True)
    final = core.resize.Bicubic(final,
                                format=vs.YUV420P10,
                                dither_type='error_diffusion')
    final = core.std.Limiter(final, 16, [235 << 2, 240 << 2])

    return depth(final, 10), endcard_length
コード例 #25
0
def do_filter():
    """Vapoursynth filtering"""
    def _nneedi3_clamp(clip: vs.VideoNode, strength: int = 1):
        bits = clip.format.bits_per_sample - 8
        thr = strength * (1 >> bits)

        luma = get_y(clip)

        strong = TAAmbk(luma, aatype='Eedi3', alpha=0.4, beta=0.4)
        weak = TAAmbk(luma, aatype='Nnedi3')
        expr = 'x z - y z - * 0 < y x y {0} + min y {0} - max ?'.format(thr)

        clip_aa = core.std.Expr([strong, weak, luma], expr)
        return core.std.ShufflePlanes([clip_aa, clip], [0, 1, 2], vs.YUV)

    def _hell_deband(clip: vs.VideoNode):
        clip = depth(clip, 32)
        preden = vrf.knlmcl(clip, 2, 2, bits=32)
        diff = core.std.MakeDiff(clip, preden)
        deband = core.placebo.Deband(preden, radius=20, threshold=28, iterations=3, grain=8, planes=1|2|4)
        merge = core.std.MergeDiff(deband, diff)
        return depth(merge, 16)

    def _hell_mask(mask: vs.VideoNode, pand: int):
        mask = lvf.scale.iterate(mask, core.std.Median, 2)
        mask = hvf.mt_expand_multi(mask, 'ellipse', 0, sw=pand, sh=pand)
        mask = hvf.mt_inpand_multi(mask, 'ellipse', 0, sw=pand - int(pand/2), sh=pand - int(pand/2))
        mask = core.std.Expr(mask, 'x 25000 < 0 x 6 * ?')
        return mask

    src = SRC_CUT

    interpolate = core.resize.Bicubic(src, src_left=3)
    f_1, f_2 = 1006, 2006
    src = src[:EDSTART+f_1] + interpolate[EDSTART+f_1] + src[EDSTART+f_1:EDSTART+f_2] \
        + interpolate[EDSTART+f_2] + src[EDSTART+f_2:-2]

    # Fix bandings in motion
    src = core.std.FreezeFrames(src, 29782, 29786, 29782)
    src = core.std.FreezeFrames(src, 29787, 29788, 29787)
    src = core.std.FreezeFrames(src, 29789, 29791, 29791)

    src = depth(src, 16)

    blur = core.bilateral.Gaussian(src, [0.45, 0])
    den = CoolDegrain(blur, tr=1, thsad=60, blksize=8, overlap=4, plane=4)



    dering = core.std.MaskedMerge(den, hvf.YAHR(den, 2, 32), muvf.AnimeMask(den, 0.2), 0)




    aa_a = core.std.MaskedMerge(dering, _nneedi3_clamp(dering), TAAmbk(dering, mtype=2, showmask=1))
    aa_b = TAAmbk(src, aatype='Nnedi3', mtype=1, nns=4, qual=2, nsize=6)
    aa = lvf.rfs(aa_a, aa_b, [(OPSTART, OPEND), (EDSTART, EDEND)])




    db_m = lvf.denoise.detail_mask(aa.std.Median(), brz_a=3000, brz_b=1500)

    db_a = dbs.f3kpf(aa, 17)
    db_b = core.std.MaskedMerge(_hell_deband(aa), aa, _hell_mask(db_m, 60))
    db_c = core.placebo.Deband(aa, radius=18, threshold=5, iterations=1, grain=6, planes=1|2|4)
    db = lvf.rfs(db_a, db_b, [(7535, 7894), (8579, 8947), (9602, 9769)])
    db = lvf.rfs(db, db_c, [(29782, 29791)])
    db = core.std.MaskedMerge(db, aa, db_m)

    grain = mdf.adptvgrnMod_mod(db, 0.2, size=1.25, sharp=60, luma_scaling=8)

    final = depth(grain, 10)

    return final, src
コード例 #26
0
def do_filter():
    """Vapoursynth filtering"""
    def _single_rate_aa(clip):
        nnargs = dict(nsize=0, nns=2, qual=1)
        eeargs = dict(alpha=0.2, beta=0.4, gamma=250, nrad=3, mdis=20)
        clip = core.eedi3m.EEDI3(clip,
                                 0,
                                 0,
                                 0,
                                 sclip=core.nnedi3.nnedi3(
                                     clip, 0, 0, 0, **nnargs),
                                 **eeargs).std.Transpose()
        clip = core.eedi3m.EEDI3(clip,
                                 0,
                                 0,
                                 0,
                                 sclip=core.nnedi3.nnedi3(
                                     clip, 0, 0, 0, **nnargs),
                                 **eeargs).std.Transpose()
        return clip

    # Fun part / Cutting
    src_funi, src_wkn = [depth(c, 16) for c in CLIPS_SRC]
    src_funi, src_wkn = src_funi[744:], src_wkn[0] + src_wkn

    # Dehardsubbing
    # comp = lvf.comparison.stack_compare(src_funi, src_wkn, height=540, make_diff=True)
    src = core.std.MaskedMerge(src_wkn, src_funi,
                               kgf.hardsubmask(src_wkn, src_funi))
    hardsub_rem = core.std.MaskedMerge(
        src, src_funi, kgf.hardsubmask_fades(src, src_funi, 8, 2000))
    src = lvf.rfs(src, hardsub_rem, [(3368, 3451)])

    # Regular filterchain
    op, ed, eyec = (1200, 3356), (18989, 19108), (31888, 34046)
    opstart = op[0]

    denoise = CoolDegrain(src, tr=1, thsad=36, blksize=8, overlap=4, plane=4)

    h = 846
    w = get_w(h)
    b, c = vdf.get_bicubic_params('mitchell')

    luma = get_y(denoise)

    descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c)

    upscale = vdf.fsrcnnx_upscale(depth(descale, 16), descale.height * 2,
                                  "Shaders/FSRCNNX_x2_56-16-4-1.glsl",
                                  core.resize.Point)
    sraa = _single_rate_aa(upscale)
    rescaled = core.resize.Bicubic(sraa,
                                   src.width,
                                   src.height,
                                   filter_param_a=0,
                                   filter_param_b=0)

    dering = core.std.MaskedMerge(
        rescaled, core.bilateral.Gaussian(rescaled, 0.3),
        hvf.HQDeringmod(rescaled, incedge=True, show=True))
    rescaled = lvf.rfs(rescaled, dering, [(opstart, opstart + 498)])
    merged = vdf.merge_chroma(rescaled, src)
    out = merged

    dehalo = fine_dehalo(out,
                         rx=2.2,
                         darkstr=0,
                         brightstr=1,
                         contra=True,
                         useMtEdge=True)
    out = dehalo

    cred_m = vdf.drm(src, h, b=b, c=c, mthr=80, mode='ellipse')
    credit = lvf.rfs(out, core.std.MaskedMerge(out, src, cred_m), [op])
    credit = lvf.rfs(credit, src, [eyec, ed])
    out = credit

    thr = 7000
    line_mask = gf.EdgeDetect(
        out, 'FDOG').std.Median().std.Expr(f'x {thr} < x x 3 * ?')

    deband = dbs.f3kpf(out, 17, 36, 36)
    deband_b = dbs.f3kbilateral(out, 20, 64, 64)
    deband = lvf.rfs(deband, deband_b, [(14775, 14846)])
    deband = core.std.MaskedMerge(deband, out, line_mask)
    out = deband

    dedimm = gf.Tweak(out, sat=1.1, cont=1.1)
    dedimm = lvf.rfs(out, dedimm, [(12957, 13061)])
    out = dedimm

    grain = core.grain.Add(out, 0.1)
    out = grain

    return depth(out, 10)