View Single Post
Old 26th September 2008, 13:33   #14  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
Originally Posted by MOmonster View Post
The variables don´t have to be global? I don`t know anymore why I think so.
Well, I can remember why ... iirc it was Restore24 which introduced this kind of variable-shifting in the conditional env.

In the 1st example with 3times AverageLuma, globals are not needed because all 3 variables are computed "now".
In the 2nd example, the globals are needed because only one variable is computed "now" (the "next" one), and the other two are derived from what the conditional environment had computed during processing the previous frame. If you need "now" the content of a variable from one frame before, then you're jumping out of ScriptClip's local context, and need a global variable to "save" that variable's content while stepping from one frame on to the next one.

The variant with independent calculation of all needed variables is of course slower (doing AverageLuma several times), and it's robust against seeking. The variant with globals is faster (only one time AverageLuma), but it's not robust against seeking and needs linear access.

When I did Restore24, the choice was easy:

a) RequstLinear() did not exist yet

b) GRunT did not exist yet

c) R24 uses not only the 3 variables 'previous', 'current', 'next'. Because of its kind of pattern reckognition, it uses six (or seven?) of such variables: previous(3), previous(2), previous(1), current, next(1), next(2). (Not sure anymore if the released versions used next(3), too.)

It's obvious why the variant with globals was chosen. The choices were to do only one time AverageLuma for every frame, or to do six (seven?) times AverageLuma for every single frame (with all except one of them being basically superfluous.)
So I went for the route that requires linear access, but does not do 500% (600%) of re-doing frame sampling operations that already had been done.


It's been quite some time since then. Knowledge/practice and available tools have noticeably developed in the meantime. I'm really looking forward to see Mrest..., erh, SRestore to do right what I had b0rked back then.

(Lord, make I don't ever have to touch Restore24 again!)
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote