Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # scanlines:  add scanlines for textmode or low-res graphics modes
  2. # col8:       remove column 9 of textmode characters
  3.  
  4.  
  5. function VGA_to_640x480(clip c, bool "col8")  {
  6.         col8 = default(col8, false)
  7.         c    = c.IsRGB  ?  c.ConvertToRGB32  :  c
  8.         c    = c.VGA__xres_640(col8)
  9.         c    = c.VGA__yres_480
  10.         return c
  11. }
  12.  
  13.  
  14. function VGA_to_960x720(clip c, bool "scanlines", bool "col8")  {
  15.         col8      = default(col8     , false)
  16.         scanlines = default(scanlines, true )
  17.         c         = c.IsRGB  ?  c.ConvertToRGB32  :  c
  18.         c         = c.VGA__xres_960(col8     )
  19.         c         = c.VGA__yres_720(scanlines)
  20.         return c.ConvertToYV12
  21. }
  22.  
  23.  
  24. # -------------------------------------------------------------------------------------------------------------------------------
  25.  
  26.  
  27. function VGA__xres_640(clip c, bool col8)  {
  28.         c = ((col8) && (c.Width == 720))  ?  c.VGA__720_to_640                :  c              # process textmode characters?
  29.         c = (640 % c.Width == 0        )  ?  c.   PointResize(640, c.Height)  :  c              # can we use PointResize?
  30.         c = (c.Width != 640            )  ?  c.BilinearResize(640, c.Height)  :  c              # use BilinearResize as a fallback
  31.         return c
  32. }
  33.  
  34.  
  35. function VGA__xres_960(clip c, bool col8)  {
  36.         c = ((col8) && (c.Width == 720))  ?  c.VGA__720_to_640                :  c
  37.         c = (960 % c.Width == 0        )  ?  c.   PointResize(960, c.Height)  :  c
  38.         c = (c.Width != 960            )  ?  c.BilinearResize(960, c.Height)  :  c
  39.         return c
  40. }
  41.  
  42.  
  43. # -------------------------------------------------------------------------------------------------------------------------------
  44.  
  45.  
  46. function VGA__yres_480(clip c)  {
  47.         c = (480 % c.Height == 0             )  ?  c.       PointResize(c.Width, 480)  :  c
  48.         c = (c.Height != 480                 )  ?  c.    BilinearResize(c.Width, 480)  :  c
  49.         return c
  50. }
  51.  
  52.  
  53. function VGA__yres_720(clip c, bool scanlines)  {
  54.         c = ((scanlines) && (c.Height == 400))  ?  c.VGA__Add_Scanlines(         720)  :  c
  55.         c = (720 % c.Height == 0             )  ?  c.       PointResize(c.Width, 720)  :  c
  56.         c = (c.Height != 720                 )  ?  c.    BilinearResize(c.Width, 720)  :  c
  57.         return c
  58. }
  59.  
  60.  
  61. # -------------------------------------------------------------------------------------------------------------------------------
  62.  
  63.  
  64. function VGA__720_to_640(clip c)  {
  65.         l = c.Crop(0, 0, 8, 0)                                                  # left  column
  66.         r = c.Crop(9, 0, 0, 0)                                                  # right columns
  67.         r = (r.Width > 9)  ?  VGA__720_to_640(r)  :  r.Crop(0, 0, 8, 0)         # recursion over right columns
  68.         StackHorizontal(l, r)
  69. }
  70.  
  71.  
  72. function VGA__Add_Scanlines(clip c, int LineCount, bool "spline")  {
  73.         spline = default(spline, false)
  74.         c
  75.         o = PointResize(Width, Height * 6).ConvertToYV12                        # stay in original colorspace as long as possible
  76.         BlankClip(o, 2).mt_lutspa(false, "y 6 % 0 == 255 0 ?")
  77.         mt_merge(o, BlankClip(o), PointResize(Width, Height))
  78.         y = LineCount
  79.         #x= y * 4 / 3
  80.         x = Width
  81.         return   spline  ?  BilinearResize(x, y)  :  Spline64Resize(Width, y).Spline36Resize(x, y)
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement