vapoursynth4_sys/
vs.rs

1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7// VapourSynth4.h
8//! This is `VapourSynth`'s main header file.
9//! Plugins and applications that use the library must include it.
10//!
11//! `VapourSynth`'s public API is all C.
12
13use std::ffi::{c_char, c_double, c_float, c_int, c_void};
14
15use super::{opaque_struct, vs_make_version};
16
17/// Major API version.
18pub const VAPOURSYNTH_API_MAJOR: u16 = 4;
19/// Minor API version. It is bumped when new functions are added to [`VSAPI`]
20/// or core behavior is noticeably changed.
21pub const VAPOURSYNTH_API_MINOR: u16 = if cfg!(feature = "vs-41") { 1 } else { 0 };
22/// API version. The high 16 bits are [`VAPOURSYNTH_API_MAJOR`], the low 16 bits are
23/// [`VAPOURSYNTH_API_MINOR`].
24pub const VAPOURSYNTH_API_VERSION: i32 =
25    vs_make_version(VAPOURSYNTH_API_MAJOR, VAPOURSYNTH_API_MINOR);
26
27/// The number of audio samples in an audio frame. It is a static number to
28/// make it possible to calculate which audio frames are needed to retrieve specific samples.
29pub const VS_AUDIO_FRAME_SAMPLES: i32 = 3072;
30
31opaque_struct!(
32    /// A frame that can hold audio or video data.
33    ///
34    /// Each row of pixels in a frame is guaranteed to have an alignment of at least 32 bytes.
35    /// Two frames with the same width and bytes per sample are guaranteed to have the same stride.
36    ///
37    /// Audio data is also guaranteed to be at least 32 byte aligned.
38    ///
39    /// Any data can be attached to a frame, using a VSMap.
40    VSFrame,
41    /// A reference to a node in the constructed filter graph. Its primary use is as an argument
42    /// to other filter or to request frames from.
43    VSNode,
44    /// The core represents one instance of VapourSynth.
45    /// Every core individually loads plugins and keeps track of memory.
46    VSCore,
47    /// A VapourSynth plugin. There are a few of these built into the core,
48    /// and therefore available at all times: the basic filters (identifier `com.vapoursynth.std`,
49    /// namespace `std`), the resizers (identifier `com.vapoursynth.resize`, namespace `resize`),
50    /// and the Avisynth compatibility module, if running in Windows
51    /// (identifier `com.vapoursynth.avisynth`, namespace `avs`).
52    ///
53    /// The Function Reference describes how to load VapourSynth and Avisynth plugins.
54    ///
55    /// A [`VSPlugin`] instance is constructed by the core when loading a plugin
56    /// (.so / .dylib / .dll), and the pointer is passed to the plugin's
57    /// `VapourSynthPluginInit2()` function.
58    ///
59    /// A VapourSynth plugin can export any number of filters.
60    ///
61    /// Plugins have a few attributes:
62    ///
63    /// - An identifier, which must be unique among all VapourSynth plugins in existence,
64    ///   because this is what the core uses to make sure a plugin only gets loaded once.
65    /// - A namespace, also unique. The filters exported by a plugin end up
66    ///     in the plugin's namespace.
67    /// - A full name, which is used by the core in a few error messages.
68    /// - The version of the plugin.
69    /// - The VapourSynth API version the plugin requires.
70    /// - A file name.
71    ///
72    /// Things you can do with a [`VSPlugin`]:
73    ///
74    /// - Enumerate all the filters it exports, using
75    ///   [`getNextPluginFunction()`](VSAPI::getNextPluginFunction).
76    /// - Invoke one of its filters, using [`invoke()`](VSAPI::invoke).
77    /// - Get its location in the file system, using [`getPluginPath()`](VSAPI::getPluginPath).
78    ///
79    /// All loaded plugins (including built-in) can be enumerated with
80    /// [`getNextPlugin()`](VSAPI::getNextPlugin).
81    ///
82    /// Once loaded, a plugin only gets unloaded when the VapourSynth core is freed.
83    VSPlugin,
84    /// A function belonging to a Vapoursynth plugin. This object primarily exists
85    /// so a plugin's name, argument list and return type can be queried by editors.
86    ///
87    /// One peculiarity is that plugin functions cannot be invoked using a
88    /// [`VSPluginFunction`] pointer but is instead done using [`invoke()`](VSAPI::invoke)
89    /// which takes a [`VSPlugin`] and the function name as a string.
90    VSPluginFunction,
91    /// Holds a reference to a function that may be called.
92    /// This type primarily exists so functions can be shared between
93    /// the scripting layer and plugins in the core.
94    VSFunction,
95    /// [`VSMap`] is a container that stores (key, value) pairs.
96    /// The keys are strings and the values can be (arrays of) integers,
97    /// floating point numbers, arrays of bytes, [`VSNode`], [`VSFrame`], or [`VSFunction`].
98    ///
99    /// The pairs in a [`VSMap`] are sorted by key.
100    ///
101    /// **In VapourSynth, [`VSMap`]s have several uses:**
102    /// - storing filters' arguments and return values
103    /// - storing user-defined functions' arguments and return values
104    /// - storing the properties attached to frames
105    ///
106    /// Only alphanumeric characters and the underscore may be used in keys.
107    ///
108    /// Creating and destroying a map can be done with [`createMap()`](VSAPI::createMap) and
109    /// [`freeMap()`](VSAPI::freeMap), respectively.
110    ///
111    /// A map's contents can be retrieved and modified using a number of functions,
112    /// all prefixed with "map".
113    ///
114    /// A map's contents can be erased with [`clearMap()`](VSAPI::clearMap).
115    VSMap,
116    /// Opaque type representing a registered logger.
117    VSLogHandle,
118    /// Opaque type representing the current frame request in a filter.
119    VSFrameContext
120);
121
122#[repr(C)]
123#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
124pub enum VSColorFamily {
125    Undefined = 0,
126    Gray = 1,
127    RGB = 2,
128    YUV = 3,
129}
130
131#[repr(C)]
132#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
133pub enum VSSampleType {
134    Integer = 0,
135    Float = 1,
136}
137
138const fn vs_make_video_id(
139    color_family: VSColorFamily,
140    sample_type: VSSampleType,
141    bits_per_sample: isize,
142    sub_sampling_w: isize,
143    sub_sampling_h: isize,
144) -> isize {
145    ((color_family as isize) << 28)
146        | ((sample_type as isize) << 24)
147        | (bits_per_sample << 16)
148        | (sub_sampling_w << 8)
149        | sub_sampling_h
150}
151
152use VSColorFamily::{Gray, RGB, YUV};
153use VSSampleType::{Float, Integer};
154
155/// The presets suffixed with H and S have floating point sample type.
156/// The H and S suffixes stand for half precision and single precision, respectively.
157/// All formats are planar.
158#[repr(C)]
159#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
160pub enum VSPresetVideoFormat {
161    None = 0,
162
163    Gray8 = vs_make_video_id(Gray, Integer, 8, 0, 0),
164    Gray9 = vs_make_video_id(Gray, Integer, 9, 0, 0),
165    Gray10 = vs_make_video_id(Gray, Integer, 10, 0, 0),
166    Gray12 = vs_make_video_id(Gray, Integer, 12, 0, 0),
167    Gray14 = vs_make_video_id(Gray, Integer, 14, 0, 0),
168    Gray16 = vs_make_video_id(Gray, Integer, 16, 0, 0),
169    Gray32 = vs_make_video_id(Gray, Integer, 32, 0, 0),
170
171    GrayH = vs_make_video_id(Gray, Float, 16, 0, 0),
172    GrayS = vs_make_video_id(Gray, Float, 32, 0, 0),
173
174    YUV410P8 = vs_make_video_id(YUV, Integer, 8, 2, 2),
175    YUV411P8 = vs_make_video_id(YUV, Integer, 8, 2, 0),
176    YUV440P8 = vs_make_video_id(YUV, Integer, 8, 0, 1),
177
178    YUV420P8 = vs_make_video_id(YUV, Integer, 8, 1, 1),
179    YUV422P8 = vs_make_video_id(YUV, Integer, 8, 1, 0),
180    YUV444P8 = vs_make_video_id(YUV, Integer, 8, 0, 0),
181
182    YUV420P9 = vs_make_video_id(YUV, Integer, 9, 1, 1),
183    YUV422P9 = vs_make_video_id(YUV, Integer, 9, 1, 0),
184    YUV444P9 = vs_make_video_id(YUV, Integer, 9, 0, 0),
185
186    YUV420P10 = vs_make_video_id(YUV, Integer, 10, 1, 1),
187    YUV422P10 = vs_make_video_id(YUV, Integer, 10, 1, 0),
188    YUV444P10 = vs_make_video_id(YUV, Integer, 10, 0, 0),
189
190    YUV420P12 = vs_make_video_id(YUV, Integer, 12, 1, 1),
191    YUV422P12 = vs_make_video_id(YUV, Integer, 12, 1, 0),
192    YUV444P12 = vs_make_video_id(YUV, Integer, 12, 0, 0),
193
194    YUV420P14 = vs_make_video_id(YUV, Integer, 14, 1, 1),
195    YUV422P14 = vs_make_video_id(YUV, Integer, 14, 1, 0),
196    YUV444P14 = vs_make_video_id(YUV, Integer, 14, 0, 0),
197
198    YUV420P16 = vs_make_video_id(YUV, Integer, 16, 1, 1),
199    YUV422P16 = vs_make_video_id(YUV, Integer, 16, 1, 0),
200    YUV444P16 = vs_make_video_id(YUV, Integer, 16, 0, 0),
201
202    YUV420PH = vs_make_video_id(YUV, Float, 16, 1, 1),
203    YUV420PS = vs_make_video_id(YUV, Float, 32, 1, 1),
204    YUV422PH = vs_make_video_id(YUV, Float, 16, 1, 0),
205    YUV422PS = vs_make_video_id(YUV, Float, 32, 1, 0),
206    YUV444PH = vs_make_video_id(YUV, Float, 16, 0, 0),
207    YUV444PS = vs_make_video_id(YUV, Float, 32, 0, 0),
208
209    RGB24 = vs_make_video_id(RGB, Integer, 8, 0, 0),
210    RGB27 = vs_make_video_id(RGB, Integer, 9, 0, 0),
211    RGB30 = vs_make_video_id(RGB, Integer, 10, 0, 0),
212    RGB36 = vs_make_video_id(RGB, Integer, 12, 0, 0),
213    RGB42 = vs_make_video_id(RGB, Integer, 14, 0, 0),
214    RGB48 = vs_make_video_id(RGB, Integer, 16, 0, 0),
215
216    RGBH = vs_make_video_id(RGB, Float, 16, 0, 0),
217    RGBS = vs_make_video_id(RGB, Float, 32, 0, 0),
218}
219
220/// Controls how a filter will be multithreaded, if at all.
221#[repr(C)]
222#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
223pub enum VSFilterMode {
224    /// Completely parallel execution. Multiple threads will call a filter's "getFrame" function,
225    /// to fetch several frames in parallel.
226    Parallel = 0,
227    /// For filters that are serial in nature but can request in advance one or more frames
228    /// they need. A filter's "getFrame" function will be called from multiple threads at a time
229    /// with activation reason [`VSActivationReason::Initial`],
230    /// but only one thread will call it with activation reason
231    /// [`VSActivationReason::AllFramesReady`] at a time.
232    ParallelRequests = 1,
233    /// Only one thread can call the filter's "getFrame" function at a time.
234    /// Useful for filters that modify or examine their internal state to
235    /// determine which frames to request.
236    ///
237    /// While the "getFrame" function will only run in one thread at a time,
238    /// the calls can happen in any order. For example, it can be called with reason
239    /// [`VSActivationReason::Initial`] for frame 0, then again with reason
240    /// [`VSActivationReason::Initial`] for frame 1,
241    /// then with reason [`VSActivationReason::AllFramesReady`]  for frame 0.
242    Unordered = 2,
243    /// For compatibility with other filtering architectures.
244    /// *DO NOT USE IN NEW FILTERS*. The filter's "getFrame" function only ever gets called from
245    /// one thread at a time. Unlike [`Unordered`](VSFilterMode::Unordered),
246    /// only one frame is processed at a time.
247    FrameState = 3,
248}
249
250/// Used to indicate the type of a [`VSFrame`] or [`VSNode`] object.
251#[repr(C)]
252#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
253pub enum VSMediaType {
254    Video = 1,
255    Audio = 2,
256}
257
258/// Describes the format of a clip.
259///
260/// Use [`queryVideoFormat()`](VSAPI::queryVideoFormat) to fill it in with proper error checking.
261/// Manually filling out the struct is allowed but discouraged
262/// since illegal combinations of values will cause undefined behavior.
263#[repr(C)]
264#[derive(Clone, Eq, PartialEq, Hash, Debug)]
265pub struct VSVideoFormat {
266    /// See [`VSColorFamily`].
267    pub color_family: VSColorFamily,
268    /// See [`VSSampleType`].
269    pub sample_type: VSSampleType,
270    /// Number of significant bits.
271    pub bits_per_sample: c_int,
272    /// Number of bytes needed for a sample. This is always a power of 2 and the smallest possible
273    /// that can fit the number of bits used per sample.
274    pub bytes_per_sample: c_int,
275
276    /// log2 subsampling factor, applied to second and third plane
277    pub sub_sampling_w: c_int,
278    /// log2 subsampling factor, applied to second and third plane.
279    ///
280    /// Convenient numbers that can be used like so:
281    /// ```py
282    /// uv_width = y_width >> subSamplingW;
283    /// ```
284    pub sub_sampling_h: c_int,
285
286    /// Number of planes, implicit from colorFamily
287    pub num_planes: c_int,
288}
289
290/// Audio channel positions as an enum. Mirrors the `FFmpeg` audio channel constants
291/// in older api versions.
292#[repr(C)]
293#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
294pub enum VSAudioChannels {
295    FrontLeft = 0,
296    FrontRight = 1,
297    FrontCenter = 2,
298    LowFrequency = 3,
299    BackLeft = 4,
300    BackRight = 5,
301    FrontLeftOFCenter = 6,
302    FrontRightOFCenter = 7,
303    BackCenter = 8,
304    SideLeft = 9,
305    SideRight = 10,
306    TopCenter = 11,
307    TopFrontLeft = 12,
308    TopFrontCenter = 13,
309    TopFrontRight = 14,
310    TopBackLeft = 15,
311    TopBackCenter = 16,
312    TopBackRight = 17,
313    StereoLeft = 29,
314    StereoRight = 30,
315    WideLeft = 31,
316    WideRight = 32,
317    SurroundDirectLeft = 33,
318    SurroundDirectRight = 34,
319    LowFrequency2 = 35,
320}
321
322/// Describes the format of a clip.
323///
324/// Use [`queryAudioFormat()`](VSAPI::queryAudioFormat) to fill it in with proper error checking.
325/// Manually filling out the struct is allowed but discouraged
326/// since illegal combinations of values will cause undefined behavior.
327#[repr(C)]
328#[derive(Clone, Eq, PartialEq, Hash, Debug)]
329pub struct VSAudioFormat {
330    /// See [`VSSampleType`].
331    pub sample_type: VSSampleType,
332    /// Number of significant bits.
333    pub bits_per_sample: c_int,
334    /// Number of bytes needed for a sample. This is always a power of 2 and the smallest possible
335    /// that can fit the number of bits used per sample, implicit from
336    /// [`VSAudioFormat::channel_layout`].
337    pub bytes_per_sample: c_int,
338    /// Number of audio channels, implicit from [`VSAudioFormat::bits_per_sample`]
339    pub num_channels: c_int,
340    /// A bitmask representing the channels present using the constants in 1 left shifted
341    /// by the constants in [`VSAudioChannels`].
342    pub channel_layout: u64,
343}
344
345/// Types of properties that can be stored in a [`VSMap`].
346#[repr(C)]
347#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
348pub enum VSPropertyType {
349    Unset = 0,
350    Int = 1,
351    Float = 2,
352    Data = 3,
353    Function = 4,
354    VideoNode = 5,
355    AudioNode = 6,
356    VideoFrame = 7,
357    AudioFrame = 8,
358}
359
360/// When a `mapGet*` function fails, it returns one of these in the err parameter.
361///
362/// All errors are non-zero.
363#[repr(C)]
364#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
365pub enum VSMapPropertyError {
366    Success = 0,
367    /// The requested key was not found in the map.
368    Unset = 1,
369    /// The wrong function was used to retrieve the property.
370    /// E.g. [`mapGetInt()`](VSAPI::mapGetInt) was used on a property of type
371    /// [`VSPropertyType::Float`].
372    Type = 2,
373    /// The requested index was out of bounds.
374    Index = 4,
375    /// The map has the error state set.
376    Error = 3,
377}
378
379/// Controls the behaviour of [`mapSetInt()`](VSAPI::mapSetInt) and friends.
380#[repr(C)]
381#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
382pub enum VSMapAppendMode {
383    /// All existing values associated with the key will be replaced with the new value.
384    Replace = 0,
385    /// The new value will be appended to the list of existing values associated with the key.
386    Append = 1,
387}
388
389/// Contains information about a [`VSCore`] instance.
390#[repr(C)]
391#[derive(Eq, PartialEq, Hash, Debug)]
392pub struct VSCoreInfo {
393    /// Printable string containing the name of the library, copyright notice,
394    /// core and API versions.
395    pub version_string: *const c_char,
396    /// Version of the core.
397    pub core: c_int,
398    /// Version of the API.
399    pub api: c_int,
400    /// Number of worker threads.
401    pub num_threads: c_int,
402    /// The framebuffer cache will be allowed to grow up to this size (bytes)
403    /// before memory is aggressively reclaimed.
404    pub max_framebuffer_size: i64,
405    /// Current size of the framebuffer cache, in bytes.
406    pub used_framebuffer_size: i64,
407}
408
409/// Contains information about a clip.
410#[repr(C)]
411#[derive(Clone, Eq, PartialEq, Hash, Debug)]
412pub struct VSVideoInfo {
413    /// Format of the clip. Will have [`VSVideoFormat::color_family`] set to
414    /// [`VSColorFamily::Undefined`] if the format can vary.
415    pub format: VSVideoFormat,
416    /// Numerator part of the clip's frame rate. It will be 0 if the frame rate can vary.
417    /// Should always be a reduced fraction.
418    pub fps_num: i64,
419    /// Denominator part of the clip's frame rate. It will be 0 if the frame rate can vary.
420    /// Should always be a reduced fraction.
421    pub fps_den: i64,
422    /// Width of the clip. Both width and height will be 0 if the clip's dimensions can vary.
423    pub width: c_int,
424    /// Height of the clip. Both width and height will be 0 if the clip's dimensions can vary.
425    pub height: c_int,
426    /// Length of the clip.
427    pub num_frames: c_int,
428}
429
430/// Contains information about a clip.
431#[repr(C)]
432#[derive(Clone, Eq, PartialEq, Hash, Debug)]
433pub struct VSAudioInfo {
434    /// Format of the clip. Unlike video the audio format can never change.
435    pub format: VSAudioFormat,
436    /// Sample rate.
437    pub sample_rate: c_int,
438    /// Length of the clip in audio samples.
439    pub num_samples: i64,
440    /// Length of the clip in audio frames.
441    ///
442    /// The total number of audio frames needed to hold [`Self::num_samples`],
443    /// implicit from [`Self::num_samples`] when calling
444    /// [`createAudioFilter()`](VSAPI::createAudioFilter)
445    pub num_frames: c_int,
446}
447
448/// See [`VSFilterGetFrame`].
449#[repr(C)]
450#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
451pub enum VSActivationReason {
452    Initial = 0,
453    AllFramesReady = 1,
454    Error = -1,
455}
456
457/// See [`addLogHandler()`](VSAPI::addLogHandler).
458#[repr(C)]
459#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
460pub enum VSMessageType {
461    Debug = 0,
462    Information = 1,
463    Warning = 2,
464    Critical = 3,
465    /// also terminates the process, should generally not be used by normal filters
466    Fatal = 4,
467}
468
469/// Options when creating a core.
470#[repr(C)]
471#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
472pub enum VSCoreCreationFlags {
473    /// Required to use the graph inspection api functions.
474    /// Increases memory usage due to the extra information stored.
475    EnableGraphInspection = 1,
476    /// Don't autoload any user plugins. Core plugins are always loaded.
477    DisableAutoLoading = 2,
478    /// Don't unload plugin libraries when the core is destroyed.
479    /// Due to a small amount of memory leaking every load and unload
480    /// (windows feature, not my fault) of a library,
481    /// this may help in applications with extreme amount of script reloading.
482    DisableLibraryUnloading = 4,
483}
484
485impl std::ops::BitOr for VSCoreCreationFlags {
486    type Output = c_int;
487
488    fn bitor(self, rhs: Self) -> Self::Output {
489        self as c_int | rhs as c_int
490    }
491}
492
493/// Options when loading a plugin.
494#[repr(C)]
495#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
496pub enum VSPluginConfigFlags {
497    /// Allow functions to be added to the plugin object after the plugin loading phase.
498    /// Mostly useful for Avisynth compatibility and other foreign plugin loaders.
499    Modifiable = 1,
500}
501
502impl std::ops::BitOr for VSPluginConfigFlags {
503    type Output = c_int;
504
505    fn bitor(self, rhs: Self) -> Self::Output {
506        self as c_int | rhs as c_int
507    }
508}
509
510/// Since the data type can contain both pure binary data and printable strings,
511/// the type also contains a hint for whether or not it is human readable.
512/// Generally the unknown type should be very rare and is almost only created
513/// as an artifact of API3 compatibility.
514#[repr(C)]
515#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
516pub enum VSDataTypeHint {
517    Unknown = -1,
518    Binary = 0,
519    Utf8 = 1,
520}
521
522/// Describes the upstream frame request pattern of a filter.
523#[repr(C)]
524#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
525pub enum VSRequestPattern {
526    /// Anything goes. Note that filters that may be requesting beyond the end of a
527    /// [`VSNode`] length in frames (repeating the last frame) should use
528    /// [`VSRequestPattern::General`]) and not any of the other modes.
529    General = 0,
530    /// Will only request an input frame at most once if all output frames are requested
531    /// exactly one time. This includes filters such as Trim, Reverse, `SelectEvery`.
532    NoFrameReuse = 1,
533    /// Only requests frame N to output frame N. The main difference to
534    /// [`VSRequestPattern::NoFrameReuse`] is that the requested frame
535    /// is always fixed and known ahead of time. Filter examples
536    /// Lut, Expr (conditionally, see [`VSRequestPattern::General`] note)
537    /// and similar.
538    StrictSpatial = 2,
539}
540
541/// Describes how the output of a node is cached.
542#[repr(C)]
543#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
544pub enum VSCacheMode {
545    /// Cache is enabled or disabled based on the reported request patterns
546    /// and number of consumers.
547    Auto = -1,
548    /// Never cache anything.
549    ForceDisable = 0,
550    /// Always use the cache.
551    ForceEnable = 1,
552}
553
554/// Core entry point
555pub type VSGetVapourSynthAPI = unsafe extern "system-unwind" fn(version: c_int) -> *const VSAPI;
556
557// SECTION - Plugin, function and filter related
558/// User-defined function called by the core to create an instance of the filter.
559/// This function is often named `fooCreate`.
560///
561/// In this function, the filter's input parameters should be retrieved and validated,
562/// the filter's private instance data should be initialised, and
563/// [`createAudioFilter()`](VSAPI::createAudioFilter) or
564/// [`createVideoFilter()`](VSAPI::createVideoFilter) should be called.
565/// This is where the filter should perform any other initialisation it requires.
566///
567/// If for some reason you cannot create the filter, you have to free any created node references
568/// using [`freeNode()`](VSAPI::freeNode), call [`mapSetError()`](VSAPI::mapSetError) on `out`,
569/// and return.
570///
571/// # Arguments
572///
573/// * `in` - Input parameter list.
574///
575///     Use [`mapGetInt()`](VSAPI::mapGetInt) and friends to retrieve a parameter value.
576///
577///     The map is guaranteed to exist only until the filter's "init" function returns.
578///     In other words, pointers returned by [`mapGetData()`](VSAPI::mapGetData)
579///     will not be usable in the filter's "getFrame" and "free" functions.
580///
581/// * `out` - Output parameter list. [`createAudioFilter()`](VSAPI::createAudioFilter) or
582///     [`createVideoFilter()`](VSAPI::createVideoFilter) will add the output node(s)
583///     with the key named "clip", or an error, if something went wrong.
584///
585/// * `userData` - Pointer that was passed to [`registerFunction()`](VSAPI::registerFunction).
586pub type VSPublicFunction = unsafe extern "system-unwind" fn(
587    in_: *const VSMap,
588    out: *mut VSMap,
589    userData: *mut c_void,
590    core: *mut VSCore,
591    vsapi: *const VSAPI,
592);
593/// A plugin's entry point. It must be called `VapourSynthPluginInit2`.
594/// This function is called after the core loads the shared library.
595/// Its purpose is to configure the plugin and to register the filters the plugin wants to export.
596///
597/// # Arguments
598///
599/// * `plugin` - A pointer to the plugin object to be initialized.
600/// * `vspapi` - A pointer to a [`VSPLUGINAPI`] struct with a subset of the `VapourSynth` API
601///     used for initializing plugins. The proper way to do things is to call
602///     [`configPlugin`](VSPLUGINAPI::configPlugin) and then
603///     [`registerFunction`](VSPLUGINAPI::registerFunction) for each function to export.
604pub type VSInitPlugin =
605    unsafe extern "system-unwind" fn(plugin: *mut VSPlugin, vspapi: *const VSPLUGINAPI);
606/// Free function type
607pub type VSFreeFunctionData = Option<unsafe extern "system-unwind" fn(userData: *mut c_void)>;
608/// A filter's "getFrame" function. It is called by the core when it needs the filter
609/// to generate a frame.
610///
611/// It is possible to allocate local data, persistent during the multiple calls
612/// requesting the output frame.
613///
614/// In case of error, call [`setFilterError()`](VSAPI::setFilterError),
615/// free `*frameData` if required, and return `NULL`.
616///
617/// Depending on the [`VSFilterMode`] set for the filter, multiple output frames
618/// could be requested concurrently.
619///
620/// It is never called concurrently for the same frame number.
621///
622/// # Arguments
623///
624/// * `n` - Requested frame number.
625/// * `activationReason` - One of [`VSActivationReason`].
626///
627///     ## Note
628///
629///     This function is first called with [`VSActivationReason::Initial`].
630///     At this point the function should request the input frames it needs and return `NULL`.
631///     When one or all of the requested frames are ready, this function is called again with
632///     [`VSActivationReason::AllFramesReady`].
633///     The function should only return a frame when called with
634///     [`VSActivationReason::AllFramesReady`].
635///
636///     If a the function is called with [`VSActivationReason::Error`] all processing has
637///     to be aborted and any.
638///
639/// * `instanceData` - The filter's private instance data.
640/// * `frameData` - Optional private data associated with output frame number `n`.
641///     It must be deallocated before the last call for the given frame
642///     ([`VSActivationReason::AllFramesReady`] or error).
643///
644///     It points to a `void *[4]` array of memory that may be used freely.
645///     See filters like Splice and Trim for examples.
646///
647/// Return a reference to the output frame number n when it is ready, or `NULL`.
648/// The ownership of the frame is transferred to the caller.
649pub type VSFilterGetFrame = unsafe extern "system-unwind" fn(
650    n: c_int,
651    activationReason: VSActivationReason,
652    instanceData: *mut c_void,
653    frameData: *mut *mut c_void,
654    frameCtx: *mut VSFrameContext,
655    core: *mut VSCore,
656    vsapi: *const VSAPI,
657) -> *const VSFrame;
658/// A filter's "free" function.
659///
660/// This is where the filter should free everything it allocated, including its instance data.
661//
662/// # Arguments
663///
664/// * `instanceData` - The filter's private instance data.
665pub type VSFilterFree = Option<
666    unsafe extern "system-unwind" fn(
667        instanceData: *mut c_void,
668        core: *mut VSCore,
669        vsapi: *const VSAPI,
670    ),
671>;
672// !SECTION
673
674// SECTION - Other
675/// Function of the client application called by the core when a requested frame is ready,
676/// after a call to [`getFrameAsync()`](VSAPI::getFrameAsync).
677///
678/// If multiple frames were requested, they can be returned in any order.
679/// Client applications must take care of reordering them.
680///
681/// This function is only ever called from one thread at a time.
682///
683/// [`getFrameAsync()`](VSAPI::getFrameAsync) may be called from this function to
684/// request more frames.
685///
686/// # Arguments
687///
688/// * `userData` - Pointer to private data from the client application,
689///     as passed previously to [`getFrameAsync()`](VSAPI::getFrameAsync).
690///
691/// * `f` - Contains a reference to the generated frame, or `NULL` in case of failure.
692///     The ownership of the frame is transferred to the caller.
693///
694/// * `n` - The frame number.
695///
696/// * `node` - Node the frame belongs to.
697///
698/// * `errorMsg` - String that usually contains an error message if the frame generation failed.
699///     `NULL` if there is no error.
700pub type VSFrameDoneCallback = unsafe extern "system-unwind" fn(
701    userData: *mut c_void,
702    f: *const VSFrame,
703    n: c_int,
704    node: *mut VSNode,
705    errorMsg: *const c_char,
706);
707/// # Arguments
708///
709/// * `msgType` - The type of message. One of [`VSMessageType`].
710///
711///     If `msgType` is [`VSMessageType::Fatal`]),
712///     `VapourSynth` will call `abort()` after the message handler returns.
713///
714/// * `msg` - The message.
715pub type VSLogHandler = Option<
716    unsafe extern "system-unwind" fn(msgType: c_int, msg: *const c_char, userData: *mut c_void),
717>;
718pub type VSLogHandlerFree = Option<unsafe extern "system-unwind" fn(userData: *mut c_void)>;
719// !SECTION
720
721/// This struct is used to access `VapourSynth`'s API when a plugin is initially loaded.
722#[allow(non_snake_case)]
723#[repr(C)]
724pub struct VSPLUGINAPI {
725    /// See [`getAPIVersion()`](VSAPI::getAPIVersion) in the struct [`VSAPI`].
726    /// Returns [`VAPOURSYNTH_API_VERSION`] of the library
727    pub getAPIVersion: unsafe extern "system-unwind" fn() -> c_int,
728    /// Used to provide information about a plugin when loaded. Must be called exactly once from
729    /// the `VapourSynthPluginInit2()` entry point. It is recommended to use the
730    /// [`vs_make_version]` macro when providing the `pluginVersion`.
731    /// If you don't know the specific `apiVersion` you actually require simply pass
732    /// [`VAPOURSYNTH_API_VERSION`] to match the header version
733    /// you're compiling against. The flags consist of values from
734    /// [`VSPluginConfigFlags`] `ORed` together but should for most plugins typically be 0.
735    ///
736    /// Returns non-zero on success.
737    pub configPlugin: unsafe extern "system-unwind" fn(
738        identifier: *const c_char,
739        pluginNamespace: *const c_char,
740        name: *const c_char,
741        pluginVersion: c_int,
742        apiVersion: c_int,
743        flags: c_int,
744        plugin: *mut VSPlugin,
745    ) -> c_int,
746    /// See [`registerFunction()`](VSAPI::registerFunction) in the struct [`VSAPI`],
747    ///
748    /// Returns non-zero on success.
749    pub registerFunction: unsafe extern "system-unwind" fn(
750        name: *const c_char,
751        args: *const c_char,
752        returnType: *const c_char,
753        argsFunc: VSPublicFunction,
754        functionData: *mut c_void,
755        plugin: *mut VSPlugin,
756    ) -> c_int,
757}
758
759/// Specifies the dependency of a filter on other nodes.
760#[repr(C)]
761#[derive(Eq, PartialEq, Hash, Debug)]
762pub struct VSFilterDependency {
763    /// The node frames are requested from.
764    pub source: *mut VSNode,
765    /// A value from [`VSRequestPattern`].
766    pub request_pattern: VSRequestPattern,
767}
768
769// MARK: VSAPI
770
771/// This giant struct is the way to access `VapourSynth`'s public API.
772#[allow(non_snake_case)]
773#[repr(C)]
774pub struct VSAPI {
775    // SECTION - Audio and video filter related including nodes
776    /// Creates a new video filter node.
777    ///
778    /// # Arguments
779    ///
780    /// * `out` - Output map for the filter node.
781    ///
782    /// * `name` - Instance name. Please make it the same as
783    ///     the filter's name for easy identification.
784    ///
785    /// * `vi` - The output format of the filter.
786    ///
787    /// * `getFrame` - The filter's "getFrame" function. Must not be `NULL`.
788    ///
789    /// * `free` - The filter's "free" function. Can be `NULL`.
790    ///
791    /// * `filterMode` - One of [`VSFilterMode`].
792    ///     Indicates the level of parallelism supported by the filter.
793    ///
794    /// * `dependencies` - An array of nodes the filter requests frames from
795    ///     and the access pattern. Used to more efficiently configure caches.
796    ///
797    /// * `numDeps` - Length of the dependencies array.
798    ///
799    /// * `instanceData` - A pointer to the private filter data. This pointer will be passed to
800    ///     the `getFrame` and `free` functions. It should be freed by the free function.
801    ///
802    /// After this function returns, `out` will contain the new node appended to
803    /// the "clip" property, or an error, if something went wrong.
804    pub createVideoFilter: unsafe extern "system-unwind" fn(
805        out: *mut VSMap,
806        name: *const c_char,
807        vi: *const VSVideoInfo,
808        getFrame: VSFilterGetFrame,
809        free: VSFilterFree,
810        filterMode: VSFilterMode,
811        dependencies: *const VSFilterDependency,
812        numDeps: c_int,
813        instanceData: *mut c_void,
814        core: *mut VSCore,
815    ),
816    /// Identical to [`createVideoFilter()`](Self::createVideoFilter) except that
817    /// the new node is returned instead of appended to the out map.
818    ///
819    /// Returns `NULL` on error.
820    pub createVideoFilter2: unsafe extern "system-unwind" fn(
821        name: *const c_char,
822        vi: *const VSVideoInfo,
823        getFrame: VSFilterGetFrame,
824        free: VSFilterFree,
825        filterMode: VSFilterMode,
826        dependencies: *const VSFilterDependency,
827        numDeps: c_int,
828        instanceData: *mut c_void,
829        core: *mut VSCore,
830    ) -> *mut VSNode,
831    /// Creates a new video filter node.
832    ///
833    /// # Arguments
834    ///
835    /// * `out` - Output map for the filter node.
836    ///
837    /// * `name` - Instance name. Please make it the same as
838    ///     the filter's name for easy identification.
839    ///
840    /// * `ai` - The output format of the filter.
841    ///
842    /// * `getFrame` - The filter's "getFrame" function. Must not be `NULL`.
843    ///
844    /// * `free` - The filter's "free" function. Can be `NULL`.
845    ///
846    /// * `filterMode` - One of [`VSFilterMode`].
847    ///     Indicates the level of parallelism supported by the filter.
848    ///
849    /// * `dependencies` - An array of nodes the filter requests frames from
850    ///     and the access pattern. Used to more efficiently configure caches.
851    ///
852    /// * `numDeps` - Length of the dependencies array.
853    ///
854    /// * `instanceData` - A pointer to the private filter data. This pointer will be passed to
855    ///     the `getFrame` and `free` functions. It should be freed by the free function.
856    ///
857    /// After this function returns, out will contain the new node appended to
858    /// the "clip" property, or an error, if something went wrong.
859    pub createAudioFilter: unsafe extern "system-unwind" fn(
860        out: *mut VSMap,
861        name: *const c_char,
862        ai: *const VSAudioInfo,
863        getFrame: VSFilterGetFrame,
864        free: VSFilterFree,
865        filterMode: VSFilterMode,
866        dependencies: *const VSFilterDependency,
867        numDeps: c_int,
868        instanceData: *mut c_void,
869        core: *mut VSCore,
870    ),
871    /// Identical to [`createAudioFilter()`](Self::createAudioFilter) except that
872    /// the new node is returned instead of appended to the out map.
873    ///
874    /// Returns `NULL` on error.
875    pub createAudioFilter2: unsafe extern "system-unwind" fn(
876        name: *const c_char,
877        ai: *const VSAudioInfo,
878        getFrame: VSFilterGetFrame,
879        free: VSFilterFree,
880        filterMode: VSFilterMode,
881        dependencies: *const VSFilterDependency,
882        numDeps: c_int,
883        instanceData: *mut c_void,
884        core: *mut VSCore,
885    ) -> *mut VSNode,
886    /// Must be called immediately after audio or video filter creation.
887    ///
888    /// Returns the upper bound of how many additional frames it is reasonable to pass to
889    /// [`cacheFrame()`](Self::cacheFrame) when trying to make a request more linear.
890    pub setLinearFilter: unsafe extern "system-unwind" fn(node: *mut VSNode) -> c_int,
891    /// Determines the strategy for frame caching. Pass a [`VSCacheMode`] constant.
892    /// Mostly useful for cache debugging since the auto mode should
893    /// work well in just about all cases. Calls to this function may also be silently ignored.
894    ///
895    /// Resets the cache to default options when called, discarding
896    /// [`setCacheOptions`](Self::setCacheOptions) changes.
897    pub setCacheMode: unsafe extern "system-unwind" fn(node: *mut VSNode, mode: VSCacheMode),
898    /// Call after setCacheMode or the changes will be discarded.
899    /// Sets internal details of a node's associated cache.
900    /// Calls to this function may also be silently ignored.
901    ///
902    /// # Arguments
903    ///
904    /// * `fixedSize` - Set to non-zero to make the cache always hold `maxSize` frames.
905    ///
906    /// * `maxSize` - The maximum number of frames to cache.
907    ///     Note that this value is automatically adjusted using
908    ///     an internal algorithm unless fixedSize is set.
909    ///
910    /// * `maxHistorySize` - How many frames that have been recently evicted from the cache to
911    ///     keep track off. Used to determine if growing or shrinking the cache is beneficial.
912    ///     Has no effect when `fixedSize` is set.
913    pub setCacheOptions: unsafe extern "system-unwind" fn(
914        node: *mut VSNode,
915        fixedSize: c_int,
916        maxSize: c_int,
917        maxHistorySize: c_int,
918    ),
919
920    /// Decreases the reference count of a node and destroys it once it reaches 0.
921    ///
922    /// It is safe to pass `NULL`.
923    pub freeNode: unsafe extern "system-unwind" fn(node: *mut VSNode),
924    /// Increment the reference count of a node. Returns the same node for convenience.
925    pub addNodeRef: unsafe extern "system-unwind" fn(node: *mut VSNode) -> *mut VSNode,
926    /// Returns [`VSMediaType`]. Used to determine if a node is of audio or video type.
927    pub getNodeType: unsafe extern "system-unwind" fn(node: *mut VSNode) -> VSMediaType,
928    /// Returns a pointer to the video info associated with a node.
929    /// The pointer is valid as long as the node lives.
930    /// It is undefined behavior to pass a non-video node.
931    pub getVideoInfo: unsafe extern "system-unwind" fn(node: *mut VSNode) -> *const VSVideoInfo,
932    /// Returns a pointer to the audio info associated with a node.
933    /// The pointer is valid as long as the node lives.
934    /// It is undefined behavior to pass a non-audio node.
935    pub getAudioInfo: unsafe extern "system-unwind" fn(node: *mut VSNode) -> *const VSAudioInfo,
936    // !SECTION
937
938    // SECTION - Frame related functions
939    /// Creates a new video frame, optionally copying the properties attached to another frame.
940    /// It is a fatal error to pass invalid arguments to this function.
941    ///
942    /// The new frame contains uninitialised memory.
943    ///
944    /// # Arguments
945    ///
946    /// * `format` - The desired colorspace format. Must not be `NULL`.
947    ///
948    /// * `width` -
949    /// * `height` - The desired dimensions of the frame, in pixels.
950    ///     Must be greater than 0 and have a suitable multiple for the subsampling in format.
951    ///
952    /// * `propSrc` - A frame from which properties will be copied. Can be `NULL`.
953    ///
954    /// Returns a pointer to the created frame.
955    /// Ownership of the new frame is transferred to the caller.
956    ///
957    /// See also [`newVideoFrame2()`](Self::newVideoFrame2).
958    pub newVideoFrame: unsafe extern "system-unwind" fn(
959        format: *const VSVideoFormat,
960        width: c_int,
961        height: c_int,
962        propSrc: *const VSFrame,
963        core: *mut VSCore,
964    ) -> *mut VSFrame,
965    /// Creates a new video frame, optionally copying the properties attached to another frame.
966    /// It is a fatal error to pass invalid arguments to this function.
967    ///
968    /// The new frame contains uninitialised memory.
969    ///
970    /// # Arguments
971    ///
972    /// * `format` - The desired colorspace format. Must not be `NULL`.
973    ///
974    /// * `width` -
975    /// * `height` - The desired dimensions of the frame, in pixels.
976    ///     Must be greater than 0 and have a suitable multiple for the subsampling in format.
977    ///
978    /// * `planeSrc` - Array of frames from which planes will be copied.
979    ///     If any elements of the array are `NULL`, the corresponding planes in the new frame
980    ///     will contain uninitialised memory.
981    ///
982    /// * `planes` - Array of plane numbers indicating which plane to copy from
983    ///     the corresponding source frame.
984    ///
985    /// * `propSrc` - A frame from which properties will be copied. Can be `NULL`.
986    ///
987    /// Returns a pointer to the created frame.
988    /// Ownership of the new frame is transferred to the caller.
989    ///
990    /// # Example
991    ///
992    /// (assume frameA, frameB, frameC are existing frames):
993    ///
994    /// ```c
995    /// const VSFrame * frames[3] = { frameA, frameB, frameC };
996    /// const int planes[3] = { 1, 0, 2 };
997    /// VSFrame *newFrame = vsapi->newVideoFrame2(f, w, h, frames, planes, frameB, core);
998    /// ```
999    ///
1000    /// The newFrame's first plane is now a copy of frameA's second plane,
1001    /// the second plane is a copy of frameB's first plane,
1002    /// the third plane is a copy of frameC's third plane
1003    /// and the properties have been copied from frameB.
1004    pub newVideoFrame2: unsafe extern "system-unwind" fn(
1005        format: *const VSVideoFormat,
1006        width: c_int,
1007        height: c_int,
1008        planeSrc: *const *const VSFrame,
1009        planes: *const c_int,
1010        propSrc: *const VSFrame,
1011        core: *mut VSCore,
1012    ) -> *mut VSFrame,
1013    /// Creates a new audio frame, optionally copying the properties attached to another frame.
1014    /// It is a fatal error to pass invalid arguments to this function.
1015    ///
1016    /// The new frame contains uninitialised memory.
1017    ///
1018    /// # Arguments
1019    ///
1020    /// * `format` - The desired audio format. Must not be `NULL`.
1021    ///
1022    /// * `numSamples` - The number of samples in the frame. All audio frames apart from
1023    ///     the last one returned by a filter must have [`VS_AUDIO_FRAME_SAMPLES`].
1024    ///
1025    /// * `propSrc` - A frame from which properties will be copied. Can be `NULL`.
1026    ///
1027    /// Returns a pointer to the created frame.
1028    /// Ownership of the new frame is transferred to the caller.
1029    ///
1030    /// See also [`newAudioFrame2()`](Self::newAudioFrame2).
1031    pub newAudioFrame: unsafe extern "system-unwind" fn(
1032        format: *const VSAudioFormat,
1033        numSamples: c_int,
1034        propSrc: *const VSFrame,
1035        core: *mut VSCore,
1036    ) -> *mut VSFrame,
1037    /// Creates a new audio frame, optionally copying the properties attached to another frame.
1038    /// It is a fatal error to pass invalid arguments to this function.
1039    ///
1040    /// The new frame contains uninitialised memory.
1041    ///
1042    /// # Arguments
1043    ///
1044    /// * `format` - The desired audio format. Must not be `NULL`.
1045    ///
1046    /// * `numSamples` - The number of samples in the frame. All audio frames apart from
1047    ///     the last one returned by a filter must have [`VS_AUDIO_FRAME_SAMPLES`].
1048    ///
1049    /// * `propSrc` - A frame from which properties will be copied. Can be `NULL`.
1050    ///
1051    /// * `channelSrc` - Array of frames from which channels will be copied.
1052    ///     If any elements of the array are `NULL`, the corresponding planes in
1053    ///     the new frame will contain uninitialised memory.
1054    ///
1055    /// * `channels` - Array of channel numbers indicating which channel to copy from
1056    ///     the corresponding source frame.
1057    ///     Note that the number refers to the nth channel and not a channel name constant.
1058    ///
1059    /// Returns a pointer to the created frame.
1060    /// Ownership of the new frame is transferred to the caller.
1061    pub newAudioFrame2: unsafe extern "system-unwind" fn(
1062        format: *const VSAudioFormat,
1063        numSamples: c_int,
1064        channelSrc: *const *const VSFrame,
1065        channels: *const c_int,
1066        propSrc: *const VSFrame,
1067        core: *mut VSCore,
1068    ) -> *mut VSFrame,
1069    /// Decrements the reference count of a frame and deletes it when it reaches 0.
1070    ///
1071    /// It is safe to pass `NULL`.
1072    pub freeFrame: unsafe extern "system-unwind" fn(f: *const VSFrame),
1073    /// Increments the reference count of a frame. Returns f as a convenience.
1074    pub addFrameRef: unsafe extern "system-unwind" fn(f: *const VSFrame) -> *mut VSFrame,
1075    /// Duplicates the frame (not just the reference). As the frame buffer is shared in
1076    /// a copy-on-write fashion, the frame content is not really duplicated until
1077    /// a write operation occurs. This is transparent for the user.
1078    ///
1079    /// Returns a pointer to the new frame. Ownership is transferred to the caller.
1080    pub copyFrame:
1081        unsafe extern "system-unwind" fn(f: *const VSFrame, core: *mut VSCore) -> *mut VSFrame,
1082    /// Returns a read-only pointer to a frame's properties.
1083    /// The pointer is valid as long as the frame lives.
1084    pub getFramePropertiesRO: unsafe extern "system-unwind" fn(f: *const VSFrame) -> *const VSMap,
1085    /// Returns a read/write pointer to a frame's properties.
1086    /// The pointer is valid as long as the frame lives.
1087    pub getFramePropertiesRW: unsafe extern "system-unwind" fn(f: *mut VSFrame) -> *mut VSMap,
1088
1089    /// Returns the distance in bytes between two consecutive lines of a plane of a video frame.
1090    /// The stride is always positive.
1091    ///
1092    /// Returns 0 if the requested plane doesn't exist or if it isn't a video frame.
1093    pub getStride: unsafe extern "system-unwind" fn(f: *const VSFrame, plane: c_int) -> isize,
1094    /// Returns a read-only pointer to a plane or channel of a frame.
1095    /// Returns `NULL` if an invalid plane or channel number is passed.
1096    ///
1097    /// # Note
1098    ///
1099    /// Don't assume all three planes of a frame are allocated
1100    /// in one contiguous chunk (they're not).
1101    pub getReadPtr: unsafe extern "system-unwind" fn(f: *const VSFrame, plane: c_int) -> *const u8,
1102    /// Returns a read-write pointer to a plane or channel of a frame.
1103    /// Returns `NULL` if an invalid plane or channel number is passed.
1104    ///
1105    /// # Note
1106    ///
1107    /// Don't assume all three planes of a frame are allocated
1108    /// in one contiguous chunk (they're not).
1109    pub getWritePtr: unsafe extern "system-unwind" fn(f: *mut VSFrame, plane: c_int) -> *mut u8,
1110
1111    /// Retrieves the format of a video frame.
1112    pub getVideoFrameFormat:
1113        unsafe extern "system-unwind" fn(f: *const VSFrame) -> *const VSVideoFormat,
1114    /// Retrieves the format of an audio frame.
1115    pub getAudioFrameFormat:
1116        unsafe extern "system-unwind" fn(f: *const VSFrame) -> *const VSAudioFormat,
1117    /// Returns a value from [`VSMediaType`] to distinguish audio and video frames.
1118    pub getFrameType: unsafe extern "system-unwind" fn(f: *const VSFrame) -> VSMediaType,
1119    /// Returns the width of a plane of a given video frame, in pixels.
1120    /// The width depends on the plane number because of the possible chroma subsampling.
1121    ///
1122    /// Returns 0 for audio frames.
1123    pub getFrameWidth: unsafe extern "system-unwind" fn(f: *const VSFrame, plane: c_int) -> c_int,
1124    /// Returns the height of a plane of a given video frame, in pixels.
1125    /// The height depends on the plane number because of the possible chroma subsampling.
1126    ///
1127    /// Returns 0 for audio frames.
1128    pub getFrameHeight: unsafe extern "system-unwind" fn(f: *const VSFrame, plane: c_int) -> c_int,
1129    /// Returns the number of audio samples in a frame. Always returns 1 for video frames.
1130    pub getFrameLength: unsafe extern "system-unwind" fn(f: *const VSFrame) -> c_int,
1131    // !SECTION
1132
1133    // SECTION - General format functions
1134    /// Tries to output a fairly human-readable name of a video format.
1135    ///
1136    /// # Arguments
1137    ///
1138    /// * `format` - The input video format.
1139    /// * `buffer` - Destination buffer. At most 32 bytes including
1140    ///     terminating `NUL` will be written.
1141    ///
1142    /// Returns non-zero on success.
1143    pub getVideoFormatName: unsafe extern "system-unwind" fn(
1144        format: *const VSVideoFormat,
1145        buffer: *mut c_char,
1146    ) -> c_int,
1147    /// Tries to output a fairly human-readable name of an audio format.
1148    ///
1149    /// # Arguments
1150    ///
1151    /// * `format` - The input audio format.
1152    /// * `buffer` - Destination buffer. At most 32 bytes including
1153    ///     terminating `NUL` will be written.
1154    ///
1155    /// Returns non-zero on success.
1156    pub getAudioFormatName: unsafe extern "system-unwind" fn(
1157        format: *const VSAudioFormat,
1158        buffer: *mut c_char,
1159    ) -> c_int,
1160    /// Fills out a \[_sic_\] [`VSVideoInfo`] struct based on the provided arguments.
1161    /// Validates the arguments before filling out format.
1162    ///
1163    /// # Arguments
1164    ///
1165    /// * `format` - The struct to fill out.
1166    /// * `colorFamily` - One of [`VSColorFamily`].
1167    /// * `sampleType` - One of [`VSSampleType`].
1168    /// * `bitsPerSample` - Number of meaningful bits for a single component.
1169    ///     The valid range is 8-32.
1170    ///
1171    ///     For floating point formats only 16 or 32 bits are allowed.
1172    /// * `subSamplingW` - log2 of the horizontal chroma subsampling.
1173    ///     0 == no subsampling. The valid range is 0-4.
1174    /// * `subSamplingH` - log2 of the vertical chroma subsampling.
1175    ///     0 == no subsampling. The valid range is 0-4.
1176    ///
1177    ///     ## Note
1178    ///     
1179    ///     RGB formats are not allowed to be subsampled in `VapourSynth`.
1180    ///
1181    /// Returns non-zero on success.
1182    pub queryVideoFormat: unsafe extern "system-unwind" fn(
1183        format: *mut VSVideoFormat,
1184        colorFamily: VSColorFamily,
1185        sampleType: VSSampleType,
1186        bitsPerSample: c_int,
1187        subSamplingW: c_int,
1188        subSamplingH: c_int,
1189        core: *mut VSCore,
1190    ) -> c_int,
1191    /// Fills out a [`VSAudioFormat`] struct based on the provided arguments.
1192    /// Validates the arguments before filling out format.
1193    ///
1194    /// # Arguments
1195    ///
1196    /// * `format` - The struct to fill out.
1197    ///
1198    /// * `sampleType` - One of [`VSSampleType`].
1199    ///
1200    /// * `bitsPerSample` - Number of meaningful bits for a single component.
1201    ///     The valid range is 8-32.
1202    ///
1203    ///     For floating point formats only 32 bits are allowed.
1204    ///
1205    /// * `channelLayout` - A bitmask constructed from bitshifted constants in
1206    ///     [`VSAudioChannels`]. For example stereo is expressed as
1207    ///     `(1 << acFrontLeft) | (1 << acFrontRight)`.
1208    ///
1209    /// Returns non-zero on success.
1210    pub queryAudioFormat: unsafe extern "system-unwind" fn(
1211        format: *mut VSAudioFormat,
1212        sampleType: VSSampleType,
1213        bitsPerSample: c_int,
1214        channelLayout: u64,
1215        core: *mut VSCore,
1216    ) -> c_int,
1217    /// Get the id associated with a video format. Similar to
1218    /// [`queryVideoFormat()`](Self::queryVideoFormat) except that it returns a format id
1219    /// instead of filling out a [`VSVideoInfo`] struct.
1220    ///
1221    /// # Arguments
1222    ///
1223    /// * `colorFamily` - One of [`VSColorFamily`].
1224    ///
1225    /// * `sampleType` - One of [`VSSampleType`].
1226    ///
1227    /// * `bitsPerSample` - Number of meaningful bits for a single component.
1228    ///     The valid range is 8-32.
1229    ///
1230    ///     For floating point formats only 16 or 32 bits are allowed.
1231    ///
1232    /// * `subSamplingW` - log2 of the horizontal chroma subsampling.
1233    ///     0 == no subsampling. The valid range is 0-4.
1234    ///
1235    /// * `subSamplingH` - log2 of the vertical chroma subsampling.
1236    ///     0 == no subsampling. The valid range is 0-4.
1237    ///
1238    ///     ## Note
1239    ///     
1240    ///     RGB formats are not allowed to be subsampled in `VapourSynth`.
1241    ///
1242    /// Returns a valid format id if the provided arguments are valid, on error 0 is returned.
1243    pub queryVideoFormatID: unsafe extern "system-unwind" fn(
1244        colorFamily: VSColorFamily,
1245        sampleType: VSSampleType,
1246        bitsPerSample: c_int,
1247        subSamplingW: c_int,
1248        subSamplingH: c_int,
1249        core: *mut VSCore,
1250    ) -> u32,
1251    /// Fills out the `VSVideoFormat` struct passed to format based
1252    ///
1253    /// # Arguments
1254    ///
1255    /// * `format` - The struct to fill out.
1256    ///
1257    /// * `id` - The format identifier: one of [`VSPresetVideoFormat`]
1258    ///     or a value gotten from [`queryVideoFormatID()`](Self::queryVideoFormatID).
1259    ///
1260    /// Returns 0 on failure and non-zero on success.
1261    pub getVideoFormatByID: unsafe extern "system-unwind" fn(
1262        format: *mut VSVideoFormat,
1263        id: u32,
1264        core: *mut VSCore,
1265    ) -> c_int,
1266    // !SECTION
1267
1268    // SECTION - Frame request and filter getFrame functions
1269    /// Fetches a frame synchronously. The frame is available when the function returns.
1270    ///
1271    /// This function is meant for external applications using the core as a library,
1272    /// or if frame requests are necessary during a filter's initialization.
1273    ///
1274    /// Thread-safe.
1275    ///
1276    /// # Arguments
1277    ///
1278    /// * `n` - The frame number. Negative values will cause an error.
1279    ///
1280    /// * `node` - The node from which the frame is requested.
1281    ///
1282    /// * `errorMsg` - Pointer to a buffer of `bufSize` bytes to store a possible error message.
1283    ///     Can be `NULL` if no error message is wanted.
1284    ///
1285    /// * `bufSize` - Maximum length for the error message, in bytes (including the trailing '0').
1286    ///     Can be 0 if no error message is wanted.
1287    ///
1288    /// Returns a reference to the generated frame, or `NULL` in case of failure.
1289    /// The ownership of the frame is transferred to the caller.
1290    ///
1291    /// # Warning
1292    ///
1293    /// Never use inside a filter's "getFrame" function.
1294    pub getFrame: unsafe extern "system-unwind" fn(
1295        n: c_int,
1296        node: *mut VSNode,
1297        errorMsg: *mut c_char,
1298        bufSize: c_int,
1299    ) -> *const VSFrame,
1300    /// Requests the generation of a frame. When the frame is ready,
1301    /// a user-provided function is called.
1302    /// Note that the completion callback will only be called from a single thread at a time.
1303    ///
1304    /// This function is meant for applications using `VapourSynth` as a library.
1305    ///
1306    /// Thread-safe.
1307    ///
1308    /// # Arguments
1309    ///
1310    /// * `n` - Frame number. Negative values will cause an error.
1311    ///
1312    /// * `node` - The node from which the frame is requested.
1313    ///
1314    /// * `callback` - See [`VSFrameDoneCallback`].
1315    ///
1316    /// * `userData` - Pointer passed to the callback.
1317    ///
1318    /// # Warning
1319    ///
1320    /// Never use inside a filter's "getFrame" function.
1321    pub getFrameAsync: unsafe extern "system-unwind" fn(
1322        n: c_int,
1323        node: *mut VSNode,
1324        callback: VSFrameDoneCallback,
1325        userData: *mut c_void,
1326    ),
1327    /// Retrieves a frame that was previously requested with
1328    /// [`requestFrameFilter()`](Self::requestFrameFilter).
1329    ///
1330    /// Only use inside a filter's "getFrame" function.
1331    ///
1332    /// A filter usually calls this function when its activation reason is
1333    /// [`VSActivationReason::AllFramesReady`].
1334    /// See [`VSActivationReason`].
1335    ///
1336    /// It is safe to retrieve a frame more than once, but each reference needs to be freed.
1337    ///
1338    /// # Arguments
1339    ///
1340    /// * `n` - The frame number.
1341    ///
1342    /// * `node` - The node from which the frame is retrieved.
1343    ///
1344    /// * `frameCtx` - The context passed to the filter's "getFrame" function.
1345    ///
1346    /// Returns a pointer to the requested frame, or `NULL` if the requested frame is
1347    /// not available for any reason. The ownership of the frame is transferred to the caller.
1348    pub getFrameFilter: unsafe extern "system-unwind" fn(
1349        n: c_int,
1350        node: *mut VSNode,
1351        frameCtx: *mut VSFrameContext,
1352    ) -> *const VSFrame,
1353    /// Requests a frame from a node and returns immediately.
1354    ///
1355    /// Only use inside a filter's "getFrame" function.
1356    ///
1357    /// A filter usually calls this function when its activation reason is arInitial.
1358    /// The requested frame can then be retrieved using
1359    /// [`getFrameFilter()`](Self::getFrameFilter), when the filter's activation reason is
1360    /// [`VSActivationReason::AllFramesReady`].
1361    ///
1362    /// It is best to request frames in ascending order, i.e. n, n+1, n+2, etc.
1363    ///
1364    /// # Arguments
1365    ///
1366    /// * `n` - The frame number. Negative values will cause an error.
1367    ///
1368    /// * `node` - The node from which the frame is requested.
1369    ///
1370    /// * `frameCtx` - The context passed to the filter's "getFrame" function.
1371    pub requestFrameFilter: unsafe extern "system-unwind" fn(
1372        n: c_int,
1373        node: *mut VSNode,
1374        frameCtx: *mut VSFrameContext,
1375    ),
1376    /// By default all requested frames are referenced until a filter's frame request is done.
1377    /// In extreme cases where a filter needs to reduce 20+ frames into a single output frame
1378    /// it may be beneficial to request these in batches
1379    /// and incrementally process the data instead.
1380    ///
1381    /// Should rarely be needed.
1382    ///
1383    /// Only use inside a filter's "getFrame" function.
1384    ///
1385    /// # Arguments
1386    ///
1387    /// * `n` - The frame number. Negative values will cause an error.
1388    ///
1389    /// * `node` - The node from which the frame is requested.
1390    ///
1391    /// * `frameCtx` - The context passed to the filter's "getFrame" function.
1392    pub releaseFrameEarly: unsafe extern "system-unwind" fn(
1393        node: *mut VSNode,
1394        n: c_int,
1395        frameCtx: *mut VSFrameContext,
1396    ),
1397    /// Pushes a not requested frame into the cache. This is useful for (source) filters
1398    /// that greatly benefit from completely linear access
1399    /// and producing all output in linear order.
1400    ///
1401    /// This function may only be used in filters that were created with
1402    /// [`setLinearFilter`](Self::setLinearFilter).
1403    ///
1404    /// Only use inside a filter's "getFrame" function.
1405    pub cacheFrame: unsafe extern "system-unwind" fn(
1406        frame: *const VSFrame,
1407        n: c_int,
1408        frameCtx: *mut VSFrameContext,
1409    ),
1410    /// Adds an error message to a frame context, replacing the existing message, if any.
1411    ///
1412    /// This is the way to report errors in a filter's "getFrame" function.
1413    /// Such errors are not necessarily fatal, i.e. the caller can try to
1414    /// request the same frame again.
1415    pub setFilterError: unsafe extern "system-unwind" fn(
1416        errorMessage: *const c_char,
1417        frameCtx: *mut VSFrameContext,
1418    ),
1419    // !SECTION
1420
1421    // SECTION - External functions
1422    /// # Arguments
1423    ///
1424    /// * `func` - User-defined function that may be called in any context.
1425    ///
1426    /// * `userData` - Pointer passed to `func`.
1427    ///
1428    /// * `free` - Callback tasked with freeing userData. Can be `NULL`.
1429    pub createFunction: unsafe extern "system-unwind" fn(
1430        func: VSPublicFunction,
1431        userData: *mut c_void,
1432        free: VSFreeFunctionData,
1433        core: *mut VSCore,
1434    ) -> *mut VSFunction,
1435    /// Decrements the reference count of a function and deletes it when it reaches 0.
1436    ///
1437    /// It is safe to pass `NULL`.
1438    pub freeFunction: unsafe extern "system-unwind" fn(f: *mut VSFunction),
1439    /// Increments the reference count of a function. Returns f as a convenience.
1440    pub addFunctionRef: unsafe extern "system-unwind" fn(f: *mut VSFunction) -> *mut VSFunction,
1441    /// Calls a function. If the call fails out will have an error set.
1442    ///
1443    /// # Arguments
1444    ///
1445    /// * `func` - Function to be called.
1446    ///
1447    /// * `in_` - Arguments passed to `func`.
1448    ///
1449    /// * `out` - Returned values from `func`.
1450    pub callFunction:
1451        unsafe extern "system-unwind" fn(func: *mut VSFunction, in_: *const VSMap, out: *mut VSMap),
1452    // !SECTION
1453
1454    // SECTION - Map and property access functions
1455    /// Creates a new property map. It must be deallocated later with [`freeMap()`](Self::freeMap).
1456    pub createMap: unsafe extern "system-unwind" fn() -> *mut VSMap,
1457    /// Frees a map and all the objects it contains.
1458    pub freeMap: unsafe extern "system-unwind" fn(map: *mut VSMap),
1459    /// Deletes all the keys and their associated values from the map, leaving it empty.
1460    pub clearMap: unsafe extern "system-unwind" fn(map: *mut VSMap),
1461    /// copies all values in src to dst, if a key already exists in dst it's replaced
1462    pub copyMap: unsafe extern "system-unwind" fn(src: *const VSMap, dst: *mut VSMap),
1463
1464    /// Adds an error message to a map. The map is cleared first.
1465    /// The error message is copied. In this state the map may only be freed,
1466    /// cleared or queried for the error message.
1467    ///
1468    /// For errors encountered in a filter's "getFrame" function, use
1469    /// [`setFilterError()`](Self::setFilterError).
1470    pub mapSetError: unsafe extern "system-unwind" fn(map: *mut VSMap, errorMessage: *const c_char),
1471    /// Returns a pointer to the error message contained in the map,
1472    /// or `NULL` if there is no error set. The pointer is valid until
1473    /// the next modifying operation on the map.
1474    pub mapGetError: unsafe extern "system-unwind" fn(map: *const VSMap) -> *const c_char,
1475
1476    /// Returns the number of keys contained in a property map.
1477    pub mapNumKeys: unsafe extern "system-unwind" fn(map: *const VSMap) -> c_int,
1478    /// Returns the nth key from a property map.
1479    ///
1480    /// Passing an invalid index will cause a fatal error.
1481    ///
1482    /// The pointer is valid as long as the key exists in the map.
1483    pub mapGetKey:
1484        unsafe extern "system-unwind" fn(map: *const VSMap, index: c_int) -> *const c_char,
1485    /// Removes the property with the given key. All values associated with the key are lost.
1486    ///
1487    /// Returns 0 if the key isn't in the map. Otherwise it returns 1.
1488    pub mapDeleteKey:
1489        unsafe extern "system-unwind" fn(map: *mut VSMap, key: *const c_char) -> c_int,
1490    /// Returns the number of elements associated with a key in a property map.
1491    ///
1492    /// Returns -1 if there is no such key in the map.
1493    pub mapNumElements:
1494        unsafe extern "system-unwind" fn(map: *const VSMap, key: *const c_char) -> c_int,
1495    /// Returns a value from [`VSPropertyType`] representing type of elements in the given key.
1496    /// If there is no such key in the map, the returned value is
1497    /// [`VSPropertyType::Unset`]).
1498    /// Note that also empty arrays created with mapSetEmpty are typed.
1499    pub mapGetType:
1500        unsafe extern "system-unwind" fn(map: *const VSMap, key: *const c_char) -> VSPropertyType,
1501    /// Creates an empty array of type in key.
1502    ///
1503    /// Returns non-zero value on failure due to key already existing or having an invalid name.
1504    pub mapSetEmpty: unsafe extern "system-unwind" fn(
1505        map: *mut VSMap,
1506        key: *const c_char,
1507        type_: VSPropertyType,
1508    ) -> c_int,
1509
1510    /// Retrieves an integer from a specified key in a map.
1511    ///
1512    /// Returns the number on success, or 0 in case of error.
1513    ///
1514    /// If the map has an error set (i.e. if [`mapGetError()`](VSAPI::mapGetError)
1515    /// returns non-`NULL`), `VapourSynth` will die with a fatal error.
1516    ///
1517    /// # Arguments
1518    ///
1519    /// * `index` - Zero-based index of the element.
1520    ///
1521    ///     Use [`mapNumElements()`](Self::mapNumElements) to know the total number of elements
1522    ///     associated with a key.
1523    ///
1524    /// * `error` - One of [`VSMapPropertyError`], [`VSMapPropertyError::Success`]
1525    ///     on success.
1526    ///
1527    ///     You may pass `NULL` here, but then any problems encountered while retrieving
1528    ///     the property will cause `VapourSynth` to die with a fatal error.
1529    pub mapGetInt: unsafe extern "system-unwind" fn(
1530        map: *const VSMap,
1531        key: *const c_char,
1532        index: c_int,
1533        error: *mut VSMapPropertyError,
1534    ) -> i64,
1535    /// Works just like [`mapGetInt()`](Self::mapGetInt) except that the value returned is
1536    /// also converted to an integer using saturation.
1537    pub mapGetIntSaturated: unsafe extern "system-unwind" fn(
1538        map: *const VSMap,
1539        key: *const c_char,
1540        index: c_int,
1541        error: *mut VSMapPropertyError,
1542    ) -> c_int,
1543    /// Retrieves an array of integers from a map. Use this function if there are a lot of numbers
1544    /// associated with a key, because it is faster than calling
1545    /// [`mapGetInt()`](Self::mapGetInt) in a loop.
1546    ///
1547    /// Returns a pointer to the first element of the array on success,
1548    /// or `NULL` in case of error. Use [`mapNumElements()`](Self::mapNumElements) to
1549    /// know the total number of elements associated with a key.
1550    ///
1551    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1552    /// the arguments and general behavior.
1553    pub mapGetIntArray: unsafe extern "system-unwind" fn(
1554        map: *const VSMap,
1555        key: *const c_char,
1556        error: *mut VSMapPropertyError,
1557    ) -> *const i64,
1558    /// Sets an integer to the specified key in a map.
1559    ///
1560    /// Multiple values can be associated with one key, but they must all be the same type.
1561    ///
1562    /// # Arguments
1563    ///
1564    /// * `key` - Name of the property. Alphanumeric characters and underscore may be used.
1565    ///
1566    /// * `i` - Value to store.
1567    ///
1568    /// * `append` - One of [`VSMapAppendMode`].
1569    ///
1570    /// Returns 0 on success, or 1 if trying to append to
1571    /// a property with the wrong type to an existing key.
1572    pub mapSetInt: unsafe extern "system-unwind" fn(
1573        map: *mut VSMap,
1574        key: *const c_char,
1575        i: i64,
1576        append: VSMapAppendMode,
1577    ) -> c_int,
1578    /// Adds an array of integers to a map. Use this function if there are a lot of numbers
1579    /// to add because it is faster than calling [`mapSetInt()`](Self::mapSetInt) in a loop.
1580    ///
1581    /// If map already contains a property with this key, that property will be overwritten and
1582    /// all old values will be lost.
1583    ///
1584    /// # Arguments
1585    ///
1586    /// * `key` - Name of the property. Alphanumeric characters and underscore may be used.
1587    ///
1588    /// * `i` - Pointer to the first element of the array to store.
1589    ///
1590    /// * `size` - Number of integers to read from the array. It can be 0, in which case
1591    ///     no integers are read from the array, and the property will be created empty.
1592    ///
1593    /// Returns 0 on success, or 1 if size is negative.
1594    pub mapSetIntArray: unsafe extern "system-unwind" fn(
1595        map: *mut VSMap,
1596        key: *const c_char,
1597        i: *const i64,
1598        size: c_int,
1599    ) -> c_int,
1600
1601    /// Retrieves a floating point number from a map.
1602    ///
1603    /// Returns the number on success, or 0 in case of error.
1604    ///
1605    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1606    /// the arguments and general behavior.
1607    pub mapGetFloat: unsafe extern "system-unwind" fn(
1608        map: *const VSMap,
1609        key: *const c_char,
1610        index: c_int,
1611        error: *mut VSMapPropertyError,
1612    ) -> c_double,
1613    /// Works just like [`mapGetFloat()`](Self::mapGetFloat) except that the value returned
1614    /// is also converted to a float.
1615    pub mapGetFloatSaturated: unsafe extern "system-unwind" fn(
1616        map: *const VSMap,
1617        key: *const c_char,
1618        index: c_int,
1619        error: *mut VSMapPropertyError,
1620    ) -> c_float,
1621    /// Retrieves an array of floating point numbers from a map. Use this function if there are
1622    /// a lot of numbers associated with a key, because it is faster than calling
1623    /// [`mapGetFloat()`](Self::mapGetFloat) in a loop.
1624    ///
1625    /// Returns a pointer to the first element of the array on success,
1626    /// or `NULL` in case of error. Use [`mapNumElements()`](Self::mapNumElements) to
1627    /// know the total number of elements associated with a key.
1628    ///
1629    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1630    /// the arguments and general behavior.
1631    pub mapGetFloatArray: unsafe extern "system-unwind" fn(
1632        map: *const VSMap,
1633        key: *const c_char,
1634        error: *mut VSMapPropertyError,
1635    ) -> *const c_double,
1636    /// Sets a float to the specified key in a map.
1637    ///
1638    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1639    /// the arguments and general behavior.
1640    pub mapSetFloat: unsafe extern "system-unwind" fn(
1641        map: *mut VSMap,
1642        key: *const c_char,
1643        d: c_double,
1644        append: VSMapAppendMode,
1645    ) -> c_int,
1646    /// Adds an array of floating point numbers to a map. Use this function if there are
1647    /// a lot of numbers to add, because it is faster than calling
1648    /// [`mapSetFloat()`](Self::mapSetFloat) in a loop.
1649    ///
1650    /// If map already contains a property with this key, that property will be overwritten and
1651    /// all old values will be lost.
1652    ///
1653    /// # Arguments
1654    ///
1655    /// * `key` - Name of the property. Alphanumeric characters and underscore may be used.
1656    ///
1657    /// * `d` - Pointer to the first element of the array to store.
1658    ///
1659    /// * `size` - Number of floating point numbers to read from the array. It can be 0,
1660    ///     in which case no numbers are read from the array,
1661    ///     and the property will be created empty.
1662    ///
1663    /// Returns 0 on success, or 1 if size is negative.
1664    pub mapSetFloatArray: unsafe extern "system-unwind" fn(
1665        map: *mut VSMap,
1666        key: *const c_char,
1667        d: *const c_double,
1668        size: c_int,
1669    ) -> c_int,
1670
1671    /// Retrieves arbitrary binary data from a map. Checking
1672    /// [`mapGetDataTypeHint()`](Self::mapGetDataTypeHint) may provide a hint about
1673    /// whether or not the data is human readable.
1674    ///
1675    /// Returns a pointer to the data on success, or `NULL` in case of error.
1676    ///
1677    /// The array returned is guaranteed to be `NULL`-terminated.
1678    /// The `NULL` byte is not considered to be part of the array
1679    /// ([`mapGetDataSize`](Self::mapGetDataSize) doesn't count it).
1680    ///
1681    /// The pointer is valid until the map is destroyed, or until the corresponding key
1682    /// is removed from the map or altered.
1683    ///
1684    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1685    /// the arguments and general behavior.
1686    pub mapGetData: unsafe extern "system-unwind" fn(
1687        map: *const VSMap,
1688        key: *const c_char,
1689        index: c_int,
1690        error: *mut VSMapPropertyError,
1691    ) -> *const c_char,
1692    /// Returns the size in bytes of a property of type ptData (see [`VSPropertyType`]),
1693    /// or 0 in case of error. The terminating `NULL` byte added by
1694    /// [`mapSetData()`](Self::mapSetData) is not counted.
1695    ///
1696    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1697    /// the arguments and general behavior.
1698    pub mapGetDataSize: unsafe extern "system-unwind" fn(
1699        map: *const VSMap,
1700        key: *const c_char,
1701        index: c_int,
1702        error: *mut VSMapPropertyError,
1703    ) -> c_int,
1704    /// Returns the size in bytes of a property of type ptData (see [`VSPropertyType`]),
1705    /// or 0 in case of error. The terminating `NULL` byte added by
1706    /// [`mapSetData()`](Self::mapSetData) is not counted.
1707    ///
1708    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1709    /// the arguments and general behavior.
1710    pub mapGetDataTypeHint: unsafe extern "system-unwind" fn(
1711        map: *const VSMap,
1712        key: *const c_char,
1713        index: c_int,
1714        error: *mut VSMapPropertyError,
1715    ) -> VSDataTypeHint,
1716    /// Sets binary data to the specified key in a map.
1717    ///
1718    /// Multiple values can be associated with one key, but they must all be the same type.
1719    ///
1720    /// # Arguments
1721    ///
1722    /// * `key` - Name of the property. Alphanumeric characters and the underscore may be used.
1723    ///
1724    /// * `data` - Value to store.
1725    ///
1726    ///     This function copies the data, so the pointer should be freed when no longer needed.
1727    ///     A terminating `NULL` is always added to the copied data but not included in
1728    ///     the total size to make string handling easier.
1729    ///
1730    /// * `size` - The number of bytes to copy. If this is negative,
1731    ///     everything up to the first `NULL` byte will be copied.
1732    ///
1733    /// * `type` - One of [`VSDataTypeHint`] to hint whether or not it is human readable data.
1734    ///
1735    /// * `append` - One of [`VSMapAppendMode`].
1736    ///
1737    /// Returns 0 on success, or 1 if trying to append to a property with the wrong type.
1738    pub mapSetData: unsafe extern "system-unwind" fn(
1739        map: *mut VSMap,
1740        key: *const c_char,
1741        data: *const c_char,
1742        size: c_int,
1743        type_: VSDataTypeHint,
1744        append: VSMapAppendMode,
1745    ) -> c_int,
1746
1747    /// Retrieves a node from a map.
1748    ///
1749    /// Returns a pointer to the node on success, or `NULL` in case of error.
1750    ///
1751    /// This function increases the node's reference count, so [`freeNode()`](Self::freeNode)
1752    /// must be used when the node is no longer needed.
1753    ///
1754    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1755    /// the arguments and general behavior.
1756    pub mapGetNode: unsafe extern "system-unwind" fn(
1757        map: *const VSMap,
1758        key: *const c_char,
1759        index: c_int,
1760        error: *mut VSMapPropertyError,
1761    ) -> *mut VSNode,
1762    /// Sets a node to the specified key in a map.
1763    ///
1764    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1765    /// the arguments and general behavior.
1766    pub mapSetNode: unsafe extern "system-unwind" fn(
1767        map: *mut VSMap,
1768        key: *const c_char,
1769        node: *mut VSNode,
1770        append: VSMapAppendMode,
1771    ) -> c_int,
1772    /// Sets a node to the specified key in a map and decreases the reference count.
1773    ///
1774    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1775    /// the arguments and general behavior.
1776    ///
1777    /// Note: always consumes the reference, even on error
1778    pub mapConsumeNode: unsafe extern "system-unwind" fn(
1779        map: *mut VSMap,
1780        key: *const c_char,
1781        node: *mut VSNode,
1782        append: VSMapAppendMode,
1783    ) -> c_int,
1784
1785    /// Retrieves a frame from a map.
1786    ///
1787    /// Returns a pointer to the frame on success, or `NULL` in case of error.
1788    ///
1789    /// This function increases the frame's reference count, so
1790    /// [`freeFrame()`](Self::freeFrame) must be used when the frame is no longer needed.
1791    ///
1792    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1793    /// the arguments and general behavior.
1794    pub mapGetFrame: unsafe extern "system-unwind" fn(
1795        map: *const VSMap,
1796        key: *const c_char,
1797        index: c_int,
1798        error: *mut VSMapPropertyError,
1799    ) -> *const VSFrame,
1800    /// Sets a frame to the specified key in a map.
1801    ///
1802    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1803    /// the arguments and general behavior.
1804    pub mapSetFrame: unsafe extern "system-unwind" fn(
1805        map: *mut VSMap,
1806        key: *const c_char,
1807        f: *const VSFrame,
1808        append: VSMapAppendMode,
1809    ) -> c_int,
1810    /// Sets a frame to the specified key in a map and decreases the reference count.
1811    ///
1812    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1813    /// the arguments and general behavior.
1814    pub mapConsumeFrame: unsafe extern "system-unwind" fn(
1815        map: *mut VSMap,
1816        key: *const c_char,
1817        f: *const VSFrame,
1818        append: VSMapAppendMode,
1819    ) -> c_int,
1820
1821    /// Retrieves a function from a map.
1822    ///
1823    /// Returns a pointer to the function on success, or `NULL` in case of error.
1824    ///
1825    /// This function increases the function's reference count, so
1826    /// [`freeFunction()`](Self::freeFunction) must be used when the function is no longer needed.
1827    ///
1828    /// See [`mapGetInt()`](Self::mapGetInt) for a complete description of
1829    /// the arguments and general behavior.
1830    pub mapGetFunction: unsafe extern "system-unwind" fn(
1831        map: *const VSMap,
1832        key: *const c_char,
1833        index: c_int,
1834        error: *mut VSMapPropertyError,
1835    ) -> *mut VSFunction,
1836    /// Sets a function object to the specified key in a map.
1837    ///
1838    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1839    /// the arguments and general behavior.
1840    pub mapSetFunction: unsafe extern "system-unwind" fn(
1841        map: *mut VSMap,
1842        key: *const c_char,
1843        func: *mut VSFunction,
1844        append: VSMapAppendMode,
1845    ) -> c_int,
1846    /// Sets a function object to the specified key in a map and decreases the reference count.
1847    ///
1848    /// See [`mapSetInt()`](Self::mapSetInt) for a complete description of
1849    /// the arguments and general behavior.
1850    pub mapConsumeFunction: unsafe extern "system-unwind" fn(
1851        map: *mut VSMap,
1852        key: *const c_char,
1853        func: *mut VSFunction,
1854        append: VSMapAppendMode,
1855    ) -> c_int,
1856    // !SECTION
1857
1858    // SECTION - Plugin and plugin function related
1859    /// Function that registers a filter exported by the plugin.
1860    /// A plugin can export any number of filters. This function may only be called during
1861    /// the plugin loading phase unless the [`VSPluginConfigFlags::Modifiable`] flag was
1862    /// set by [`configPlugin`](VSPLUGINAPI::configPlugin).
1863    ///
1864    /// # Arguments
1865    ///
1866    /// * `name` - Filter name. The characters allowed are letters, numbers, and the underscore.
1867    ///     The first character must be a letter. In other words: ^[a-zA-Z][a-zA-Z0-9_]*$
1868    ///
1869    ///     Filter names _should be_ `PascalCase`.
1870    ///
1871    /// * `args` - String containing the filter's list of arguments.
1872    ///
1873    ///     Arguments are separated by a semicolon. Each argument is made of several fields
1874    ///     separated by a colon. Don't insert additional whitespace characters,
1875    ///     or `VapourSynth` will die.
1876    ///
1877    ///     ## Fields:
1878    ///
1879    ///     * The argument name.
1880    ///
1881    ///         The same characters are allowed as for the filter's name.
1882    ///         Argument names should be all lowercase and use only letters and the underscore.
1883    ///
1884    ///     * The type.
1885    ///
1886    ///         * "int": `int64_t`
1887    ///         * "float": double
1888    ///         * "data": const char*
1889    ///         * "anode": const [`VSNode`]* (audio type)
1890    ///         * "vnode": const [`VSNode`]* (video type)
1891    ///         * "aframe": const [`VSFrame`]* (audio type)
1892    ///         * "vframe": const [`VSFrame`]* (video type)
1893    ///         * "func": const [`VSFunction`]*
1894    ///
1895    ///         It is possible to declare an array by appending "[]" to the type.
1896    ///
1897    ///     * "opt"
1898    ///
1899    ///         If the parameter is optional.
1900    ///
1901    ///     * "empty"
1902    ///
1903    ///         For arrays that are allowed to be empty.
1904    ///
1905    ///     * "any"
1906    ///
1907    ///         Can only be placed last without a semicolon after.
1908    ///         Indicates that all remaining arguments that don't match
1909    ///         should also be passed through.
1910    ///
1911    ///     ## Example
1912    ///
1913    ///     The following example declares the arguments "blah", "moo", and "asdf":
1914    ///
1915    ///     ```txt
1916    ///     blah:vnode;moo:int[]:opt;asdf:float:opt;
1917    ///     ```
1918    ///
1919    ///     The following example declares the arguments "blah" and accepts all other arguments
1920    ///     no matter the type:
1921    ///
1922    ///     ```txt
1923    ///     blah:vnode;any
1924    ///     ```
1925    ///
1926    /// * `returnType` - Specifies works similarly to `args` but instead specifies which keys
1927    ///     and what type will be returned. Typically this will be:
1928    ///
1929    ///     ```txt
1930    ///     clip:vnode;
1931    ///     ```
1932    ///
1933    ///     for video filters. It is important to not simply specify "any" for all filters
1934    ///     since this information is used for better auto-completion in many editors.
1935    ///
1936    /// * `argsFunc` -  See [`VSPublicFunction`].
1937    ///
1938    /// * `functionData` - Pointer to user data that gets passed to `argsFunc`
1939    ///     when creating a filter. Useful to register multiple filters using
1940    ///     a single `argsFunc` function.
1941    ///
1942    /// * `plugin` - Pointer to the plugin object in the core, as passed to
1943    ///     `VapourSynthPluginInit2()`.
1944    pub registerFunction: unsafe extern "system-unwind" fn(
1945        name: *const c_char,
1946        args: *const c_char,
1947        returnType: *const c_char,
1948        argsFunc: VSPublicFunction,
1949        functionData: *mut c_void,
1950        plugin: *mut VSPlugin,
1951    ) -> c_int,
1952    /// Returns a pointer to the plugin with the given identifier, or NULL if not found.
1953    ///
1954    /// # Arguments
1955    ///
1956    /// * `identifier` - Reverse URL that uniquely identifies the plugin.
1957    pub getPluginByID: unsafe extern "system-unwind" fn(
1958        identifier: *const c_char,
1959        core: *mut VSCore,
1960    ) -> *mut VSPlugin,
1961    /// Returns a pointer to the plugin with the given namespace, or `NULL` if not found.
1962    ///
1963    /// [`getPluginByID`](Self::getPluginByID) is generally a better option.
1964    ///
1965    /// # Arguments
1966    ///
1967    /// * `ns` - Namespace.
1968    pub getPluginByNamespace:
1969        unsafe extern "system-unwind" fn(ns: *const c_char, core: *mut VSCore) -> *mut VSPlugin,
1970    /// Used to enumerate over all currently loaded plugins.
1971    /// The order is fixed but provides no other guarantees.
1972    ///
1973    /// # Arguments
1974    ///
1975    /// * `plugin` - Current plugin. Pass `NULL` to get the first plugin.
1976    ///
1977    /// Returns a pointer to the next plugin in order or
1978    /// `NULL` if the final plugin has been reached.
1979    pub getNextPlugin:
1980        unsafe extern "system-unwind" fn(plugin: *mut VSPlugin, core: *mut VSCore) -> *mut VSPlugin,
1981    /// Returns the name of the plugin that was passed to
1982    /// [`configPlugin`](VSPLUGINAPI::configPlugin).
1983    pub getPluginName: unsafe extern "system-unwind" fn(plugin: *mut VSPlugin) -> *const c_char,
1984    /// Returns the identifier of the plugin that was passed to
1985    /// [`configPlugin`](VSPLUGINAPI::configPlugin).
1986    pub getPluginID: unsafe extern "system-unwind" fn(plugin: *mut VSPlugin) -> *const c_char,
1987    /// Returns the namespace the plugin currently is loaded in.
1988    pub getPluginNamespace:
1989        unsafe extern "system-unwind" fn(plugin: *mut VSPlugin) -> *const c_char,
1990    /// Used to enumerate over all functions in a plugin.
1991    /// The order is fixed but provides no other guarantees.
1992    ///
1993    /// # Arguments
1994    ///
1995    /// * `func` - Current function. Pass `NULL` to get the first function.
1996    ///
1997    /// * `plugin` - The plugin to enumerate functions in.
1998    ///
1999    /// Returns a pointer to the next function in order or
2000    /// `NULL` if the final function has been reached.
2001    pub getNextPluginFunction: unsafe extern "system-unwind" fn(
2002        func: *mut VSPluginFunction,
2003        plugin: *mut VSPlugin,
2004    ) -> *mut VSPluginFunction,
2005    /// Get a function belonging to a plugin by its name.
2006    pub getPluginFunctionByName: unsafe extern "system-unwind" fn(
2007        name: *const c_char,
2008        plugin: *mut VSPlugin,
2009    ) -> *mut VSPluginFunction,
2010    /// Returns the name of the function that was passed to
2011    /// [`registerFunction()`](Self::registerFunction).
2012    pub getPluginFunctionName:
2013        unsafe extern "system-unwind" fn(func: *mut VSPluginFunction) -> *const c_char,
2014    /// Returns the argument string of the function that was passed to
2015    /// [`registerFunction()`](Self::registerFunction).
2016    pub getPluginFunctionArguments:
2017        unsafe extern "system-unwind" fn(func: *mut VSPluginFunction) -> *const c_char,
2018    /// Returns the return type string of the function that was passed to
2019    /// [`registerFunction()`](Self::registerFunction).
2020    pub getPluginFunctionReturnType:
2021        unsafe extern "system-unwind" fn(func: *mut VSPluginFunction) -> *const c_char,
2022    /// Returns the absolute path to the plugin, including the plugin's file name.
2023    /// This is the real location of the plugin, i.e. there are no symbolic links in the path.
2024    ///
2025    /// Path elements are always delimited with forward slashes.
2026    ///
2027    /// `VapourSynth` retains ownership of the returned pointer.
2028    pub getPluginPath: unsafe extern "system-unwind" fn(plugin: *const VSPlugin) -> *const c_char,
2029    /// Returns the version of the plugin.
2030    /// This is the same as the version number passed to
2031    /// [`configPlugin()`](VSPLUGINAPI::configPlugin).
2032    pub getPluginVersion: unsafe extern "system-unwind" fn(plugin: *const VSPlugin) -> c_int,
2033    /// Invokes a filter.
2034    ///
2035    /// [`invoke()`](Self::invoke) checks that the args passed to the filter are consistent
2036    /// with the argument list registered by the plugin that contains the filter,
2037    /// calls the filter's "create" function, and checks that
2038    /// the filter returns the declared types.
2039    /// If everything goes smoothly, the filter will be ready to generate frames after
2040    /// [`invoke()`](Self::invoke) returns.
2041    ///
2042    /// # Arguments
2043    ///
2044    /// * `plugin` - A pointer to the plugin where the filter is located. Must not be `NULL`.
2045    ///
2046    ///     See [`getPluginByID()`](Self::getPluginByID).
2047    ///
2048    /// * `name` - Name of the filter to invoke.
2049    ///
2050    /// * `args` - Arguments for the filter.
2051    ///
2052    /// Returns a map containing the filter's return value(s).
2053    /// The caller takes ownership of the map.
2054    /// Use [`mapGetError()`](Self::mapGetError) to check if the filter was invoked successfully.
2055    ///
2056    /// Most filters will either set an error, or one or more clips with the key "clip".
2057    /// The exception to this are functions, for example `LoadPlugin`,
2058    /// which doesn't return any clips for obvious reasons.
2059    pub invoke: unsafe extern "system-unwind" fn(
2060        plugin: *mut VSPlugin,
2061        name: *const c_char,
2062        args: *const VSMap,
2063    ) -> *mut VSMap,
2064    // !SECTION
2065
2066    // SECTION - Core and information
2067    /// Creates the `VapourSynth` processing core and returns a pointer to it.
2068    /// It is possible to create multiple cores but in most cases it shouldn't be needed.
2069    ///
2070    /// # Arguments
2071    ///
2072    /// * `flags` - [`VSCoreCreationFlags`] `ORed` together if desired.
2073    ///    Pass 0 for sane defaults that should suit most uses.
2074    ///
2075    pub createCore: unsafe extern "system-unwind" fn(flags: c_int) -> *mut VSCore,
2076
2077    /// Frees a core. Should only be done after all frame requests have completed
2078    /// and all objects belonging to the core have been released.
2079    pub freeCore: unsafe extern "system-unwind" fn(core: *mut VSCore),
2080
2081    /// Sets the maximum size of the framebuffer cache.
2082    ///
2083    /// Note: the total cache size at which vapoursynth more aggressively tries to reclaim memory,
2084    /// it is not a hard limit
2085    ///
2086    /// # Return:
2087    ///
2088    /// the new maximum size.
2089    pub setMaxCacheSize: unsafe extern "system-unwind" fn(bytes: i64, core: *mut VSCore) -> i64,
2090
2091    /// Sets the number of threads used for processing. Pass 0 to automatically detect.
2092    /// Returns the number of threads that will be used for processing.
2093    pub setThreadCount:
2094        unsafe extern "system-unwind" fn(threads: c_int, core: *mut VSCore) -> c_int,
2095
2096    /// Returns information about the `VapourSynth` core.
2097    pub getCoreInfo: unsafe extern "system-unwind" fn(core: *mut VSCore, info: *mut VSCoreInfo),
2098
2099    /// Returns the highest [`VAPOURSYNTH_API_VERSION`]
2100    /// the library support.
2101    pub getAPIVersion: unsafe extern "system-unwind" fn() -> c_int,
2102    // !SECTION
2103
2104    // SECTION - Message handler
2105    /// Send a message through `VapourSynth`'s logging framework.
2106    /// See [`addLogHandler`](Self::addLogHandler).
2107    ///
2108    /// # Arguments
2109    /// * `msgType` - The type of message. One of [`VSMessageType`].
2110    ///
2111    ///     If `msgType` is [`VSMessageType::Fatal`],
2112    ///     `VapourSynth` will call `abort()` after delivering the message.
2113    ///
2114    /// * `msg` - The message.
2115    pub logMessage: unsafe extern "system-unwind" fn(
2116        msgType: VSMessageType,
2117        msg: *const c_char,
2118        core: *mut VSCore,
2119    ),
2120    /// Installs a custom handler for the various error messages `VapourSynth` emits.
2121    /// The message handler is per [`VSCore`] instance. Returns a unique handle.
2122    ///
2123    /// If no log handler is installed up to a few hundred messages are cached and
2124    /// will be delivered as soon as a log handler is attached. This behavior exists mostly
2125    /// so that warnings when auto-loading plugins (default behavior) won't disappear-
2126    ///
2127    /// # Arguments
2128    ///
2129    /// * `handler` -  Custom message handler. If this is `NULL`,
2130    ///     the default message handler will be restored.
2131    ///
2132    /// * `free` - Called when a handler is removed.
2133    ///
2134    /// * `userData` - Pointer that gets passed to the message handler.
2135    pub addLogHandler: unsafe extern "system-unwind" fn(
2136        handler: VSLogHandler,
2137        free: VSLogHandlerFree,
2138        userData: *mut c_void,
2139        core: *mut VSCore,
2140    ) -> *mut VSLogHandle,
2141    /// Removes a custom handler. Return non-zero on success and zero if the handle is invalid.
2142    ///
2143    /// # Arguments
2144    ///
2145    /// * `handle` - Handle obtained from [`addLogHandler()`](Self::addLogHandler).
2146    pub removeLogHandler:
2147        unsafe extern "system-unwind" fn(handle: *mut VSLogHandle, core: *mut VSCore) -> c_int,
2148
2149    // !SECTION
2150
2151    // MARK: API 4.1
2152    // mostly graph and node inspection, PLEASE DON'T USE INSIDE FILTERS
2153
2154    /* Additional cache management to free memory */
2155    /// clears the cache of the specified node
2156    #[cfg(feature = "vs-41")]
2157    pub clearNodeCache: unsafe extern "system-unwind" fn(node: *mut VSNode),
2158    /// clears all caches belonging to the specified core
2159    #[cfg(feature = "vs-41")]
2160    pub clearCoreCaches: unsafe extern "system-unwind" fn(core: *mut VSCore),
2161
2162    /* Basic node information */
2163    /// the name passed to `create*Filter*`
2164    #[cfg(feature = "vs-41")]
2165    pub getNodeName: unsafe extern "system-unwind" fn(node: *mut VSNode) -> *const c_char,
2166    #[cfg(feature = "vs-41")]
2167    /// returns [`VSFilterMode`]
2168    pub getNodeFilterMode: unsafe extern "system-unwind" fn(node: *mut VSNode) -> VSFilterMode,
2169    #[cfg(feature = "vs-41")]
2170    pub getNumNodeDependencies: unsafe extern "system-unwind" fn(node: *mut VSNode) -> c_int,
2171    #[cfg(feature = "vs-41")]
2172    pub getNodeDependencies:
2173        unsafe extern "system-unwind" fn(node: *mut VSNode) -> *const VSFilterDependency,
2174
2175    /* Node timing functions */
2176    /// non-zero when filter timing is enabled
2177    pub getCoreNodeTiming: unsafe extern "system-unwind" fn(core: *mut VSCore) -> c_int,
2178    /// non-zero enables filter timing, note that disabling simply stops the counters from incrementing
2179    pub setCoreNodeTiming: unsafe extern "system-unwind" fn(core: *mut VSCore, enable: c_int),
2180    /// time spent processing frames in nanoseconds, reset sets the counter to 0 again
2181    pub getNodeProcessingTime:
2182        unsafe extern "system-unwind" fn(node: *mut VSNode, reset: c_int) -> i64,
2183    /// time spent processing frames in nanoseconds in all destroyed nodes, reset sets the counter to 0 again
2184    pub getFreedNodeProcessingTime:
2185        unsafe extern "system-unwind" fn(core: *mut VSCore, reset: c_int) -> i64,
2186
2187    // MARK: Graph information
2188    /*
2189     * !!! Experimental/expensive graph information
2190     * These functions only exist to retrieve internal details for debug purposes and
2191     * graph visualization They will only only work properly when used on a core created
2192     * with `ccfEnableGraphInspection` and are not safe to use concurrently with frame requests
2193     * or other API functions. Because of this they are unsuitable for use in plugins and filters.
2194     */
2195    /// level=0 returns the name of the function that created the filter,
2196    /// specifying a higher level will retrieve the function above that
2197    /// invoked it or `NULL` if a non-existent level is requested
2198    #[cfg(feature = "vs-graph")]
2199    pub getNodeCreationFunctionName:
2200        unsafe extern "system-unwind" fn(node: *mut VSNode, level: c_int) -> *const c_char,
2201    /// level=0 returns a copy of the arguments passed to the function that created the filter,
2202    /// returns `NULL` if a non-existent level is requested
2203    #[cfg(feature = "vs-graph")]
2204    pub getNodeCreationFunctionArguments:
2205        unsafe extern "system-unwind" fn(node: *mut VSNode, level: c_int) -> *const VSMap,
2206}
2207
2208#[link(name = "vapoursynth")]
2209unsafe extern "system-unwind" {
2210    /// Returns a pointer to the global [`VSAPI`] instance.
2211    ///
2212    /// Returns `NULL` if the requested API version is not supported or
2213    /// if the system does not meet the minimum requirements to run `VapourSynth`.
2214    /// It is recommended to pass [`VAPOURSYNTH_API_VERSION`]
2215    pub fn getVapourSynthAPI(version: c_int) -> *const VSAPI;
2216}
2217
2218#[cfg(test)]
2219mod tests {
2220    use super::*;
2221
2222    #[test]
2223    fn layout() {
2224        assert_eq!(
2225            std::mem::size_of::<VSPresetVideoFormat>(),
2226            std::mem::size_of::<c_int>(),
2227            "VSPresetFormat"
2228        );
2229        assert_eq!(
2230            std::mem::size_of::<VSDataTypeHint>(),
2231            std::mem::size_of::<c_int>(),
2232            "VSDataTypeHint"
2233        );
2234        assert_eq!(
2235            std::mem::size_of::<VSCoreCreationFlags>(),
2236            std::mem::size_of::<c_int>(),
2237            "VSCoreCreationFlags"
2238        );
2239        assert_eq!(
2240            std::mem::size_of::<VSFilterMode>(),
2241            std::mem::size_of::<c_int>(),
2242            "VSFilterMode"
2243        );
2244        assert_eq!(
2245            std::mem::size_of::<VSColorFamily>(),
2246            std::mem::size_of::<c_int>(),
2247            "VSColorFamily"
2248        );
2249        assert_eq!(
2250            std::mem::size_of::<VSSampleType>(),
2251            std::mem::size_of::<c_int>(),
2252            "VSSampleType"
2253        );
2254        assert_eq!(
2255            std::mem::size_of::<VSMapAppendMode>(),
2256            std::mem::size_of::<c_int>(),
2257            "VSMapAppendMode"
2258        );
2259        assert_eq!(
2260            std::mem::size_of::<VSMessageType>(),
2261            std::mem::size_of::<c_int>(),
2262            "VSMessageType"
2263        );
2264        assert_eq!(
2265            std::mem::size_of::<VSCacheMode>(),
2266            std::mem::size_of::<c_int>(),
2267            "VSCacheMode"
2268        );
2269    }
2270}