Advertisement
Zastin

ResFinder mod (AVS)

May 7th, 2017
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. ### Kernel [int]
  2. ### ------------------
  3. ### 1 = Bilinear (Default)
  4. ### 2 = Bicubic
  5. ### - MitchellNetravali (b=0.3333 c=0.3333) (default)
  6. ### - CatmullRom (b=0 c=0.5 ) (kernel=3 still uses CatRom like the original did)
  7. ###
  8. ### Mode [int]
  9. ### ------------------
  10. ### 1 = Stack (Default)
  11. ### 2 = Plus Only
  12. ### 3 = Minus Only
  13. ###
  14. ### PARNum [float]
  15. ### PARDen [float]
  16. ###
  17. ### b [float]
  18. ### c [float]
  19. ###
  20. ### ------------------
  21. ### per .ts 1440x1080 si usa un PAR = 4/3, quindi PARNum = 4 e PARDen = 3
  22.  
  23. function ResFinder(clip clp, int "Res", int "Kernel", int "Mode", float "PARNum", float "PARDen", float "b", float "c")
  24. {
  25. Res = Default(Res, 720)
  26. PARNum = Default(PARNum, 16)
  27. PARDen = Default(PARDen, 9)
  28. Kernel = default(Kernel, 1)
  29. Mode = default(Mode, 1)
  30. b = default(b, 1.0/3)
  31. c = default(c, 1.0/3)
  32.  
  33. Assert (Res%2 == 0, "Res must be Mod2")
  34. Assert (!(Kernel > 3 || Kernel < 1), "Kernel must be 1, 2 or 3.")
  35. Assert (!(Mode > 3 || Mode < 1), "Mode must be 1, 2 or 3.")
  36.  
  37. ResWidth = Round((Res*clp.Width()/clp.Height())*PARNum/PARDen)
  38. ResWidth = (ResWidth > clp.Width()) && (Res < clp.Height()) ? clp.Width() : ResWidth
  39.  
  40. return ResWidth%2 == 0 ? clp.GenerateClip(Res, ResWidth, Kernel,b,c).GenerateReport(Res, ResWidth, 1) : clp.Mod2Function(Res, ResWidth , Mode, Kernel,b,c)
  41.  
  42. function Mod2Function(clip clp, int Res, int ResWidth, int Mode, int Kernel, float b, float c){
  43. ResRemaining = ResWidth%2
  44. return Mode == 1 ? StackVertical(clp.GenerateClip(Res, ResWidth + ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth + ResRemaining, 2), clp.GenerateClip(Res, ResWidth - ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth - ResRemaining, 3)) :
  45. \ Mode == 2 ? clp.GenerateClip(Res, ResWidth + ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth + ResRemaining, 2) :
  46. \ clp.GenerateClip(Res, ResWidth - ResRemaining, Kernel,b,c).GenerateReport(Res, ResWidth - ResRemaining, 3)
  47. }
  48.  
  49. function GenerateClip(clip clp, int Res, int ResWidth, int Kernel, float b, float c)
  50. {
  51. return Kernel == 1 ? mt_makediff(clp, clp.debilinear(ResWidth,Res).BilinearResize(clp.Width(),clp.Height()),u=1,v=1) :
  52. \ Kernel == 3 ? mt_makediff(clp, clp.debicubic(ResWidth,Res, b=0, c=0.5).BicubicResize(clp.Width(),clp.Height(), b=0, c=0.5),u=1,v=1) :
  53. \ mt_makediff(clp, clp.debicubic(ResWidth,Res, b=b, c=c).BicubicResize(clp.Width(),clp.Height(), b=b, c=c),u=1,v=1)
  54. }
  55.  
  56. function GenerateReport(clip clp, int Res, int ResWidth, int Mode)
  57. {
  58. turnback = 1
  59. clp.Removegrain(1,-1).mt_lut("x 128 - 0 > x " + string(turnback) + " - 128 > x " + string(turnback) + " - 128 ? x " + string(turnback) + " + 128 < x " + string(turnback) + " + 128 ? ?",u=1,v=1).Histogram("luma").Greyscale()
  60. Mode == 1 ? WriteFile(".\output.txt",""" "=;" """ , string(Res), """ ";" """, "AverageLuma()") :
  61. \ Mode == 2 ? WriteFile(".\output.txt",""" "+;" """ , string(Res), """ ";" """, "AverageLuma()") :
  62. \ WriteFile(".\output.txt",""" "-;" """ , string(Res), """ ";" """, "AverageLuma()")
  63. ScriptClip(" Subtitle( String(AverageLuma())) ")
  64. Mode == 2 ? Subtitle("Plus", align=8) :
  65. \ Mode == 3 ? Subtitle("Minus", align=8) : last
  66. return Subtitle(String(ResWidth), align=9)
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement