Thread: VirtualDub2
View Single Post
Old 23rd May 2017, 13:16   #274  |  Link
shekh
Registered User
 
Join Date: Mar 2015
Posts: 775
The part you probably misread in the sdk:

Quote:
With copyProc, it becomes possible to map the allocation and deallocation hooks onto traditional C++ object semantics, which makes filter data management much easier. In particular, the three hooks can be mapped as follows:

Filter API entry point Equivalent C++ method
initProc Constructor
deinitProc Destructor
copyProc Copy constructor
Quote:
It think it's possible if the system call FilterInit and FilterDeinit only on "initial" object, and not the cloned.
But it is not, as soon as clone object is created both objects are equal in rights. FilterDeinit/destructor is called equally for both.

Quote:
And if "buff" is not allocated in constructor, but in Start, it must be freed in End, not DeInit or destructor.
You can allocate stuff in constructor, init, start, run, config or anywhere else. There is no rule against this.
The only sane rule is: everything you allocate must be reasonably freed.
Where exactly to put something can only be advice, not rule.

btw can you share sdk 1.2? It seems I have lost it (only 1.1 is still on virtualdub.org)

If you want to read help to the letter:

Quote:
initProc
Initializes a filter's per-instance data.

int initProc(VDXFilterActivation *fa, const VDXFilterFunctions *ff);

Remarks
This function is called whenever a filter instance is created, and is usually used to initialize variables in the private data structure. Regardless of whether it is provided, VirtualDub will initialize the data structure to zeroes, so most filters will not need this function.
ok except it does not mention that it is NOT called when copy instance is created, which somewhat changes the game.

Quote:
copyProc
Creates a clone of the filter instance.

int copyProc(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst);

Remarks
This function allows you to implement a copy constructor for your filter, which then allows you to store pointers to allocated and destructable objects in your filter structure. To do this, you must tie copyProc to your class's copy constructor, initProc to your regular constructor, and deinitProc to your destructor. See using a class object for your filter for more details.
again (translating)
initProc = Constructor (constructor is wrapper for initProc)
deinitProc = Destructor (destructor is wrapper for deinitProc)
copyProc = Copy constructor (copy constructor is wrapper for copyProc)

Do you still insist to ignore copy constructor?

Why there exists virtual VDXVideoFilter::Init? IMO you are supposed to ignore it unless you want to return error to deny filter usage (maybe it cannot find required library).
Init is called anyway after constructor is called but there is no way to return error from a constructor.
__________________
VirtualDub2
shekh is offline   Reply With Quote