Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # BCSInterlacedResize_mod Ver. 1.1
- function BCSInterlacedResize_mod(clip clip, float "dest_height", float "crop", float "shift", float "blur", int "mode", string "preset", bool "edge", bool "info")
- {
- org_height = clip.Height()
- dest_height = Float(default(dest_height, PresetBCS("dest_height", preset)))
- crop = default(crop, PresetBCS("crop", preset, dest_height))
- shift = default(shift, PresetBCS("shift", preset, dest_height, org_height))
- blur = default(blur, PresetBCS("blur", preset, dest_height, org_height, mode))
- mode = default(mode, 1)
- half_target_height = Ceil(dest_height / 4.0) * 2
- adjust = (half_target_height - dest_height / 2.0) * org_height / dest_height
- org_height = org_height / 2.0
- clip = clip.SeparateFields() # correctly Assume[TB]FF() before calling this function!!
- Tf = clip.SelectEven()
- Tf = (blur != 0) ? Tf.Blur(0, blur, false) : Tf
- Tf = (mode < 2) ? Tf.BlackmanResize(clip.Width(), half_target_height, 0, crop - shift, 0, org_height + adjust, 1)
- \ : Tf.LanczosResize( clip.Width(), half_target_height, 0, crop - shift, 0, org_height + adjust, 1)
- Bf = clip.SelectOdd()
- Bf = (blur != 0) ? Bf.Blur(0, blur, false) : Bf
- Bf = (mode < 2) ? Bf.BlackmanResize(clip.Width(), half_target_height, 0, crop + shift, 0, org_height + adjust, 1)
- \ : Bf.LanczosResize( clip.Width(), half_target_height, 0, crop + shift, 0, org_height + adjust, 1)
- clip = Interleave(Tf, Bf).Weave()
- default(edge, false) ? Eval("
- top = (shift - crop) * dest_height / org_height
- top = (top < 0) ? 0 : clip.IsYV12() ? Int(top / 2) * 2 : Int(top)
- bottom = (adjust + crop + shift) * dest_height / org_height
- bottom = (bottom < 0) ? 0 : clip.IsYV12() ? Int(bottom / 2) * 2 : Int(bottom)
- clip = clip.LetterBox(top, bottom)
- ") : NOP
- clip = default(info, false) ? clip.subtitle("preset = " + UCase(default(preset, "N/A")) + "\ndest_height = " + string(dest_height)
- \ + "\ncrop = " + string(crop) + "\nshift = "+string(shift) + "\nblur = " + string(blur), x = 16, y = 16, lsp = 0) : clip
- return clip
- }
- function ResizeBCS(clip clip, int target_width, int target_height, float "src_left", float "src_top", float "src_width", float "src_height",
- \ float "dest_height", float "crop", int "org_height", bool "scale", string "preset", bool "edge", string "resizer", bool "interlaced", string "bobber")
- {
- src_left = default(src_left, 0)
- src_top = default(src_top, 0)
- src_width = default(src_width, 0)
- src_height = default(src_height, 0)
- dest_height = Float(default(dest_height, PresetBCS("dest_height", preset)))
- crop = default(crop, PresetBCS("crop", preset, dest_height))
- org_height = default(org_height, 1080)
- resizer = default(resizer, "Spline36Resize")
- interlaced = default(interlaced, false)
- bobber = default(bobber, "Bob(b=0, c=0.5)")
- default(scale, false) ? Eval("
- src_top = src_top * dest_height / org_height
- src_height = src_height * dest_height / org_height
- ") : NOP
- adj_top = crop * dest_height * 2.0 / org_height
- src_height = (src_height <= 0) ? dest_height - src_top + src_height : src_height
- parity = clip.GetParity()
- clip = interlaced ? Eval("clip." + bobber) : clip
- clip = Eval("clip." + resizer + "(target_width, target_height, src_left, src_top - adj_top, src_width, src_height)")
- clip = parity ? clip.AssumeTFF() : clip.AssumeBFF()
- clip = interlaced ? clip.SeparateFields().SelectEvery(4, 0, 3).Weave() : clip
- default(edge, false) ? Eval("
- top = (adj_top - src_top) * target_height / src_height
- top = (top < 0) ? 0 : clip.IsYV12() ? Int(top / 2) * 2 : Int(top)
- bottom = (src_height - dest_height + src_top - adj_top) * target_height / src_height
- bottom = (bottom < 0) ? 0 : clip.IsYV12() ? Int(bottom / 2) * 2 : Int(bottom)
- clip = clip.LetterBox(top, bottom)
- ") : NOP
- return clip
- }
- function PresetBCS(string variable, string "preset", float "dest_height", int "org_height", int "mode")
- {
- variable = LCase(variable)
- preset = UCase(default(preset, ""))
- org_height = default(org_height, 1080)
- mode = default(mode, 1)
- dest_height = (preset == "GONZO" || preset == "SPICE" || preset == "WOLF") ? 720
- \ : (preset == "487") ? 487 : default(dest_height, 486)
- crop = (preset == "486R" ) ? -0.25
- \ : (preset == "SPICE") ? -0.20
- \ : (preset == "WOLF" ) ? 0.20
- \ : (preset == "ORIGINAL" && dest_height != 486 && dest_height != 720) ? 0
- \ : (dest_height == 486) ? 0.75 : (dest_height == 487) ? -0.42 : (dest_height == 720) ? -0.07 : 0
- shift = (preset == "486A" ) ? 0.32
- \ : (preset == "GONZO") ? 0.12
- \ : (preset == "SPICE" || preset == "WOLF") ? 0.0
- \ : (preset == "ORIGINAL") ? (dest_height == 486) ? 0.32 : (dest_height == 720) ? 0.12 : 0
- \ : (org_height - dest_height) / (dest_height * 4.0)
- blur = (preset == "WOLF") ? -0.50
- \ : (preset == "ORIGINAL" && dest_height != 486 && dest_height != 720) ? 0
- \ : (org_height * -18.0 + ((mode < 2) ? dest_height * 14.0 : dest_height)) / (dest_height * 52.0)
- return (variable == "dest_height") ? dest_height
- \ : (variable == "crop" ) ? crop
- \ : (variable == "shift") ? shift
- \ : (variable == "blur" ) ? blur
- \ : 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement