Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Kernel [int]
- ### ------------------
- ### 1 = Bilinear (Default)
- ### 2 = Bicubic
- ### - MitchellNetravali (b=0.3333 c=0.3333) (default)
- ### - CatmullRom (b=0 c=0.5 ) (kernel=3 still uses CatRom like the original did)
- ###
- ### Mode [int]
- ### ------------------
- ### 1 = Stack (Default)
- ### 2 = Plus Only
- ### 3 = Minus Only
- ###
- ### PARNum [float]
- ### PARDen [float]
- ###
- ### b [float]
- ### c [float]
- ###
- ### ------------------
- ### per .ts 1440x1080 si usa un PAR = 4/3, quindi PARNum = 4 e PARDen = 3
- function ResFinder(clip clp, int "Res", int "Kernel", int "Mode", float "PARNum", float "PARDen", float "b", float "c")
- {
- Res = Default(Res, 720)
- PARNum = Default(PARNum, 16)
- PARDen = Default(PARDen, 9)
- Kernel = default(Kernel, 1)
- Mode = default(Mode, 1)
- b = default(b, 1.0/3)
- c = default(c, 1.0/3)
- Assert (Res%2 == 0, "Res must be Mod2")
- Assert (!(Kernel > 3 || Kernel < 1), "Kernel must be 1, 2 or 3.")
- Assert (!(Mode > 3 || Mode < 1), "Mode must be 1, 2 or 3.")
- ResWidth = Round((Res*clp.Width()/clp.Height())*PARNum/PARDen)
- ResWidth = (ResWidth > clp.Width()) && (Res < clp.Height()) ? clp.Width() : ResWidth
- return ResWidth%2 == 0 ? clp.GenerateClip(Res, ResWidth, Kernel,b,c).GenerateReport(Res, ResWidth, 1) : clp.Mod2Function(Res, ResWidth , Mode, Kernel,b,c)
- function Mod2Function(clip clp, int Res, int ResWidth, int Mode, int Kernel, float b, float c){
- ResRemaining = ResWidth%2
- return Mode == 1 ? StackVertical(clp.GenerateClip(Res, ResWidth + ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth + ResRemaining, 2), clp.GenerateClip(Res, ResWidth - ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth - ResRemaining, 3)) :
- \ Mode == 2 ? clp.GenerateClip(Res, ResWidth + ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth + ResRemaining, 2) :
- \ clp.GenerateClip(Res, ResWidth - ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth - ResRemaining, 3)
- }
- function GenerateClip(clip clp, int Res, int ResWidth, int Kernel, float b, float c)
- {
- return Kernel == 1 ? mt_makediff(clp, clp.debilinear(ResWidth,Res).BilinearResize(clp.Width(),clp.Height()),u=1,v=1) :
- \ Kernel == 3 ? mt_makediff(clp, clp.debicubic(ResWidth,Res, b=0, c=0.5).BicubicResize(clp.Width(),clp.Height(), b=0, c=0.5),u=1,v=1) :
- \ mt_makediff(clp, clp.debicubic(ResWidth,Res, b=b, c=c).BicubicResize(clp.Width(),clp.Height(), b=b, c=c),u=1,v=1)
- }
- function GenerateReport(clip clp, int Res, int ResWidth, int Mode)
- {
- turnback = 1
- clp.Removegrain(1,-1).mt_lut("x 128 - 0 > x " + string(turnback) + " - 128 > x " + string(turnback) + " - 128 ? x " + string(turnback) + " + 128 < x " + string(turnback) + " + 128 ? ?",u=1,v=1).Histogram("luma").Greyscale()
- Mode == 1 ? WriteFile(".\output.txt",""" "=;" """ , string(Res), """ ";" """, "AverageLuma()") :
- \ Mode == 2 ? WriteFile(".\output.txt",""" "+;" """ , string(Res), """ ";" """, "AverageLuma()") :
- \ WriteFile(".\output.txt",""" "-;" """ , string(Res), """ ";" """, "AverageLuma()")
- ScriptClip(" Subtitle( String(AverageLuma())) ")
- Mode == 2 ? Subtitle("Plus", align=8) :
- \ Mode == 3 ? Subtitle("Minus", align=8) : last
- return Subtitle(String(ResWidth), align=9)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement