Never call Py_Finalize()
[vapoursynth-svn.git] / sdk / filter_skeleton.c
blob552b3189b0cf7a552cb00ce33e3755fb22714785
1 //////////////////////////////////////////
2 // This file contains a simple filter
3 // skeleton you can use to get started.
4 // With no changes it simply passes
5 // frames through.
7 #include "VapourSynth.h"
8 #include "VSHelper.h"
10 typedef struct {
11 VSNodeRef *node;
12 const VSVideoInfo *vi;
13 } FilterData;
15 static void VS_CC filterInit(VSMap *in, VSMap *out, void **instanceData, VSNode *node, VSCore *core, const VSAPI *vsapi) {
16 FilterData *d = (FilterData *) * instanceData;
17 vsapi->setVideoInfo(d->vi, 1, node);
20 static const VSFrameRef *VS_CC filterGetFrame(int n, int activationReason, void **instanceData, void **frameData, VSFrameContext *frameCtx, VSCore *core, const VSAPI *vsapi) {
21 FilterData *d = (FilterData *) * instanceData;
23 if (activationReason == arInitial) {
24 vsapi->requestFrameFilter(n, d->node, frameCtx);
25 } else if (activationReason == arAllFramesReady) {
26 const VSFrameRef *frame = vsapi->getFrameFilter(n, d->node, frameCtx);
28 // your code here...
30 return frame;
33 return 0;
36 static void VS_CC filterFree(void *instanceData, VSCore *core, const VSAPI *vsapi) {
37 FilterData *d = (FilterData *)instanceData;
38 vsapi->freeNode(d->node);
39 free(d);
42 static void VS_CC filterCreate(const VSMap *in, VSMap *out, void *userData, VSCore *core, const VSAPI *vsapi) {
43 FilterData d;
44 FilterData *data;
46 d.node = vsapi->propGetNode(in, "clip", 0, 0);
47 d.vi = vsapi->getVideoInfo(d.node);
49 data = malloc(sizeof(d));
50 *data = d;
52 vsapi->createFilter(in, out, "Filter", filterInit, filterGetFrame, filterFree, fmParallel, 0, data, core);
53 return;
56 //////////////////////////////////////////
57 // Init
59 VS_EXTERNAL_API(void) VapourSynthPluginInit(VSConfigPlugin configFunc, VSRegisterFunction registerFunc, VSPlugin *plugin) {
60 configFunc("com.example.filter", "filter", "VapourSynth Filter Skeleton", VAPOURSYNTH_API_VERSION, 1, plugin);
61 registerFunc("Filter", "clip:clip;", filterCreate, 0, plugin);