Advertisement
Guest User

Untitled

a guest
Apr 24th, 2010
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.22 KB | None | 0 0
  1. # BCSInterlacedResize_mod Ver. 1.1
  2.  
  3. function BCSInterlacedResize_mod(clip clip, float "dest_height", float "crop", float "shift", float "blur", int "mode", string "preset", bool "edge", bool "info")
  4. {
  5. org_height = clip.Height()
  6. dest_height = Float(default(dest_height, PresetBCS("dest_height", preset)))
  7. crop = default(crop, PresetBCS("crop", preset, dest_height))
  8. shift = default(shift, PresetBCS("shift", preset, dest_height, org_height))
  9. blur = default(blur, PresetBCS("blur", preset, dest_height, org_height, mode))
  10. mode = default(mode, 1)
  11.  
  12. half_target_height = Ceil(dest_height / 4.0) * 2
  13. adjust = (half_target_height - dest_height / 2.0) * org_height / dest_height
  14. org_height = org_height / 2.0
  15.  
  16. clip = clip.SeparateFields() # correctly Assume[TB]FF() before calling this function!!
  17.  
  18. Tf = clip.SelectEven()
  19. Tf = (blur != 0) ? Tf.Blur(0, blur, false) : Tf
  20. Tf = (mode < 2) ? Tf.BlackmanResize(clip.Width(), half_target_height, 0, crop - shift, 0, org_height + adjust, 1)
  21. \ : Tf.LanczosResize( clip.Width(), half_target_height, 0, crop - shift, 0, org_height + adjust, 1)
  22. Bf = clip.SelectOdd()
  23. Bf = (blur != 0) ? Bf.Blur(0, blur, false) : Bf
  24. Bf = (mode < 2) ? Bf.BlackmanResize(clip.Width(), half_target_height, 0, crop + shift, 0, org_height + adjust, 1)
  25. \ : Bf.LanczosResize( clip.Width(), half_target_height, 0, crop + shift, 0, org_height + adjust, 1)
  26.  
  27. clip = Interleave(Tf, Bf).Weave()
  28.  
  29. default(edge, false) ? Eval("
  30. top = (shift - crop) * dest_height / org_height
  31. top = (top < 0) ? 0 : clip.IsYV12() ? Int(top / 2) * 2 : Int(top)
  32. bottom = (adjust + crop + shift) * dest_height / org_height
  33. bottom = (bottom < 0) ? 0 : clip.IsYV12() ? Int(bottom / 2) * 2 : Int(bottom)
  34. clip = clip.LetterBox(top, bottom)
  35. ") : NOP
  36.  
  37. clip = default(info, false) ? clip.subtitle("preset = " + UCase(default(preset, "N/A")) + "\ndest_height = " + string(dest_height)
  38. \ + "\ncrop = " + string(crop) + "\nshift = "+string(shift) + "\nblur = " + string(blur), x = 16, y = 16, lsp = 0) : clip
  39.  
  40. return clip
  41. }
  42.  
  43. function ResizeBCS(clip clip, int target_width, int target_height, float "src_left", float "src_top", float "src_width", float "src_height",
  44. \ float "dest_height", float "crop", int "org_height", bool "scale", string "preset", bool "edge", string "resizer", bool "interlaced", string "bobber")
  45. {
  46. src_left = default(src_left, 0)
  47. src_top = default(src_top, 0)
  48. src_width = default(src_width, 0)
  49. src_height = default(src_height, 0)
  50.  
  51. dest_height = Float(default(dest_height, PresetBCS("dest_height", preset)))
  52. crop = default(crop, PresetBCS("crop", preset, dest_height))
  53. org_height = default(org_height, 1080)
  54.  
  55. resizer = default(resizer, "Spline36Resize")
  56. interlaced = default(interlaced, false)
  57. bobber = default(bobber, "Bob(b=0, c=0.5)")
  58.  
  59. default(scale, false) ? Eval("
  60. src_top = src_top * dest_height / org_height
  61. src_height = src_height * dest_height / org_height
  62. ") : NOP
  63.  
  64. adj_top = crop * dest_height * 2.0 / org_height
  65. src_height = (src_height <= 0) ? dest_height - src_top + src_height : src_height
  66. parity = clip.GetParity()
  67.  
  68. clip = interlaced ? Eval("clip." + bobber) : clip
  69. clip = Eval("clip." + resizer + "(target_width, target_height, src_left, src_top - adj_top, src_width, src_height)")
  70. clip = parity ? clip.AssumeTFF() : clip.AssumeBFF()
  71. clip = interlaced ? clip.SeparateFields().SelectEvery(4, 0, 3).Weave() : clip
  72.  
  73. default(edge, false) ? Eval("
  74. top = (adj_top - src_top) * target_height / src_height
  75. top = (top < 0) ? 0 : clip.IsYV12() ? Int(top / 2) * 2 : Int(top)
  76. bottom = (src_height - dest_height + src_top - adj_top) * target_height / src_height
  77. bottom = (bottom < 0) ? 0 : clip.IsYV12() ? Int(bottom / 2) * 2 : Int(bottom)
  78. clip = clip.LetterBox(top, bottom)
  79. ") : NOP
  80.  
  81. return clip
  82. }
  83.  
  84. function PresetBCS(string variable, string "preset", float "dest_height", int "org_height", int "mode")
  85. {
  86. variable = LCase(variable)
  87. preset = UCase(default(preset, ""))
  88. org_height = default(org_height, 1080)
  89. mode = default(mode, 1)
  90.  
  91. dest_height = (preset == "GONZO" || preset == "SPICE" || preset == "WOLF") ? 720
  92. \ : (preset == "487") ? 487 : default(dest_height, 486)
  93.  
  94. crop = (preset == "486R" ) ? -0.25
  95. \ : (preset == "SPICE") ? -0.20
  96. \ : (preset == "WOLF" ) ? 0.20
  97. \ : (preset == "ORIGINAL" && dest_height != 486 && dest_height != 720) ? 0
  98. \ : (dest_height == 486) ? 0.75 : (dest_height == 487) ? -0.42 : (dest_height == 720) ? -0.07 : 0
  99.  
  100. shift = (preset == "486A" ) ? 0.32
  101. \ : (preset == "GONZO") ? 0.12
  102. \ : (preset == "SPICE" || preset == "WOLF") ? 0.0
  103. \ : (preset == "ORIGINAL") ? (dest_height == 486) ? 0.32 : (dest_height == 720) ? 0.12 : 0
  104. \ : (org_height - dest_height) / (dest_height * 4.0)
  105.  
  106. blur = (preset == "WOLF") ? -0.50
  107. \ : (preset == "ORIGINAL" && dest_height != 486 && dest_height != 720) ? 0
  108. \ : (org_height * -18.0 + ((mode < 2) ? dest_height * 14.0 : dest_height)) / (dest_height * 52.0)
  109.  
  110. return (variable == "dest_height") ? dest_height
  111. \ : (variable == "crop" ) ? crop
  112. \ : (variable == "shift") ? shift
  113. \ : (variable == "blur" ) ? blur
  114. \ : 0
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement