MrPete
5th January 2015, 14:03
As I just said elsewhere, I think I'm close to understanding something significant.
IMPORTANT? I wonder if all of the following (particularly ScriptClip) depends on whether I'm using the default or the GRunT ScriptClip environment? Like most, I'm using GRunT...
Let me share a bit of concept-code... please help me understand how to do what I want.
I comment the following based on an almost-certainly-wrong guess of how it "really works"...
My goal for a slightly-sophisticated decimation routine:
a) Initialize and track the most-recently-emitted original clip frame number
b) Initialize and track the current state of a frame-analysis state machine. State is currently one of 0, 1 or 2. (FWIW, 0=Search, 1=SprocketLock, 2=OverallLock)
NOTE: I understand that "normally" one wants runtime code to be completely independent of which frame is being retrieved. QUESTION: is it 100% necessary to make that assumption? My limited experience says as long as one runs through the clip in sequence, start-to-finish (eg use Vdub "Run video analysis pass"), one can process frames reliably in-sequence.
#
# Top Level Code
# Values set during Parsing Phase
#
global lastoutTopLev = -1 # never sent yet
global MyStateTopLev = 0 # search
myclip = AviSource(...)
RestoreFilmFrames(myclip,...)
#
# END OF Top Level Code
#
function RestoreFilmFrames(clip,...)
{
#
# Nested locally but still set during Parsing Phase?
#
global lastoutLocal = -1
global MyStateLocal = 0
f0 = myclip.ScriptClip("""
#
# WHAT'S AVAILABLE HERE? lastoutTopLev? lastoutLocal? etc
# Does it depend on whether included in args?
MyStateLocal==0 ? ...
MyStateTopLev==0 ? ...
#
# Dummy code... decide whether to send current frame...
#
sendthis = True
# How do I set a "survivable" value?
global lastoutTopLev = sendthis ? current_frame : lastoutTopLev
global MyStateTopLev = newstate
global MyStateLocal = newstate
""",args="lastoutTopLev,MyStateTopLev,lastoutLocal,MyStateLocal")
return(f0);
}
I have lots of confused questions:
- Is it true that even global variables are invisible in ScriptClip unless included in args?
- Where can I / can I NOT set the initial value of a global/static variable?
- What does it take to retrieve and update the value of a global/static variable?
- Do I actually need to use "global"? Are "args" variables pass-by-reference or pass-by-value or something quite different?
- From a variable-initialization perspective, do I need to worry about the fact that frame-serving basically processes statements bottom-to-top of code?
IMPORTANT? I wonder if all of the following (particularly ScriptClip) depends on whether I'm using the default or the GRunT ScriptClip environment? Like most, I'm using GRunT...
Let me share a bit of concept-code... please help me understand how to do what I want.
I comment the following based on an almost-certainly-wrong guess of how it "really works"...
My goal for a slightly-sophisticated decimation routine:
a) Initialize and track the most-recently-emitted original clip frame number
b) Initialize and track the current state of a frame-analysis state machine. State is currently one of 0, 1 or 2. (FWIW, 0=Search, 1=SprocketLock, 2=OverallLock)
NOTE: I understand that "normally" one wants runtime code to be completely independent of which frame is being retrieved. QUESTION: is it 100% necessary to make that assumption? My limited experience says as long as one runs through the clip in sequence, start-to-finish (eg use Vdub "Run video analysis pass"), one can process frames reliably in-sequence.
#
# Top Level Code
# Values set during Parsing Phase
#
global lastoutTopLev = -1 # never sent yet
global MyStateTopLev = 0 # search
myclip = AviSource(...)
RestoreFilmFrames(myclip,...)
#
# END OF Top Level Code
#
function RestoreFilmFrames(clip,...)
{
#
# Nested locally but still set during Parsing Phase?
#
global lastoutLocal = -1
global MyStateLocal = 0
f0 = myclip.ScriptClip("""
#
# WHAT'S AVAILABLE HERE? lastoutTopLev? lastoutLocal? etc
# Does it depend on whether included in args?
MyStateLocal==0 ? ...
MyStateTopLev==0 ? ...
#
# Dummy code... decide whether to send current frame...
#
sendthis = True
# How do I set a "survivable" value?
global lastoutTopLev = sendthis ? current_frame : lastoutTopLev
global MyStateTopLev = newstate
global MyStateLocal = newstate
""",args="lastoutTopLev,MyStateTopLev,lastoutLocal,MyStateLocal")
return(f0);
}
I have lots of confused questions:
- Is it true that even global variables are invisible in ScriptClip unless included in args?
- Where can I / can I NOT set the initial value of a global/static variable?
- What does it take to retrieve and update the value of a global/static variable?
- Do I actually need to use "global"? Are "args" variables pass-by-reference or pass-by-value or something quite different?
- From a variable-initialization perspective, do I need to worry about the fact that frame-serving basically processes statements bottom-to-top of code?