Selur's Little Message Board

Full Version: Fixed a problem with Vapoursynth version of "Stab"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The Vapoursynth version of "Stab" doesn't use DePanEstimate, so it doesn't use the "range" parameter, which can cause random jerking around in some cases, and is less accurate than the AviSynth version.

Hybrid loads the Vapoursynth version of DePan.dll but doesn't use it... DePanEstimate is included in the this dll. Havsfunc instead uses libmvtools.dll, which has ports of DePan and DePanEstimate, but those don't include the "range" function.

So to add DePanEstimate and Range using DePan.dll, I changed the script in havsfunc.py from this:

Code:
##############################################################################
# Original script by g-force converted into a stand alone script by McCauley #
# latest version from December 10, 2008                                      #
##############################################################################
def Stab(clp, dxmax=4, dymax=4, mirror=0):
    if not isinstance(clp, vs.VideoNode):
        raise vs.Error('Stab: This is not a clip')

    temp = AverageFrames(clp, weights=[1] * 15, scenechange=25 / 255)
    inter = core.std.Interleave([core.rgvs.Repair(temp, AverageFrames(clp, weights=[1] * 3, scenechange=25 / 255), mode=[1]), clp])
    mdata = inter.mv.DepanEstimate(trust=0, dxmax=dxmax, dymax=dymax)
    last = inter.mv.DepanCompensate(data=mdata, offset=-1, mirror=mirror)
    return last[::2]

To this:

Code:
# Stab function that uses DePanEstimate from "Depan" plugin which supports
# the range parameter. DePanEstimate from MvTools is missing that paramater.
# Function copied from https://github.com/HomeOfVapourSynthEvolution/havsfunc
##############################################################################
# Original script by g-force converted into a stand alone script by McCauley #
# latest version from December 10, 2008                                      #
##############################################################################
def Stab(clp, range=1, dxmax=4, dymax=4, mirror=0):
    if not isinstance(clp, vs.VideoNode):
        raise vs.Error('Stab: This is not a clip')

    temp = AverageFrames(clp, weights=[1] * 15, scenechange=25 / 255)
    inter = core.std.Interleave([core.rgvs.Repair(temp, AverageFrames(clp, weights=[1] * 3, scenechange=25 / 255), mode=[1]), clp])
    mdata = core.depan.DePanEstimate(inter, range=range, trust=0, dxmax=dxmax, dymax=dymax)
    last = core.depan.DePan(inter, data=mdata, offset=-1, mirror=mirror)
    return last[::2]

I am not a coder, so this was adapted from this, which has incorrect syntax.

This came from an issue that I posted about on the havsfunc Github issues board, so I'm not sure if this will be included officially or not.
Nice, will change the code in Hybrid to use Stab from 'lostfunc' instead of 'havsfunc'. Smile

Cu Selur