Advertisement
Guest User

maa2mod

a guest
Jan 31st, 2014
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. MAA2 v0.41 mod
  3. =========
  4.  
  5. Updated version of the MAA antialising script from AnimeIVTC.
  6. MAA2 uses tp7's SangNom2 and FTurn, which provide a nice speedup for SangNom-based antialiasing,
  7. especially when only processing the luma plane.
  8. The defaults of MAA2 match up with MAA, so you'll get identical output (save for the more accurate border region processing of SangNom2)
  9. when using this script as a drop-in replacement.
  10.  
  11. MAA2 supports Y8, YV12 and YV24 input.
  12.  
  13. Requirements:
  14.  
  15.    * AviSynth 2.6a4
  16.    * SangNom2 0.3+
  17.    * FTurn
  18.    * Masktools 2.0a48
  19.    
  20. Parameters:
  21.  
  22.    + [int] mask (-200)
  23.        *   0: Disable masking
  24.        *   1: Enable masking
  25.        *  -i: Enable masking with custom treshold (sensible values are between 0 and 30)
  26.    + [bool] chroma (false)
  27.        *   false: Don't process chroma channels (copy UV from the source clip if present)
  28.        *   true: Process chroma channels
  29.    + [float] ss (2.0)
  30.        *   Supersampling factor (sensible values are between 2.0 and 4.0 for HD content)
  31.    + [int] aa (48)
  32.        *   Sangnom2 luma antialiasing strength
  33.    + [int] aac (aa-8)
  34.        *   Sangnom2 chroma antialiasing strength
  35.    + [int] threads (4)
  36.        *   Number of threads used by every Sangnom2 instance
  37.    + [int] show (0)
  38.        *   0: Don't overlay mask
  39.        *   1: Overlay mask only
  40.        *   2: Overlay mask and run antialiasing on the luma plane
  41.        
  42. */
  43.  
  44. function maa2(clip c, int "mask", bool "chroma", float "ss", int "aa", int "aac", int "threads", int "show")
  45. {
  46.     chroma = Default(chroma, false)
  47.     mask = Default(mask, -200)
  48.     mtresh = (mask < 0) ? -mask : 7
  49.     show = Default(show, 0)
  50.     uv = (chroma) ? 3 : 1
  51.  
  52.     Assert(c.IsY8 || c.IsYV12 || c.IsYV24, "MAA2: Input must be Y8, YV12 or YV24")
  53.     Assert(0 <= show <= 2, "MAA2: Parameter 'show' must be between 0 and 2")
  54.  
  55.     m = (mask != 0) ? c.mt_edge("min/max",0,mtresh,0,mtresh-6,u=uv,v=uv).mt_inflate(u=uv,v=uv) : nop()
  56.  
  57.     c_aa = (chroma && show==0) ? c.Sangnom2AA(ss,aa,aac,threads) : c.ConvertToY8().Sangnom2AA(ss,aa,threads=threads)
  58.  
  59.     c_aa = (show==1) ? (c.IsY8) ? c_aa.ConvertToYV12().mt_lut(y=2, u=0,v=0)
  60.                               \ : c.mt_lut("x 2 /", y=2, u=3,v=3)
  61.        \ : (show==2) ? (c.IsY8) ? c_aa.ConvertToYV12().mt_lut(y=2, u=0,v=0)
  62.                               \ : YtoUV(c.UtoY8(), c.VtoY8(), c_aa).mt_lut("x 2 /", y=2, u=3,v=3)
  63.        \ : c_aa
  64.  
  65.     return (mask !=0) ? (show > 0) ? (c.IsYV24) ? mt_merge(c,c_aa,m.YtoUV(m,m),u=3,v=3)
  66.                                               \ : mt_merge(c.ConvertToYV12(),c_aa,m,u=3,v=3, luma=true)
  67.                     \ : (chroma) ? mt_merge(c,c_aa,m,u=3,v=3)
  68.                     \ : mt_merge(c,c_aa,m,u=2,v=2)
  69.       \ : c.mt_logic(c_aa,"and", y=4, u=2, v=2)
  70. }
  71.  
  72. function Sangnom2AA(clip c, float "ss", int "aa", int "aac", int "threads")
  73. {
  74.     threads = Default(threads, 4)    
  75.     aa = Default(aa, 48)
  76.     aac = Default(aac, aa-8)
  77.     aac = (aac<0) ? 0 : aac
  78.     ss = Default(ss, 2.0)
  79.     ss_w = int(round(c.width*ss/4.0)*4)
  80.     ss_h = int(round(c.height*ss/4.0)*4)
  81.  
  82.     Assert(ss > 0, "MAA2: Supersampling factor must be > 0")
  83.  
  84.     return c.Spline36Resize(ss_w,ss_h).FTurnLeft() \
  85.             .SangNom2(threads=threads, aa=aa, aac=aac).FTurnRight().SangNom2(threads=threads, aa=aa, aac=aac).Spline36Resize(c.width,c.height)
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement