View Full Version : Invoke()
WarpEnterprises
15th September 2003, 15:22
If I use a env->Invoke() a new filter is constructed.
This can be done every frame in a GetFrame().
So there is a contruction every frame.
But when gets the filter DEstructed? Or is it kept until the script is closed?
And how does ScriptClip handle ressources not needed anymore?
sh0dan
15th September 2003, 16:10
PClip should do ref-counting - that means that when the PClip is not referenced anymore it will be destroyed.
If you don't assign it to a class member variable, but only as a local variable (in GetFrame for instance), the PClip will be de-referenced, and destroyed when the GetFrame function returns.
PClip is only a wrapper for IClip, which is the actual filter base class. It is there to make it easier to work with IClip.
The PClip in ScriptClip is destroyed at every frame, because a new one has to be created for the next frame.
Bidoche
15th September 2003, 18:14
PClip is a smart pointer to IClip, ie it behaves like IClip * from the user point of vue while doing a side task : updating an embedded refcount in IClip.
When the refcount reach zero, it means the Clip cannot be used anymore and so it deletes itself.
Smart pointers are generally template classes, in order to avoid rewriting the same thing over and over, like for PClip and PVideoFrame.
In 3.0, PClip is smart_ref<const Clip>, PVideoFrame smart_ref_cow<VideoFrame>, CPVideoFrame smart_ref<const VideoFrame>...
And my templates allow implicit upcasting, and downcasting through a template function.
ie you can do :PClip clip = ...
smart_ref<Trim> trim = smart_cast<Trim>(clip); //explicit downcasting (may fail)
int begin = trim->GetBegin(); //supposedly this method exists
//...
clip = trim; //implicit upcasting
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.