Log in

View Full Version : Clip length halved after MCompensate?


zorr
2nd May 2018, 23:26
Greetings,

While trying some frame reconstruction ideas I stumbled upon a weird phenomena: seems like in some cases the clip length is divided by 2 after MCompensate (using MVTools2 pfmod v2.7.30).

Here's a script which demonstrates this:


AVISource("D:\optimizer\test\Motion Estimation Torture Clip part 3.avi")

orig = last
#return orig # 24 frames

super = MSuper()
#return super # 24 frames

fv = MAnalyse(super, isb = false, delta=2)
bv = MAnalyse(super, isb = true, delta=2)
inter = MFlowInter(super, bv, fv, time=50)

interleaved = Interleave(inter, orig)
#return interleaved # 48 frames

super2 = MSuper(interleaved)
#return super2 # 48 frames

fv2 = MAnalyse(super2, isb = false)
bv2 = MAnalyse(super2, isb = true)

showfv = MShow(super2, fv2)
#return showfv # 48 frames

showbv = MShow(super2, bv2)
#return showbv # 48 frames

f = MCompensate(super2, fv2)
#return f # 24 frames (WHY ?)

b = MCompensate(super2, bv2)
return b # 24 frames (WHY ?)



So first I have a clip with 24 frames. I create another version of it with MFlowInter and then Interleave that with the original, having a total of 48 frames. If I do another pass of MSuper, MAnalyze and MCompensate on that the result only has 24 frames. Both the super clip and the vectors clip given to MCompensate have 48 frames but the output has 24 frames.

So is this the way it's supposed to work or did I encounter a bug?
Thanks.

wonkey_monkey
3rd May 2018, 15:13
MCompensate's first parameter is the "implicit last" clip - like when you call MSuper() the first time, it automatically applies to last because you didn't pass a clip name.

When you call MCompensate(super2, fv2), you're actually calling MCompensate(last, super2, fv2).

last still has 24 frames, and you're applying super2/fv2 to it, which weren't built from last, so you won't get correct results.

zorr
3rd May 2018, 22:09
MCompensate's first parameter is the "implicit last" clip - like when you call MSuper() the first time, it automatically applies to last because you didn't pass a clip name.

When you call MCompensate(super2, fv2), you're actually calling MCompensate(last, super2, fv2).


Sometimes it's the simplest things... yes, that's true and an embarrassing mistake. :o Somehow I thought MCompensate only needs the super clip and the vectors clip, but obviously it also needs the actual video clip, which it then took from 'last' since it wasn't provided. So here's the corrected script:


AVISource("D:\optimizer\test\Motion Estimation Torture Clip part 3.avi")

orig = last
#return orig # 24 frames

super = MSuper(orig)
#return super # 24 frames

fv = MAnalyse(super, isb = false, delta=2)
bv = MAnalyse(super, isb = true, delta=2)
inter = MFlowInter(orig, super, bv, fv, time=50)

interleaved = Interleave(inter, orig)
#return interleaved # 48 frames

super2 = MSuper(interleaved)
#return super2 # 48 frames

fv2 = MAnalyse(super2, isb = false)
bv2 = MAnalyse(super2, isb = true)

showfv = MShow(super2, fv2)
#return showfv # 48 frames

showbv = MShow(super2, bv2)
#return showbv # 48 frames

f = MCompensate(interleaved, super2, fv2)
#return f # 48 frames (YES !)

b = MCompensate(interleaved, super2, bv2)
return b # 48 frames (YES !)


I still think that this implicit variable business is a bit dangerous, better to define it every time. Is there a consensus how to write "safe" code where this cannot happen? I think using the object oriented style

interleaved.MCompensate(super2, fv2)

would be good, unfortunately you cannot do that for every function, for example

orig.MAnalyse(super, isb = false, delta=2)

will fail with 'Invalid arguments to function MAnalyze' since it doesn't have that implicit argument.

StainlessS
3rd May 2018, 23:37
I guess that the better way may be to always explicitly use last or some named variable,

interleaved.MCompensate(super2, fv2)
Last.MCompensate(super2, fv2)
super.MAnalyse(isb = false, delta=2)

at least that way, it is quite obvious after a Copy & Paste session.

EDIT: Also, it is a bit faster using explicit Last rather than relying on implicit Last, but only of any real relevance
in the runtime environment, (tries explict Last first, and if error then tries Implicit).
Non implicit Last is quicker (in Scripclip) !:- https://forum.doom9.org/showthread.php?t=168698

zorr
4th May 2018, 21:37
I guess that the better way may be to always explicitly use last or some named variable,

interleaved.MCompensate(super2, fv2)
Last.MCompensate(super2, fv2)
super.MAnalyse(isb = false, delta=2)



Yes, I'm going to start using that. Also I realized MAnalyze takes the super clip as implicit parameter.


EDIT: Also, it is a bit faster using explicit Last rather than relying on implicit Last, but only of any real relevance
in the runtime environment, (tries explict Last first, and if error then tries Implicit).
Non implicit Last is quicker (in Scripclip) !:- https://forum.doom9.org/showthread.php?t=168698

That's good information as well. I suppose there is no difference speedwise between last.MCompensate(super, fv) and MCompensate(last,super, fv) ?

StainlessS
5th May 2018, 01:08
For the most part, no difference unless in runtime. (scriptclip or whatever)