Exemplo n.º 1
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)
    out = src



    ref = hvf.SMDegrain(out, thSAD=300)
    denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref)
    out = denoise

    crop = core.std.Crop(out, left=12)
    crop = awf.bbmod(crop, left=2, thresh=20 << 8)
    resize = core.resize.Bicubic(crop, 1920)
    out = lvf.rfs(out, resize, [(78, 89)])


    y = get_y(out)
    lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate()

    fkrescale = fake_rescale(
        y, 882, 0, 1,
        deringer=lambda x: gf.MaskedDHA(x, rx=1.85, ry=1.85, darkstr=0.25, brightstr=1.0, maskpull=100, maskpush=200),
        antialiser=lambda c: lvf.sraa(c, 2, 13, downscaler=core.resize.Bicubic)
    )
    merged = core.std.MaskedMerge(y, fkrescale, lineart)
    out = vdf.merge_chroma(merged, out)


    dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True)
    out = dering


    out = lvf.rfs(
        out, denoise,
        [(0, 11), (38, 77), (115, 133), (316, 395), (441, 460), (606, 779), (825, 844), (990, 1127)]
    )




    detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000)
    deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband




    grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333)
    out = grain


    decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8)
    out = decz



    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 2
0
def do_filter() -> vs.VideoNode:
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    out = src

    luma = get_y(out)
    rows = [
        core.std.CropAbs(luma, out.width, 1, top=out.height - 1),
        core.std.CropAbs(luma, out.width, 1, top=out.height - 2)
    ]
    diff = core.std.Expr(rows, 'x y - abs').std.PlaneStats()

    row_fix = vdf.merge_chroma(
        luma.fb.FillBorders(bottom=1, mode="fillmargins"),
        out.fb.FillBorders(bottom=2, mode="fillmargins"))

    fixrow = core.std.FrameEval(out,
                                partial(_select_row, clip=out,
                                        row_fix=row_fix),
                                prop_src=diff)
    out = fixrow

    fixedge_a = awf.bbmod(out, 1, 1, 1, 1, 20, blur=700, u=False, v=False)

    fixedge = out
    fixedge = lvf.rfs(fixedge, fixedge_a, [(EDSTART + 309, EDEND)])
    out = fixedge

    out = depth(out, 16)

    dehalo = gf.MaskedDHA(out, rx=1.4, ry=1.4, darkstr=0.02, brightstr=1)
    dehalo = lvf.rfs(out, dehalo, [(EDEND + 1, src.num_frames - 1)])
    out = dehalo

    resize = core.std.Crop(out, right=12, bottom=8).resize.Bicubic(1920, 1080)
    resize = lvf.rfs(out, resize, [(27005, 27076)])
    out = resize

    # Denoising only the chroma
    pre = hvf.SMDegrain(out, tr=2, thSADC=300, plane=3)
    planes = split(out)
    planes[1], planes[2] = [
        mvf.BM3D(planes[i], 1.25, radius2=2, pre=plane(pre, i))
        for i in range(1, 3)
    ]
    out = join(planes)

    preden = core.dfttest.DFTTest(out, sbsize=16, sosize=12, tbsize=1)
    detail_mask = lvf.mask.detail_mask(preden, brz_a=2500, brz_b=1500)

    deband = vdf.dumb3kdb(preden, 16, threshold=[17, 17], grain=[24, 0])
    deband = core.std.MergeDiff(deband, out.std.MakeDiff(preden))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    decz = vdf.decsiz(out, min_in=128 << 8, max_in=192 << 8)
    out = decz

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 3
0
def do_filter() -> vs.VideoNode:
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    out = src

    luma = get_y(out)
    rows = [
        core.std.CropAbs(luma, out.width, 1, top=out.height - 1),
        core.std.CropAbs(luma, out.width, 1, top=out.height - 2)
    ]
    diff = core.std.Expr(rows, 'x y - abs').std.PlaneStats()

    row_fix = vdf.merge_chroma(
        luma.fb.FillBorders(bottom=1, mode="fillmargins"),
        out.fb.FillBorders(bottom=2, mode="fillmargins"))

    fixrow = core.std.FrameEval(out,
                                partial(_select_row, clip=out,
                                        row_fix=row_fix),
                                prop_src=diff)
    out = fixrow

    out = depth(out, 16)

    # Denoising only the chroma
    pre = hvf.SMDegrain(out, tr=2, thSADC=300, plane=3)
    planes = split(out)
    planes[1], planes[2] = [
        mvf.BM3D(planes[i], 1.25, radius2=2, pre=plane(pre, i))
        for i in range(1, 3)
    ]
    out = join(planes)

    preden = core.dfttest.DFTTest(out, sbsize=16, sosize=12, tbsize=1)
    detail_mask = lvf.mask.detail_mask(preden, brz_a=2500, brz_b=1500)

    deband = vdf.dumb3kdb(preden, 16, threshold=[17, 17], grain=[24, 0])
    deband = core.std.MergeDiff(deband, out.std.MakeDiff(preden))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    decz = vdf.decsiz(out, min_in=128 << 8, max_in=192 << 8)
    out = decz

    ref = depth(src, 16)
    credit = out
    credit = lvf.rfs(out, ref, CREDITS)
    out = credit

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 4
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 32)
    out = src

    clips = [out[f] for f in range(out.num_frames)]

    mean = core.average.Mean(clips).std.AssumeFPS(fpsnum=1, fpsden=1)
    full = vdf.to_444(mean, znedi=False)
    out = depth(full, 16)

    decz = vdf.decsiz(out, sigmaS=50, min_in=0, max_in=1)
    out = decz

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 5
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)
    out = src



    ref = hvf.SMDegrain(out, thSAD=300)
    denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref)
    out = denoise



    dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True)
    out = dering


    detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000)
    deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband




    grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333)
    out = grain


    decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8)
    out = decz



    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 6
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)
    out = src

    edstart1, edend1 = 37428, 37428 + 2160
    edstart2, edend2 = edend1 + 12, edend1 + 2160




    ref = hvf.SMDegrain(out, thSAD=300)
    denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref)
    out = denoise




    y = get_y(out)
    lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate()

    fkrescale = fake_rescale(
        y, 882, 0, 1,
        deringer=lambda x: gf.MaskedDHA(x, rx=1.85, ry=1.85, darkstr=0.25, brightstr=1.0, maskpull=100, maskpush=200),
        antialiser=lambda c: lvf.sraa(c, 2, 13, downscaler=core.resize.Bicubic)
    )
    merged = core.std.MaskedMerge(y, fkrescale, lineart)
    out = vdf.merge_chroma(merged, out)


    dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True)
    out = dering



    out = lvf.rfs(out, denoise, [(edstart1, src.num_frames - 1)])


    detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000)
    deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband




    grain = adptvgrnMod(out, 0.3, static=True, grain_chroma=False, hi=[128, 240], seed=333)
    out = grain


    decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8)
    out = decz



    ref = depth(src, 16)
    src_c, src_nced1, src_nced2 = [
        depth(x, 16).std.Convolution(
            [1, 2, 1, 2, 4, 2, 1, 2, 1]
        ) for x in [src, JPBD_NCED1.src_cut, JPBD_NCED2.src_cut]
    ]

    ending_mask1 = vdf.dcm(out, src_c[edstart1:edend1 + 1], src_nced1[:edend1 - edstart1 + 1], edstart1, edend1, 2, 2)
    ending_mask2 = vdf.dcm(out, src_c[edstart2:edend2 + 1], src_nced2[:edend2 - edstart2 + 1], edstart2, edend2, 2, 2)
    ending_mask = core.std.Expr([ending_mask1, ending_mask2], 'x y +')
    ending_mask = iterate(ending_mask, core.std.Inflate, 4)

    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, ending_mask), [(edstart1, edend2)])
    credit = lvf.rfs(credit, ref, [(21594, 21737), (39589, 39599), (41744, src.num_frames - 1)])
    out = credit


    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
Exemplo n.º 7
0
def do_filter():
    """Vapoursynth filtering"""
    src = JPBD.src_cut
    src = depth(src, 16)
    out = src

    opstart, opend = 2712, 4869

    ref = hvf.SMDegrain(out, thSAD=300)
    denoise = mvf.BM3D(out, [1.5, 1.25], radius1=1, ref=ref)
    out = denoise

    crop = core.std.Crop(out, left=12)
    crop = awf.bbmod(crop, left=2, thresh=20 << 8)
    resize = core.resize.Bicubic(crop, 1920)
    out = lvf.rfs(out, resize, [(86, 201)])

    y = get_y(out)
    lineart = gf.EdgeDetect(y, 'scharr').morpho.Dilate(2, 2).std.Inflate()

    fkrescale = fake_rescale(y,
                             882,
                             0,
                             1,
                             deringer=lambda x: gf.MaskedDHA(x,
                                                             rx=1.85,
                                                             ry=1.85,
                                                             darkstr=0.25,
                                                             brightstr=1.0,
                                                             maskpull=100,
                                                             maskpush=200),
                             antialiser=lambda c: lvf.sraa(
                                 c, 2, 13, downscaler=core.resize.Bicubic))
    merged = core.std.MaskedMerge(y, fkrescale, lineart)
    out = vdf.merge_chroma(merged, out)

    dering = hvf.EdgeCleaner(out, 17, smode=1, hot=True)
    out = dering

    detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1000)
    deband = vdf.dumb3kdb(out, 15, threshold=17, grain=(24, 0))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    grain = adptvgrnMod(out,
                        0.3,
                        static=True,
                        grain_chroma=False,
                        hi=[128, 240],
                        seed=333)
    out = grain

    decz = vdf.decsiz(out, min_in=128 << 8, max_in=200 << 8)
    out = decz

    ref = depth(src, 16)
    src_c, src_ncop = [
        depth(x, 16).std.Convolution([1, 2, 1, 2, 4, 2, 1, 2, 1])
        for x in [src, JPBD_NCOP.src_cut]
    ]

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

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

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])