-
Notifications
You must be signed in to change notification settings - Fork 12
videofilt_vdxframe_addingscriptsupport
VirtualDub Plugin SDK 1.2
Adding script support
Adding script support to a VDXFrame-based filter is also simplified.
To declare the script object, use the VDXVF_DECLARE_SCRIPT_METHODS
macro within the filter class definition:
public:
virtual void Run();
// ...
VDXVF_DECLARE_SCRIPT_METHODS();
protected:
Note that this must be done publicly as the script object needs to be
accessible to the VDXVideoFilterDefinition
template.
Next, define the script method table and the methods themselves:
VDXVF_BEGIN_SCRIPT_METHODS(MyFilter)
VDXVF_DEFINE_SCRIPT_METHOD(MyFilter, ScriptConfig, "ii")
VDXVF_DEFINE_SCRIPT_METHOD2(MyFilter, ScriptConfig2, "iii")
VDXVF_END_SCRIPT_METHODS()
This creates overloads of the Config()
script function. Use
VDXVF_DEFINE_SCRIPT_METHOD
for the first overload and
VDXVF_DEFINE_SCRIPT_METHOD2
for the subsequent ones. The third
argument is the signature string. Note that unlike the raw definition,
the string used here does not include the return value, which is always
declared as 0
(void).
Now the script methods themselves can be implemented:
void MyFilter::ScriptConfig(IVDXScriptInterpreter *isi, const VDXScriptValue *argv, int argc) {
mConfig.mBrightness = argv[0].asInt();
mConfig.mContrast = 100;
}
void MyFilter::ScriptConfig2(IVDXScriptInterpreter *isi, const VDXScriptValue *argv, int argc) {
mConfig.mBrightness = argv[0].asInt();
mConfig.mContrast = argv[1].asInt();
}
As usual, VDXFrame marshals the this pointer, so these are declared as non-static methods.
Finally, implement GetScriptString()
to generate the Config()
call
in script. This is done the same as GetSettingsString()
.
void MyFilter::GetSettingString(char *buf, int maxlen) {
SafePrintf(buf, maxlen, "Config(%d,%d)"
, mConfig.mBrightness
, mConfig.mContrast
);
}
Copyright (C) 2007-2012 Avery Lee.
Setting up your development environment
Conventions
Plugin initialization
Dynamic loading
Reference counting
Using CPU extensions
Introduction
What's new
Breaking changes
Gotchas
Deprecated features
Migrating from the old Filter SDK
Programming model
Handling bitmaps
Creating a video filter
Setting filter parameters
Processing video frames
Managing filter data
Creating time-varying filters
Handling aspect ratio
Prefetching multiple source frames
Handling multiple sources
Making a filter configurable
Scripting support
CPU dependent optimization
VDXA index omitted
Getting started
Writing the module entry point
Creating a video filter
Adding configurability
Adding script support
Introduction
What's new
Autodetect
Direct mode
Video frames vs. samples
Video decodint model
Video decoder