Formerly davidh*****
Join Date: Jan 2004
Posts: 2,496
|
Okay, here's the beta plugin: pixel_rpn. It is x86 only!
And you'll also need xyremap (this is the fast beta version, the old version may be okay)
And here is the very long script:
Code:
dgsource("vis.dgi") # ffmpeg source will hopefully work
rgb=converttorgb24
################################################################################
################################################################################
## first call to pixel_rpn: fix shifts and broken frames
################################################################################
################################################################################
rgb=rgb.pixel_rpn("
$rgb:
################################################################################
# first replace broken frames with blends of their good neighbours
################################################################################
n 505 == ?: [c0(-1,6,0)] 0.75 * [c0(3,6,0)] 0.25 * + :
n 506 == ?: [c0(-2,6,0)] 0.5 * [c0(2,6,0)] 0.5 * + :
n 507 == ?: [c0(-3,6,0)] 0.25 * [c0(1,6,0)] 0.75 * + :
n 1015 == ?: [c0(-1,9,0)] 0.89 * [c0(8,9,0)] 0.11 * + :
n 1016 == ?: [c0(-2,9,0)] 0.78 * [c0(7,9,0)] 0.22 * + :
n 1017 == ?: [c0(-3,9,0)] 0.67 * [c0(6,9,0)] 0.33 * + :
n 1018 == ?: [c0(-4,9,0)] 0.56 * [c0(5,9,0)] 0.44 * + :
n 1019 == ?: [c0(-5,9,0)] 0.44 * [c0(4,9,0)] 0.56 * + :
n 1020 == ?: [c0(-6,9,0)] 0.33 * [c0(3,9,0)] 0.67 * + :
n 1021 == ?: [c0(-7,9,0)] 0.22 * [c0(2,9,0)] 0.78 * + :
n 1022 == ?: [c0(-8,9,0)] 0.11 * [c0(1,9,0)] 0.89 * + :
n 1422 == ?: [c0(-1,9,0)] 0.67 * [c0(2,9,0)] 0.33 * + :
n 1423 == ?: [c0(-2,9,0)] 0.33 * [c0(1,9,0)] 0.67 * + :
################################################################################
# fix horizontal shifts in clip
################################################################################
n 230 <= ?: [c0] :
n 252 <= ?: [c0(5,0)] :
n 360 <= ?: [c0(-2,0)] :
n 390 <= ?: [c0(6,0)] :
n 416 <= ?: [c0(-2,0)] :
n 729 <= ?: [c0(6,0)] :
[c0(9,0)]
################################################################################
# the statements above are nested if...then...else structures.
# this next operation endifs them in one go:
################################################################################
. repeat
")
################################################################################
################################################################################
## second call to pixel_rpn: generate mask and also mask some parts manually
################################################################################
################################################################################
masked=rgb.pixel_rpn("
$rgb:
[c0] # just copy the RGB channels as is
$a:
################################################################################
# what follows are a bunch of conditions which calculate areas to mask
################################################################################
# bottom line
n 1016 <= ?:
590
590 n 550 - 0.4 * +
590 n 1000 - 0.1 * -
590 n 690 - 0.5 * +
720 n 770 - 0.9 * -
min max min max
:
515 n 1813 - 0 max 5 * +
650 min
.
y <=
# top line
150 n 73 - 0 max - 45 max
n 1424 >= ?: 18 + .
n 1756 >= ?: 10 + .
y >
# right
1075
n 291 >= ?: 15 + .
n 305 >= ?: 15 + .
n 320 >= ?: 20 + .
n 354 >= ?: 20 + .
n 421 >= ?: 15 + .
n 649 >= ?: 15 - .
n 675 >= ?: 20 - .
n 708 >= ?: 30 - .
n 775 >= ?: 50 - .
x <
# left
95
n 1430 >= ?: 80 + .
x >
# corner
x 1100 >
y 100 <
*
# corners
n 430 >=
n 506 <
x y 1.5 * - -390 <
* *
x y - -300 <
# another corner
n 908 >=
n 933 <
x 960 >
y 460 >
* * *
# foot bit
n 1755 ==
x y - 567 <
x 640 >
*
y 100 <
+ *
n 1753 ==
y 100 <
*
# post-it
n 759 >=
y 600 >
n 773 <
* *
# more bits
n 1424 >=
y 155 x 0.25 * - <
*
n 1511 >=
y 80 <
*
n 1558 >=
n 1567 <
y x 1.25 * + 734 >
y x 0.66 * - -310 >
y x 1.25 * + 1485 >
+ * * *
n 1847 >=
x 500 >
y 465 >
x 915 <
* * *
n 1865 >=
x 500 >
*
n 1866 >=
x 300 >
*
################################################################################
# all the above conditions are added (acts as a logical or)
################################################################################
+ repeat
?:
0 # if true (non-zero), output 0
:
[b0] [g0] [r0] min < # if not mostly blue...
# [g0] 2 * [r0] > * # or mostly red... (uncomment this to remove red tissue)
?:
1 # then solid
:
0 # else clear
.
.
")
################################################################################
# the following call generates a clip with an overlaid mask for debugging
################################################################################
debug=masked.pixel_rpn("
$g: [a0] 255 *
$rb: [c0]
")
#return debug
################################################################################
# applies a 5x5 gaussian blur to the mask, and premultiplies RGB by alpha
################################################################################
masked=pixel_rpn(masked,"
$a:
[a0(-2,-2)] [a0(-1,-2)] dup + dup + [a0(0,-2)] dup + dup + [a0(1,-2)] dup + dup + [a0(2,-2)] + + + +
[a0(-2,-1)] [a0(-1,-1)] dup + dup + [a0(0,-1)] dup dup + + dup + [a0(1,-1)] dup + dup + [a0(2,-1)] + + + + dup + dup +
[a0(-2, 0)] [a0(-1, 0)] dup + dup + [a0(0, 0)] dup dup + + dup + [a0(1, 0)] dup + dup + [a0(2, 0)] + + + + dup dup + + dup +
[a0(-2, 1)] [a0(-1, 1)] dup + dup + [a0(0, 1)] dup dup + + dup + [a0(1, 1)] dup + dup + [a0(2, 1)] + + + + dup + dup +
[a0(-2, 2)] [a0(-1, 2)] dup + dup + [a0(0, 2)] dup + dup + [a0(1, 2)] dup + dup + [a0(2, 2)] + + + +
+ repeat
dup 0.00390625 * @A^ # store normalised alpha for premultiplication
$rgb:
[c0] A * # premultiply by alpha (this only works because pixel_rpn calculates in the order ABGR, allowing us to set A and use it here)
")
################################################################################
# increase to full HD resolution and remap to a moving isometric projection
################################################################################
isometric=masked.addborders(320,180,320,180).xyremap( \
x=" x 1080 - t 1500 * + 2 t 0.0 * - * 0.666666 * ", \
y="h y 1150 + t 1500 * - 2 t 0.0 * - * x - 0.666666 * -" \
).trim(1,0) # trim first frame, which is a dupe
################################################################################
# render as a stack, using pixel_rpn's [<.c] trick to copy the previous frame
################################################################################
stack=isometric.pixel_rpn("
$settings:
frames:2000 # pad out to 2000 frames
offset:25 # add 25 frames to the start
$rgb:
[c0] [a0] 0.0039215686274509803921568627451 * 0.5 * @A *
# the '0.5 *' in the line above renders at half opacity for a nicer result - try 0.1 and 0.01 for different transparencies
[<.c] 1 A - * +
")
################################################################################
# because we rendered the stack with half opacity slices,
# re-overlay full opacity slices for better animation.
# if you remove the "0.5 *" above, you can skip this call
################################################################################
pixel_rpn(stack,isometric,"
$rgb:
[a1(-25)] 0.0039215686274509803921568627451 * @A [c1(-25)] * # the (-25) offsets the offset added above, putting stack and isometric back in sync
1 A - [c0] *
+
")
converttoyv12 # convert to yv12 for encoding
assumefps(60)
I've annotated it as best I can, but I know it's not very readable. Any questions, let me know.
Last edited by wonkey_monkey; 7th January 2017 at 16:27.
|