1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
use std::os::raw::*;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSFrameRef {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSNodeRef {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSCore {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSPlugin {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSNode {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSFuncRef {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSMap {
    _unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSFrameContext {
    _unused: [u8; 0],
}
#[allow(clippy::unreadable_literal)]
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSColorFamily {
    cmGray = 1000000,
    cmRGB = 2000000,
    cmYUV = 3000000,
    cmYCoCg = 4000000,
    cmCompat = 9000000,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSSampleType {
    stInteger = 0,
    stFloat = 1,
}
#[allow(clippy::unreadable_literal)]
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSPresetFormat {
    pfNone = 0,
    pfGray8 = 1000010,
    pfGray16 = 1000011,
    pfGrayH = 1000012,
    pfGrayS = 1000013,
    pfYUV420P8 = 3000010,
    pfYUV422P8 = 3000011,
    pfYUV444P8 = 3000012,
    pfYUV410P8 = 3000013,
    pfYUV411P8 = 3000014,
    pfYUV440P8 = 3000015,
    pfYUV420P9 = 3000016,
    pfYUV422P9 = 3000017,
    pfYUV444P9 = 3000018,
    pfYUV420P10 = 3000019,
    pfYUV422P10 = 3000020,
    pfYUV444P10 = 3000021,
    pfYUV420P16 = 3000022,
    pfYUV422P16 = 3000023,
    pfYUV444P16 = 3000024,
    pfYUV444PH = 3000025,
    pfYUV444PS = 3000026,
    pfYUV420P12 = 3000027,
    pfYUV422P12 = 3000028,
    pfYUV444P12 = 3000029,
    pfYUV420P14 = 3000030,
    pfYUV422P14 = 3000031,
    pfYUV444P14 = 3000032,
    pfRGB24 = 2000010,
    pfRGB27 = 2000011,
    pfRGB30 = 2000012,
    pfRGB48 = 2000013,
    pfRGBH = 2000014,
    pfRGBS = 2000015,
    pfCompatBGR32 = 9000010,
    pfCompatYUY2 = 9000011,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSFilterMode {
    fmParallel = 100,
    fmParallelRequests = 200,
    fmUnordered = 300,
    fmSerial = 400,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSFormat {
    pub name: [c_char; 32usize],
    pub id: c_int,
    pub colorFamily: c_int,
    pub sampleType: c_int,
    pub bitsPerSample: c_int,
    pub bytesPerSample: c_int,
    pub subSamplingW: c_int,
    pub subSamplingH: c_int,
    pub numPlanes: c_int,
}
pub const VSNodeFlags_nfNoCache: VSNodeFlags = VSNodeFlags(1);
pub const VSNodeFlags_nfIsCache: VSNodeFlags = VSNodeFlags(2);
#[cfg(feature = "gte-vapoursynth-api-33")]
pub const VSNodeFlags_nfMakeLinear: VSNodeFlags = VSNodeFlags(4);
impl ::std::ops::BitOr<VSNodeFlags> for VSNodeFlags {
    type Output = Self;
    #[inline]
    fn bitor(self, other: Self) -> Self {
        VSNodeFlags(self.0 | other.0)
    }
}
impl ::std::ops::BitOrAssign for VSNodeFlags {
    #[inline]
    fn bitor_assign(&mut self, rhs: VSNodeFlags) {
        self.0 |= rhs.0;
    }
}
impl ::std::ops::BitAnd<VSNodeFlags> for VSNodeFlags {
    type Output = Self;
    #[inline]
    fn bitand(self, other: Self) -> Self {
        VSNodeFlags(self.0 & other.0)
    }
}
impl ::std::ops::BitAndAssign for VSNodeFlags {
    #[inline]
    fn bitand_assign(&mut self, rhs: VSNodeFlags) {
        self.0 &= rhs.0;
    }
}
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct VSNodeFlags(pub c_int);
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSPropTypes {
    ptUnset = 117,
    ptInt = 105,
    ptFloat = 102,
    ptData = 115,
    ptNode = 99,
    ptFrame = 118,
    ptFunction = 109,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSGetPropErrors {
    peUnset = 1,
    peType = 2,
    peIndex = 4,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSPropAppendMode {
    paReplace = 0,
    paAppend = 1,
    paTouch = 2,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSCoreInfo {
    pub versionString: *const c_char,
    pub core: c_int,
    pub api: c_int,
    pub numThreads: c_int,
    pub maxFramebufferSize: i64,
    pub usedFramebufferSize: i64,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSVideoInfo {
    pub format: *const VSFormat,
    pub fpsNum: i64,
    pub fpsDen: i64,
    pub width: c_int,
    pub height: c_int,
    pub numFrames: c_int,
    pub flags: c_int,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSActivationReason {
    arInitial = 0,
    arFrameReady = 1,
    arAllFramesReady = 2,
    arError = -1,
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSMessageType {
    mtDebug = 0,
    mtWarning = 1,
    mtCritical = 2,
    mtFatal = 3,
}
pub type VSPublicFunction = unsafe extern "system" fn(
    in_: *const VSMap,
    out: *mut VSMap,
    userData: *mut c_void,
    core: *mut VSCore,
    vsapi: *const VSAPI,
);
pub type VSRegisterFunction = unsafe extern "system" fn(
    name: *const c_char,
    args: *const c_char,
    argsFunc: VSPublicFunction,
    functionData: *mut c_void,
    plugin: *mut VSPlugin,
);
pub type VSConfigPlugin = unsafe extern "system" fn(
    identifier: *const c_char,
    defaultNamespace: *const c_char,
    name: *const c_char,
    apiVersion: c_int,
    readonly: c_int,
    plugin: *mut VSPlugin,
);
pub type VSInitPlugin = Option<
    unsafe extern "system" fn(
        configFunc: VSConfigPlugin,
        registerFunc: VSRegisterFunction,
        plugin: *mut VSPlugin,
    ),
>;
pub type VSFreeFuncData = Option<unsafe extern "system" fn(userData: *mut c_void)>;
pub type VSFilterInit = unsafe extern "system" fn(
    in_: *mut VSMap,
    out: *mut VSMap,
    instanceData: *mut *mut c_void,
    node: *mut VSNode,
    core: *mut VSCore,
    vsapi: *const VSAPI,
);
pub type VSFilterGetFrame = unsafe extern "system" fn(
    n: c_int,
    activationReason: c_int,
    instanceData: *mut *mut c_void,
    frameData: *mut *mut c_void,
    frameCtx: *mut VSFrameContext,
    core: *mut VSCore,
    vsapi: *const VSAPI,
) -> *const VSFrameRef;
pub type VSFilterFree = Option<
    unsafe extern "system" fn(instanceData: *mut c_void, core: *mut VSCore, vsapi: *const VSAPI),
>;
pub type VSFrameDoneCallback = Option<
    unsafe extern "system" fn(
        userData: *mut c_void,
        f: *const VSFrameRef,
        n: c_int,
        arg1: *mut VSNodeRef,
        errorMsg: *const c_char,
    ),
>;
pub type VSMessageHandler =
    Option<unsafe extern "system" fn(msgType: c_int, msg: *const c_char, userData: *mut c_void)>;
#[cfg(feature = "gte-vapoursynth-api-36")]
pub type VSMessageHandlerFree = Option<unsafe extern "system" fn(userData: *mut c_void)>;
#[cfg(feature = "gte-vapoursynth-api-36")]
pub type VSMessageHandlerId = c_int;
#[repr(C)]
#[derive(Copy, Clone)]
pub struct VSAPI {
    pub createCore: unsafe extern "system" fn(threads: c_int) -> *mut VSCore,
    pub freeCore: unsafe extern "system" fn(core: *mut VSCore),
    #[cfg_attr(
        feature = "gte-vapoursynth-api-36",
        deprecated(note = "use `getCoreInfo2` instead")
    )]
    pub getCoreInfo: unsafe extern "system" fn(core: *mut VSCore) -> *const VSCoreInfo,
    pub cloneFrameRef: unsafe extern "system" fn(f: *const VSFrameRef) -> *const VSFrameRef,
    pub cloneNodeRef: unsafe extern "system" fn(node: *mut VSNodeRef) -> *mut VSNodeRef,
    pub cloneFuncRef: unsafe extern "system" fn(f: *mut VSFuncRef) -> *mut VSFuncRef,
    pub freeFrame: unsafe extern "system" fn(f: *const VSFrameRef),
    pub freeNode: unsafe extern "system" fn(node: *mut VSNodeRef),
    pub freeFunc: unsafe extern "system" fn(f: *mut VSFuncRef),
    pub newVideoFrame: unsafe extern "system" fn(
        format: *const VSFormat,
        width: c_int,
        height: c_int,
        propSrc: *const VSFrameRef,
        core: *mut VSCore,
    ) -> *mut VSFrameRef,
    pub copyFrame:
        unsafe extern "system" fn(f: *const VSFrameRef, core: *mut VSCore) -> *mut VSFrameRef,
    pub copyFrameProps:
        unsafe extern "system" fn(src: *const VSFrameRef, dst: *mut VSFrameRef, core: *mut VSCore),
    pub registerFunction: unsafe extern "system" fn(
        name: *const c_char,
        args: *const c_char,
        argsFunc: VSPublicFunction,
        functionData: *mut c_void,
        plugin: *mut VSPlugin,
    ),
    pub getPluginById:
        unsafe extern "system" fn(identifier: *const c_char, core: *mut VSCore) -> *mut VSPlugin,
    pub getPluginByNs:
        unsafe extern "system" fn(ns: *const c_char, core: *mut VSCore) -> *mut VSPlugin,
    pub getPlugins: unsafe extern "system" fn(core: *mut VSCore) -> *mut VSMap,
    pub getFunctions: unsafe extern "system" fn(plugin: *mut VSPlugin) -> *mut VSMap,
    #[allow(clippy::type_complexity)]
    pub createFilter: unsafe extern "system" fn(
        in_: *const VSMap,
        out: *mut VSMap,
        name: *const c_char,
        init: VSFilterInit,
        getFrame: VSFilterGetFrame,
        free: VSFilterFree,
        filterMode: c_int,
        flags: c_int,
        instanceData: *mut c_void,
        core: *mut VSCore,
    ),
    pub setError: unsafe extern "system" fn(map: *mut VSMap, errorMessage: *const c_char),
    pub getError: unsafe extern "system" fn(map: *const VSMap) -> *const c_char,
    pub setFilterError:
        unsafe extern "system" fn(errorMessage: *const c_char, frameCtx: *mut VSFrameContext),
    pub invoke: unsafe extern "system" fn(
        plugin: *mut VSPlugin,
        name: *const c_char,
        args: *const VSMap,
    ) -> *mut VSMap,
    pub getFormatPreset: unsafe extern "system" fn(id: c_int, core: *mut VSCore) -> *const VSFormat,
    pub registerFormat: unsafe extern "system" fn(
        colorFamily: c_int,
        sampleType: c_int,
        bitsPerSample: c_int,
        subSamplingW: c_int,
        subSamplingH: c_int,
        core: *mut VSCore,
    ) -> *const VSFormat,
    pub getFrame: unsafe extern "system" fn(
        n: c_int,
        node: *mut VSNodeRef,
        errorMsg: *mut c_char,
        bufSize: c_int,
    ) -> *const VSFrameRef,
    pub getFrameAsync: unsafe extern "system" fn(
        n: c_int,
        node: *mut VSNodeRef,
        callback: VSFrameDoneCallback,
        userData: *mut c_void,
    ),
    pub getFrameFilter: unsafe extern "system" fn(
        n: c_int,
        node: *mut VSNodeRef,
        frameCtx: *mut VSFrameContext,
    ) -> *const VSFrameRef,
    pub requestFrameFilter:
        unsafe extern "system" fn(n: c_int, node: *mut VSNodeRef, frameCtx: *mut VSFrameContext),
    pub queryCompletedFrame: unsafe extern "system" fn(
        node: *mut *mut VSNodeRef,
        n: *mut c_int,
        frameCtx: *mut VSFrameContext,
    ),
    pub releaseFrameEarly:
        unsafe extern "system" fn(node: *mut VSNodeRef, n: c_int, frameCtx: *mut VSFrameContext),
    pub getStride: unsafe extern "system" fn(f: *const VSFrameRef, plane: c_int) -> c_int,
    pub getReadPtr: unsafe extern "system" fn(f: *const VSFrameRef, plane: c_int) -> *const u8,
    pub getWritePtr: unsafe extern "system" fn(f: *mut VSFrameRef, plane: c_int) -> *mut u8,
    pub createFunc: unsafe extern "system" fn(
        func: VSPublicFunction,
        userData: *mut c_void,
        free: VSFreeFuncData,
        core: *mut VSCore,
        vsapi: *const VSAPI,
    ) -> *mut VSFuncRef,
    pub callFunc: unsafe extern "system" fn(
        func: *mut VSFuncRef,
        in_: *const VSMap,
        out: *mut VSMap,
        core: *mut VSCore,
        vsapi: *const VSAPI,
    ),
    pub createMap: unsafe extern "system" fn() -> *mut VSMap,
    pub freeMap: unsafe extern "system" fn(map: *mut VSMap),
    pub clearMap: unsafe extern "system" fn(map: *mut VSMap),
    pub getVideoInfo: unsafe extern "system" fn(node: *mut VSNodeRef) -> *const VSVideoInfo,
    pub setVideoInfo:
        unsafe extern "system" fn(vi: *const VSVideoInfo, numOutputs: c_int, node: *mut VSNode),
    pub getFrameFormat: unsafe extern "system" fn(f: *const VSFrameRef) -> *const VSFormat,
    pub getFrameWidth: unsafe extern "system" fn(f: *const VSFrameRef, plane: c_int) -> c_int,
    pub getFrameHeight: unsafe extern "system" fn(f: *const VSFrameRef, plane: c_int) -> c_int,
    pub getFramePropsRO: unsafe extern "system" fn(f: *const VSFrameRef) -> *const VSMap,
    pub getFramePropsRW: unsafe extern "system" fn(f: *mut VSFrameRef) -> *mut VSMap,
    pub propNumKeys: unsafe extern "system" fn(map: *const VSMap) -> c_int,
    pub propGetKey: unsafe extern "system" fn(map: *const VSMap, index: c_int) -> *const c_char,
    pub propNumElements: unsafe extern "system" fn(map: *const VSMap, key: *const c_char) -> c_int,
    pub propGetType: unsafe extern "system" fn(map: *const VSMap, key: *const c_char) -> c_char,
    pub propGetInt: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> i64,
    pub propGetFloat: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> f64,
    pub propGetData: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> *const c_char,
    pub propGetDataSize: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> c_int,
    pub propGetNode: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> *mut VSNodeRef,
    pub propGetFrame: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> *const VSFrameRef,
    pub propGetFunc: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        index: c_int,
        error: *mut c_int,
    ) -> *mut VSFuncRef,
    pub propDeleteKey: unsafe extern "system" fn(map: *mut VSMap, key: *const c_char) -> c_int,
    pub propSetInt: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        i: i64,
        append: c_int,
    ) -> c_int,
    pub propSetFloat: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        d: f64,
        append: c_int,
    ) -> c_int,
    pub propSetData: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        data: *const c_char,
        size: c_int,
        append: c_int,
    ) -> c_int,
    pub propSetNode: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        node: *mut VSNodeRef,
        append: c_int,
    ) -> c_int,
    pub propSetFrame: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        f: *const VSFrameRef,
        append: c_int,
    ) -> c_int,
    pub propSetFunc: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        func: *mut VSFuncRef,
        append: c_int,
    ) -> c_int,
    pub setMaxCacheSize: unsafe extern "system" fn(bytes: i64, core: *mut VSCore) -> i64,
    pub getOutputIndex: unsafe extern "system" fn(frameCtx: *mut VSFrameContext) -> c_int,
    pub newVideoFrame2: unsafe extern "system" fn(
        format: *const VSFormat,
        width: c_int,
        height: c_int,
        planeSrc: *mut *const VSFrameRef,
        planes: *const c_int,
        propSrc: *const VSFrameRef,
        core: *mut VSCore,
    ) -> *mut VSFrameRef,
    #[cfg_attr(
        feature = "gte-vapoursynth-api-36",
        deprecated(note = "use `addMessageHandler` and `removeMessageHandler` instead")
    )]
    pub setMessageHandler:
        unsafe extern "system" fn(handler: VSMessageHandler, userData: *mut c_void),
    pub setThreadCount: unsafe extern "system" fn(threads: c_int, core: *mut VSCore) -> c_int,
    pub getPluginPath: unsafe extern "system" fn(plugin: *const VSPlugin) -> *const c_char,

    #[cfg(feature = "gte-vapoursynth-api-31")]
    pub propGetIntArray: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        error: *mut c_int,
    ) -> *const i64,
    #[cfg(feature = "gte-vapoursynth-api-31")]
    pub propGetFloatArray: unsafe extern "system" fn(
        map: *const VSMap,
        key: *const c_char,
        error: *mut c_int,
    ) -> *const f64,
    #[cfg(feature = "gte-vapoursynth-api-31")]
    pub propSetIntArray: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        i: *const i64,
        size: c_int,
    ) -> c_int,
    #[cfg(feature = "gte-vapoursynth-api-31")]
    pub propSetFloatArray: unsafe extern "system" fn(
        map: *mut VSMap,
        key: *const c_char,
        d: *const f64,
        size: c_int,
    ) -> c_int,
    #[cfg(feature = "gte-vapoursynth-api-34")]
    pub logMessage: unsafe extern "system" fn(msgType: c_int, msg: *const c_char),
    #[cfg(feature = "gte-vapoursynth-api-36")]
    pub addMessageHandler: unsafe extern "system" fn(
        handler: VSMessageHandler,
        free: VSMessageHandlerFree,
        userData: *mut c_void,
    ) -> VSMessageHandlerId,
    #[cfg(feature = "gte-vapoursynth-api-36")]
    pub removeMessageHandler: unsafe extern "system" fn(id: VSMessageHandlerId) -> c_int,
    #[cfg(feature = "gte-vapoursynth-api-36")]
    pub getCoreInfo2: unsafe extern "system" fn(core: *mut VSCore, info: *mut VSCoreInfo),
}

#[cfg(feature = "vapoursynth-functions")]
extern "system" {
    pub fn getVapourSynthAPI(version: c_int) -> *const VSAPI;
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct VSScript {
    _unused: [u8; 0],
}
#[repr(i32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum VSEvalFlags {
    efSetWorkingDir = 1,
}

#[cfg(feature = "vsscript-functions")]
extern "system" {
    #[cfg(feature = "gte-vsscript-api-31")]
    pub fn vsscript_getApiVersion() -> c_int;
    pub fn vsscript_init() -> c_int;
    pub fn vsscript_finalize() -> c_int;
    pub fn vsscript_evaluateScript(
        handle: *mut *mut VSScript,
        script: *const c_char,
        scriptFilename: *const c_char,
        flags: c_int,
    ) -> c_int;
    pub fn vsscript_evaluateFile(
        handle: *mut *mut VSScript,
        scriptFilename: *const c_char,
        flags: c_int,
    ) -> c_int;
    pub fn vsscript_createScript(handle: *mut *mut VSScript) -> c_int;
    pub fn vsscript_freeScript(handle: *mut VSScript);
    pub fn vsscript_getError(handle: *mut VSScript) -> *const c_char;
    pub fn vsscript_getOutput(handle: *mut VSScript, index: c_int) -> *mut VSNodeRef;
    #[cfg(feature = "gte-vsscript-api-31")]
    pub fn vsscript_getOutput2(
        handle: *mut VSScript,
        index: c_int,
        alpha: *mut *mut VSNodeRef,
    ) -> *mut VSNodeRef;
    pub fn vsscript_clearOutput(handle: *mut VSScript, index: c_int) -> c_int;
    pub fn vsscript_getCore(handle: *mut VSScript) -> *mut VSCore;
    pub fn vsscript_getVSApi() -> *const VSAPI;
    #[cfg(feature = "gte-vsscript-api-32")]
    pub fn vsscript_getVSApi2(version: c_int) -> *const VSAPI;
    pub fn vsscript_getVariable(
        handle: *mut VSScript,
        name: *const c_char,
        dst: *mut VSMap,
    ) -> c_int;
    pub fn vsscript_setVariable(handle: *mut VSScript, vars: *const VSMap) -> c_int;
    pub fn vsscript_clearVariable(handle: *mut VSScript, name: *const c_char) -> c_int;
    pub fn vsscript_clearEnvironment(handle: *mut VSScript);
}