View Full Version : Can a plugin call built in filters?
Xesdeeni
2nd October 2002, 14:28
I'm working on a filter that currently relies on the script calling some built in filters before calling the plugin to prepare the input for the filter. I would like to remove this burden from the user by calling the built in filters from within the plugin as necessary.
What is the best way of doing this? Should I create the built in filter object in my constructor, pass it the _child provided to me, and call this object's GetFrame() instead of _child's in my GetFrame()? If so, how do I construct the arguments for the Create_Filter() call?
Is there a better/easier way?
Xesdeeni
Guest
2nd October 2002, 14:43
Use Invoke(). It is described in Ben's original tutorial on writing plugins.
Xesdeeni
2nd October 2002, 17:28
Thank you very much. Two more questions:
1. So I call Invoke() from the Create_Filter() function, and replace the args[0].AsClip() value in the new call with the return value, right?
2. I need to decide whether to call Invoke() on the clip based on the format it is when I recieve it. The information I need would be in the vi member, but that is in the base class of the object I haven't yet created. Is there another place to get this information in the Create_Filter() function, and will it be valid?
Xesdeeni
Xesdeeni
3rd October 2002, 13:53
Well, through trial-and-error, I think I got this figured out. The answer to #1 below is "yes." #2 is a bit trickier:
What I did was to create multiple (what I will call) streams as potential inputs for the filter. One comes from the normal args[0].AsClip() method. The others use Invoke() to create alternates to the normal stream:
In Create_Filter()PClip pChildNormal = args[0].AsClip();
PClip pChildStream2 = pEnv->Invoke("BuiltIn1", args[0]).AsClip();
PClip pChildStream3 = pEnv->Invoke("BuiltIn2", args[0]).AsClip();Then I pass all the streams to the filter constructor:return(new Filter(pChildNormal,
pChildStream2,
pChildStream3,
...));In the constructor, I pass the normal stream to the base class, and save the other streams in member varables:class Filter : public GenericVideoFilter
{
private:
PClip m_pChildStream2;
PClip m_pChildStream3;
...
public:
Filter(PClip pChildNormal,
PClip pChildStream2,
PClip pChildStream3,
...) :
GenericVideoFilter(pChildNormal),
m_pChildWeave(pChildStream2),
m_pChildDoubleWeave(pChildStream3),
...
{
...
}Then, in the GetFrame() method, I choose which of the streams I want to use as an input:PClip pChild;
if(/* use normal stream */)
pChild = child; // in GenericVideoFilter base class
else if(/* use stream 2 */)
pChild = m_pChildStream2;
else if(/* use stream 3 */)
pChild = m_pChildStream3;
else ...
pChild->GetFrame(n, pEnv);
...This seems to work well. I hope this helps anyone else trying to do something similar.
Xesdeeni
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.