2 * Copyright (c) 2012 Fredrik Mellbin
4 * This file is part of VapourSynth.
6 * VapourSynth is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * VapourSynth is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with VapourSynth; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #define VAPOURSYNTH_API_VERSION 3
28 // Convenience for C++ users.
30 # define VS_EXTERN_C extern "C"
36 # define VS_CC __stdcall
41 // And now for some symbol hide-and-seek...
42 #if defined(_WIN32) // Windows being special
43 # define VS_EXTERNAL_API(ret) VS_EXTERN_C __declspec(dllexport) ret VS_CC
44 #elif defined(__GNUC__) && __GNUC__ >= 4
45 # define VS_EXTERNAL_API(ret) VS_EXTERN_C __attribute__((visibility("default"))) ret VS_CC
47 # define VS_EXTERNAL_API(ret) VS_EXTERN_C ret VS_CC
50 #if !defined(VSCORE_EXPORTS) && defined(_WIN32)
51 # define VS_API(ret) VS_EXTERN_C __declspec(dllimport) ret VS_CC
53 # define VS_API(ret) VS_EXTERNAL_API(ret)
56 typedef struct VSFrameRef VSFrameRef
;
57 typedef struct VSNodeRef VSNodeRef
;
58 typedef struct VSCore VSCore
;
59 typedef struct VSPlugin VSPlugin
;
60 typedef struct VSNode VSNode
;
61 typedef struct VSFuncRef VSFuncRef
;
62 typedef struct VSMap VSMap
;
63 typedef struct VSAPI VSAPI
;
64 typedef struct VSFrameContext VSFrameContext
;
66 typedef enum VSColorFamily
{
72 // special for compatibility
76 typedef enum VSSampleType
{
81 // The +10 is so people won't be using the constants interchangably "by accident"
82 typedef enum VSPresetFormat
{
85 pfGray8
= cmGray
+ 10,
91 pfYUV420P8
= cmYUV
+ 10,
113 pfRGB24
= cmRGB
+ 10,
121 // special for compatibility, if you implement these in any filter I'll personally kill you
122 // I'll also change their ids around to break your stuff regularly
123 pfCompatBGR32
= cmCompat
+ 10,
127 typedef enum VSFilterMode
{
128 fmParallel
= 100, // completely parallel execution
129 fmParallelRequests
= 200, // for filters that are serial in nature but can request one or more frames they need in advance
130 fmUnordered
= 300, // for filters that modify their internal state every request
131 fmSerial
= 400 // for source filters and compatibility with other filtering architectures
134 typedef struct VSFormat
{
137 int colorFamily
; // see VSColorFamily
138 int sampleType
; // see VSSampleType
139 int bitsPerSample
; // number of significant bits
140 int bytesPerSample
; // actual storage is always in a power of 2 and the smallest possible that can fit the number of bits used per sample
142 int subSamplingW
; // log2 subsampling factor, applied to second and third plane
145 int numPlanes
; // implicit from colorFamily
148 typedef enum VSNodeFlags
{
152 typedef enum VSGetPropErrors
{
158 typedef enum VSPropAppendMode
{
164 typedef struct VSCoreInfo
{
165 const char *versionString
;
169 int64_t maxFramebufferSize
;
170 int64_t usedFramebufferSize
;
173 typedef struct VSVideoInfo
{
174 const VSFormat
*format
;
183 typedef enum VSActivationReason
{
186 arAllFramesReady
= 2,
190 typedef enum VSMessageType
{
197 // core function typedefs
198 typedef VSCore
*(VS_CC
*VSCreateCore
)(int threads
);
199 typedef void (VS_CC
*VSFreeCore
)(VSCore
*core
);
200 typedef const VSCoreInfo
*(VS_CC
*VSGetCoreInfo
)(VSCore
*core
);
202 // function/filter typedefs
203 typedef void (VS_CC
*VSPublicFunction
)(const VSMap
*in
, VSMap
*out
, void *userData
, VSCore
*core
, const VSAPI
*vsapi
);
204 typedef void (VS_CC
*VSFreeFuncData
)(void *userData
);
205 typedef void (VS_CC
*VSFilterInit
)(VSMap
*in
, VSMap
*out
, void **instanceData
, VSNode
*node
, VSCore
*core
, const VSAPI
*vsapi
);
206 typedef const VSFrameRef
*(VS_CC
*VSFilterGetFrame
)(int n
, int activationReason
, void **instanceData
, void **frameData
, VSFrameContext
*frameCtx
, VSCore
*core
, const VSAPI
*vsapi
);
207 typedef int (VS_CC
*VSGetOutputIndex
)(VSFrameContext
*frameCtx
);
208 typedef void (VS_CC
*VSFilterFree
)(void *instanceData
, VSCore
*core
, const VSAPI
*vsapi
);
209 typedef void (VS_CC
*VSRegisterFunction
)(const char *name
, const char *args
, VSPublicFunction argsFunc
, void *functionData
, VSPlugin
*plugin
);
210 typedef void (VS_CC
*VSCreateFilter
)(const VSMap
*in
, VSMap
*out
, const char *name
, VSFilterInit init
, VSFilterGetFrame getFrame
, VSFilterFree free
, int filterMode
, int flags
, void *instanceData
, VSCore
*core
);
211 typedef VSMap
*(VS_CC
*VSInvoke
)(VSPlugin
*plugin
, const char *name
, const VSMap
*args
);
212 typedef void (VS_CC
*VSSetError
)(VSMap
*map
, const char *errorMessage
);
213 typedef const char *(VS_CC
*VSGetError
)(const VSMap
*map
);
214 typedef void (VS_CC
*VSSetFilterError
)(const char *errorMessage
, VSFrameContext
*frameCtx
);
216 typedef const VSFormat
*(VS_CC
*VSGetFormatPreset
)(int id
, VSCore
*core
);
217 typedef const VSFormat
*(VS_CC
*VSRegisterFormat
)(int colorFamily
, int sampleType
, int bitsPerSample
, int subSamplingW
, int subSamplingH
, VSCore
*core
);
219 // frame and clip handling
220 typedef void (VS_CC
*VSFrameDoneCallback
)(void *userData
, const VSFrameRef
*f
, int n
, VSNodeRef
*, const char *errorMsg
);
221 typedef void (VS_CC
*VSGetFrameAsync
)(int n
, VSNodeRef
*node
, VSFrameDoneCallback callback
, void *userData
);
222 typedef const VSFrameRef
*(VS_CC
*VSGetFrame
)(int n
, VSNodeRef
*node
, char *errorMsg
, int bufSize
);
223 typedef void (VS_CC
*VSRequestFrameFilter
)(int n
, VSNodeRef
*node
, VSFrameContext
*frameCtx
);
224 typedef const VSFrameRef
*(VS_CC
*VSGetFrameFilter
)(int n
, VSNodeRef
*node
, VSFrameContext
*frameCtx
);
225 typedef const VSFrameRef
*(VS_CC
*VSCloneFrameRef
)(const VSFrameRef
*f
);
226 typedef VSNodeRef
*(VS_CC
*VSCloneNodeRef
)(VSNodeRef
*node
);
227 typedef VSFuncRef
*(VS_CC
*VSCloneFuncRef
)(VSFuncRef
*f
);
228 typedef void (VS_CC
*VSFreeFrame
)(const VSFrameRef
*f
);
229 typedef void (VS_CC
*VSFreeNode
)(VSNodeRef
*node
);
230 typedef void (VS_CC
*VSFreeFunc
)(VSFuncRef
*f
);
231 typedef VSFrameRef
*(VS_CC
*VSNewVideoFrame
)(const VSFormat
*format
, int width
, int height
, const VSFrameRef
*propSrc
, VSCore
*core
);
232 typedef VSFrameRef
*(VS_CC
*VSNewVideoFrame2
)(const VSFormat
*format
, int width
, int height
, const VSFrameRef
**planeSrc
, const int *planes
, const VSFrameRef
*propSrc
, VSCore
*core
);
233 typedef VSFrameRef
*(VS_CC
*VSCopyFrame
)(const VSFrameRef
*f
, VSCore
*core
);
234 typedef void (VS_CC
*VSCopyFrameProps
)(const VSFrameRef
*src
, VSFrameRef
*dst
, VSCore
*core
);
235 typedef int (VS_CC
*VSGetStride
)(const VSFrameRef
*f
, int plane
);
236 typedef const uint8_t *(VS_CC
*VSGetReadPtr
)(const VSFrameRef
*f
, int plane
);
237 typedef uint8_t *(VS_CC
*VSGetWritePtr
)(VSFrameRef
*f
, int plane
);
240 typedef const VSVideoInfo
*(VS_CC
*VSGetVideoInfo
)(VSNodeRef
*node
);
241 typedef void (VS_CC
*VSSetVideoInfo
)(const VSVideoInfo
*vi
, int numOutputs
, VSNode
*node
);
242 typedef const VSFormat
*(VS_CC
*VSGetFrameFormat
)(const VSFrameRef
*f
);
243 typedef int (VS_CC
*VSGetFrameWidth
)(const VSFrameRef
*f
, int plane
);
244 typedef int (VS_CC
*VSGetFrameHeight
)(const VSFrameRef
*f
, int plane
);
245 typedef const VSMap
*(VS_CC
*VSGetFramePropsRO
)(const VSFrameRef
*f
);
246 typedef VSMap
*(VS_CC
*VSGetFramePropsRW
)(VSFrameRef
*f
);
247 typedef int (VS_CC
*VSPropNumKeys
)(const VSMap
*map
);
248 typedef const char *(VS_CC
*VSPropGetKey
)(const VSMap
*map
, int index
);
249 typedef int (VS_CC
*VSPropNumElements
)(const VSMap
*map
, const char *key
);
250 typedef char(VS_CC
*VSPropGetType
)(const VSMap
*map
, const char *key
);
252 typedef VSMap
*(VS_CC
*VSCreateMap
)(void);
253 typedef void (VS_CC
*VSFreeMap
)(VSMap
*map
);
254 typedef void (VS_CC
*VSClearMap
)(VSMap
*map
);
256 typedef int64_t (VS_CC
*VSPropGetInt
)(const VSMap
*map
, const char *key
, int index
, int *error
);
257 typedef double(VS_CC
*VSPropGetFloat
)(const VSMap
*map
, const char *key
, int index
, int *error
);
258 typedef const char *(VS_CC
*VSPropGetData
)(const VSMap
*map
, const char *key
, int index
, int *error
);
259 typedef int (VS_CC
*VSPropGetDataSize
)(const VSMap
*map
, const char *key
, int index
, int *error
);
260 typedef VSNodeRef
*(VS_CC
*VSPropGetNode
)(const VSMap
*map
, const char *key
, int index
, int *error
);
261 typedef const VSFrameRef
*(VS_CC
*VSPropGetFrame
)(const VSMap
*map
, const char *key
, int index
, int *error
);
262 typedef VSFuncRef
*(VS_CC
*VSPropGetFunc
)(const VSMap
*map
, const char *key
, int index
, int *error
);
264 typedef int (VS_CC
*VSPropDeleteKey
)(VSMap
*map
, const char *key
);
265 typedef int (VS_CC
*VSPropSetInt
)(VSMap
*map
, const char *key
, int64_t i
, int append
);
266 typedef int (VS_CC
*VSPropSetFloat
)(VSMap
*map
, const char *key
, double d
, int append
);
267 typedef int (VS_CC
*VSPropSetData
)(VSMap
*map
, const char *key
, const char *data
, int size
, int append
);
268 typedef int (VS_CC
*VSPropSetNode
)(VSMap
*map
, const char *key
, VSNodeRef
*node
, int append
);
269 typedef int (VS_CC
*VSPropSetFrame
)(VSMap
*map
, const char *key
, const VSFrameRef
*f
, int append
);
270 typedef int (VS_CC
*VSPropSetFunc
)(VSMap
*map
, const char *key
, VSFuncRef
*func
, int append
);
274 typedef void (VS_CC
*VSConfigPlugin
)(const char *identifier
, const char *defaultNamespace
, const char *name
, int apiVersion
, int readonly
, VSPlugin
*plugin
);
275 typedef void (VS_CC
*VSInitPlugin
)(VSConfigPlugin configFunc
, VSRegisterFunction registerFunc
, VSPlugin
*plugin
);
277 typedef VSPlugin
*(VS_CC
*VSGetPluginId
)(const char *identifier
, VSCore
*core
);
278 typedef VSPlugin
*(VS_CC
*VSGetPluginNs
)(const char *ns
, VSCore
*core
);
280 typedef VSMap
*(VS_CC
*VSGetPlugins
)(VSCore
*core
);
281 typedef VSMap
*(VS_CC
*VSGetFunctions
)(VSPlugin
*plugin
);
283 typedef void (VS_CC
*VSCallFunc
)(VSFuncRef
*func
, const VSMap
*in
, VSMap
*out
, VSCore
*core
, const VSAPI
*vsapi
);
284 typedef VSFuncRef
*(VS_CC
*VSCreateFunc
)(VSPublicFunction func
, void *userData
, VSFreeFuncData free
);
286 typedef void (VS_CC
*VSQueryCompletedFrame
)(VSNodeRef
**node
, int *n
, VSFrameContext
*frameCtx
);
287 typedef void (VS_CC
*VSReleaseFrameEarly
)(VSNodeRef
*node
, int n
, VSFrameContext
*frameCtx
);
289 typedef int64_t (VS_CC
*VSSetMaxCacheSize
)(int64_t bytes
, VSCore
*core
);
291 typedef void (VS_CC
*VSMessageHandler
)(int msgType
, const char *msg
);
292 typedef void (VS_CC
*VSSetMessageHandler
)(VSMessageHandler handler
);
295 VSCreateCore createCore
;
297 VSGetCoreInfo getCoreInfo
;
299 VSCloneFrameRef cloneFrameRef
;
300 VSCloneNodeRef cloneNodeRef
;
301 VSCloneFuncRef cloneFuncRef
;
303 VSFreeFrame freeFrame
;
307 VSNewVideoFrame newVideoFrame
;
308 VSCopyFrame copyFrame
;
309 VSCopyFrameProps copyFrameProps
;
311 VSRegisterFunction registerFunction
;
312 VSGetPluginId getPluginId
;
313 VSGetPluginNs getPluginNs
;
314 VSGetPlugins getPlugins
;
315 VSGetFunctions getFunctions
;
316 VSCreateFilter createFilter
; // do never use inside a filter's getframe function
317 VSSetError setError
; // use to signal errors outside filter getframe functions
318 VSGetError getError
; // use to query errors, returns 0 if no error
319 VSSetFilterError setFilterError
; // use to signal errors in the filter getframe function
320 VSInvoke invoke
; // may not be used inside a filter's getframe method
322 VSGetFormatPreset getFormatPreset
; //threadsafe
323 VSRegisterFormat registerFormat
; // threadsafe
325 VSGetFrame getFrame
; // do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor
326 VSGetFrameAsync getFrameAsync
; // do never use inside a filter's getframe function, for external applications using the core as a library or for requesting frames in a filter constructor
327 VSGetFrameFilter getFrameFilter
; // only use inside a filter's getframe function
328 VSRequestFrameFilter requestFrameFilter
; // only use inside a filter's getframe function
329 VSQueryCompletedFrame queryCompletedFrame
; // only use inside a filter's getframe function
330 VSReleaseFrameEarly releaseFrameEarly
; // only use inside a filter's getframe function
332 VSGetStride getStride
;
333 VSGetReadPtr getReadPtr
;
334 VSGetWritePtr getWritePtr
;
336 VSCreateFunc createFunc
;
339 //property access functions
340 VSCreateMap createMap
;
344 VSGetVideoInfo getVideoInfo
;
345 VSSetVideoInfo setVideoInfo
;
346 VSGetFrameFormat getFrameFormat
;
347 VSGetFrameWidth getFrameWidth
;
348 VSGetFrameHeight getFrameHeight
;
349 VSGetFramePropsRO getFramePropsRO
;
350 VSGetFramePropsRW getFramePropsRW
;
352 VSPropNumKeys propNumKeys
;
353 VSPropGetKey propGetKey
;
354 VSPropNumElements propNumElements
;
355 VSPropGetType propGetType
;
356 VSPropGetInt propGetInt
;
357 VSPropGetFloat propGetFloat
;
358 VSPropGetData propGetData
;
359 VSPropGetDataSize propGetDataSize
;
360 VSPropGetNode propGetNode
;
361 VSPropGetFrame propGetFrame
;
362 VSPropGetFunc propGetFunc
;
364 VSPropDeleteKey propDeleteKey
;
365 VSPropSetInt propSetInt
;
366 VSPropSetFloat propSetFloat
;
367 VSPropSetData propSetData
;
368 VSPropSetNode propSetNode
;
369 VSPropSetFrame propSetFrame
;
370 VSPropSetFunc propSetFunc
;
372 VSSetMaxCacheSize setMaxCacheSize
;
373 VSGetOutputIndex getOutputIndex
;
374 VSNewVideoFrame2 newVideoFrame2
;
376 VSSetMessageHandler setMessageHandler
;
379 VS_API(const VSAPI
*) getVapourSynthAPI(int version
);
381 #endif // VAPOURSYNTH_H