예제 #1
0
def deband(clip: vs.VideoNode,
           strong: Optional[List[Range]] = None) -> vs.VideoNode:
    mask = detail_mask(clip)
    deband = core.std.MaskedMerge(dumb3kdb(clip, radius=16, threshold=40),
                                  clip, mask)
    deband_strong = core.std.MaskedMerge(
        dumb3kdb(clip, radius=16, threshold=50), clip, mask)
    return replace_ranges(deband, deband_strong, strong or [])
예제 #2
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])
예제 #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

    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])
예제 #4
0
def deband(clip: vs.VideoNode) -> vs.VideoNode:
    grad_mask, yrangebig = morpho_mask(
        clip.dfttest.DFTTest(sigma=14, sigma2=10, sbsize=1,
                             sosize=0).rgvs.RemoveGrain(3))
    y = vsutil.get_y(clip)
    mask = lvf.mask.detail_mask(clip, brz_b=0.03)
    deband_dumb: vs.VideoNode = vdf.dumb3kdb(clip, radius=16, threshold=24)
    deband_weak: vs.VideoNode = core.std.MaskedMerge(vsutil.get_y(deband_dumb),
                                                     y, mask)
    deband_norm: vs.VideoNode = vsutil.get_y(
        vdf.dumb3kdb(clip, radius=16, threshold=30))
    deband_strong: vs.VideoNode = f3kbilateral(y, range=12, y=50)
    deband = core.std.MaskedMerge(deband_strong, deband_norm, grad_mask)
    deband = core.std.MaskedMerge(deband, deband_weak, yrangebig)
    deband = core.std.ShufflePlanes([deband, deband_dumb],
                                    planes=[0, 1, 2],
                                    colorfamily=vs.YUV)
    return deband
예제 #5
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])
예제 #6
0
def deband(clip: vs.VideoNode) -> vs.VideoNode:
    """
    mostly stole this from varde
    """
    grad_mask, yrangebig = morpho_mask(
        clip.dfttest.DFTTest(sigma=14, sigma2=10, sbsize=1,
                             sosize=0).rgvs.RemoveGrain(3))
    y = vsutil.get_y(clip)
    mask = detail_mask(y, brz_a=0.05, brz_b=0.03)
    dumb: vs.VideoNode = dumb3kdb(clip)
    deband_weak = core.std.MaskedMerge(vsutil.get_y(dumb), y, mask)
    deband_norm = f3kbilateral(y, y=36)
    deband_strong = f3kbilateral(y, y=65)
    deband = core.std.MaskedMerge(deband_strong, deband_norm, grad_mask)
    deband = core.std.MaskedMerge(deband, deband_weak, yrangebig)
    deband = core.std.ShufflePlanes([deband, dumb],
                                    planes=[0, 1, 2],
                                    colorfamily=vs.YUV)
    return deband
예제 #7
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])
예제 #8
0
def do_filter():
    """Vapoursynth filtering"""
    src = WEB.src_cut
    src = src.std.AssumeFPS(src)

    src = depth(src, 16)
    out = src

    denoise = hvf.SMDegrain(out, tr=3, thSAD=150, thSADC=150)
    out = denoise

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

    y = get_y(out)
    taps = 5
    w, h = 1600, 900
    descale = core.descale.Delanczos(depth(y, 32), w, h, taps)

    upscale = vdf.nnedi3_upscale(descale, pscrn=1, correct_shift=False)
    rescale = core.resize.Bicubic(upscale,
                                  1920,
                                  1080,
                                  src_left=.5,
                                  src_top=.5,
                                  filter_param_a=-.5,
                                  filter_param_b=.25)
    out = depth(rescale, 16)

    sharp = hvf.LSFmod(out,
                       strength=90,
                       Smode=3,
                       edgemode=0,
                       source=get_y(denoise))
    out = sharp

    merge = vdf.merge_chroma(out, denoise)
    out = merge

    detail_mask = lvf.mask.detail_mask(out, brz_a=2250, brz_b=1200)
    pref = out.std.Convolution([1, 2, 1, 2, 4, 2, 1, 2,
                                1]).std.Convolution([1] * 9)
    deband1 = vdf.dumb3kdb(pref, 17, 45, grain=16, seed=333)
    deband2 = vdf.dumb3kdb(pref,
                           15,
                           49,
                           grain=16,
                           sample_mode=4,
                           use_neo=True,
                           blur_first=False,
                           seed=333)

    th_lo, th_hi = 20 << 8, 26 << 8
    strength = '{1} x - {1} {0} - /'.format(th_lo, th_hi)
    deband = core.std.Expr([pref, deband1, deband2], [
        f'x {th_lo} > x {th_hi} < and z ' + strength + ' * y 1 ' + strength +
        f' - * + x {th_lo} <= z y ? ?', 'y'
    ])

    deband = core.std.MergeDiff(deband, out.std.MakeDiff(pref))
    deband = core.std.MaskedMerge(deband, out, detail_mask)
    out = deband

    grain = adptvgrnMod(out,
                        0.3,
                        0.15,
                        size=1.2,
                        luma_scaling=16,
                        hi=[128, 240],
                        protect_neutral=False,
                        seed=333)
    out = grain

    ref = denoise
    rescale_mask = vdf.drm(src, h, 'spline36', mthr=80).std.Maximum()
    credit = out
    credit = lvf.rfs(credit, core.std.MaskedMerge(credit, ref, rescale_mask),
                     [(2374, 4530), (4544, 4648), (4701, 4762), (30070, 30210),
                      (31266, 33422)])
    credit = lvf.rfs(credit, ref, [(33423, src.num_frames - 1)])
    out = credit

    return depth(out, 10).std.Limiter(16 << 2, [235 << 2, 240 << 2], [0, 1, 2])
예제 #9
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])
예제 #10
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])