View Single Post
Old 17th April 2019, 05:53   #9  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,829
I had another thought, although it seems odd to me the Interpolate() function always crops and resizes before it does the frame interpolation stuff. If your source is standard definition it'd be faster to interpolate frames first, then upscale.

When I use ffdshow's Avisynth filter, I usually aim to change the resolution as little as possible and then let the player upscale to fullscreen. That way you can crop if need be, but there's no need to add borders as the player will do it in fullscreen mode. I'm still not exactly sure what you're doing though. Anyway....

I also did this for myself, to see if I understand how to pass strings for cropping/resizing correctly. It seems to be working. It's much the same MyResizing() function as before, except it only creates global strings for cropping and resizing (it seems mental not to calculate them together) and passes the source through untouched.

So assuming the global environment works with the way you're doing things, you should be able to load the function and use MyResizing() before Interpolate() to create the strings. Why you'd do it that way, I'm not sure, but this might give you some ideas.

Code:
function MyResizing(clip Source, int "NewWidth", int "NewHeight")   {

	SourceWidth = width(Source)
	SourceHeight = height(Source)
	SourceAspect = float(SourceWidth) / float(SourceHeight)
	NewWidth = default(NewWidth, 1366) >= SourceWidth ? SourceWidth : default(NewWidth, 1366)
	NewHeight = default(NewHeight, 768) >= SourceHeight ? SourceHeight : default(NewHeight, 768)
	NewAspect = float(NewWidth) / float(NewHeight)

SourceAspect < NewAspect ? eval("""
	HeightCrop = round(max(0, SourceHeight - (float(SourceWidth) / NewAspect) / 2.0)) * 2
	CL = 0
	CT = floor(HeightCrop / 4.0) * 2
	CR = 0
	CB = HeightCrop - CT
""") : SourceAspect > NewAspect ? eval("""
	WidthCrop = round(max(0, SourceWidth - (float(SourceHeight) * NewAspect) / 2.0)) * 2
	CL = floor(WidthCrop / 4.0) * 2
	CT = 0
	CR = WidthCrop - CL
	CB = 0
""") : eval("""  CL=0  CT=0  CR=0  CB=0  """)

global crop_string = (CL == CT == CR == CB == 0) ? "" : \
"Crop("+string(CL)+","+string(CT)+","+string(-CR)+","+string(-CB)+")"

global resize_string = (SourceWidth == NewWidth) && (SourceHeight == NewHeight) ? "" : \
"BicubicResize("+string(NewWidth)+","+string(NewHeight)+",b=0,c=0.75)"

return source   }
MyResizing(640,480)

Code:
function TestingTesting(clip src)   {

	input = crop_string=="" ? src : eval("src."+crop_string)
	input = resize_string=="" ? input : eval("input."+resize_string)

	return input   }
TestingTesting()

Edit1: MyResizing() changed to only downscale.
The default for NewWidth is 1366, but when NewWidth >= the source width, it's ignored.
The default for NewHeight is 768, but when NewHeight >= the source height, it's ignored.
Edit2: Fixed the cropping.

Last edited by hello_hello; 18th April 2019 at 20:34.
hello_hello is offline   Reply With Quote