Guest User

Untitled

a guest
Oct 29th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ######
  2. ##
  3. ## HQDering v0.2 by mf, modified by lachs0r
  4. ##
  5. ## Applies derining by using a smart smoother near edges (where ringing occurs) only.
  6. ##
  7. ## Usage: Import("HQDering-v0.2.avs")
  8. ##        HQDering()
  9. ##
  10. ####
  11.  
  12. function HQDering(clip input, int "strength", int "overall", string "smoother", string "params") {
  13.  
  14.  strength = Default(strength, 255)  # strength, 0-255
  15.  overall  = Default(overall, 0)     # overall smoothing, 0-255
  16.  smoother = Default(smoother, "Deen")   # filter that smooths
  17. #params   = default defined below   # filter parameters - use Chr(34) for quotes
  18.  
  19. defaultnull = Default(params, "")
  20. defaultdeen = Default(params, Chr(34)+"a3d"+Chr(34)+", 2, 12, 15, 20")
  21.  
  22. params = (smoother=="Deen") ? defaultdeen : defaultnull
  23.  
  24. try {
  25. smoothedwparams = Eval(smoother + "(input, " + params + ")")
  26. }
  27. catch(err_msg) {
  28. smoothedwoparams = Eval(smoother + "(input)")
  29. }
  30.  
  31. smoothed = (params=="") ? smoothedwoparams : smoothedwparams
  32.  
  33. input.EdgeMask(0, 255, 255, 255, "line", Y=3, V=1, U=1)
  34. normalmask = last
  35.  
  36. normalmask.Levels(0, 3.3, 90, 0, 255).Blur(1.0)
  37. amplifiedmask = last.Levels(0, 3.3, 90, 0, 255).deflate.deflate
  38.  
  39. normalmask.inflate.inflate.inflate.Levels(0, 3.3, 90, 0, 255).Blur(1.0).inflate.inflate.inflate.Levels(0, 3.3, 255, 0, 255).inflate.inflate.mt_expand
  40. thickmask = last
  41.  
  42. overlay(amplifiedmask.invert, thickmask, mode="multiply")
  43.  
  44. Levels(60, 3.0, 140, overall, strength)
  45.  
  46. # maskedmerge causes aliasing, so supersample
  47. # spline36 causes slight ringing, so don’t do that
  48. ringingmask = last.spline16resize(last.width*5,last.height*5)
  49. input = input.spline16resize(last.width*5,last.height*5)
  50. smoothed = smoothed.spline16resize(last.width*5,last.height*5)
  51.  
  52. MaskedMerge(input, smoothed, ringingmask)
  53.  
  54. spline16resize(input.width/5,input.height/5)
  55.  
  56. }
Add Comment
Please, Sign In to add comment