Seedmanc

quality mvtools coding

Oct 14th, 2018
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  #  setmemorymax(2000)
  2. TEST_FRAMES = 20
  3. MIDDLE_FRAME = 600
  4.  
  5. # original framerate
  6. FPS_NUM = 30
  7. FPS_DEN = 1
  8.  
  9. # source clip
  10. Asrc=FFmpegSource2("f:\Hibikin - Watashtachi wa Zutto... Deshou (AVS test video 60fps 720p 10bit CRF0).mkv"  ).assumefps(60)
  11. Asrc=Asrc.trim(0,60*30-9)+Asrc.trim(60*40+60*60+9,0)
  12. asrc.selecteven
  13. AssumeFPS(FPS_NUM, FPS_DEN)
  14.  
  15. #return last
  16.  
  17. # needed for some parameter combinations
  18. #ConvertToYV24()
  19.  
  20. orig = last
  21.  
  22. mt=true #happens without this parameter as well since mt is true by default
  23.  
  24.  
  25. super_pel = 4                   # optimize super_pel = _n_ | 1,2,4 | super_pel
  26. super_sharp = 0                 # optimize super_sharp = _n_ | 0..2 ; max:super_pel 1 == 0 2 ? | super_sharp
  27. super_rfilter = 2               # optimize super_rfilter = _n_ | 0..4 | super_rfilter  
  28. super_render = MSuper(pel=super_pel, sharp=super_sharp, rfilter=super_rfilter, orig, mt=mt )   
  29.  
  30. blockSize = 8                   # optimize blockSize = _n_ | 4,6,8,12,16,24,32,48,64 ; min:divide 0 > 8 2 ? ; filter:overlap 2 * x <= | blockSize
  31. searchAlgo = 3                  # optimize searchAlgo = _n_ | 0..5 D | searchAlgo
  32. searchRange = 12                    # optimize searchRange = _n_ | 1..30 | searchRange
  33. searchRangeFinest = 19              # optimize searchRangeFinest = _n_ | 1..40 | searchRangeFinest
  34. lambda = 2336               # optimize lambda = _n_ | 0..20000 | lambda
  35. lsad=16770                  # optimize lsad=_n_ | 8..20000 | lsad
  36. pnew=113                        # optimize pnew=_n_ | 0..256 | pnew
  37. plevel=0                    # optimize plevel=_n_ | 0..2 | plevel
  38. overlap=4                   # optimize overlap=_n_ | 0,4,8,12,16,20,24,28,32 ; max:blockSize 2 / | overlap
  39. divide=2                    # optimize divide=_n_ | 0..2 ; max:blockSize 8 >= 2 0 ? overlap 4 % 0 == 2 0 ? min | divide
  40. globalMotion = true             # optimize globalMotion = _n_ | false,true | globalMotion
  41. badSAD = 4                  # optimize badSAD = _n_ | 4..10000 | badSAD
  42. badRange = 15               # optimize badRange = _n_ | 2..50 | badRange
  43. negBadRange = true              # optimize negBadRange = _n_ | false,true | negBadRange
  44. meander = false                 # optimize meander = _n_ | false,true | meander
  45. temporal = true             # optimize temporal = _n_ | false,true | temporal
  46. trymany = true                  # optimize trymany = _n_ | false,true | trymany
  47. dct = 9                     # optimize dct = _n_ | 0,2,3,4,5,6,7,8,9,10 D | dct
  48.  
  49. delta = 1
  50. useChroma = true
  51.  
  52. resultBadRange = (negBadRange ? -1 : 1)*badRange
  53. bv = MAnalyse(super_render, isb = true, blksize=blockSize, search=searchAlgo, searchparam=searchRange, pelsearch=searchRangeFinest,
  54. \ chroma=useChroma, delta=delta, lambda=lambda, lsad=lsad, pnew=pnew, plevel=plevel, global=globalMotion, overlap=overlap ,
  55. \ divide=divide, badSAD=badSAD, badrange=resultBadRange, meander=meander, temporal=temporal, trymany=trymany, dct=dct, mt=mt)
  56. fv = MAnalyse(super_render, isb = false, blksize=blockSize, search=searchAlgo, searchparam=searchRange, pelsearch=searchRangeFinest,
  57. \ chroma=useChroma, delta=delta, lambda=lambda, lsad=lsad, pnew=pnew, plevel=plevel, global=globalMotion, overlap=overlap ,
  58. \ divide=divide, badSAD=badSAD, badrange=resultBadRange, meander=meander, temporal=temporal, trymany=trymany, dct=dct, mt=mt)
  59.  
  60.  
  61.  
  62. threshold = 10000
  63. maskScale = 300                 # optimize maskScale = _n_ | 1..300 | maskScale
  64. mask_fps = 0                    # optimize mask_fps = _n_ | 0..2 | mask_fps
  65. inter = orig.MFlowFPS(super_render, bv, fv, num=FPS_NUM*2, den=FPS_DEN, mask=mask_fps, ml=maskScale, thSCD1=threshold )
  66.  
  67. # return this to look at the clip with doubled framerate
  68. #return inter
  69.  
  70. fps_only = inter.SelectOdd()
  71.  
  72. # second pass  
  73. super_render2 = MSuper(pel=super_pel, sharp=super_sharp, rfilter=super_rfilter, fps_only ) 
  74. bv2 = MAnalyse(super_render2, isb = true, blksize=blockSize, search=searchAlgo, searchparam=searchRange, pelsearch=searchRangeFinest,
  75. \ chroma=useChroma, delta=delta, lambda=lambda, lsad=lsad, pnew=pnew, plevel=plevel, global=globalMotion, overlap=overlap,
  76. \ divide=divide, badSAD=badSAD, badrange=resultBadRange, meander=meander, temporal=temporal, trymany=trymany, mt=mt)
  77. fv2 = MAnalyse(super_render2, isb = false, blksize=blockSize, search=searchAlgo, searchparam=searchRange, pelsearch=searchRangeFinest,
  78. \ chroma=useChroma, delta=delta, lambda=lambda, lsad=lsad, pnew=pnew, plevel=plevel, global=globalMotion, overlap=overlap,
  79. \ divide=divide, badSAD=badSAD, badrange=resultBadRange, meander=meander, temporal=temporal, trymany=trymany, mt=mt)
  80. inter2 = fps_only.MFlowFPS(super_render2, bv2, fv2, num=FPS_NUM*2, den=FPS_DEN, mask=mask_fps, ml=maskScale, thSCD1=threshold  )
  81. fps_only2 = inter2.SelectOdd()
  82.  
  83.  
  84. delimiter = "; "
  85.  
  86. inter_yv12 = fps_only2#.ConvertToYV12()
  87. orig_yv12 = orig#.ConvertToYV12()
  88.  
  89. # for comparison original must be forwarded one frame
  90. orig_yv12 = trim(orig_yv12,1,0)
  91.  
  92. inter_yv12 = inter_yv12.Trim(MIDDLE_FRAME - TEST_FRAMES/2 + (TEST_FRAMES%2==0?1:0), MIDDLE_FRAME + TEST_FRAMES/2)
  93. orig_yv12 = orig_yv12.Trim(MIDDLE_FRAME - TEST_FRAMES/2 + (TEST_FRAMES%2==0?1:0), MIDDLE_FRAME + TEST_FRAMES/2)
  94. last = inter_yv12
  95.  
  96. global total = 0.0
  97. global ssim_total = 0.0
  98. global avstimer = 0.0
  99. frame_count = FrameCount()
  100. FrameEvaluate(last, """
  101.     global ssim = SSIM_FRAME(orig_yv12, inter_yv12)
  102.     global ssim_total = ssim_total + (ssim == 1.0 ? 0.0 : ssim)
  103. """)#, args="orig_yv12, inter_yv12, delta, frame_count")   
  104.  
  105. # NOTE: AvsTimer call should be before the WriteFile call
  106. AvsTimer(frames=1, type=0, total=false, name="Optimizer")
  107.  
  108. # per frame logging (ssim, time)
  109. resultFile = "F:\avsoptim\work\result_1539505120402_1539510071778.txt"  # output out1="ssim: MAX(float)" out2="time: MIN(time) ms" file="F:\avsoptim\work\result_1539505120402_1539510071778.txt"
  110. WriteFile(resultFile, "current_frame", "delimiter", "ssim", "delimiter", "avstimer")
  111. WriteFileIf(resultFile, "current_frame == frame_count-1", """ "stop " """, "ssim_total", append=true)
  112.  
  113. return last
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×