videofilt_vdxframe_creatingavideofilter - shekh/VirtualDub2 GitHub Wiki
VirtualDub Plugin SDK 1.2
Creating a filter
Once you have the entry point in place, you can begin writing the video filters themselves.
To create a video filter, first derive from the VDXVideoFilter base
class to produce the derived class for your filter. There are two
methods on the wrapper base class that must be overridden, GetParams()
and Run(). These correspond to the paramProc and runProc entry
points, respectively. Therefore, this is the minimal filter
implementation:
#include <vd2/VDXFrame/VideoFilter.h>
class EmptyFilter : public VDXVideoFilter {
public:
virtual uint32 GetParams();
virtual void Run();
};
uint32 EmptyFilter::GetParams() {
return FILTERPARAM_SWAP_BUFFERS;
}
void EmptyFilter::Run() {
}
The VDXVideoFilter class contains protected fields called fa and
ff that correspond to the filter activation and functions structures
traditionally passed to the filter entry points. This avoids having to
declare them on every method and allows code written to use those
variables to port directly over to the wrappers.
Other entry points in the video filter API are also exposed in the
VideoFilter base class, and can be implemented as simply as overloading
the appropriate base class method. The base class methods are sometimes
simplified — for instance, both the stringProc and stringProc2 API
methods can be implemented by overloading
VDXVideoFilter::GetSettingsString().
Once you have the video filter class in place, the video filter
definition can be created using the VDXVideoFilterDefinition template:
extern VDXFilterDefinition filterDef_emptyFilter =
VDXVideoFilterDefinition<EmptyFilter>(
"My Name",
"Sample: Empty Filter",
"Sample filter from the VirtualDub Plugin SDK: Does nothing");
The three arguments to the constructor are author, name, and description. All other fields are derived from the filter class.
That's it — you should now have a working video filter.
Copyright (C) 2007-2012 Avery Lee.