View Single Post
Old 29th October 2021, 01:19   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Mod to Mugfunky/JohnMeyer/Selur Filldrops()

Code:
#########################################################################################
#
# FillDrops.avsi
#
# An AviSynth filter to detect and replace duplicate frames
# with a motion-interpolation of the adjacent frames.
#
# mod 2021-07-10 by Selur
# mod 29 Oct 2021, Added ThreshIs8Bit arg. ssS. https://forum.doom9.org/showthread.php?p=1956020#post1956020
#
# - based on Mug Funky's FillDrops
# - FillDrops by johnmeyer on Doom9's forum
# https://forum.doom9.org/showthread.php?p=1775184#post1775184
# - mod by Selur to parametrize Luma Difference Threshold
# https://forum.videohelp.com/threads/402416-repair-Videos-with-duplicates-and-dropped-frames#post2624936
#
### Requirements ###
#-------------------
# Avs v2.60/+
# MvTools2 (https://github.com/pinterf/mvtools)
#
### Arguments ###
#-----------------
# thresh (default=0.1) - Luma Difference Threshold
#    Lets you specify how different a frame has to be (from the previous frame)
#    before it's considered not to be a duplicate, and therefore not replaced with a motion interpolated frame.
#    If the threshold is too small, some duplicate will not be replaced.
#    If it's too large, many frames which aren't duplicates (just having very small motions) will be replaced.
#    (explanation by jagabo on VideoHelp)
#
# ---------------
# ThreshIs8Bit, Default False, If True and bit depth > 8 bit, then thresh is converted to current bit depth threshold.
### Changelog ###
#---------------
# Changed requirements: from MvTools to MvTools2 (johnmeyer)
# Parametrized Luma Difference Threshold (Selur)
# ssS: Added Bool arg "ThreshIs8Bit", default = False.
#########################################################################################

Function FillDrops(clip c, float "thresh",Bool "ThreshIs8Bit") {
    thresh       = Default(thresh, 0.1)
    ThreshIs8Bit = Default(ThreshIs8Bit,False) # False = thresh is in current bit depth range
    try { bpc=c.BitsPerComponent } catch(msg) { bpc=8 }
    thresh = (ThreshIs8Bit) ? thresh * BitLShift(1,bpc-8) : thresh
    #
    super = MSuper(c, pel=2)
    vfe = MAnalyse(super, truemotion=true, isb=false, delta=1)
    vbe = MAnalyse(super, truemotion=true, isb=true, delta=1)
    filldrops = MFlowInter(c, super, vbe, vfe, time=50)
    fixed = ConditionalFilter(c, filldrops, c, "YDifferenceFromPrevious()", "lessthan", String(thresh))
    return fixed
}

Function FilldropsI (clip c, float "thresh",Bool "ThreshIs8Bit") {
    thresh       = Default(thresh, 0.1)
    ThreshIs8Bit = Default(ThreshIs8Bit,False) # False = thresh is in current bit depth range
    try { bpc=c.BitsPerComponent } catch(msg) { bpc=8 }
    thresh = (ThreshIs8Bit) ? thresh * BitLShift(1,bpc-8) : thresh
    #
    even = c.SeparateFields().SelectEven()
    super_even=MSuper(even,pel=2)
    vfe=manalyse(super_even,truemotion=true,isb=false,delta=1)
    vbe=manalyse(super_even,truemotion=true,isb=true,delta=1)
    filldrops_e = mflowinter(even,super_even,vbe,vfe,time=50)
    odd  = c.SeparateFields().SelectOdd()
    super_odd=MSuper(odd,pel=2)
    vfo=manalyse(super_odd,truemotion=true,isb=false,delta=1)
    vbo=manalyse(super_odd,truemotion=true,isb=true,delta=1)
    filldrops_o = mflowinter(odd,super_odd,vbo,vfo,time=50)
    evenfixed = ConditionalFilter(even, filldrops_e, even, "YDifferenceFromPrevious()", "lessthan",  String(thresh))
    oddfixed  = ConditionalFilter(odd,  filldrops_o, odd,  "YDifferenceFromPrevious()", "lessthan",  String(thresh))
    Interleave(evenfixed,oddfixed)
    Weave()
}
You wanna update it on your github JKyle ?

EDIT:
Added arg, Bool "ThreshIs8Bit", default=False.

Quote:
ThreshIs8Bit, Default False, If True and bit depth > 8 bit, then thresh is converted to current bit depth threshold.
If true, Eg, if bit depth = 10, then multiply thresh by 4 : if bit depth 16 then mult thresh by 256.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 29th October 2021 at 01:34.
StainlessS is offline   Reply With Quote