Can't the Interpolate() function call a function to do the resizing and give it the clip so there's no having to worry about creating strings? I assume demo() is another function too, so it's the same idea. Using the previous MyResizing() function to do the work (which is already configured to default to a 1366x768 output).
Code:
function interpolate(clip src)
{
input = src.MyResizing()
#MT-MODE-1 #do not remove this line!
super=SVSuper(input, super_params)
vectors=SVAnalyse(super, analyse_params, src=input)
smooth=SVSmoothFps(input, super, vectors, smoothfps_params, mt=threads, src=src)
#MT-MODE-2 #do not remove this line!
return demo_mode==0 ? smooth : demo(input,smooth)
}
Quote:
How to convert this to function what gives resize_string?
|
Assuming the calculations are correct, I think you're after something like this, although with the SourceAspect stuff different.
source_width = float(width(Source))
source_height = float(height(Source))
SourceAspect = source_width / source_height
If you defined the new width, height and aspect in a similar way, you wouldn't have to type float() so much.
Code:
function ResizeString(clip Source, int "NewWidth", int "NewHeight")
{
NewWidth = default(NewWidth, 1366)
NewHeight = default(NewHeight, 768)
SourceAspect = float(source_width) / float(source_height)
MyAspect = float(NewWidth) / float(NewHeight)
SourceAspect > MyAspect ? eval("""
ResizedWidth=NewWidth
ResizedHeight=round(float(source_height) * float(NewWidth) / float(source_width) / 2.0) * 2
""") : eval("""
ResizedHeight=NewHeight
ResizedWidth=round(float(source_width) * float(NewHeight) / float(source_height) / 2.0 ) * 2
""")
return "BicubicResize("+String(ResizedWidth)+","+ResizedHeight+",b=0,c=0.75)"
}
So instead of just calling the cropped and resized clip, you'd call the ResizeString() function for the resizing and a yet to be created CropString() function for the cropping??
Code:
function interpolate(clip src)
{
input = CropString()=="" ? src : eval("src."+CropString())
input = ResizeString()=="" ? input : eval("input."+ResizeString())
#MT-MODE-1 #do not remove this line!
super=SVSuper(input, super_params)
vectors=SVAnalyse(super, analyse_params, src=input)
smooth=SVSmoothFps(input, super, vectors, smoothfps_params, mt=threads, src=src)
#MT-MODE-2 #do not remove this line!
return demo_mode==0 ? smooth : demo(input,smooth)
}
That looks about right (no promises), and hopefully it's what you're after. I'm out of time for the moment. Hopefully someone else will help further if need be, or there's always tomorrow.