Exemple #1
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')




    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise


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


    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height*2, '_shaders/FSRCNNX_x2_56-16-4-1.glsl', core.resize.Point)

    antialias = single_rate_antialiasing(upscale, 13, alpha=0.3, beta=0.45, gamma=320, mdis=18)

    scaled = muvf.SSIM_downsample(antialias, src.width, src.height, kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)



    # Slight sharp though CAS
    sharp = hvf.LSFmod(out, strength=75, 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=48, depth=8)
    out = warp


    preden = core.knlm.KNLMeansCL(out, d=0, a=3, h=0.6, device_type='GPU', channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)
    deband = dbs.f3kpf(out, 17, 42, 42)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband


    adg_mask = core.adg.Mask(out.std.PlaneStats(), 20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain


    return depth(out, 10)
Exemple #2
0
    def main(self: Filtering) -> vs.VideoNode:  # noqa
        """Vapoursynth filtering"""
        src = WEB.clip_cut
        src = src.std.AssumeFPS(src)


        src = depth(src, 16)
        out = src


        denoise = hvf.SMDegrain(out, tr=1, thSAD=100, thSADC=100)
        out = denoise


        dering = hvf.EdgeCleaner(out, 15, smode=1, hot=True)
        dering = gf.MaskedDHA(dering, darkstr=0.05, brightstr=0.75)
        out = dering


        aaa = vdf.scale.nnedi3_upscale(get_y(out), pscrn=1, correct_shift=False)
        aaa = aaa.resize.Bicubic(1920, 1080, src_left=0.5, src_top=0.5, filter_param_a=-0.5, filter_param_b=0.25)
        out = vdf.misc.merge_chroma(aaa, out)


        cwarp = xvs.WarpFixChromaBlend(out, 64, depth=4)
        out = cwarp


        detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1200)
        deband = vdf.deband.dumb3kdb(out, 16, threshold=33, grain=[24, 0])
        deband = core.std.MaskedMerge(deband, out, detail_mask)
        out = deband


        return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])[:100]
Exemple #3
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)
    out = src + src[-1]

    denoise = mvf.BM3D(out, [2.5, 1.5], radius1=1)
    diff = core.std.MakeDiff(out, denoise)
    out = denoise

    luma = get_y(out)
    dehalo = gf.MaskedDHA(luma,
                          rx=2.5,
                          ry=2.5,
                          darkstr=0.15,
                          brightstr=1.2,
                          maskpull=48,
                          maskpush=140)
    out = dehalo

    dering = gf.HQDeringmod(out, sharp=3, drrep=24, thr=24, darkthr=0)
    out = dering

    antialias_mask = gf.EdgeDetect(out, 'FDOG')
    antialias = lvf.sraa(out,
                         1.5,
                         13,
                         gamma=100,
                         downscaler=core.resize.Spline64)
    out = core.std.MaskedMerge(out, antialias, antialias_mask)

    out = vdf.merge_chroma(out, denoise)

    warp = xvs.WarpFixChromaBlend(out, 64, depth=8)
    out = warp

    deband_mask = lvf.denoise.detail_mask(out, brz_a=2250,
                                          brz_b=1500).std.Median()
    deband = dbs.f3kpf(out, 17, 36, 36)
    deband_b = dbs.f3kpf(out, 17, 56, 48)
    deband = lvf.rfs(deband, deband_b, [(23708, 24371)])
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    out = deband

    grain_original = core.std.MergeDiff(out, diff)
    grain_new = core.grain.Add(out, 0.15, 0, constant=True)
    grain_mask = core.adg.Mask(out.std.PlaneStats(),
                               30).std.Expr(f'x x {96<<8} - 0.25 * +')
    grain = core.std.MaskedMerge(grain_new, grain_original, grain_mask)
    out = grain

    ending = lvf.rfs(out, src, [(31241, src.num_frames - 1)])
    out = ending

    return depth(out, 10)
Exemple #4
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)

    h = 720
    w = get_w(h)
    # getnative script returns 0.2 0.5 as best combo but it introduces too much halos.
    # I think it's plain mitchell but robidoux is good too and very slightly sharp.
    b, c = vdf.get_bicubic_params('robidoux')
    opstart = 0

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)
    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')

    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

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

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

    warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)
    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])
    deband = core.std.MaskedMerge(deband, out, mask)
    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    return depth(out, 10)
Exemple #5
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    full_stuff = [(0, 1310), (15484, 15639)]

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)
    upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1)
    upscale = lvf.rfs(upscale, upscale_smooth, [(5534, 5598)])

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

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

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src = [
        depth(x, 16) for x in [denoise, rescale_mask, src]
    ]
    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    credit = lvf.rfs(credit, src, [(31707, 33937)])
    out = credit

    smooth = gf.JohnFPS(out[31707:33937 + 1], 60000, 1001)
    clips = [out[:31707], smooth, out[33937 + 1:]]
    vfr = muvf.VFRSplice(clips, 'symphogearg_13_timecode.txt')
    cfr = core.std.AssumeFPS(vfr, src)
    out = cfr

    return depth(out, 10)
Exemple #6
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src += src[-1]
    ep10 = JPBD_10.src_cut

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    opstart, opend = 2973, 5370
    edstart, edend = 31887, src.num_frames - 1
    opstart_ep10, opend_ep10 = 768, 3164
    full_stuff = [(5449, 5580), (16465, 16620)]

    # Fix compositing error in the OP
    op_src, op_10 = src[opstart:opend + 1], ep10[opstart_ep10:opend_ep10 + 1]
    fix = lvf.rfs(op_src, op_10, [(0, 79), (1035, 1037)])
    fix_src = insert_clip(src, fix, opstart)
    src = depth(fix_src, 32)

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])

    deband_c = placebo.deband(deband, 17, 5, 1)
    deband_c = dbs.f3kbilateral(deband_c, 22, 64, 64)
    deband = lvf.rfs(deband, deband_c, [(15612, 15695)])

    deband_mask2 = vdf.edge_detect(
        out.knlm.KNLMeansCL(d=2, a=2, h=0.4, device_type='GPU', channels='Y'),
        'FDOG', 1100, (8, 1))
    deband_mask2 = iterate(deband_mask2, core.std.Deflate, 4)
    deband_d = placebo.deband(out, 16, 12, 3)
    deband_d = core.std.MaskedMerge(deband_d, out, deband_mask2)
    deband = lvf.rfs(deband, deband_d, [(16339, 16542)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src, src_ncop, src_nced = [
        depth(x, 16) for x in
        [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    out = credit

    src_c, src_ncop, src_nced = [
        c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu')
        for c in [src, src_ncop, src_nced]
    ]

    opening_mask = vdf.dcm(out, src_c[opstart:opend + 1],
                           src_ncop[:opend - opstart + 1], opstart, opend, 4,
                           4).std.Inflate()
    ending_mask = vdf.dcm(out, src_c[edstart:edend + 1],
                          src_nced[:edend - edstart + 1], edstart, edend, 4,
                          4).std.Inflate()
    credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +')

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask),
                     [(opstart, opend), (edstart, edend)])
    out = credit

    return depth(out, 10)
Exemple #7
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut

    # Variables
    opstart, opend = 2111, 4268
    edstart, edend = 31650, 33809
    full_zone = [(18727, 18774), (31590, 31649), (33990, src.num_frames - 1)
                 ]  # eyecatch, episode name and next episode
    shabc_zone = [(edstart + 15, edstart + 1215),
                  (edstart + 1882, edstart + 2126)]
    h = 720
    w = get_w(h)

    # Bicubic sharp parts don't have bad edges
    edges_a = core.edgefixer.ContinuityFixer(src, *[[2, 1, 1]] * 4)
    edges_b = awf.bbmod(src, left=6, thresh=32, blur=200)
    edges = lvf.rfs(edges_a, edges_b, [(edstart + 1275, edstart + 1757)])
    edges = lvf.rfs(edges, src, [(opstart, opend)] + full_zone)
    out = depth(edges, 32)

    # Denoise
    ref = hvf.SMDegrain(depth(get_y(out), 16), thSAD=450)
    denoise = hybrid_denoise(out, 0.35, 1.4, dict(a=2, d=1),
                             dict(ref=depth(ref, 32)))
    out = denoise
    # denoise = out

    # Descale
    luma = get_y(out)
    lineart = vdf.edge_detect(luma, 'FDOG', 0.055,
                              (1, 1)).std.Median().std.BoxBlur(0, 1, 1, 1, 1)

    descale_a = core.descale.Despline36(luma, w,
                                        h).std.SetFrameProp('descaleKernel',
                                                            data='spline36')
    descale_b = core.descale.Debicubic(luma, w, h, 0, 1).std.SetFrameProp(
        'descaleKernel', data='sharp_bicubic')
    descale = lvf.rfs(descale_a, descale_b, shabc_zone)

    # Chroma reconstruction
    # y_m is the assumed mangled luma.
    # Descale 1080p -> Bad conversion in 422 720p -> Regular 1080p 420
    radius = 2
    y, u, v = descale, plane(out, 1), plane(out, 2)
    y_m = core.resize.Point(y, 640, 720,
                            src_left=-1).resize.Bicubic(960,
                                                        540,
                                                        filter_param_a=1 / 3,
                                                        filter_param_b=1 / 3)

    # 0.25 for 444 and 0.25 for right shifting
    y_m, u, v = [
        c.resize.Bicubic(w,
                         h,
                         src_left=0.25 + 0.25,
                         filter_param_a=0,
                         filter_param_b=.5) for c in [y_m, u, v]
    ]

    y_fixup = core.std.MakeDiff(y, y_m)
    yu, yv = Regress(y_m, u, v, radius=radius, eps=1e-7)

    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)

    # -0.5 * 720/1080 = -1/3
    # -1/3 for the right shift
    # https://forum.doom9.org/showthread.php?p=1802716#post1802716
    u_r, v_r = [
        c.resize.Bicubic(960,
                         540,
                         src_left=-1 / 3,
                         filter_param_a=-.5,
                         filter_param_b=.25) for c in [u_r, v_r]
    ]

    upscale = vdf.fsrcnnx_upscale(
        descale,
        height=h * 2,
        shader_file=r'shaders\FSRCNNX_x2_56-16-4-1.glsl',
        upscaler_smooth=eedi3_upscale,
        profile='zastin')

    antialias = sraa_eedi3(upscale,
                           3,
                           alpha=0.2,
                           beta=0.4,
                           gamma=40,
                           nrad=3,
                           mdis=20)

    downscale = muvf.SSIM_downsample(antialias,
                                     src.width,
                                     src.height,
                                     filter_param_a=0,
                                     filter_param_b=0)
    downscale = core.std.MaskedMerge(luma, downscale, lineart)

    merged_a = join([downscale, u_r, v_r])
    merged_b = vdf.merge_chroma(downscale, denoise)
    merged = lvf.rfs(merged_a, merged_b, shabc_zone)
    out = depth(merged, 16)

    warp = xvs.WarpFixChromaBlend(out, 80, 2, depth=8)
    out = warp

    dering = gf.MaskedDHA(out,
                          rx=1.25,
                          ry=1.25,
                          darkstr=0.05,
                          brightstr=1.0,
                          maskpull=48,
                          maskpush=140)
    out = dering

    qtgmc = hvf.QTGMC(out, Preset="Slower", InputType=1, ProgSADMask=2.0)
    qtgmc = vdf.fade_filter(out, out, qtgmc, edstart + 1522,
                            edstart + 1522 + 24)
    qtgmc = lvf.rfs(out, qtgmc, [(edstart + 1522 + 25, edstart + 1757)])
    out = qtgmc

    out = lvf.rfs(out, depth(denoise, 16), [(opstart, opend)])

    detail_dark_mask = detail_dark_mask_func(get_y(out),
                                             brz_a=8000,
                                             brz_b=6000)
    detail_light_mask = lvf.denoise.detail_mask(out, brz_a=2500, brz_b=1200)
    detail_mask = core.std.Expr([detail_dark_mask, detail_light_mask],
                                'x y +').std.Median()
    detail_mask_grow = iterate(detail_mask, core.std.Maximum, 2)
    detail_mask_grow = iterate(detail_mask_grow, core.std.Inflate,
                               2).std.BoxBlur(0, 1, 1, 1, 1)

    detail_mask = core.std.Expr([get_y(out), detail_mask_grow, detail_mask],
                                f'x {32<<8} < y z ?')

    deband = dumb3kdb(out, 22, 30)
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    ref = get_y(out).std.PlaneStats()
    adgmask_a = core.adg.Mask(ref, 30)
    adgmask_b = core.adg.Mask(ref, 12)

    stgrain = sizedgrn(out, 0.1, 0.05, 1.05, sharp=80)
    stgrain = core.std.MaskedMerge(out, stgrain, adgmask_b)
    stgrain = core.std.MaskedMerge(out, stgrain, adgmask_a.std.Invert())

    dygrain = sizedgrn(out, 0.2, 0.05, 1.15, sharp=80, static=False)
    dygrain = core.std.MaskedMerge(out, dygrain, adgmask_a)
    grain = core.std.MergeDiff(dygrain, out.std.MakeDiff(stgrain))
    out = grain

    ref = depth(edges, 16)
    credit = out
    rescale_mask = vdf.diff_rescale_mask(ref, h, b=0, c=1, mthr=40, sw=0, sh=0)
    rescale_mask = vdf.region_mask(rescale_mask, *[10] * 4)
    rescale_mask = hvf.mt_expand_multi(rescale_mask,
                                       mode='ellipse',
                                       sw=4,
                                       sh=4).std.BoxBlur(0, 1, 1, 1, 1)

    credit = lvf.rfs(credit, ref, full_zone)
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask),
                     [(edstart, edend)])
    out = credit

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2])
Exemple #8
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)
Exemple #9
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    opstart, opend = 1392, 3788
    edstart, edend = 31889, src.num_frames - 1
    full_stuff = [(3801, 3908), (16203, 16358)]

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)
    upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1)
    upscale = lvf.rfs(upscale, upscale_smooth, [(18547, 18586)])

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])

    deband_c = placebo.deband(out, 17, 8, 3)
    import kagefunc
    deband_mask_c = kagefunc.retinex_edgemask(preden)
    deband_mask_c = iterate(deband_mask_c, core.std.Maximum,
                            3).std.Binarize(15000).std.Deflate()
    deband = lvf.rfs(deband,
                     core.std.MaskedMerge(deband_c, deband, deband_mask_c),
                     [(7409, 7600), (7960, 8055)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src, src_ncop, src_nced = [
        depth(x, 16) for x in
        [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    out = credit

    src_c, src_ncop, src_nced = [
        c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu')
        for c in [src, src_ncop, src_nced]
    ]

    opening_mask = vdf.dcm(out, src_c[opstart:opend + 1],
                           src_ncop[:opend - opstart + 1], opstart, opend, 4,
                           4).std.Inflate()
    ending_mask = vdf.dcm(out, src_c[edstart:edend + 1],
                          src_nced[:edend - edstart + 1], edstart, edend, 4,
                          4).std.Inflate()
    credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +')

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask),
                     [(opstart, opend), (edstart, edend)])
    out = credit

    return depth(out, 10)
Exemple #10
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    ep11 = JPBD_11.src_cut

    opstart = 0
    opstart_ep11, opend_ep11 = 744, 3140
    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')

    # Fix compositing error in the OP
    ncop, op_11 = src, ep11[opstart_ep11:opend_ep11 + 1]
    fix = lvf.rfs(ncop, op_11, [(0, 79), (1035, 1037)])
    src = depth(fix, 32)

    def denoise_and_rescale(clip):
        denoise = hybrid_denoise(clip, 0.5, 2)
        out = denoise

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

        descale = core.descale.Debicubic(luma, w, h, b, c)
        upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                      '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                      core.resize.Point)

        antialias = single_rate_antialiasing(upscale,
                                             13,
                                             alpha=0.3,
                                             beta=0.45,
                                             gamma=320,
                                             mdis=18)
        scaled = muvf.SSIM_downsample(antialias,
                                      src.width,
                                      src.height,
                                      kernel='Bicubic')

        rescale = core.std.MaskedMerge(luma, scaled, line_mask)
        merged = vdf.merge_chroma(rescale, out)
        return depth(merged, 16)

    out = denoise_and_rescale(src)
    to_zoom = denoise_and_rescale(depth(JPBD_11.src_cut[8590:8605], 32))

    zoom = core.std.FrameEval(to_zoom, partial(_zoom_prog, clip=to_zoom))
    out = insert_clip(out, zoom, 1685)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

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

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

    warp = xvs.WarpFixChromaBlend(out, thresh=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)
    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])
    deband = core.std.MaskedMerge(deband, out, mask)
    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    return depth(out, 10)
Exemple #11
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)
    src += src[-1]

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    full_stuff = [(313, 1993), (15602, 15757), (19240, 19295)]

    denoise = hybrid_denoise(src, 0.5, 2)
    denoise_b = hybrid_denoise(src, 0.6, 7.5, bm3d_args=dict(profile1='high'))
    deband = lvf.rfs(denoise, denoise_b, [(4002, 4061)])
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(out, _aa_extra(depth(denoise, 16)), [(2794, 2949)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)
    deband = dbs.f3kpf(out, 17, 42, 42)
    deband = core.std.MaskedMerge(deband, out, deband_mask)
    deband_b = rkt.rekt_fast(
        deband, lambda x: core.neo_f3kdb.Deband(
            x, 8, 96, 96, 96, sample_mode=1, keep_tv_range=True), 1112, 264,
        184, 0)
    deband = lvf.rfs(deband, deband_b, [(4002, 4061)])
    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    grain_b = adptvgrnMod(grain,
                          0.6,
                          size=1.85,
                          static=False,
                          luma_scaling=4,
                          grain_chroma=False)
    grain = lvf.rfs(grain, grain_b, [(204, 2049)])
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src = [
        depth(x, 16) for x in [denoise, rescale_mask, src]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    credit = lvf.rfs(
        credit,
        core.std.MaskedMerge(credit, ref,
                             vdf.region_mask(rescale_mask, 1450, 0, 947, 0)),
        [(33860, 33925)])
    credit = lvf.rfs(credit, src, [(0, 203), (2049, 2229), (31768, 33839)])
    out = credit

    smooth = gf.JohnFPS(out[31888:33840], 60000, 1001)
    clips = [out[:31888], smooth, out[33840:]]
    vfr = muvf.VFRSplice(clips, 'symphogearg_01_timecode.txt')
    cfr = core.std.AssumeFPS(vfr, src)
    out = cfr

    return depth(out, 10)
Exemple #12
0
def do_filter():
    """Vapoursynth filtering"""
    scene_change = []
    with open('k.log') as file:
        lines = file.readlines()
        for line in lines:
            line = line.split()
            scene_change.append(int(line[0]))

    src = CLIP_SRC

    # Lol?
    border = awf.bbmod(src, 4, thresh=128, blur=15, y=True, u=True, v=True)
    border = lvf.ef(border, [6, 3, 3], radius=[12, 6, 6])
    border = lvf.rfs(src, border, scene_change)
    out = depth(border, 16)

    # joletb has stronk eyes
    planes = split(out)
    planes[1], planes[2] = [
        core.resize.Spline16(plane, src_top=-0.25) for plane in planes[1:]
    ]
    out = join(planes)

    # qual=2 produces weird artefacts and a stronger alpha/beta/gamma smudges details.
    new_fields = core.eedi3m.EEDI3(out,
                                   1,
                                   alpha=0.25,
                                   beta=0.3,
                                   gamma=400,
                                   nrad=3,
                                   mdis=20,
                                   vcheck=3,
                                   sclip=core.nnedi3.nnedi3(out,
                                                            1,
                                                            nsize=3,
                                                            nns=3,
                                                            qual=1,
                                                            pscrn=4))
    out = new_fields

    # omegartifacted frames
    def freeze_frame_after(clip, frame):
        return core.std.FreezeFrames(clip, frame, frame, frame + 1)

    def freeze_frame_before(clip, frame):
        return core.std.FreezeFrames(clip, frame, frame, frame - 1)

    cursed_frames = [
        2326, 8907, 12211, 12551, 13990, 14403, 15462, 17673, 19382, 23099,
        23738, 24031, 24802, 25083
    ]
    for cursed_frame in cursed_frames:
        out = freeze_frame_after(out, cursed_frame)
    cursed_frames = [5695, 9115, 9116, 17671, 18432]
    for cursed_frame in cursed_frames:
        out = freeze_frame_before(out, cursed_frame)

    # omegartifacted frames ²
    denoise_li = hvf.SMDegrain(out, thSAD=200)
    denoise_hi = hvf.SMDegrain(out, thSAD=350)
    denoise = lvf.rfs(denoise_li, denoise_hi, scene_change)

    def hard_denoise(clip):
        clip = hvf.SMDegrain(clip, thSAD=500)
        clip = knlm_denoise(clip, (2, 2), dict(a=8))
        return clip

    cursed_frames = [
        595, 1191, 2643, 2663, 2664, 2665, 2666, 2667, 2671, 2672, 2674, 2675,
        2679, 3999, 4419, 6351, 6355, 6547, 8906, 11731, 14176, 14177, 14178,
        14179, 18430, 18435, 18437, 18438, 18439, 27766
    ]
    cursed_frames += range(10767, 10776)
    cursed_frames += range(25013, 25018)
    cursed_frames += range(27663, 27668)
    cursed_frames += range(29642, 29646)
    cursed_frames += range(31384, 31388)

    uncursed = hard_denoise(out)
    denoise = lvf.rfs(denoise, uncursed, cursed_frames)
    out = denoise

    # It helps to fix the the aliasing left
    antialias = lvf.sraa(out, rep=13)
    out = antialias

    # Compensative line darkening and sharpening
    luma = get_y(out)
    darken = hvf.Toon(luma, 0.20)
    darken_mask = core.std.Expr([
        core.std.Convolution(
            luma, [5, 10, 5, 0, 0, 0, -5, -10, -5], divisor=4, saturate=False),
        core.std.Convolution(
            luma, [5, 0, -5, 10, 0, -10, 5, 0, -5], divisor=4, saturate=False)
    ], [
        'x y max {neutral} / 0.86 pow {peak} *'.format(
            neutral=1 << (luma.format.bits_per_sample - 1),
            peak=(1 << luma.format.bits_per_sample) - 1)
    ])
    darken = core.std.MaskedMerge(luma, darken, darken_mask)

    # Slight sharp through CAS
    sharp = hvf.LSFmod(darken,
                       strength=65,
                       Smode=3,
                       Lmode=1,
                       edgemode=1,
                       edgemaskHQ=True)
    out = vdf.merge_chroma(sharp, out)

    # Chroma planes are pure crap
    chromableed = xvs.WarpFixChromaBlend(out, 96, depth=8)
    out = chromableed

    detail_mask = lvf.denoise.detail_mask(out, brz_a=2700, brz_b=1500)
    deband = placebo.deband(out, 17, 5.75, grain=4)
    deband_b = placebo.deband(out, 24, 8, 2, grain=4)
    deband_c = placebo.deband(out, 17, 8, grain=4)
    deband_d = placebo.deband(out, 20, 12, 3, grain=4)

    deband = lvf.rfs(deband, deband_b, [(4596, 4669), (23036, 23098)])
    deband = lvf.rfs(deband, deband_c, [(1646, 1711), (29768, 29840),
                                        (29932, 30037), (30163, 30243)])
    deband = lvf.rfs(deband, deband_d, [(1712, 1830)])

    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    return depth(out, 10)
Exemple #13
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    opstart, opend = 768, 3164
    edstart, edend = 30571, 32728
    full_stuff = [(3189, 3296), (13806, 13961)]

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)
    upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1)
    upscale = lvf.rfs(upscale, upscale_smooth, [(5534, 5598)])

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    # Fix random productions errors
    # AAAAAAAAAAAAARGHHHHHHHHHHHHHHH WHYYYY THE STUDIO DID THIS
    ncop = JPBD_NCOP.src_cut
    ncop = lvf.rfs(ncop,
                   depth(src, 8)[opstart:opend + 1], [(0, 79), (1035, 1037)])

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src, src_ncop, src_nced = [
        depth(x, 16)
        for x in [denoise, rescale_mask, src, ncop, JPBD_NCED.src_cut]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    out = credit

    src_c, src_ncop, src_nced = [
        c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu')
        for c in [src, src_ncop, src_nced]
    ]

    opening_mask = vdf.dcm(out, src_c[opstart:opend + 1],
                           src_ncop[:opend - opstart + 1], opstart, opend, 4,
                           4).std.Inflate()
    ending_mask = vdf.dcm(out, src_c[edstart:edend + 1],
                          src_nced[:edend - edstart + 1], edstart, edend, 4,
                          4).std.Inflate()
    credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +')
    credit_mask = core.std.FreezeFrames(credit_mask, opstart + 1685,
                                        opstart + 1699, opstart + 1684)

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask),
                     [(opstart, opend), (edstart, edend)])
    out = credit

    return depth(out, 10)
Exemple #14
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    ep10 = JPBD_10.src_cut

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    opstart, opend = 672, 3068
    edstart, edend = 31888, src.num_frames - 1
    opstart_ep10, opend_ep10 = 768, 3164
    full_stuff = [(3853, 3984), (16130, 16279)]

    # Fix borders of the henshin
    start, end = 26596, 27387
    white_clip = core.std.BlankClip(src, color=[235, 128, 128])

    # Good length for the three henshins
    hibiki = TRANSFOS.src_cut[912:1716]
    hibiki = core.std.DeleteFrames(hibiki, [203, 204])
    hibiki = core.std.DeleteFrames(hibiki, range(316, 320))
    hibiki = core.std.DeleteFrames(hibiki, range(391, 394))

    tsubasa = TRANSFOS.src_cut[2178:2738]
    tsubasa = core.std.DuplicateFrames(white_clip[:8] + tsubasa, range(10, 20))
    tsubasa = core.std.DuplicateFrames(tsubasa, range(196, 203))
    tsubasa = core.std.DuplicateFrames(tsubasa, [443, 443, 443])

    yukine = TRANSFOS.src_cut[3240:3828]

    # The intro
    intro = 203
    new_tranfos = hibiki[:intro]

    # Adjust croppings
    hibiki_crop_a = core.std.Crop(hibiki[intro:], src.width / 3, src.width / 3,
                                  0, 0)
    dev = -150
    hibiki_crop_b = core.std.Crop(hibiki[intro:], src.width / 3 + dev,
                                  src.width / 3 - dev, 0, 0)
    dev = -270
    hibiki_crop_c = core.std.Crop(hibiki[intro:], src.width / 3 + dev,
                                  src.width / 3 - dev, 0, 0)
    hibiki_crop = lvf.rfs(hibiki_crop_a, hibiki_crop_b,
                          [(391 - intro, 471 - intro)])
    hibiki_crop = lvf.rfs(hibiki_crop, hibiki_crop_c,
                          [(472 - intro, 552 - intro)])

    tsubasa_crop_a = core.std.Crop(tsubasa, src.width / 3, src.width / 3, 0, 0)
    dev = -400
    tsubasa_crop_b = core.std.Crop(tsubasa, src.width / 3 + dev,
                                   src.width / 3 - dev, 0, 0)
    tsubasa_crop = lvf.rfs(tsubasa_crop_a, tsubasa_crop_b,
                           [(445 - intro, 460 - intro)])
    tsubasa_crop = (tsubasa_crop[:461 - intro] + core.std.FrameEval(
        tsubasa_crop[461 - intro:478 - intro],
        partial(_prog_crop, clip=tsubasa[461 - intro:478 - intro], dev=dev)) +
                    tsubasa_crop[478 - intro:])

    yukine_crop = core.std.Crop(yukine, src.width / 3, src.width / 3, 0, 0)

    # Stack & merge
    new_tranfos += core.std.StackHorizontal(
        [tsubasa_crop, hibiki_crop, yukine_crop])
    src = insert_clip(src, new_tranfos[:end - start], start)

    # Fix compositing error in the OP
    op_src, op_10 = src[opstart:opend + 1], ep10[opstart_ep10:opend_ep10 + 1]
    fix = lvf.rfs(op_src, op_10, [(0, 79), (1035, 1037)])
    fix_src = insert_clip(src, fix, opstart)
    src = depth(fix_src, 32)

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)
    upscale_smooth = vdf.nnedi3_upscale(descale, pscrn=1)
    upscale = vdf.fade_filter(upscale, upscale, upscale_smooth, 18018, 18068)
    upscale = lvf.rfs(upscale, upscale_smooth, [(18068, 18134)])

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    antialias_a = lvf.sraa(out,
                           1.3,
                           3,
                           alpha=0.3,
                           beta=0.45,
                           gamma=40,
                           nrad=3,
                           mdis=25)
    antialias_b = lvf.sraa(out,
                           1.85,
                           13,
                           alpha=0.3,
                           beta=0.6,
                           gamma=400,
                           nrad=2,
                           mdis=15)
    antialias = vdf.fade_filter(antialias, antialias_a, antialias_b, 12718,
                                12861)
    antialias = lvf.rfs(antialias, antialias_b, [(24063, 24149)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])

    deband_c = placebo.deband(out, 10, 3, 1)
    deband = lvf.rfs(deband, deband_c, [(241, 300), (11076, 11183)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src, src_ncop, src_nced = [
        depth(x, 16) for x in
        [denoise, rescale_mask, src, JPBD_NCOP.src_cut, JPBD_NCED.src_cut]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    out = credit

    src_c, src_ncop, src_nced = [
        c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu')
        for c in [src, src_ncop, src_nced]
    ]

    opening_mask = vdf.dcm(out, src_c[opstart:opend + 1],
                           src_ncop[:opend - opstart + 1], opstart, opend, 4,
                           4).std.Inflate()
    ending_mask = vdf.dcm(out, src_c[edstart:edend + 1],
                          src_nced[:edend - edstart + 1], edstart, edend, 4,
                          4).std.Inflate()
    credit_mask = core.std.Expr([opening_mask, ending_mask], 'x y +')

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, credit_mask),
                     [(opstart, opend), (edstart, edend)])
    out = credit

    return depth(out, 10)
Exemple #15
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    ep10 = JPBD_10.src_cut

    h = 720
    w = get_w(h)
    b, c = vdf.get_bicubic_params('robidoux')
    opstart, opend = 744, 3140
    opstart_ep10, opend_ep10 = 768, 3164
    full_stuff = [(3145, 3269), (18289, 18444), (29158, 33410)]

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 2),
                           right=1212)
    fixstudioshit = lvf.rfs(src, border, [31759])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1212)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31760])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1274)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [(31761, 31762)])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1300)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31763])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1322)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31764])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1342)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31765])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1356)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31766])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1368)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31767])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1376)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [31768])

    border = rkt.rekt_fast(src,
                           lambda x: core.fb.FillBorders(x, 0, 0, 0, 6),
                           right=1382)
    fixstudioshit = lvf.rfs(fixstudioshit, border, [(31769, 31793)])

    src = fixstudioshit

    # Fix compositing error in the OP
    op_src, op_10 = src[opstart:opend + 1], ep10[opstart_ep10:opend_ep10 + 1]
    fix = lvf.rfs(op_src, op_10, [(0, 79), (1035, 1037)])
    fix_src = insert_clip(src, fix, opstart)
    src = depth(fix_src, 32)

    denoise = hybrid_denoise(src, 0.5, 2)
    out = denoise

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

    descale = core.descale.Debicubic(luma, w, h, b, c)
    upscale = vdf.fsrcnnx_upscale(descale, None, descale.height * 2,
                                  '_shaders/FSRCNNX_x2_56-16-4-1.glsl',
                                  core.resize.Point)

    antialias = single_rate_antialiasing(upscale,
                                         13,
                                         alpha=0.3,
                                         beta=0.45,
                                         gamma=320,
                                         mdis=18)

    scaled = muvf.SSIM_downsample(antialias,
                                  src.width,
                                  src.height,
                                  kernel='Bicubic')
    rescale = core.std.MaskedMerge(luma, scaled, line_mask)
    merged = vdf.merge_chroma(rescale, out)
    out = depth(merged, 16)

    antialias = lvf.rfs(
        out,
        lvf.sraa(out,
                 1.65,
                 9,
                 alpha=0.3,
                 beta=0.45,
                 gamma=240,
                 nrad=3,
                 mdis=25), [(opstart + 840, opstart + 881)])
    out = antialias

    # Slight sharp though CAS
    sharp = hvf.LSFmod(out,
                       strength=75,
                       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=48, depth=8)
    out = warp

    preden = core.knlm.KNLMeansCL(out,
                                  d=0,
                                  a=3,
                                  h=0.6,
                                  device_type='GPU',
                                  channels='Y')
    deband_mask = lvf.denoise.detail_mask(preden, brz_a=2000, brz_b=800, rad=4)

    deband = dbs.f3kpf(out, 17, 42, 42)
    deband_b = placebo.deband(out, 22, 6, 2)
    deband = lvf.rfs(deband, deband_b, [(opstart + 1515, opstart + 1603)])

    deband_c = placebo.deband(out, 17, 6, 3)
    deband = lvf.rfs(deband, deband_c, [(12529, 12615)])

    deband_d = placebo.deband(out, 10, 3, 1)
    deband = lvf.rfs(deband, deband_d, [(21077, 21304), (22141, 22278),
                                        (22861, 22944), (29354, 29425),
                                        (33555, 33614)])

    deband = core.std.MaskedMerge(deband, out, deband_mask)

    out = deband

    adg_mask = core.adg.Mask(out.std.PlaneStats(),
                             20).std.Expr(f'x x {128<<8} - 0.25 * +')
    grain = core.grain.Add(out, 0.2, constant=True)
    grain = core.std.MaskedMerge(out, grain, adg_mask, 0)
    out = grain

    rescale_mask = vdf.drm(luma, b=b, c=c, sw=4, sh=4)
    ref, rescale_mask, src, src_ncop = [
        depth(x, 16) for x in [denoise, rescale_mask, src, JPBD_NCOP.src_cut]
    ]

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, rescale_mask),
                     full_stuff)
    out = credit

    src_c, src_ncop = [
        c.knlm.KNLMeansCL(a=7, h=35, d=0, device_type='gpu')
        for c in [src, src_ncop]
    ]

    opening_mask = vdf.dcm(out, src_c[opstart:opend + 1],
                           src_ncop[:opend - opstart + 1], opstart, opend, 4,
                           4).std.Inflate()

    credit = lvf.rfs(out, core.std.MaskedMerge(out, ref, opening_mask),
                     [(opstart, opend)])
    out = credit

    return depth(out, 10)
Exemple #16
0
def do_filter():
    """Vapoursynth filtering"""
    src = CLIP_SRC
    out = depth(src, 16)

    clip = out
    clip = core.std.FreezeFrames(clip, 1432, 1433, 1434)
    clip = core.std.FreezeFrames(clip, 1503, 1514, 1515)
    out = clip

    planes = split(out)
    planes[1], planes[2] = [
        core.resize.Spline16(plane, src_left=-0.25) for plane in planes[1:]
    ]
    out = join(planes)

    # qual=2 produces weird artefacts and a stronger alpha/beta/gamma smudges details.
    new_fields = core.eedi3m.EEDI3(out,
                                   1,
                                   alpha=0.4,
                                   beta=0.5,
                                   gamma=300,
                                   nrad=3,
                                   mdis=20,
                                   vcheck=3,
                                   sclip=core.nnedi3.nnedi3(out,
                                                            1,
                                                            nsize=3,
                                                            nns=3,
                                                            qual=1,
                                                            pscrn=4))
    out = new_fields

    denoise = gf.MCDegrainSharp(
        out,
        tr=3,
        bblur=0.65,
        csharp=lambda x: hvf.LSFmod(
            x, strength=85, Smode=3, Lmode=1, edgemode=0),
        thSAD=285,
        rec=True)
    out = denoise

    edge_cleaner = hvf.EdgeCleaner(out, 35, rmode=13, smode=1, hot=True)
    out = edge_cleaner

    antialias = lvf.sraa(out,
                         2,
                         13,
                         downscaler=core.resize.Bicubic,
                         alpha=0.25,
                         beta=0.35,
                         gamma=400)
    antialias_a = lvf.sraa(out, 1.4, 9, downscaler=core.resize.Bicubic)
    antialias = lvf.rfs(antialias, antialias_a, [(1223, 1229)])
    out = antialias

    chromableed = xvs.WarpFixChromaBlend(out, 72, depth=8)
    out = chromableed

    detail_mask = lvf.denoise.detail_mask(out, brz_a=2300, brz_b=1000)
    deband = placebo.deband(out, 17, 4.25, grain=6)
    deband_a = placebo.deband(out, 17, 8, 2, grain=6)
    deband_b = placebo.deband(out, 17, 6, grain=6)
    deband = lvf.rfs(deband, deband_a, [(1230, 1330)])
    deband = lvf.rfs(deband, deband_b, [(1678, 1889)])

    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    return depth(out, 10)