PDA

View Full Version : Porting a VirtualDub filter


Si
8th March 2003, 11:09
Dear Experts,

101 needed in plugin coding again :o

In my VirtualDub filters, if I want a variable to be carried across several frames, I just declare it as static in the RunProc and it works fine.

I'm having a bit of trouble in porting my progressive frame restorer filter and I'm wondering if this technique if valid or not.

Should I delclare it static as in

class PFR : public GenericVideoFilter {

static int FramesSinceChangetoP;

or should it be just

int FramesSinceChangetoP;

and can I intialise it like:

int FramesSinceChangetoP = 0;

Sorry for stupid questions but I don't think they were quite covered in Ben's Invert example

regards

Simon

neuron2
8th March 2003, 13:34
Declare it as a member of your filter class (not static) and initialize it in the constructor.

Si
8th March 2003, 16:19
Constructor :confused: :scared:

Your saying after all these years I'm finally going to have to actually understand all that C++ stuff I read about in the beginning :p

regards

Simon

neuron2
8th March 2003, 23:02
That would be a good idea, yes.

I'll give you a little help. Your filter class has a name and a definition. That definition can contain both C-style declarations and function declarations. Two of the latter are special. If there is a function member with the same name as the filter class, then it is the constructor and is executed once when the filter is instantiated. Typically it is used for, you guessed it, initialization of stuff. The other has the same name but with a ~ in front. That is the destructor and is run once when the filter is deinstantiated.

Get a basic C++ book and read about class declarations. That's all you really need to understand this aspect of it. Also, look at existing filters to see how they do what you need to do.

Si
9th March 2003, 01:00
If you can show me the equivalence between whats in the 1st few chapters of my C++ books and Avisynth filter code ... :)

Its one of those things - if you know it (or are lucky in finding a revelant example) then it would be easy. My brain just hasn't got any more room for another language (and I don't like quiche :) )

Anyway - thanks for the hints - I think I've worked out that the initialisation goes in the same place as the colourspace check. (in my speak - between the 2nd curly brackets. ;)

BTW Could you point to any of your filters that employ this method?

regards
Simon