Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. ##AutoResize v1.3
  2. #created by dansrfe
  3.  
  4. ##Changes##
  5.  
  6. # 11/12/10 - Updated
  7. # 11/15/10 - Minor bugfixes and documentation added to avs
  8. # 11/16/10 - Major changes. Added input PAR setting for flagged content. Optimized code.
  9.  
  10. # This function will resize to any AR, and add black borders to reach any destination resolution.
  11. # It also shows info such as resolution and AR changes as well as the fps. This function was
  12. # primarily made to enable effective subtitle rendering at max screen resolution and optimum
  13. # placement area with ffdshow to madVR.
  14.  
  15. ##Syntax:##
  16.  
  17. # Resize(int Mode, bool Info, float AR, int ScreenWidth, int ScreenHeight)
  18.  
  19. # Mode: Any positive number to enable it. Any negative number to disable it. (default: none)
  20. # Info: Shows resolution and AR changes along with fps information in upper left corner. (default: "false")
  21. # AR: Changes AR with respect to screen resolution (default: input AR)
  22. # PAR: Defines pixel aspect ratio of input. Options: ("wide" for 16/9 & "[any string]" for 4/3) (default: null)
  23. # ScreenWidth: Screen width (default: 1920)
  24. # ScreenHeight: Screen height (default: 1080)
  25.  
  26. ##NOTE##
  27.  
  28. # When InputPAR is activated AR option will automatically be disabled. If InputPAR is enabled then it will only affect non-HD video.
  29. # If HD video AR needs to be changed then you must use the AR option.
  30.  
  31. function Resize(clip c, int "Mode", bool "Info", float "AR", string "PAR", int "ScreenWidth", int "ScreenHeight")
  32. {
  33. Info = Default(Info , False)
  34. Mode = Default(Mode , 0)
  35. ScreenWidth = Default(ScreenWidth , 1920)
  36. ScreenHeight = Default(ScreenHeight, 1080)
  37.  
  38. SetMTMode(2)
  39. last = c
  40.  
  41. AR_Screen = Float (ScreenWidth) / ScreenHeight
  42. AR_norm = Float ( Width) / Height
  43. Dest_AR = Default(AR, AR_norm)
  44. InputPAR = (string (PAR)=="") ? Dest_AR : ((string (PAR)=="wide") ? float(16.0)/9 : float(4)/3)
  45. Resize_BoxWidth = Round(Float(ScreenHeight) * InputPAR)
  46. Resize_LetterboxHeight = Round(Float(ScreenWidth ) / InputPAR)
  47.  
  48. Mod2Box = Resize_BoxWidth + (Resize_BoxWidth % 2)
  49. Mod2Letterbox = Resize_LetterboxHeight - (Resize_LetterboxHeight % 2)
  50.  
  51. Border_Letterbox = (ScreenHeight - Mod2Letterbox) / 2
  52. Border_Box = (ScreenWidth - Mod2Box ) / 2
  53.  
  54. Resize_Letter = Spline64Resize(ScreenWidth, Mod2Letterbox).ThreadRequest
  55. Resize_Box = Spline64Resize(Mod2Box , ScreenHeight ).ThreadRequest
  56. Upscale_Letterbox = (Border_Letterbox == 0) ? Resize_Letter.ThreadRequest : Resize_Letter.ThreadRequest.AddBorders( 0, Border_Letterbox, 0, Border_Letterbox).ThreadRequest
  57. Upscale_Box = (Border_Box == 0) ? Resize_Box : Resize_Box .ThreadRequest.AddBorders(Border_Box, 0, Border_Box, 0).ThreadRequest
  58.  
  59. 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)
  60.  
  61. HD_BorderWidth = (ScreenWidth - Width ) / 2
  62. HD_BorderHeight = (ScreenHeight - Height) / 2
  63.  
  64. ResizeHeight = (Height == ScreenHeight) && (AR_norm == Dest_AR) ? AddBorders(0, HD_BorderWidth , 0, HD_BorderWidth ).ThreadRequest : Letterbox_or_Box
  65. ResizeWidth = (Width == ScreenWidth ) && (AR_norm == Dest_AR) ? AddBorders(0, HD_BorderHeight, 0, HD_BorderHeight).ThreadRequest : ResizeHeight
  66.  
  67. HD = ((Width == ScreenWidth) && (Height == ScreenHeight)) && (AR_norm == Dest_AR) ? last : ResizeWidth
  68. SelectRes = (InputPAR >= AR_Screen) ? Resize_Letter : Resize_Box
  69. ChangeAR = (AR_norm == InputPAR) ? String(AR_norm) : (String(AR_norm) + " -> " + String(InputPAR))
  70. ChangeRes = (SelectRes.Width != Width) || (SelectRes.Height != Height) ? String(Width) + " x " + String(Height) + " -> " + String(SelectRes.Width) + " x " + String(SelectRes.Height) : String(Width) + " x " + String(Height)
  71.  
  72. SourceInfo = HD.Subtitle("Source res: " , x= 25, y=25, Size=22, Font="Arial", Text_Color=$DC143C)
  73. \. Subtitle(String(ChangeRes) , x=140, y=25, Size=22, Font="Arial" )
  74. \. Subtitle("A/R: " , x= 92, y=49, Size=22, Font="Arial", Text_Color=$DC143C)
  75. \. Subtitle(String(ChangeAR) , x=141, y=49, Size=22, Font="Arial" )
  76. \. Subtitle("FPS: " , x= 88, y=72, Size=22, Font="Arial", Text_Color=$DC143C)
  77. \. Subtitle(String(framerate(c)), x=141, y=72, Size=22, Font="Arial" )
  78.  
  79. (Mode >= 1) ? (Info ? SourceInfo.ThreadRequest : HD) : last
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement