gists/speedrun_comparison/spddiff.avs
2018-10-11 16:45:35 +02:00

172 lines
5.7 KiB
Plaintext

global fontsize = 26
function DiffClip(clip c, int diff)
{ BlankClip(c, diff).Subtitle(String(-diff), align=5, size=c.Height / 8) }
function PadWithDiff(clip c, int len)
{ c.FrameCount < len ? c + DiffClip(c, len - c.FrameCount) : c }
function DualMonoToStereo(clip left, clip right)
{ MergeChannels(ConvertToMono(left), ConvertToMono(right)) }
function MergeHoriz(clip left, clip right, int audio_index)
{
v = Overlay(AddBorders(left, 0, 0, right.Width, 0), right, left.Width, 0)
return audio_index == 0 \
? AudioDub(v, DualMonoToStereo(left, right)) \
: audio_index == 1 ? AudioDub(v, left) \
: audio_index == 2 ? AudioDub(v, right) \
: v
}
function MergeVert(clip top, clip bottom, int audio_index)
{
v = Overlay(AddBorders(top, 0, 0, 0, bottom.Height), bottom, 0, top.Height)
return audio_index == 0 \
? AudioDub(v, DualMonoToStereo(top, bottom)) \
: audio_index == 1 ? AudioDub(v, top) \
: audio_index == 2 ? AudioDub(v, bottom) \
: v
}
function Cmp(clip left, clip right)
{
frames = max(left.FrameCount, right.FrameCount)
left = PadWithDiff(left, frames)
right = PadWithDiff(right, frames)
return MergeHoriz(left, right, 0)
}
function TextHoriz(clip c, int frames, string left, string right)
{
size = fontsize
tleft = BlankClip(c, frames, height=size).Subtitle(left, align=2, size=size)
tright = BlankClip(c, frames, height=size).Subtitle(right, align=2, size=size)
MergeHoriz(tleft, tright, -1)
AddBorders(0, 2, 0, 2)
}
function MakeFrameNumberClip(clip c, int frames)
{
width = fontsize * 5 / 2 + 1
halved = (c.Width - width) / 2
ShowFrameNumber(BlankClip(c, frames, width=width, height=fontsize + 1), size=fontsize)
Crop(0, 5, -0, -0)
AddBorders(halved, 0, halved, 4)
AddBorders(0, 2, 0, 2)
}
function AdjustClip(clip c, int offset)
{
# set up your padding and resizing here
PointResize(c, c.Width * 2, c.Height * 2)
AddBorders(64 + offset, 0, 64 - offset, 0)
MergeVert(MakeFrameNumberClip(last.FrameCount), last, 2)
AddBorders(0, 16 - 2, 0, 16)
}
# http://tasvideos.org/485M.html
global old_name = "phil"
global old_date = "2006-02-25"
global old_frames = 32248
global old_time = "08:57.47"
global old_comment = "http://tasvideos.org/985S.html"
AviSource("phil5-ddragon-again.avi")+\
AviSource("phil5-ddragon-again_part2.avi")+\
AviSource("phil5-ddragon-again_part3.avi")
Trim(0, old_frames + 1636)
#ShowFrameNumber(scroll=true)
AdjustClip(0)#-48)
global old = last
# http://tasvideos.org/3211M.html
global new_name = "alyosha"
global new_date = "2016-08-28"
global new_frames = 31869
global new_time = "08:50.28"
global new_comment = "http://tasvideos.org/5207S.html"
AviSource("alyosha-doubledragon-again.avi")+\
AviSource("alyosha-doubledragon-again_part2.avi")+\
AviSource("alyosha-doubledragon-again_part3.avi")
Trim(0, new_frames + 1636)
#ShowFrameNumber(scroll=true)
AdjustClip(0)#48)
global new = last
# compare by slice
function x(int oldStart, int oldEnd, int newStart, int newEnd, string title)
{
left = Trim(old, oldStart, oldEnd)
right = Trim(new, newStart, newEnd)
frames = max(left.FrameCount, right.FrameCount)
fc = MakeFrameNumberClip(left, frames)
TextHoriz(left, frames, old_name + " (" + old_date + ")", new_name + " (" + new_date + ")")
MergeVert(last, TextHoriz(left, frames, String(old_frames) + " frames (" + old_time + ")", string(new_frames) + " frames (" + new_time + ")"), -1)
MergeVert(last, TextHoriz(left, frames, old_comment, new_comment), -1)
MergeVert(last, Cmp(left, right), 2)
MergeVert(last, TextHoriz(left, frames, title, title), 1)
MergeVert(last, TextHoriz(left, frames, "in " + String(left.FrameCount) + " frames", "in " + String(Right.FrameCount) + " frames"), 1)
MergeVert(last, MergeHoriz(fc, fc, -1), 1)
}
# compare by split (start is last split)
global prevOldSplit = 0
global prevNewSplit = 0
function s(int oldSplit, int newSplit, string title)
{
ot = prevOldSplit
nt = prevNewSplit
global prevOldSplit = oldSplit + 1
global prevNewSplit = newSplit + 1
return x(ot, oldSplit, nt, newSplit, title)
}
# TODO: frames gained/lost in corner per file
s( 1557, 1547, "first screen scroll")+\
s( 1869, 1862, "first door opening")+\
s( 2123, 2143, "second screen scroll")+\
s( 3041, 3067, "third screen scroll")+\
s( 3973, 4017, "door entered")+\
s( 4729, 4817, "mission completed")+\
s( 5943, 6059, "first screen scroll")+\
s( 6489, 6601, "background visible again")+\
s( 7118, 7229, "second screen scroll")+\
s( 7604, 7713, "top of first ladder")+\
s( 7988, 8094, "top of second ladder")+\
s( 8316, 8416, "top of third ladder")+\
s( 8649, 8749, "first door opening")+\
s( 9291, 9393, "mission completed")+\
s(10515,10611, "first screen scroll")+\
s(11695,11747, "second screen scroll")+\
s(12514,12581, "third screen scroll")+\
s(13412,13543, "fourth screen scroll")+\
s(14588,14773, "door entered")+\
s(15369,15548, "platformer begin")+\
s(15764,15933, "platformer finished")+\
s(16087,16256, "first door opening")+\
s(16941,17111, "door entered")+\
s(17008,17179, "loaded")+\
s(17794,17984, "first screen scroll")+\
s(18793,18983, "black screen")+\
s(19398,19608, "boss defeated")+\
s(20776,20994, "mission completed")+\
s(22572,22804, "first screen scroll")+\
s(23183,23400, "climbed wall")+\
s(24076,24398, "black screen")+\
s(24326,24642, "top of first ladder")+\
s(24788,25108, "top of second ladder")+\
s(25606,25917, "top of third ladder")+\
s(26147,26446, "top of fourth ladder")+\
s(26283,26642, "black screen")+\
s(27623,27788, "first screen scroll")+\
s(27951,28118, "first door opening")+\
s(28800,28585, "second door opening")+\
s(29492,29152, "third door opening")+\
s(29660,29320, "fourth door opening")+\
s(29944,29545, "fifth door opening")+\
s(30683,30290, "sixth door opening")+\
s(old_frames,new_frames, "end of input")+\
s( 0, 0, "end of game")
AddBorders(0, 16, 0, 16)