Advertisement
Guest User

Untitled

a guest
Nov 27th, 2013
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # avisynth script template for cel anime dvds that contain field blending/aliasing, dot-crawl and rainbowing.
  2. # note: this thing tries to be mild, since the creator doesn't believe in overfiltering and destroying the original sources.
  3.  
  4. function daa3slow(clip c) {
  5. dbl = merge(c.nnedi3(etype=1, field = 1, nns = 4, qual=2, nsize = 3,fapprox = 7,pscrn=1),c.nnedi3(etype=1, field = 0, nns = 4, qual=2, nsize = 3,fapprox = 7,pscrn=1))
  6. dblD = mt_makediff(c,dbl,U=3,V=3)
  7. shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
  8. DD = shrpD.repair(dblD,13)
  9. return dbl.mt_adddiff(DD,U=3,V=3) }
  10.  
  11. #or use this faster version if daa3slow is too fast for you:
  12. function daa3(clip c) {
  13. dbl = merge(c.nnedi3(etype=1, field = 1, nns = 2,nsize = 3,fapprox = 7,pscrn=1),c.nnedi3(etype=1, field = 0, nns = 2, nsize = 3,fapprox = 7,pscrn=1))
  14. dblD = mt_makediff(c,dbl,U=3,V=3)
  15. shrpD = mt_makediff(dbl,dbl.removegrain(11),U=3,V=3)
  16. DD = shrpD.repair(dblD,13)
  17. return dbl.mt_adddiff(DD,U=3,V=3) }
  18.  
  19.  
  20.  
  21. # Here comes your video source line (your video must still be interlaced - it gets IVTCed/decimated as a first step, below)
  22.  
  23.  
  24.  
  25.  
  26. # inverse telecine + decimation, to get to 24 fps.
  27. # if your source is not DVD footage via dgindex/dgdecode, you probably need to uncomment
  28. # the following line to make TFM() work.
  29.  
  30. #assumetff()
  31.  
  32. tfm(slow=2,pp=1,mode=2).tdecimate()
  33. assumefps(24000,1001)
  34.  
  35.  
  36.  
  37. # Here comes a hack against dot crawl - it doesn't remove it 100%ly, but is rather detail safe.
  38. # It however needs that the file "noisepattern.avi" must be present in the location specified below.
  39. # That video contains a sample of dot-crawl noise to serve as a 'training' for fft3dfilter.
  40. # it is a sample video from a lousy ADV DVD... ask and ye shall be given, I guess?
  41. # try htttp://ulozto.net/x493J9tg/noisepattern-avi
  42.  
  43. # also, your video needs to be 720x480 here - crop at the end of the script instead
  44.  
  45. src = last
  46.  
  47.  
  48. # change the path of the noisepattern.avi file to wherever you put it
  49. avisource("c:\pattern\noisepattern.avi") + last
  50.  
  51. unf = last
  52. fft3dfilter(sigma= 1.7500, plane=0,bw=8,bh=8)
  53. den = last
  54. denoisediff = mt_makediff(unf,den,U=3,V=3)
  55. fft3dfilter(sigma= 0.01, pframe = 0, px = 34,py = 18, plane=0,pfactor =0.7,pcutoff=0.01,pshow=false,bw=8,bh=8)
  56. mt_adddiff(denoisediff,U=3,V=3)
  57. trim(1,0)
  58.  
  59.  
  60. # Now we will derainbow. Again, rather detail safe, but some limited discoloration can happen.
  61. # Current derainbowing methods available are sadly far form perfect.
  62.  
  63. prerb = last
  64. derbmask = removegrainhd(rank=23,radius=6).tedgemask(threshY=8).mt_inflate()
  65.  
  66. prefiltered = last
  67. derbsuperfilt = MSuper(prefiltered)
  68. derbsuper = derbsuperfilt
  69. derbbackward_vectors = MAnalyse(derbsuperfilt, truemotion = true, isb = true, chroma=false)
  70. derbforward_vectors = MAnalyse(derbsuperfilt, truemotion = true, isb = false, chroma=false)
  71. derbforward_compensation = MCompensate(derbsuper, derbforward_vectors)
  72. derbbackward_compensation = MCompensate(derbsuper, derbbackward_vectors)
  73. interleave(derbforward_compensation,last,derbbackward_compensation)
  74. dfmderainbow(maskthresh=10)
  75. selectevery(3,1)
  76. mt_merge(prerb,last, derbmask,luma=true)
  77.  
  78.  
  79. # now antialising (your video should still be 720x480 here - or at least should have height divisible by 4)
  80. # this line covers up nasty aliasing and interlacing artifacts (combing) that are left from field blends.
  81. # It nicely smooths those nasties and is still quite nice to detail.
  82. # The daa3slow() function is defined at the start of this script.
  83.  
  84. spline36resize(width,height*3/2).daa3slow.spline36resize(width,height)
  85.  
  86. #now we will stabilise lines/edges, it also helps against some dot crawl and shimmering. It should be detail-safe, though not 100%.
  87.  
  88. source = last
  89.  
  90. prefilt = last.removegrain(6).FFT3Dfilter(sigma=1.5,bw=16,bh=16,bt=3,ow=8,oh=8,plane=4)
  91. superfilt = prefilt.MSuper(pel=2, sharp=1)
  92. super = MSuper(pel=2, sharp=1)
  93. backward_vec2 = MAnalyse(superfilt, isb = true, delta = 2, overlap=4)
  94. backward_vec1 = MAnalyse(superfilt, isb = true, delta = 1, overlap=4)
  95. forward_vec1 = MAnalyse(superfilt, isb = false, delta = 1, overlap=4)
  96. forward_vec2 = MAnalyse(superfilt, isb = false, delta = 2, overlap=4)
  97.  
  98.  
  99. degrainedge = source.MDegrain2(super, backward_vec1,forward_vec1,backward_vec2,forward_vec2,thSAD=230)
  100. edgemask = removegrainhd(rank=25,radius=6).tedgemask(threshY=8)
  101.  
  102. mt_merge(source,degrainedge,edgemask,luma=true)
  103.  
  104. #You can crop now. Also, add denoising filters now if desired. /Please be gentle ;)/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement