Advertisement
mawen1250

Repair16.avsi

Aug 1st, 2012
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Repair16(clip input, clip source, int "mode", int "modeU", int "modeV", float "weight", float "thr"){
  2.  
  3.   mode    = Default(mode,   1    )
  4.   modeU   = Default(modeU,  mode )
  5.   modeV   = Default(modeV,  modeU)
  6.   weight  = Default(weight, 1.0  )
  7.   thr     = Default(thr,    0.0  )
  8.  
  9.   weight  = min(max(weight, 0.0), 1.0)
  10.   thr     = max(thr, 0.0)
  11.   Y       = mode  >= 1 ? 3 : 1
  12.   U       = modeU >= 1 ? 3 : 1
  13.   V       = modeV >= 1 ? 3 : 1
  14.  
  15.   fix16   = input.Dither_repair16(source, mode, modeU, modeV)
  16.   weightM = input.Dither_lut16(Y=Y==1?1:Round(-65535*weight), U=U==1?1:Round(-65535*weight), V=V==1?1:Round(-65535*weight))
  17.   fix16   = thr == 0.0 ? fix16 : input.Dither_limit_dif16(fix16, thr=thr, Y=Y, U=U, V=V)
  18.   final   = weight == 0.0 ? input
  19.   \       : weight == 1.0 ? mt_lutxy(fix16, input, Y=mode==0?4:mode>=1?2:1, U=modeU==0?4:modeU>=1?2:1, V=modeV==0?4:modeV>=1?2:1)
  20.   \                       : Dither_merge16(input, fix16, weightM, luma=false, Y=mode==0?2:Y, U=modeU==0?2:U, V=modeV==0?2:V)
  21.  
  22.   return final
  23.  
  24. }
  25.  
  26. Function Repair16_8(clip input, clip source, int "mode", int "modeU", int "modeV", float "weight", float "thr", bool "lsb_in"){
  27.  
  28.   mode    = Default(mode,   1    )
  29.   modeU   = Default(modeU,  mode )
  30.   modeV   = Default(modeV,  modeU)
  31.   weight  = Default(weight, 1.0  )
  32.   thr     = Default(thr,    0.5  )
  33.   lsb_in  = Default(lsb_in, false)
  34.  
  35.   weight  = min(max(weight, 0.0), 1.0)
  36.   thr     = max(thr, 0.0)
  37.   Y       = mode  >= 1 ? 3 : 1
  38.   U       = modeU >= 1 ? 3 : 1
  39.   V       = modeV >= 1 ? 3 : 1
  40.    
  41.   input8  = lsb_in ? input .DitherPost(mode=-1, Y=Y, U=U, V=V) : input
  42.   source8 = lsb_in ? source.DitherPost(mode=-1, Y=Y, U=U, V=V) : source
  43.   input16 = lsb_in ? input  : input .Dither_convert_8_to_16()
  44.  
  45.   fix8    = input8 .Repair(source8, mode, modeU, modeV)
  46.   difM8   = lsb_in ? mt_lutxy(input8, fix8, "x y != " + String(255*weight) + " 0 ?", Y=Y, U=U, V=V)
  47.   \                : mt_lut(input8, Y=Y==1?1:Round(-255*weight), U=U==1?1:Round(-255*weight), V=V==1?1:Round(-255*weight))
  48.   fix16   = fix8   .Dither_convert_8_to_16()
  49.   fix16   = input16.Dither_limit_dif16(fix16, thr=thr, Y=Y, U=U, V=V)
  50.   final   = weight == 0.0 ? input16
  51.   \       : weight == 1.0 ? mt_lutxy(fix16, input16, Y=mode==0?4:mode>=1?2:1, U=modeU==0?4:modeU>=1?2:1, V=modeV==0?4:modeV>=1?2:1)
  52.   \                       : Dither_merge16_8(input16, fix16, difM8, luma=false, Y=mode==0?2:Y, U=modeU==0?2:U, V=modeV==0?2:V)
  53.  
  54.   return final
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement