View Single Post
Old 23rd January 2023, 10:20   #91  |  Link
Emulgator
Big Bit Savings Now !
 
Emulgator's Avatar
 
Join Date: Feb 2007
Location: close to the wall
Posts: 1,545
Code:
def Super(src, pel=4):
    if not isinstance(src, vs.VideoNode):
       raise TypeError("Oyster.Super: src has to be a video clip!")
    elif src.format.sample_type != vs.FLOAT or src.format.bits_per_sample < 32:
       raise TypeError("Oyster.Super: the sample type of src has to be single precision!")
    elif src.format.subsampling_w > 0 or src.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Super: subsampled stuff not supported!")
    if not isinstance(pel, int):
       raise TypeError("Oyster.Super: pel has to be an integer!")
    elif pel != 2 and pel != 4:
       raise RuntimeError("Oyster.Super: pel has to be 2 or 4!")
    core                       = import core
    src                        = core.SetFieldBased(src, 0)
    colorspace                 = src.format.color_family
    if colorspace == vs.RGB:
       src                     = core.RGB2OPP(src, 1)
    clip                       = internal.super(core, src, pel)
    del core
    return clip

def Basic(src, super=None, radius=6, pel=4, sad=2000.0, short_time=False):
    if not isinstance(src, vs.VideoNode):
       raise TypeError("Oyster.Basic: src has to be a video clip!")
    elif src.format.sample_type != vs.FLOAT or src.format.bits_per_sample < 32:
       raise TypeError("Oyster.Basic: the sample type of src has to be single precision!")
    elif src.format.subsampling_w > 0 or src.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Basic: subsampled stuff not supported!")
    if not isinstance(super, vs.VideoNode) and super is not None:
       raise TypeError("Oyster.Basic: super has to be a video clip or None!")
    elif super is not None:
       if super.format.sample_type != vs.FLOAT or super.format.bits_per_sample < 32 or super.format.subsampling_w > 0 or super.format.subsampling_h > 0:
          raise RuntimeError("Oyster.Basic: corrupted super clip!")
    if not isinstance(radius, int):
       raise TypeError("Oyster.Basic: radius has to be an integer!")
    elif radius < 1:
       raise RuntimeError("Oyster.Basic: radius has to be greater than 0!")
    if not isinstance(pel, int):
       raise TypeError("Oyster.Basic: pel has to be an integer!")
    elif pel != 1 and pel != 2 and pel != 4:
       raise RuntimeError("Oyster.Basic: pel has to be 1, 2 or 4!")
    if not isinstance(sad, float) and not isinstance(sad, int):
       raise TypeError("Oyster.Basic: sad has to be a real number!")
    elif sad <= 0.0:
       raise RuntimeError("Oyster.Basic: sad has to be greater than 0!")
    if not isinstance(short_time, bool):
       raise TypeError("Oyster.Basic: short_time has to be boolean!")
    core                       = import core
    color                      = True
    rgb                        = False
    colorspace                 = src.format.color_family
    if colorspace == vs.RGB:
       src                     = core.RGB2OPP(src, 1)
       rgb                     = True
    if colorspace == vs.GRAY:
       color                   = False
    src                        = core.SetFieldBased(src, 0)
    super                      = core.SetFieldBased(super, 0) if super is not None else None
    clip                       = internal.basic(core, src, super, radius, pel, sad, short_time, color)
    clip                       = core.OPP2RGB(clip, 1) if rgb else clip
    del core
    return clip

def Deringing(src, ref, radius=6, h=6.4, sigma=16.0, \
              mse=[None, None], hard_thr=3.2, block_size=8, block_step=1, group_size=32, bm_range=24, bm_step=1, ps_num=2, ps_range=8, ps_step=1, \
              lowpass=None):
    if not isinstance(src, vs.VideoNode):
       raise TypeError("Oyster.Deringing: src has to be a video clip!")
    elif src.format.sample_type != vs.FLOAT or src.format.bits_per_sample < 32:
       raise TypeError("Oyster.Deringing: the sample type of src has to be single precision!")
    elif src.format.subsampling_w > 0 or src.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Deringing: subsampled stuff not supported!")
    if not isinstance(ref, vs.VideoNode):
       raise TypeError("Oyster.Deringing: ref has to be a video clip!")
    elif ref.format.sample_type != vs.FLOAT or ref.format.bits_per_sample < 32:
       raise TypeError("Oyster.Deringing: the sample type of ref has to be single precision!")
    elif ref.format.subsampling_w > 0 or ref.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Deringing: subsampled stuff not supported!")
    if not isinstance(radius, int):
       raise TypeError("Oyster.Deringing: radius has to be an integer!")
    elif radius < 1:
       raise RuntimeError("Oyster.Deringing: radius has to be greater than 0!")
    if not isinstance(h, float) and not isinstance(h, int):
       raise TypeError("Oyster.Deringing: h has to be a real number!")
    elif h <= 0:
       raise RuntimeError("Oyster.Deringing: h has to be greater than 0!")
    if not isinstance(mse, list):
       raise TypeError("Oyster.Deringing: mse parameter has to be an array!")
    elif len(mse) != 2:
       raise RuntimeError("Oyster.Deringing: mse parameter has to contain 2 elements exactly!")
    for i in range(2):
        if not isinstance(mse[i], float) and not isinstance(mse[i], int) and mse[i] is not None:
           raise TypeError("Oyster.Deringing: elements in mse must be real numbers or None!")
    if not isinstance(lowpass, list) and lowpass is not None:
       raise TypeError("Oyster.Deringing: lowpass has to be a list or None!")
    core                       = import core
    rgb                        = False
    color                      = True
    mse[0]                     = sigma * 160.0 + 1200.0 if mse[0] is None else mse[0]
    mse[1]                     = sigma * 120.0 + 800.0 if mse[1] is None else mse[1]
    lowpass                    = [0.0,sigma, 0.48,1024.0, 1.0,1024.0] if lowpass is None else lowpass
    matrix                     = None
    colorspace                 = src.format.color_family
    if colorspace == vs.RGB:
       rgb                     = True
       matrix                  = 100
       src                     = core.RGB2OPP(src, 1)
       ref                     = core.RGB2OPP(ref, 1)
    if colorspace == vs.GRAY:
       color                   = False
    src                        = core.SetFieldBased(src, 0)
    ref                        = core.SetFieldBased(ref, 0)
    clip                       = internal.deringing(core, src, ref, radius, h, sigma, \
                                                    mse, hard_thr, block_size, block_step, group_size, bm_range, bm_step, ps_num, ps_range, ps_step, \
                                                    lowpass, color, matrix)
    clip                       = core.OPP2RGB(clip, 1) if rgb else clip
    del core
    return clip

def Destaircase(src, ref, radius=6, sigma=16.0, \
                mse=[None, None], hard_thr=3.2, block_size=8, block_step=1, group_size=32, bm_range=24, bm_step=1, ps_num=2, ps_range=8, ps_step=1, \
                thr=0.03125, elast=0.015625, lowpass=None):
    if not isinstance(src, vs.VideoNode):
       raise TypeError("Oyster.Destaircase: src has to be a video clip!")
    elif src.format.sample_type != vs.FLOAT or src.format.bits_per_sample < 32:
       raise TypeError("Oyster.Destaircase: the sample type of src has to be single precision!")
    elif src.format.subsampling_w > 0 or src.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Destaircase: subsampled stuff not supported!")
    if not isinstance(ref, vs.VideoNode):
       raise TypeError("Oyster.Destaircase: ref has to be a video clip!")
    elif ref.format.sample_type != vs.FLOAT or ref.format.bits_per_sample < 32:
       raise TypeError("Oyster.Destaircase: the sample type of ref has to be single precision!")
    elif ref.format.subsampling_w > 0 or ref.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Destaircase: subsampled stuff not supported!")
    if not isinstance(radius, int):
       raise TypeError("Oyster.Destaircase: radius has to be an integer!")
    elif radius < 1:
       raise RuntimeError("Oyster.Destaircase: radius has to be greater than 0!")
    if not isinstance(mse, list):
       raise TypeError("Oyster.Destaircase: mse parameter has to be an array!")
    elif len(mse) != 2:
       raise RuntimeError("Oyster.Destaircase: mse parameter has to contain 2 elements exactly!")
    for i in range(2):
        if not isinstance(mse[i], float) and not isinstance(mse[i], int) and mse[i] is not None:
           raise TypeError("Oyster.Destaircase: elements in mse must be real numbers or None!")
    if not isinstance(thr, float) and not isinstance(thr, int):
       raise TypeError("Oyster.Destaircase: thr has to be a real number!")
    elif thr < 0 or thr > 1:
       raise RuntimeError("Oyster.Destaircase: thr has to fall in [0, 1]!")
    if not isinstance(elast, float) and not isinstance(elast, int):
       raise TypeError("Oyster.Destaircase: elast has to be a real number!")
    elif elast < 0 or elast > thr:
       raise RuntimeError("Oyster.Destaircase: elast has to fall in [0, thr]!")
    if not isinstance(lowpass, list) and lowpass is not None:
       raise TypeError("Oyster.Destaircase: lowpass has to be a list or None!")
    core                       = import core
    rgb                        = False
    mse[0]                     = sigma * 160.0 + 1200.0 if mse[0] is None else mse[0]
    mse[1]                     = sigma * 120.0 + 800.0 if mse[1] is None else mse[1]
    lowpass                    = [0.0,sigma, 0.48,1024.0, 1.0,1024.0] if lowpass is None else lowpass
    matrix                     = None
    colorspace                 = src.format.color_family
    if colorspace == vs.RGB:
       rgb                     = True
       matrix                  = 100
       src                     = core.RGB2OPP(src, 1)
       ref                     = core.RGB2OPP(ref, 1)
    src                        = core.SetFieldBased(src, 0)
    ref                        = core.SetFieldBased(ref, 0)
    clip                       = internal.destaircase(core, src, ref, radius, sigma, \
                                                      mse, hard_thr, block_size, block_step, group_size, bm_range, bm_step, ps_num, ps_range, ps_step, \
                                                      thr, elast, lowpass, matrix)
    clip                       = core.OPP2RGB(clip, 1) if rgb else clip
    del core
    return clip

def Deblocking(src, ref, radius=6, h=6.4, sigma=16.0, \
               mse=[None, None], hard_thr=3.2, block_size=8, block_step=1, group_size=32, bm_range=24, bm_step=1, ps_num=2, ps_range=8, ps_step=1, \
               lowpass=[0.0,0.0, 0.12,1024.0, 1.0,1024.0]):
    if not isinstance(src, vs.VideoNode):
       raise TypeError("Oyster.Deblocking: src has to be a video clip!")
    elif src.format.sample_type != vs.FLOAT or src.format.bits_per_sample < 32:
       raise TypeError("Oyster.Deblocking: the sample type of src has to be single precision!")
    elif src.format.subsampling_w > 0 or src.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Deblocking: subsampled stuff not supported!")
    if not isinstance(ref, vs.VideoNode):
       raise TypeError("Oyster.Deblocking: ref has to be a video clip!")
    elif ref.format.sample_type != vs.FLOAT or ref.format.bits_per_sample < 32:
       raise TypeError("Oyster.Deblocking: the sample type of ref has to be single precision!")
    elif ref.format.subsampling_w > 0 or ref.format.subsampling_h > 0:
       raise RuntimeError("Oyster.Deblocking: subsampled stuff not supported!")
    if not isinstance(radius, int):
       raise TypeError("Oyster.Deblocking: radius has to be an integer!")
    elif radius < 1:
       raise RuntimeError("Oyster.Deblocking: radius has to be greater than 0!")
    if not isinstance(h, float) and not isinstance(h, int):
       raise TypeError("Oyster.Deblocking: h has to be a real number!")
    elif h <= 0:
       raise RuntimeError("Oyster.Deblocking: h has to be greater than 0!")
    if not isinstance(mse, list):
       raise TypeError("Oyster.Deblocking: mse parameter has to be an array!")
    elif len(mse) != 2:
       raise RuntimeError("Oyster.Deblocking: mse parameter has to contain 2 elements exactly!")
    for i in range(2):
        if not isinstance(mse[i], float) and not isinstance(mse[i], int) and mse[i] is not None:
           raise TypeError("Oyster.Deblocking: elements in mse must be real numbers or None!")
    if not isinstance(lowpass, list):
       raise TypeError("Oyster.Deblocking: lowpass has to be a list!")
    core                       = import core
    rgb                        = False
    color                      = True
    mse[0]                     = sigma * 160.0 + 1200.0 if mse[0] is None else mse[0]
    mse[1]                     = sigma * 120.0 + 800.0 if mse[1] is None else mse[1]
    matrix                     = None
    colorspace                 = src.format.color_family
    if colorspace == vs.RGB:
       rgb                     = True
       matrix                  = 100
       src                     = core.RGB2OPP(src, 1)
       ref                     = core.RGB2OPP(ref, 1)
    if colorspace == vs.GRAY:
       color                   = False
    src                        = core.SetFieldBased(src, 0)
    ref                        = core.SetFieldBased(ref, 0)
    clip                       = internal.deblocking(core, src, ref, radius, h, sigma, \
                                                     mse, hard_thr, block_size, block_step, group_size, bm_range, bm_step, ps_num, ps_range, ps_step, \
                                                     lowpass, color, matrix)
    clip                       = core.OPP2RGB(clip, 1) if rgb else clip
    del core
    return clip
__________________
"To bypass shortcuts and find suffering...is called QUALity" (Die toten Augen von Friedrichshain)
"Data reduction ? Yep, Sir. We're that issue working on. Synce invntoin uf lingöage..."

Last edited by Emulgator; 23rd January 2023 at 10:43.
Emulgator is offline   Reply With Quote