Printable Version of Topic
Click here to view this topic in its original format
Unofficial VirtualDub Support Forums > VirtualDub Filters and Filter Development > Startproc And Endproc Called More Than Once


Posted by: gingko Sep 13 2008, 04:22 AM
I have added a function trace to my filtsdk-1_05 based filter as follows:
CODE
void FnTrace(const char *str, int indentAdjust, int calls, int frame) {
   char intStrBuf[INTSTRBUFSZ + 1];

   if (indentAdjust < 0) {     // pre-adjust the indent (usually -1 to close a block)
    FTIndent += indentAdjust;
   }

   for (int i = 1;  i <= FTIndent;  ++i) {
       OutputDebugString(" ");
   }

   OutputDebugString(str);

   if (indentAdjust >= 0 && frame >= 0) {
       _itoa_s(frame, intStrBuf, INTSTRBUFSZ, 10);
       OutputDebugString(" frame[");  OutputDebugString(intStrBuf);  OutputDebugString("]");
   }

   if (calls >= 0) {
       _itoa_s(calls, intStrBuf, INTSTRBUFSZ, 10);
       OutputDebugString(" call[");   OutputDebugString(intStrBuf);  OutputDebugString("]");
   }

   OutputDebugString("\n");

   if (indentAdjust > 0) { FTIndent += indentAdjust; }   // post-adjust the indent (usually +1 to start a block)
}


// In the StartProc, RunProc and EndProc functions...
int Start/Run/EndProc(FilterActivation *fa, const FilterFunctions *ff) {
   static int calls = 0;
   FnTrace("Start/Run/EndProc {", 1, ++calls, mfd->currentFrame);

   ...

   FnTrace("}", -1, -1, -1);
   return 0;
}

The FnTace output gets intermingled with normal Debug output in MSVC2005, as it would.
The stripped output of the trace is:
CODE
'VirtualDub.exe': Loaded 'C:\Program Files\VirtualDub\VirtualDub.exe', Symbols loaded.
...   Loading stuff

StartProc frame[0] call[1]  i.e. 1st call of StartProc
RunProc   frame[0] call[1]
EndProc   frame[1] call[1]
StartProc frame[1] call[2]  i.e. 2nd call of StartProc
EndProc   frame[1] call[2]
StartProc frame[1] call[3]
EndProc   frame[1] call[3]
StartProc frame[1] call[4]

'VirtualDub.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
...   Loading stuff

RunProc   frame[1] call[2]

RunProc   frame[1] call[3]  Note: my frame numbers are base 1, this is the first frame of the filtering
RunProc   frame[2] call[4]
...     (frames 3 to 181)
RunProc   frame[182] call[184]

The thread 'Dub-I/O' (0xf80) has exited with code 0 (0x0).

RunProc   frame[183] call[185]
...     (frames 184 to 212)
RunProc   frame[213] call[215]

The thread 'Win32 Thread' (0xe60) has exited with code 0 (0x0).
exiting stuff
...

EndProc   frame[214] call[4]  Note: Frame 214 is? the last frame of src.
StartProc frame[214] call[5]
RunProc   frame[214] call[216]

'VirtualDub.exe': Unloaded 'C:\WINDOWS\system32\d3d9.dll'
... unloading and exiting stuff
The program '[3624] VirtualDub.exe: Native' has exited with code 0 (0x0).


I was anticipating something simpler like:
CODE
load stuff
startproc
runproc
 ... (one RunProc for each frame)
runproc
endproc
unload stuff


Should it to be anticipated that Start/Run/EndProc will go through several cycles during one filter instance?


Posted by: phaeron Sep 14 2008, 05:14 PM
Oh yes. You're practically guaranteed at least two, one for when the preview panes reinit and one for the actual render to disk. More if settings are changed and the preview panes have to reinit again.

Powered by Invision Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)