Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##AutoResize v1.3
- #created by dansrfe
- ##Changes##
- # 11/12/10 - Updated
- # 11/15/10 - Minor bugfixes and documentation added to avs
- # 11/16/10 - Major changes. Added input PAR setting for flagged content. Optimized code.
- # This function will resize to any AR, and add black borders to reach any destination resolution.
- # It also shows info such as resolution and AR changes as well as the fps. This function was
- # primarily made to enable effective subtitle rendering at max screen resolution and optimum
- # placement area with ffdshow to madVR.
- ##Syntax:##
- # Resize(int Mode, bool Info, float AR, int ScreenWidth, int ScreenHeight)
- # Mode: Any positive number to enable it. Any negative number to disable it. (default: none)
- # Info: Shows resolution and AR changes along with fps information in upper left corner. (default: "false")
- # AR: Changes AR with respect to screen resolution (default: input AR)
- # PAR: Defines pixel aspect ratio of input. Options: ("wide" for 16/9 & "[any string]" for 4/3) (default: null)
- # ScreenWidth: Screen width (default: 1920)
- # ScreenHeight: Screen height (default: 1080)
- ##NOTE##
- # When InputPAR is activated AR option will automatically be disabled. If InputPAR is enabled then it will only affect non-HD video.
- # If HD video AR needs to be changed then you must use the AR option.
- function Resize(clip c, int "Mode", bool "Info", float "AR", string "PAR", int "ScreenWidth", int "ScreenHeight")
- {
- Info = Default(Info , False)
- Mode = Default(Mode , 0)
- ScreenWidth = Default(ScreenWidth , 1920)
- ScreenHeight = Default(ScreenHeight, 1080)
- SetMTMode(2)
- last = c
- AR_Screen = Float (ScreenWidth) / ScreenHeight
- AR_norm = Float ( Width) / Height
- Dest_AR = Default(AR, AR_norm)
- InputPAR = (string (PAR)=="") ? Dest_AR : ((string (PAR)=="wide") ? float(16.0)/9 : float(4)/3)
- Resize_BoxWidth = Round(Float(ScreenHeight) * InputPAR)
- Resize_LetterboxHeight = Round(Float(ScreenWidth ) / InputPAR)
- Mod2Box = Resize_BoxWidth + (Resize_BoxWidth % 2)
- Mod2Letterbox = Resize_LetterboxHeight - (Resize_LetterboxHeight % 2)
- Border_Letterbox = (ScreenHeight - Mod2Letterbox) / 2
- Border_Box = (ScreenWidth - Mod2Box ) / 2
- Resize_Letter = Spline64Resize(ScreenWidth, Mod2Letterbox).ThreadRequest
- Resize_Box = Spline64Resize(Mod2Box , ScreenHeight ).ThreadRequest
- Upscale_Letterbox = (Border_Letterbox == 0) ? Resize_Letter.ThreadRequest : Resize_Letter.ThreadRequest.AddBorders( 0, Border_Letterbox, 0, Border_Letterbox).ThreadRequest
- Upscale_Box = (Border_Box == 0) ? Resize_Box : Resize_Box .ThreadRequest.AddBorders(Border_Box, 0, Border_Box, 0).ThreadRequest
- Letterbox_or_Box = (InputPAR >= AR_Screen) ? (width < 1280 ? Upscale_Letterbox.Colormatrix("Rec.601->Rec.709") : Upscale_Letterbox) : (height < 720 ? Upscale_Box.Colormatrix("Rec.601->Rec.709") : Upscale_Box)
- HD_BorderWidth = (ScreenWidth - Width ) / 2
- HD_BorderHeight = (ScreenHeight - Height) / 2
- ResizeHeight = (Height == ScreenHeight) && (AR_norm == Dest_AR) ? AddBorders(0, HD_BorderWidth , 0, HD_BorderWidth ).ThreadRequest : Letterbox_or_Box
- ResizeWidth = (Width == ScreenWidth ) && (AR_norm == Dest_AR) ? AddBorders(0, HD_BorderHeight, 0, HD_BorderHeight).ThreadRequest : ResizeHeight
- HD = ((Width == ScreenWidth) && (Height == ScreenHeight)) && (AR_norm == Dest_AR) ? last : ResizeWidth
- SelectRes = (InputPAR >= AR_Screen) ? Resize_Letter : Resize_Box
- ChangeAR = (AR_norm == InputPAR) ? String(AR_norm) : (String(AR_norm) + " -> " + String(InputPAR))
- ChangeRes = (SelectRes.Width != Width) || (SelectRes.Height != Height) ? String(Width) + " x " + String(Height) + " -> " + String(SelectRes.Width) + " x " + String(SelectRes.Height) : String(Width) + " x " + String(Height)
- SourceInfo = HD.Subtitle("Source res: " , x= 25, y=25, Size=22, Font="Arial", Text_Color=$DC143C)
- \. Subtitle(String(ChangeRes) , x=140, y=25, Size=22, Font="Arial" )
- \. Subtitle("A/R: " , x= 92, y=49, Size=22, Font="Arial", Text_Color=$DC143C)
- \. Subtitle(String(ChangeAR) , x=141, y=49, Size=22, Font="Arial" )
- \. Subtitle("FPS: " , x= 88, y=72, Size=22, Font="Arial", Text_Color=$DC143C)
- \. Subtitle(String(framerate(c)), x=141, y=72, Size=22, Font="Arial" )
- (Mode >= 1) ? (Info ? SourceInfo.ThreadRequest : HD) : last
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement