Log in

View Full Version : ResizeMin - 17 Feb 2020


StainlessS
17th February 2020, 22:03
ResizeMin.avs, Avs v2.58/v2.60 + GScript, OR AVS+


#ResizerMin.avs : Script to show minimum allowed Resizer Upsize Source, or DownSize Destination, clip size.

# Req RT_Stats v1.43+, AVS+ OR GScript, DebugView[google].

########## CONFIG ################
TST_SRC = True # True, test Upsize source minimum, else Downsize dest minimum.
DO_258_ONLY = True # If true, test ONLY avs v2.58 ColorSpaces/Resizers
#####################################

SIZERS="""Dummy
Point
Bilinear
Bicubic
Spline16
Spline36
Spline64
Gauss
Lanczos4
Lanczos
Blackman
sinc
"""

CSS="""Dummy
RGB24
RGB32
YUY2
YV12
YV16
YV24
Y8
YV411
RGB48
RGB64
RGBP8
RGBAP8
YUV420P8
YUV422P8
YUV444P8
YUVA420P8
YUVA422P8
YUVA444P8
"""

Is26=IsAvs26
IsPlus=IsAvsPlus
HasGScript=GScriptExists

SzEnd=(DO_258_ONLY || !Is26) ? 10 : 11
CsEnd=(DO_258_ONLY || !Is26) ? 4 : (!IsPlus) ? 8 : 18
myName="ResizerMin: "
RT_DebugF("\n%s\nMinimum Resizer %s clip size\n",VersionString,(TST_SRC)?"Upsize Source":"Downsize Dest",name=myName)

GSTRING="""
For(Sz=1,SzEnd) {
Sizer = SIZERS.RT_TxtGetLine(Sz)
RT_DebugF("%d/%d] SIZER='%sResize'",Sz,SzEnd,Sizer,name=myName)
For(csi=1,CsEnd) {
CSP=CSS.RT_TxtGetLine(csi)
XMod=CSP.X_CsXMod ValidW=-1
for(W=XMod,XMod*100,XMod) {
if(TST_SRC) { # Upsize Src Width
Blankclip(Length=1,Width=W,height=480,Pixel_type=CSP)
try { Eval(Sizer+"Resize(256,256)") ValidW=W W=XMod*1000} # W=XMod*1000 == Break
catch (msg) {}
} Else { # Downsize Dest Width
Blankclip(Length=1,Width=640,height=480,Pixel_type=CSP)
try { Eval(Sizer+"Resize("+String(W,"%.0f")+",480)") ValidW=W W=XMod*1000 }
catch (msg) {}
}
}
YMod=CSP.X_CsYMod ValidH=-1
for(H=YMod,YMod*100,YMod) {
if(TST_SRC) { # Upsize Src Height
Blankclip(Length=1,Width=640,height=H,Pixel_type=CSP)
try { Eval(Sizer+"Resize(256,256)") ValidH=H H=YMod*1000}
catch (msg) {}
} Else { # Downsize Dest Height
Blankclip(Length=1,Width=640,height=480,Pixel_type=CSP)
try { Eval(Sizer+"Resize(640,"+String(H,"%.0f")+")") ValidH=H H=YMod*1000 }
catch (msg) {}
}
}
RT_DebugF(" %8s %d,%d",CSP,ValidW,ValidH,name=myName)
CHKW = X_MinResize(Sizer,CSP,Wid=True, Src=TST_SRC)
CHKH = X_MinResize(Sizer,CSP,Wid=False,Src=TST_SRC)
Assert(CHKW==ValidW && CHKH==ValidH,RT_string("Error: RSZ=%s CSP=%s %d,%d CHK= %d,%d",Sizer,CSP,ValidW,ValidH,CHKW,CHKH)) # CHECK X_MinResize() returns correct numbers
}
}
"""
HasGScript ? GSCRIPT(GSTRING) : Eval(GSTRING)

Return MessageClip("Done")

##################################################
Function GScriptExists() { Return RT_FunctionExist("GScript")}
# Below, No Requirements
Function IsAvs26() { VersionNumber>=2.6}
Function IsAvsNeo() { FindStr(VersionString," Neo")!=0}
Function IsAvsPlus() { FindStr(VersionString,"AviSynth+")!=0||IsAvsNeo}
### AVS version agnostic functions
Function X_YMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Height/ExtractU.Height):(IsYV12 ?2:1) } # Y Min crop multiple for Progressive
Function X_XMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Width/ExtractU.Width):IsAvs26?(IsYV411?4:IsYUY2||IsYV16||IsYV12?2:1):(IsRGB?1:2)} # X Min crop multiple
Function X_CsXMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsXMod: CSP Clip or Pixel_Type string ONLY") Return X_XMod }
Function X_CsYMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsYMod: CSP Clip or Pixel_Type string ONLY") Return X_YMod }

Function X_MinResize(String Resizer,Val CSP,Bool "Wid",Bool "Src",Int "Taps") { # Minimum required Width or Height, Source or Dest, for Resizer and Colorspace, CSP can be Clip or String eg "RGB32"
S=Resizer.UCase I=FindStr(S,"RESIZE") S=(I==0) ? S : S.LeftStr(I-1) # Can use eg Resizer either "BiLinearResize or just BiLinear"
Ix=(S=="POINT")?0:(S=="BILINEAR")?1:(S=="BICUBIC")?2:(S=="SPLINE16")?3:(S=="SPLINE36")?4:(S=="SPLINE64")?5:(S=="GAUSS")?6:(S=="LANCZOS4")?7:(S=="LANCZOS")?8:(S=="BLACKMAN")?9:(S=="SINC")?10:-1
Assert(0 <= IX <= (IsAvs26?10:9), "X_MinResize: No such Resizer filter (" + S + "Resize)")
defT=Select(Ix, 0,-1,-2,-2,-3,-4,-4,-4,3,4,4)
Wid=Default(Wid,True) # True = Inquire Width, else Height
Src=Default(Src,True) # True = Inquire Upscale Src, else DownScale Dest
Assert(defT>0 || !Taps.Defined,"X_MinResize: "+S+"RESIZE Does not have a Taps arg")
Taps=(defT>0) ? Default(Taps,defT) : Abs(defT)
Assert(CSP.IsClip || CSP.IsString,"X_MinResize: CSP clip or Pixel_Type string ONLY")
Return (Wid) ? (Taps+1) * CSP.X_CsXMod : (IsAvs26) ? (Taps+1) * CSP.X_CsYMod
\ : (Src) ? (Taps+1) * 2 : Max((Taps+1)*2,4) # Fix for v2.58 Peculiarities
}

EDIT: Updated. Now Configurable Upsize src min, or downsize dest min.

EDIT: These can be used alone

# Below, No Requirements
Function IsAvs26() { VersionNumber>=2.6}
Function IsAvsNeo() { FindStr(VersionString," Neo")!=0}
Function IsAvsPlus() { FindStr(VersionString,"AviSynth+")!=0||IsAvsNeo}
### AVS version agnostic functions
Function X_YMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Height/ExtractU.Height):(IsYV12 ?2:1) } # Y Min crop multiple for Progressive
Function X_XMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Width/ExtractU.Width):IsAvs26?(IsYV411?4:IsYUY2||IsYV16||IsYV12?2:1):(IsRGB?1:2)} # X Min crop multiple
Function X_CsXMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsXMod: CSP Clip or Pixel_Type string ONLY") Return X_XMod }
Function X_CsYMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsYMod: CSP Clip or Pixel_Type string ONLY") Return X_YMod }

Function X_MinResize(String Resizer,Val CSP,Bool "Wid",Bool "Src",Int "Taps") { # Minimum required Width or Height, Source or Dest, for Resizer and Colorspace, CSP can be Clip or String eg "RGB32"
S=Resizer.UCase I=FindStr(S,"RESIZE") S=(I==0) ? S : S.LeftStr(I-1) # Can use eg Resizer either "BiLinearResize or just BiLinear"
Ix=(S=="POINT")?0:(S=="BILINEAR")?1:(S=="BICUBIC")?2:(S=="SPLINE16")?3:(S=="SPLINE36")?4:(S=="SPLINE64")?5:(S=="GAUSS")?6:(S=="LANCZOS4")?7:(S=="LANCZOS")?8:(S=="BLACKMAN")?9:(S=="SINC")?10:-1
Assert(0 <= IX <= (IsAvs26?10:9), "X_MinResize: No such Resizer filter (" + S + "Resize)")
defT=Select(Ix, 0,-1,-2,-2,-3,-4,-4,-4,3,4,4)
Wid=Default(Wid,True) # True = Inquire Width, else Height
Src=Default(Src,True) # True = Inquire Upscale Src, else DownScale Dest
Assert(defT>0 || !Taps.Defined,"X_MinResize: "+S+"RESIZE Does not have a Taps arg")
Taps=(defT>0) ? Default(Taps,defT) : Abs(defT)
Assert(CSP.IsClip || CSP.IsString,"X_MinResize: CSP clip or Pixel_Type string ONLY")
Return (Wid) ? (Taps+1) * CSP.X_CsXMod : (IsAvs26) ? (Taps+1) * CSP.X_CsYMod
\ : (Src) ? (Taps+1) * 2 : Max((Taps+1)*2,4) # Fix for v2.58 Peculiarities
}

StainlessS
17th February 2020, 22:03
Output for v2.58
Upsize Src min


AviSynth 2.58, build:Dec 22 2008 [08:46:51]
Minimum Resizer Upsize Source clip size

1/10] SIZER='PointResize'
RGB24 1,2
RGB32 1,2
YUY2 2,2
YV12 2,2
2/10] SIZER='BilinearResize'
RGB24 2,4
RGB32 2,4
YUY2 4,4
YV12 4,4
3/10] SIZER='BicubicResize'
RGB24 3,6
RGB32 3,6
YUY2 6,6
YV12 6,6
4/10] SIZER='Spline16Resize'
RGB24 3,6
RGB32 3,6
YUY2 6,6
YV12 6,6
5/10] SIZER='Spline36Resize'
RGB24 4,8
RGB32 4,8
YUY2 8,8
YV12 8,8
6/10] SIZER='Spline64Resize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
7/10] SIZER='GaussResize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
8/10] SIZER='Lanczos4Resize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
9/10] SIZER='LanczosResize'
RGB24 4,8
RGB32 4,8
YUY2 8,8
YV12 8,8
10/10] SIZER='BlackmanResize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10


Downsize Dest min


AviSynth 2.58, build:Dec 22 2008 [08:46:51]
Minimum Resizer Downsize Dest clip size

1/10] SIZER='PointResize'
RGB24 1,4
RGB32 1,4
YUY2 2,4
YV12 2,4
2/10] SIZER='BilinearResize'
RGB24 2,4
RGB32 2,4
YUY2 4,4
YV12 4,4
3/10] SIZER='BicubicResize'
RGB24 3,6
RGB32 3,6
YUY2 6,6
YV12 6,6
4/10] SIZER='Spline16Resize'
RGB24 3,6
RGB32 3,6
YUY2 6,6
YV12 6,6
5/10] SIZER='Spline36Resize'
RGB24 4,8
RGB32 4,8
YUY2 8,8
YV12 8,8
6/10] SIZER='Spline64Resize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
7/10] SIZER='GaussResize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
8/10] SIZER='Lanczos4Resize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10
9/10] SIZER='LanczosResize'
RGB24 4,8
RGB32 4,8
YUY2 8,8
YV12 8,8
10/10] SIZER='BlackmanResize'
RGB24 5,10
RGB32 5,10
YUY2 10,10
YV12 10,10

StainlessS
17th February 2020, 22:04
Output for Avs+ v3.5.0(currently a test dll)

Upsize Src min


AviSynth+ 3.5 (r2947, master, i386)
Minimum Resizer Upsize Source clip size

1/10] SIZER='PointResize'
RGB24 1,1
RGB32 1,1
YUY2 2,1
YV12 2,2
2/10] SIZER='BilinearResize'
RGB24 2,2
RGB32 2,2
YUY2 4,2
YV12 4,4
3/10] SIZER='BicubicResize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
4/10] SIZER='Spline16Resize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
5/10] SIZER='Spline36Resize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
6/10] SIZER='Spline64Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
7/10] SIZER='GaussResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
8/10] SIZER='Lanczos4Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
9/10] SIZER='LanczosResize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
10/10] SIZER='BlackmanResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10


Downsize dest min


AviSynth+ 3.5 (r2947, master, i386)
Minimum Resizer Downsize Dest clip size

1/10] SIZER='PointResize'
RGB24 1,1
RGB32 1,1
YUY2 2,1
YV12 2,2
2/10] SIZER='BilinearResize'
RGB24 2,2
RGB32 2,2
YUY2 4,2
YV12 4,4
3/10] SIZER='BicubicResize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
4/10] SIZER='Spline16Resize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
5/10] SIZER='Spline36Resize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
6/10] SIZER='Spline64Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
7/10] SIZER='GaussResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
8/10] SIZER='Lanczos4Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
9/10] SIZER='LanczosResize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
10/10] SIZER='BlackmanResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10


EDIT:
Full Avs+ colorspaces(8 bit only, hbd will be same), showing Minimum Resizer Upsize Source clip size ONLY, Min Downsize dest min will be same.
[Avs v2.60 Std will be same for below valid 2.60 colorspaces]


AviSynth+ 3.5 (r2947, master, i386)
Minimum Resizer Upsize Source clip size

1/11] SIZER='PointResize'
RGB24 1,1
RGB32 1,1
YUY2 2,1
YV12 2,2
YV16 2,1
YV24 1,1
Y8 1,1
YV411 4,1
RGB48 1,1
RGB64 1,1
RGBP8 1,1
RGBAP8 1,1
YUV420P8 2,2
YUV422P8 2,1
YUV444P8 1,1
YUVA420P8 2,2
YUVA422P8 2,1
YUVA444P8 1,1
2/11] SIZER='BilinearResize'
RGB24 2,2
RGB32 2,2
YUY2 4,2
YV12 4,4
YV16 4,2
YV24 2,2
Y8 2,2
YV411 8,2
RGB48 2,2
RGB64 2,2
RGBP8 2,2
RGBAP8 2,2
YUV420P8 4,4
YUV422P8 4,2
YUV444P8 2,2
YUVA420P8 4,4
YUVA422P8 4,2
YUVA444P8 2,2
3/11] SIZER='BicubicResize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
YV16 6,3
YV24 3,3
Y8 3,3
YV411 12,3
RGB48 3,3
RGB64 3,3
RGBP8 3,3
RGBAP8 3,3
YUV420P8 6,6
YUV422P8 6,3
YUV444P8 3,3
YUVA420P8 6,6
YUVA422P8 6,3
YUVA444P8 3,3
4/11] SIZER='Spline16Resize'
RGB24 3,3
RGB32 3,3
YUY2 6,3
YV12 6,6
YV16 6,3
YV24 3,3
Y8 3,3
YV411 12,3
RGB48 3,3
RGB64 3,3
RGBP8 3,3
RGBAP8 3,3
YUV420P8 6,6
YUV422P8 6,3
YUV444P8 3,3
YUVA420P8 6,6
YUVA422P8 6,3
YUVA444P8 3,3
5/11] SIZER='Spline36Resize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
YV16 8,4
YV24 4,4
Y8 4,4
YV411 16,4
RGB48 4,4
RGB64 4,4
RGBP8 4,4
RGBAP8 4,4
YUV420P8 8,8
YUV422P8 8,4
YUV444P8 4,4
YUVA420P8 8,8
YUVA422P8 8,4
YUVA444P8 4,4
6/11] SIZER='Spline64Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
YV16 10,5
YV24 5,5
Y8 5,5
YV411 20,5
RGB48 5,5
RGB64 5,5
RGBP8 5,5
RGBAP8 5,5
YUV420P8 10,10
YUV422P8 10,5
YUV444P8 5,5
YUVA420P8 10,10
YUVA422P8 10,5
YUVA444P8 5,5
7/11] SIZER='GaussResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
YV16 10,5
YV24 5,5
Y8 5,5
YV411 20,5
RGB48 5,5
RGB64 5,5
RGBP8 5,5
RGBAP8 5,5
YUV420P8 10,10
YUV422P8 10,5
YUV444P8 5,5
YUVA420P8 10,10
YUVA422P8 10,5
YUVA444P8 5,5
8/11] SIZER='Lanczos4Resize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
YV16 10,5
YV24 5,5
Y8 5,5
YV411 20,5
RGB48 5,5
RGB64 5,5
RGBP8 5,5
RGBAP8 5,5
YUV420P8 10,10
YUV422P8 10,5
YUV444P8 5,5
YUVA420P8 10,10
YUVA422P8 10,5
YUVA444P8 5,5
9/11] SIZER='LanczosResize'
RGB24 4,4
RGB32 4,4
YUY2 8,4
YV12 8,8
YV16 8,4
YV24 4,4
Y8 4,4
YV411 16,4
RGB48 4,4
RGB64 4,4
RGBP8 4,4
RGBAP8 4,4
YUV420P8 8,8
YUV422P8 8,4
YUV444P8 4,4
YUVA420P8 8,8
YUVA422P8 8,4
YUVA444P8 4,4
10/11] SIZER='BlackmanResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
YV16 10,5
YV24 5,5
Y8 5,5
YV411 20,5
RGB48 5,5
RGB64 5,5
RGBP8 5,5
RGBAP8 5,5
YUV420P8 10,10
YUV422P8 10,5
YUV444P8 5,5
YUVA420P8 10,10
YUVA422P8 10,5
YUVA444P8 5,5
11/11] SIZER='sincResize'
RGB24 5,5
RGB32 5,5
YUY2 10,5
YV12 10,10
YV16 10,5
YV24 5,5
Y8 5,5
YV411 20,5
RGB48 5,5
RGB64 5,5
RGBP8 5,5
RGBAP8 5,5
YUV420P8 10,10
YUV422P8 10,5
YUV444P8 5,5
YUVA420P8 10,10
YUVA422P8 10,5
YUVA444P8 5,5

StainlessS
17th February 2020, 22:05
Machine Combined, showing where different requirements [for Height]
For avs v2.60/Avs+, both Upsize_Src min and Downsize_Dest min sizes are the same.
Only v2.58 colorspaces shown below.


MINIMUM RESIZER CLIP SIZE

UPSIZE SOURCE DOWNSIZE DEST

Avs v2.60/Avs+ : Avs v2.58 : Avs v2.60/Avs+ : Avs v2.58
1/10] SIZER='PointResize'
RGB24 1, 1 1, 2 *** : 1, 1 1, 4 ***
RGB32 1, 1 1, 2 *** : 1, 1 1, 4 ***
YUY2 2, 1 2, 2 *** : 2, 1 2, 4 ***
YV12 2, 2 2, 2 : 2, 2 2, 4 ***
2/10] SIZER='BilinearResize'
RGB24 2, 2 2, 4 *** : 2, 2 2, 4 ***
RGB32 2, 2 2, 4 *** : 2, 2 2, 4 ***
YUY2 4, 2 4, 4 *** : 4, 2 4, 4 ***
YV12 4, 4 4, 4 : 4, 4 4, 4
3/10] SIZER='BicubicResize'
RGB24 3, 3 3, 6 *** : 3, 3 3, 6 ***
RGB32 3, 3 3, 6 *** : 3, 3 3, 6 ***
YUY2 6, 3 6, 6 *** : 6, 3 6, 6 ***
YV12 6, 6 6, 6 : 6, 6 6, 6
4/10] SIZER='Spline16Resize'
RGB24 3, 3 3, 6 *** : 3, 3 3, 6 ***
RGB32 3, 3 3, 6 *** : 3, 3 3, 6 ***
YUY2 6, 3 6, 6 *** : 6, 3 6, 6 ***
YV12 6, 6 6, 6 : 6, 6 6, 6
5/10] SIZER='Spline36Resize'
RGB24 4, 4 4, 8 *** : 4, 4 4, 8 ***
RGB32 4, 4 4, 8 *** : 4, 4 4, 8 ***
YUY2 8, 4 8, 8 *** : 8, 4 8, 8 ***
YV12 8, 8 8, 8 : 8, 8 8, 8
6/10] SIZER='Spline64Resize'
RGB24 5, 5 5,10 *** : 5, 5 5,10 ***
RGB32 5, 5 5,10 *** : 5, 5 5,10 ***
YUY2 10, 5 10,10 *** : 10, 5 10,10 ***
YV12 10,10 10,10 : 10,10 10,10
7/10] SIZER='GaussResize'
RGB24 5, 5 5,10 *** : 5, 5 5,10 ***
RGB32 5, 5 5,10 *** : 5, 5 5,10 ***
YUY2 10, 5 10,10 *** : 10, 5 10,10 ***
YV12 10,10 10,10 : 10,10 10,10
8/10] SIZER='Lanczos4Resize'
RGB24 5, 5 5,10 *** : 5, 5 5,10 ***
RGB32 5, 5 5,10 *** : 5, 5 5,10 ***
YUY2 10, 5 10,10 *** : 10, 5 10,10 ***
YV12 10,10 10,10 : 10,10 10,10
9/10] SIZER='LanczosResize'
RGB24 4, 4 4, 8 *** : 4, 4 4, 8 ***
RGB32 4, 4 4, 8 *** : 4, 4 4, 8 ***
YUY2 8, 4 8, 8 *** : 8, 4 8, 8 ***
YV12 8, 8 8, 8 : 8, 8 8, 8
10/10] SIZER='BlackmanResize'
RGB24 5, 5 5,10 *** : 5, 5 5,10 ***
RGB32 5, 5 5,10 *** : 5, 5 5,10 ***
YUY2 10, 5 10,10 *** : 10, 5 10,10 ***
YV12 10,10 10,10 : 10,10 10,10

StainlessS
19th February 2020, 00:21
Post #1 update to single script for Min Upsize Src, or Min Downsize dest [Renamed to ResizeMin.avs].
All previously remaining posts updated, remainder removed, (Cleanup).

These functions can be used separately
[EDIT: X_MinResize() intended only where full size source clip is being resized, ie no account taken for Src_left, Src_Top etc args.]

EDIT: No requirements.

Function IsAvs26() { VersionNumber>=2.6}
Function IsAvsNeo() { FindStr(VersionString," Neo")!=0}
Function IsAvsPlus() { FindStr(VersionString,"AviSynth+")!=0||IsAvsNeo}
### AVS version agnostic functions
Function X_YMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Height/ExtractU.Height):(IsYV12 ?2:1) } # Y Min crop multiple for Progressive
Function X_XMod(clip c) { c IsAvsPlus ? (NumComponents==1||IsRGB?1:Width/ExtractU.Width):IsAvs26?(IsYV411?4:IsYUY2||IsYV16||IsYV12?2:1):(IsRGB?1:2)} # X Min crop multiple
Function X_CsXMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsXMod: CSP Clip or Pixel_Type string ONLY") Return X_XMod }
Function X_CsYMod(Val CSP) { (CSP.IsClip)?CSP:(CSP.IsString)?Blankclip(Length=1,Width=16,height=16,Pixel_type=CSP):Assert(False,"X_CsYMod: CSP Clip or Pixel_Type string ONLY") Return X_YMod }

Function X_MinResize(String Resizer,Val CSP,Bool "Wid",Bool "Src",Int "Taps") { # Minimum required Width or Height, Source or Dest, for Resizer and Colorspace, CSP can be Clip or String eg "RGB32"
S=Resizer.UCase I=FindStr(S,"RESIZE") S=(I==0) ? S : S.LeftStr(I-1) # Can use eg Resizer either "BiLinearResize or just BiLinear"
Ix=(S=="POINT")?0:(S=="BILINEAR")?1:(S=="BICUBIC")?2:(S=="SPLINE16")?3:(S=="SPLINE36")?4:(S=="SPLINE64")?5:(S=="GAUSS")?6:(S=="LANCZOS4")?7:(S=="LANCZOS")?8:(S=="BLACKMAN")?9:(S=="SINC")?10:-1
Assert(0 <= IX <= (IsAvs26?10:9), "X_MinResize: No such Resizer filter (" + S + "Resize)")
defT=Select(Ix, 0,-1,-2,-2,-3,-4,-4,-4,3,4,4)
Wid=Default(Wid,True) # True = Inquire Width, else Height
Src=Default(Src,True) # True = Inquire Upscale Src, else DownScale Dest
Assert(defT>0 || !Taps.Defined,"X_MinResize: "+S+"RESIZE Does not have a Taps arg")
Taps=(defT>0) ? Default(Taps,defT) : Abs(defT)
Assert(CSP.IsClip || CSP.IsString,"X_MinResize: CSP clip or Pixel_Type string ONLY")
Return (Wid) ? (Taps+1) * CSP.X_CsXMod : (IsAvs26) ? (Taps+1) * CSP.X_CsYMod
\ : (Src) ? (Taps+1) * 2 : Max((Taps+1)*2,4) # Fix for v2.58 Peculiarities
}