Advertisement
Guest User

scaled444tonative

a guest
Apr 5th, 2020
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # base on ChromaReconstructor and fulltonative by feisty2
  2.  
  3. function scaled444tonative (clip src, int "a", float "h", int "lowpass", int "mode", int "device_type", int "device_id", int "fast", float "sDev", float "iDev", float "cs", bool "d2", int "kernS", int "kernI", int "resType")
  4. {
  5.     fast            = default(fast, 0)
  6.     a               = default(a, fast!=0 ? 1 : 32)
  7.     h               = default(h, 6.4)
  8.     lowpass         = default(lowpass, 6)
  9.     mode            = default(mode, 0)
  10.     sDev            = default (sDev,      31.1)
  11.     iDev            = default (iDev,      15.1)
  12.     d2              = default (d2,        true)
  13.     kernS           = default (kernS,        8)
  14.     kernI           = default (kernI,        3)
  15.     restype         = default (restype,      0)
  16.     sisphbd         = AvsPlusVersionNumber > 2294
  17.     siscfloat       = sisphbd ? IsVideoFloat(src) : false
  18.     pad             = fast < 3 && fast != 1 ? src.sh_padding (2, 2, 2, 2) : src
  19.     srcy            = sisphbd ? ExtractY(pad) : ConvertToY8(pad)
  20.     srcu            = sisphbd ? ExtractU(pad) : UToY8(pad)
  21.     srcv            = sisphbd ? ExtractV(pad) : VToY8(pad)
  22.     u4x             = fast < 3 && fast != 1 ? pad.nnedi3_rpow2(2, nns=4, qual=2, etype=1, nsize=0).nnedi3_rpow2(2, nns=4, qual=2, etype=1, nsize=0) : pad
  23.     luma            = fast < 3 && fast != 1 ? sisphbd ? ExtractY(u4x) : ConvertToY8(u4x) : srcy
  24.     u               = siscfloat ? mt_lut (sisphbd ? ExtractU(u4x) : UToY8(u4x), "x range_half +", use_expr=2) : fast < 3 && fast != 1 ? sisphbd ? ExtractU(u4x) : UToY8(u4x) : srcu
  25.     v               = siscfloat ? mt_lut (sisphbd ? ExtractV(u4x) : VToY8(u4x), "x range_half +", use_expr=2) : fast < 3 && fast != 1 ? sisphbd ? ExtractV(u4x) : VToY8(u4x) : srcv
  26.     unew            = fast > 1 ? U.ConvertToYv12().TBilateral(diameterL=Round(pow(2 * a + 1,2)), sDevL=sDev, iDevL=iDev, csL=cs, d2=d2, chroma=false, ppclip=luma.ConvertToYV12(), kernS=kernS, kernI=kernI, resType=resType).ConvertToY8() : KNLMeansCL (u, d=0, a=a, s=0, h=h, wref=1.0, rclip=luma, device_type=device_type, device_id=device_id)
  27.     unew            = fast < 3 && fast != 1 ? sresizexnr (unew, pad.width, pad.height, src_left=-1.5, src_top=-1.5, kernel="spline64") : unew
  28.     vnew            = fast > 1 ? V.ConvertToYv12().TBilateral(diameterL=Round(pow(2 * a + 1,2)), sDevL=sDev, iDevL=iDev, csL=cs, d2=d2, chroma=false, ppclip=luma.ConvertToYV12(), kernS=kernS, kernI=kernI, resType=resType).ConvertToY8() : KNLMeansCL (v, d=0, a=a, s=0, h=h, wref=1.0, rclip=luma, device_type=device_type, device_id=device_id)
  29.     vnew            = fast < 3 && fast != 1 ? sresizexnr (vnew, pad.width, pad.height, src_left=-1.5, src_top=-1.5, kernel="spline64") : vnew
  30.     uhi             = mode == 1 ? mt_MakeDiff (unew, fgauss_h (unew, p=lowpass)) : mt_MakeDiff (unew, fgauss (unew, p=lowpass))
  31.     vhi             = mode == 1 ? mt_MakeDiff (vnew, fgauss_h (vnew, p=lowpass)) : mt_MakeDiff (vnew, fgauss (vnew, p=lowpass))
  32.     ufinal          = !siscfloat ? srcu.mt_AddDiff(uhi) : mt_lut (mt_MakeDiff (mt_lut (srcu, "x range_half +", use_expr=2), uhi), "x range_half -", use_expr=2)
  33.     vfinal          = !siscfloat ? srcv.mt_AddDiff(vhi) : mt_lut (mt_MakeDiff (mt_lut (srcv, "x range_half +", use_expr=2), vhi), "x range_half -", use_expr=2)
  34.     fmerge           = YToUV(UFinal, VFinal, srcy)
  35.     fclip            = Crop (fmerge, 2, 2, -2, -2)
  36.     return fclip
  37.     }
  38.  
  39. function fgauss_h(clip src, int "p")
  40. {
  41.              p        = default(p, 30)
  42.              w        = src.width
  43.              h        = src.height
  44.              upsmp    = resizex(src, w * 2, h, kernel="gauss", a1=100)
  45.              return resizex(upsmp, w, h, kernel="gauss", a1=p)
  46. }
  47.  
  48. function fgauss(clip src, int "p")
  49. {
  50.              p        = default(p, 30)
  51.              w        = src.width
  52.              h        = src.height
  53.              upsmp    = resizex(src, w * 2, h * 2, kernel="gauss", a1=100)
  54.              return resizex(upsmp, w, h, kernel="gauss", a1=p)
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement