CODICE
# ResFinderMod; Version 0.3.1; 2013-12-17. Khanattila
# Based on the idea by Liquid Dr4k3 in the RecensubHQ, http://recensubshq.forumfree.it/?t=67675729/
# Dependence: Debilinear, Debicubic, MaskTools v2 and AVSLib, http://avslib.sourceforge.net/
# License: GNU GPL version 3.0 or any later version published by the FSF, http://www.fsf.org/
# No warranty, use at your own risk
#
# ResFinderMod (
# clip c,
# int frame,
# int sup,
# int inf,
# int kernel (1), [1 = Bilinear, 2 = MitchellNetravali, 3 = CatmullRom]
# int PARNum (1),
# int PARDen (1),
# String filename ("output.txt")
# )
LoadModule("avslib", "array", "core")
LoadModule("avslib", "array", "functions")
LoadModule("avslib", "filters", "stack")
function ResFinderMod(clip c, int frame, int sup, int inf, int "kernel", int "PARNum", int "PARDen", String "filename") {
c = c.Trim(frame, -1)
kernel = Default(kernel, 1)
PARNum = Default(PARNum, 1)
PARDen = Default(PARDen, 1)
PAR = Float(PARNum) / Float(PARDen)
filename = Default(filename, "output.txt")
side = Ceil(Sqrt((sup-inf)/2+1))
Assert(c.IsYV12(), "'c' must be YV12")
Assert(sup%2 == 0, "'sup' must be Mod2")
Assert(inf%2 == 0, "'inf' must be Mod2")
Assert(sup >= inf, "'sup' must be >= 'inf'")
Assert((kernel >=1 && kernel <= 3), "kernel must be 1, 2 or 3")
global RFM_c = c
global RFM_kernel = kernel
global RFM_PAR = PAR
global RFM_filename = filename
counter = ArrayRange(inf, sup, 2)
counter = ArrayOpFunc(counter, "ResWriter", "RFM_c, RFM_kernel, RFM_PAR, RFM_filename")
Stack(counter, side, side).BilinearResize(c.Width(), c.Height())
}
function ResWriter(int i, clip c, int kernel, float PAR, string filename) {
j = Round(i/2*c.Width()/c.Height()*PAR)*2
interpol = kernel == 1 ? DebilinearY(c, j, i).BilinearResize(c.Width(), c.Height()) : kernel == 2 ?
\ DebicubicY(c, j, i, b=0.3333, c=0.3333).BicubicResize(c.Width(), c.Height(), b=0.3333, c=0.3333) :
\ DebicubicY(c, j, i, b=0, c=0.5).BicubicResize(c.Width(), c.Height(), b=0, c=5)
under = mt_lutxy(c, interpol, "x y -", u=1, v=1)
over = (mt_lutxy(c, interpol, "y x -", u=1, v=1))
delta = mt_lutxy(under, over, "x y -", u=1, v=1)
WriteFile(delta, filename, String(j), """ " ; " """ , String(i), """ " ; " """, "AverageLuma()")
}