コード例 #1
0
def do_filter():
    """Vapoursynth filtering"""
    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)
        sraa = _sraa(upscale, dict(nsize=3, nns=3, qual=1, pscrn=1))
        return core.resize.Bicubic(sraa, clip.width*factor, clip.height*factor,
                                   src_top=.5, src_left=.5, filter_param_a=0, filter_param_b=0.25)

    # My GPU’s dying on it
    def _sraa(clip: vs.VideoNode, nnargs: dict)-> vs.VideoNode:
        clip = clip.nnedi3cl.NNEDI3CL(0, False, **nnargs).std.Transpose()
        clip = clip.nnedi3cl.NNEDI3CL(0, False, **nnargs).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, 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, [(3917, 4024)])


    # Regular filterchain
    op, ed = (17238, 19468), (31889, 34045)
    h = 846
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')

    luma = get_y(src)

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

    descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c)
    rescaled = _nnedi3(depth(descale, 16), src.height/h, dict(nsize=0, nns=4, qual=2, pscrn=2))
    rescaled = core.std.MaskedMerge(luma, rescaled, line_mask)
    merged = vdf.merge_chroma(rescaled, src)
    out = merged

    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, [ed])
    out = credit

    deband = dbs.f3kpf(out, 17, 36, 36)
    deband = core.std.MaskedMerge(deband, out, line_mask)
    grain = core.grain.Add(deband, 0.25)

    return depth(grain, 10)
コード例 #2
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)
コード例 #3
0
def do_filter():
    """Vapoursynth filtering"""
    def _rescale(clip: vs.VideoNode, dx: int, dy: int):
        eeargs = dict(pscrn=2, alpha=0.3, beta=0.4, gamma=500, nrad=3, mdis=18)
        ux = clip.width * 2
        uy = clip.height * 2
        clip = iaa.eedi3_instance(clip.std.Transpose(),
                                  nnedi3Mode='opencl',
                                  **eeargs)
        clip = core.resize.Bicubic(clip,
                                   height=dx,
                                   src_top=-0.5,
                                   src_height=ux,
                                   filter_param_a=0,
                                   filter_param_b=0)
        clip = iaa.eedi3_instance(clip.std.Transpose(),
                                  nnedi3Mode='opencl',
                                  **eeargs)
        return core.resize.Bicubic(clip,
                                   height=dy,
                                   src_top=-0.5,
                                   src_height=uy,
                                   filter_param_a=0,
                                   filter_param_b=0)

    # 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 + src_wkn[-1]

    # Dehardsubbing
    # comp = lvf.comparison.stack_compare(src_funi, src_wkn, height=720, 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, [(4018, 4138)])

    # Regular filterchain
    op, ed, eyec = (1534, 3692), (16280, 16399), (31888, 34046)
    opstart = op[0]
    h = 846
    w = get_w(h)
    b, c = vdf.get_bicubic_params('mitchell')

    luma = get_y(src)

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

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

    rescaled = _rescale(depth(descale, 16), src.width, src.height)
    rescaled = core.std.MaskedMerge(luma, rescaled, line_mask)

    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

    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

    deband = dbs.f3kpf(out, 17, 36, 36)
    deband = core.std.MaskedMerge(deband, out, line_mask)

    dedimm = gf.Tweak(deband, sat=1.28, cont=1.28)
    dedimm = lvf.rfs(deband, dedimm, [(1112, 1159), (7764, 7780), (9436, 9514),
                                      (20607, 20755), (26972, 27006)])

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

    return depth(grain, 10)
コード例 #4
0
def do_filter():
    """Vapoursynth filtering"""

    def _nnedi3(clip: vs.VideoNode, factor: float, args: dict) -> vs.VideoNode:
        upscale = clip.std.Transpose().nnedi3cl.NNEDI3CL(0, True, **args) \
            .std.Transpose().nnedi3cl.NNEDI3CL(0, True, **args)
        sraa = _sraa(upscale, dict(nsize=3, nns=3, qual=1, pscrn=1),
                dict(alpha=0.3, beta=0.4, gamma=500, nrad=3, mdis=18))
        return core.resize.Bicubic(sraa, clip.width*factor, clip.height*factor,
                                   src_top=.5, src_left=.5, filter_param_a=0, filter_param_b=0)

    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

    # 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=720, 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, [(3796, 3892)])

    # Regular filterchain
    op, ed, eyec = (1630, 3788), (31888, 34046), (16400, 16519)
    h = 846
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')

    luma = get_y(src)

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

    descale = core.descale.Debicubic(depth(luma, 32), w, h, b, c)
    rescaled = _nnedi3(depth(descale, 16), src.height/h, dict(nsize=0, nns=4, qual=2, pscrn=2))
    rescaled = core.std.MaskedMerge(luma, rescaled, line_mask)
    merged = vdf.merge_chroma(rescaled, src)
    out = merged

    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

    deband = dbs.f3kpf(out, 17, 36, 36)
    deband = core.std.MaskedMerge(deband, out, line_mask)

    dedimm = gf.Tweak(deband, sat=1.15, cont=1.15)
    dedimm = lvf.rfs(deband, dedimm, [(21093, 21211)])

    grain = core.grain.Add(dedimm, 0.2)

    return depth(grain, 10)