GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 7
Functions: 0.0% 0 / 0 / 4
Branches: -% 0 / 0 / 0

include/avisynth_c.h
Line Branch Exec Source
1 // Avisynth C Interface Version 0.20
2 // Copyright 2003 Kevin Atkinson
3
4 // Copyright 2020 AviSynth+ project
5 // Actual C Interface version follows the global Avisynth+ IF version numbers.
6
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 // MA 02110-1301 USA, or visit
21 // http://www.gnu.org/copyleft/gpl.html .
22 //
23 // As a special exception, I give you permission to link to the
24 // Avisynth C interface with independent modules that communicate with
25 // the Avisynth C interface solely through the interfaces defined in
26 // avisynth_c.h, regardless of the license terms of these independent
27 // modules, and to copy and distribute the resulting combined work
28 // under terms of your choice, provided that every copy of the
29 // combined work is accompanied by a complete copy of the source code
30 // of the Avisynth C interface and Avisynth itself (with the version
31 // used to produce the combined work), being distributed under the
32 // terms of the GNU General Public License plus this exception. An
33 // independent module is a module which is not derived from or based
34 // on Avisynth C Interface, such as 3rd-party filters, import and
35 // export plugins, or graphical user interfaces.
36
37 // NOTE: this is a partial update of the Avisynth C interface to recognize
38 // new color spaces and interface elements added in Avisynth 2.60 and AviSynth+.
39 // This interface is not 100% Avisynth+ CPP interface equivalent.
40
41 // 170103: added new CPU constants (FMA4, AVX512xx)
42 // 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64.
43 // 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access
44 // 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access
45 // 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init
46 // 180524: avs_is_same_colorspace VideoInfo parameters to const
47 // 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff
48 // 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions
49 // 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define)
50 // 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN
51 // 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference)
52 // 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions:
53 // if they are not loadable, they will work in a classic Avisynth compatible mode
54 // Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead
55 // Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel)
56 // Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL
57 // 2002xx non-Windows friendly additions
58 // 200305 avs_vsprintf parameter type change: (void *) to va_list
59 // 200330: (remove test SIZETMOD define for clarity)
60 // 200513: user must use explicite #define AVS26_FALLBACK_SIMULATION for having fallback helpers in dynamic loaded library section
61 // 200513: Follow AviSynth+ V8 interface additions
62 // AVS_VideoFrame struct extended with placeholder for frame property pointer
63 // avs_subframe_planar_a
64 // avs_copy_frame_props
65 // avs_get_frame_props_ro, avs_get_frame_props_rw
66 // avs_prop_num_keys, avs_prop_get_key, avs_prop_num_elements, avs_prop_get_type, avs_prop_get_data_size
67 // avs_prop_get_int, avs_prop_get_float, avs_prop_get_data, avs_prop_get_clip, avs_prop_get_frame, avs_prop_get_int_array, avs_prop_get_float_array
68 // avs_prop_set_int, avs_prop_set_float, avs_prop_set_data, avs_prop_set_clip, avs_prop_set_frame, avs_prop_set_int_array, avs_prop_set_float_array
69 // avs_prop_delete_key, avs_clear_map
70 // avs_new_video_frame_p, avs_new_video_frame_p_a
71 // avs_get_env_property (internal system properties), AVS_AEP_xxx (AvsEnvProperty) enums
72 // avs_get_var_try, avs_get_var_bool, avs_get_var_int, avs_get_var_double, avs_get_var_string, avs_get_var_long
73 // avs_pool_allocate, avs_pool_free
74 // 2021: Follow AviSynth+ V9 interface additions
75 // avs_is_property_writable, avs_make_property_writable
76 // Add enum AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION (AVISYNTH_INTERFACE_VERSION still exists)
77 // Add enum AVS_AEP_HOST_SYSTEM_ENDIANNESS to system property request types (avs_get_env_property)
78 // Add enums AVS_AEP_INTERFACE_VERSION and AVS_AEP_INTERFACE_BUGFIX for direct interface version system property request types (avs_get_env_property)
79 // Bugfix 9.1: fix avs_prop_get_data
80 // 2023: Follow AviSynth+ V10 interface additions
81 // Add enum AVS_DEFAULT_PLANE (as 0) to plane constants
82 // prop_src argument now const in avs_new_video_frame_p and avs_new_video_frame_p_a (no change in use)
83 // Add pixel_type to struct AVS_VideoFrame
84 // Add avs_video_frame_get_pixel_type and avs_video_frame_amend_pixel_type for getting and setting AVS_VideoFrame pixel_type
85 // Additional AviSynth+ V10 interface additions:
86 // Add enum AVS_SPEAKER_xxx, AVS_IT_SPEAKER_xxx
87 // Audio channel mask support API: avs_is_channel_mask_known, avs_set_channel_mask, avs_get_channel_mask
88
89 // 2025 Follow AviSynth+ V11 interface additions (AVSValue new 64-bit types);
90 // Setters are all accept AVS_Value by reference, like avs_set_to_clip did so far. (unlike avs_new_xxx inline helpers, which returns AVS_Value directly)
91 // - avs_val_defined = avs_defined
92 // - avs_val_is_xxx = avs_is_xxx (bool, clip, int, long_strict, string, float_strict, float, error, array)
93 // - avs_set_to_xxx ~avs_new_value_xxx (bool, clip, int, long, string, float, double, error, array)
94 // - avs_set_to_void = AVS_void constant direct assignment
95 // - avs_get_as_xxx = avs_as_xxx (bool, clip, int, long, string, float, error, array)
96 // - avs_get_array_size = avs_array_size
97 // - avs_get_array_elt = avs_array_elt
98 // Including:
99 // Modified INLINE typecheck and getter helpers for 64-bit data type awareness:
100 // - avs_is_int, avs_is_float
101 // - avs_as_int, avs_as_float
102 // Strict type checkers
103 // - avs_val_is_long_strict, avs_val_is_floatf_strict
104 // New INLINE getter helpers for 64-bit data (prefer using API calls):
105 // - avs_as_long
106 // New optional plugin entry point: avisynth_c_plugin_init2
107 // - A C plugin signals to AviSynth that it is V11 interface (64-bit data) ready by implementing avisynth_c_plugin_init2 as well.
108 // avisynth_c_plugin_init2 has the same signature as avisynth_c_plugin_init and can
109 // simply call forward to the old avisynth_c_plugin_init entry point. Both entry points can be implemented;
110 // AviSynth+ will first check avisynth_c_plugin_init2, then avisynth_c_plugin_init.
111 // Don't forget to add a new
112 // avisynth_c_plugin_init2@4 = _avisynth_c_plugin_init2@4
113 // line to your existing .def file on Win32.
114 // Deprecated inline helper functions, which in turn would call API.
115 // - avs_get_pitch => avs_get_pitch_p(p, AVS_DEFAULT_PLANE)
116 // avs_get_row_size => avs_get_row_size_p(p, AVS_DEFAULT_PLANE)
117 // avs_get_height => avs_get_height_p(p, AVS_DEFAULT_PLANE)
118 // avs_get_read_ptr => avs_get_read_ptr_p(p, AVS_DEFAULT_PLANE)
119 // avs_get_write_ptr => vs_get_write_ptr_p(p, AVS_DEFAULT_PLANE)
120 // avs_release_frame => avs_release_video_frame
121 // avs_copy_frame => avs_copy_video_frame
122 // - Use #define AVSC_ALLOW_DEPRECATED if they still need for you,
123 // but better fix your code: use the recommended replacements.
124 // Intentionally renamed AVS_VideoFrame internal fields, direct access was always prohibited, next API will remove the access.
125 // Add missing AVS_MT_xxxx mode constants to header like c++ header enum MtMode
126 // Add AVS_PROPDATATYPEHINT_xxx for AVSPropDataTypeHint
127 // New avs_prop_get_int_saturated and avs_prop_get_float_saturated
128 // New avs_prop_get_data_type_hint
129 // New avs_prop_set_data_h
130 // New avs_add_func_r: alternative avs_add_func which returns the result in a byref parameter
131 // New AVS_ApplyFuncR type
132 // 20250415 V11.1 Fix AVS_Value 64 bit data member declaration for 64-bit non Intel (other than X86_X64) systems.
133 // 20250601 V12 Global lock acquire and release: avs_acquire_global_lock, avs_release_global_lock
134 // 20251127 V12 AVS_CACHE_INFORM_NUM_THREADS constant to inform the filter about the number of threads by avs_set_cache_hints
135 // Add const AVS_AEP_CACHESIZE_L2 for avs_get_env_property level 2 cache size query,
136 // 20251202 Add avs_get_cpu_flags_ex returning full 64 bit flags, new AVX-512 group flags, ARM64 CPU flags.
137
138 // Notes.
139 // Choose either method:
140 // By loading avisynth.dll/.so/.dylib dinamically, AviSynth versions with different API level can be supported.
141 // - Use #define AVSC_NO_DECLSPEC for function pointer definitions only.
142 // - Load the library dynamically and get the necessary API functions as needed.
143 // - Earlier AviSynth versions may contain fewer API functions.
144 // By detecting the loaded AviSynth/interface version, it's the caller's responsibility
145 // to call only those API functions which have valid function pointers and are documented to work.
146 // E.g., you should only use frame property-related functions when lib.avs_get_version(clip) >= 9.
147 // For linking avisynth.lib/libavisynth directly to your module:
148 // - Leave AVSC_NO_DECLSPEC undefined.
149 // - Link the provided .lib to your module.
150 // - Your plugin/software won't work with older AviSynth instances if it uses newer API functions.
151 // The plugin DLL won't load due to dependency issues. (On Windows: platform returned code 127)
152
153
154 #ifndef __AVISYNTH_C__
155 #define __AVISYNTH_C__
156
157 #include "avs/config.h"
158 #include "avs/capi.h"
159 #include "avs/types.h"
160
161 #define AVS_FRAME_ALIGN FRAME_ALIGN
162 /////////////////////////////////////////////////////////////////////
163 //
164 // Constants
165 //
166
167 #ifndef __AVISYNTH_12_H__
168 enum {
169 AVISYNTH_INTERFACE_CLASSIC_VERSION = 6,
170 AVISYNTH_INTERFACE_VERSION = 12,
171 AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps
172 };
173 #endif
174
175 enum {
176 AVS_SAMPLE_INT8 = 1 << 0,
177 AVS_SAMPLE_INT16 = 1 << 1,
178 AVS_SAMPLE_INT24 = 1 << 2,
179 AVS_SAMPLE_INT32 = 1 << 3,
180 AVS_SAMPLE_FLOAT = 1 << 4
181 };
182
183 enum {
184 AVS_DEFAULT_PLANE = 0,
185 AVS_PLANAR_Y = 1 << 0,
186 AVS_PLANAR_U = 1 << 1,
187 AVS_PLANAR_V = 1 << 2,
188 AVS_PLANAR_ALIGNED = 1 << 3,
189 AVS_PLANAR_Y_ALIGNED = AVS_PLANAR_Y | AVS_PLANAR_ALIGNED,
190 AVS_PLANAR_U_ALIGNED = AVS_PLANAR_U | AVS_PLANAR_ALIGNED,
191 AVS_PLANAR_V_ALIGNED = AVS_PLANAR_V | AVS_PLANAR_ALIGNED,
192 AVS_PLANAR_A = 1 << 4,
193 AVS_PLANAR_R = 1 << 5,
194 AVS_PLANAR_G = 1 << 6,
195 AVS_PLANAR_B = 1 << 7,
196 AVS_PLANAR_A_ALIGNED = AVS_PLANAR_A | AVS_PLANAR_ALIGNED,
197 AVS_PLANAR_R_ALIGNED = AVS_PLANAR_R | AVS_PLANAR_ALIGNED,
198 AVS_PLANAR_G_ALIGNED = AVS_PLANAR_G | AVS_PLANAR_ALIGNED,
199 AVS_PLANAR_B_ALIGNED = AVS_PLANAR_B | AVS_PLANAR_ALIGNED
200 };
201
202 // Colorspace properties.
203 enum {
204 AVS_CS_YUVA = 1 << 27,
205 AVS_CS_BGR = 1 << 28,
206 AVS_CS_YUV = 1 << 29,
207 AVS_CS_INTERLEAVED = 1 << 30,
208 AVS_CS_PLANAR = 1 << 31,
209
210 AVS_CS_SHIFT_SUB_WIDTH = 0,
211 AVS_CS_SHIFT_SUB_HEIGHT = 8,
212 AVS_CS_SHIFT_SAMPLE_BITS = 16,
213
214 AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,
215 AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24
216 AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16
217 AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411
218
219 AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
220 AVS_CS_UPLANEFIRST = 1 << 4, // I420
221
222 AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,
223 AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411
224 AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420
225 AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9
226
227 AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
228 AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,
229 AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS,
230 AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS,
231 AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS,
232 AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,
233 AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,
234
235 AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA
236 | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_WIDTH_MASK | AVS_CS_SUB_HEIGHT_MASK,
237 AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST),
238
239 AVS_CS_RGB_TYPE = 1 << 0,
240 AVS_CS_RGBA_TYPE = 1 << 1,
241
242 AVS_CS_GENERIC_YUV444 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1, // 4:4:4 planar
243 AVS_CS_GENERIC_YUV422 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1, // 4:2:2 planar
244 AVS_CS_GENERIC_YUV420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2, // 4:2:0 planar
245 AVS_CS_GENERIC_Y = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV, // Y only (4:0:0)
246 AVS_CS_GENERIC_RGBP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE, // planar RGB
247 AVS_CS_GENERIC_RGBAP = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE, // planar RGBA
248 AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1, // 4:4:4:A planar
249 AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1, // 4:2:2:A planar
250 AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2 // 4:2:0:A planar
251 };
252
253 // Specific color formats
254 enum {
255 AVS_CS_UNKNOWN = 0,
256 AVS_CS_BGR24 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
257 AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,
258 AVS_CS_YUY2 = 1 << 2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,
259 // AVS_CS_YV12 = 1 << 3 Reserved
260 // AVS_CS_I420 = 1 << 4 Reserved
261 AVS_CS_RAW32 = 1 << 5 | AVS_CS_INTERLEAVED,
262
263 AVS_CS_YV24 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8, // YUV 4:4:4 planar
264 AVS_CS_YV16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:2 planar
265 AVS_CS_YV12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8, // YUV 4:2:0 planar
266 AVS_CS_I420 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2, // YUV 4:2:0 planar
267 AVS_CS_IYUV = AVS_CS_I420,
268 AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_1, // YUV 4:1:1 planar
269 AVS_CS_YUV9 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_4, // YUV 4:1:0 planar
270 AVS_CS_Y8 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8, // Y 4:0:0 planar
271
272 //-------------------------
273 // AVS16: new planar constants go live! Experimental PF 160613
274 // 10-12-14-16 bit + planar RGB + BGR48/64 160725
275 AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples
276 AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples
277 AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples
278 AVS_CS_Y10 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10, // Y 4:0:0 10bit samples
279
280 AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples
281 AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples
282 AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples
283 AVS_CS_Y12 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12, // Y 4:0:0 12bit samples
284
285 AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples
286 AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples
287 AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples
288 AVS_CS_Y14 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14, // Y 4:0:0 14bit samples
289
290 AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples
291 AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples
292 AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples
293 AVS_CS_Y16 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16, // Y 4:0:0 16bit samples
294
295 // 32 bit samples (float)
296 AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32, // YUV 4:4:4 32bit samples
297 AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:2 32bit samples
298 AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32, // YUV 4:2:0 32bit samples
299 AVS_CS_Y32 = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32, // Y 4:0:0 32bit samples
300
301 // RGB packed
302 AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 3x16 bit
303 AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16, // BGR 4x16 bit
304 // no packed 32 bit (float) support for these legacy types
305
306 // RGB planar
307 AVS_CS_RGBP = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8, // Planar RGB 8 bit samples
308 AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples
309 AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples
310 AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples
311 AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples
312 AVS_CS_RGBPS = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples
313
314 // RGBA planar
315 AVS_CS_RGBAP = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8, // Planar RGBA 8 bit samples
316 AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples
317 AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples
318 AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples
319 AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples
320 AVS_CS_RGBAPS = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples
321
322 // Planar YUVA
323 AVS_CS_YUVA444 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:4:4 8bit samples
324 AVS_CS_YUVA422 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:2 8bit samples
325 AVS_CS_YUVA420 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8, // YUVA 4:2:0 8bit samples
326
327 AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples
328 AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples
329 AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples
330
331 AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples
332 AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples
333 AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples
334
335 AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples
336 AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples
337 AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples
338
339 AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples
340 AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples
341 AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples
342
343 AVS_CS_YUVA444PS = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:4:4 32bit samples
344 AVS_CS_YUVA422PS = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:2 32bit samples
345 AVS_CS_YUVA420PS = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32, // YUVA 4:2:0 32bit samples
346 };
347
348 // AvsChannelMask enum: Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE
349 // in AvsImageTypeFlags they are shifted by 4 bits
350 enum {
351 AVS_MASK_SPEAKER_FRONT_LEFT = 0x1,
352 AVS_MASK_SPEAKER_FRONT_RIGHT = 0x2,
353 AVS_MASK_SPEAKER_FRONT_CENTER = 0x4,
354 AVS_MASK_SPEAKER_LOW_FREQUENCY = 0x8,
355 AVS_MASK_SPEAKER_BACK_LEFT = 0x10,
356 AVS_MASK_SPEAKER_BACK_RIGHT = 0x20,
357 AVS_MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40,
358 AVS_MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80,
359 AVS_MASK_SPEAKER_BACK_CENTER = 0x100,
360 AVS_MASK_SPEAKER_SIDE_LEFT = 0x200,
361 AVS_MASK_SPEAKER_SIDE_RIGHT = 0x400,
362 AVS_MASK_SPEAKER_TOP_CENTER = 0x800,
363 AVS_MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000,
364 AVS_MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000,
365 AVS_MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000,
366 AVS_MASK_SPEAKER_TOP_BACK_LEFT = 0x8000,
367 AVS_MASK_SPEAKER_TOP_BACK_CENTER = 0x10000,
368 AVS_MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000,
369 // Bit mask locations used up for the above positions
370 AVS_MASK_SPEAKER_DEFINED = 0x0003FFFF,
371 // Bit mask locations reserved for future use
372 AVS_MASK_SPEAKER_RESERVED = 0x7FFC0000,
373 // Used to specify that any possible permutation of speaker configurations
374 // Due to lack of available bits this one is put differently into image_type
375 AVS_MASK_SPEAKER_ALL = 0x80000000
376 };
377
378 // AvsImageTypeFlags
379 enum {
380 AVS_IT_BFF = 1 << 0,
381 AVS_IT_TFF = 1 << 1,
382 AVS_IT_FIELDBASED = 1 << 2,
383
384 // Audio channel mask support
385 AVS_IT_HAS_CHANNELMASK = 1 << 3,
386 // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask
387 // otherwise same as AvsChannelMask
388 AVS_IT_SPEAKER_FRONT_LEFT = 0x1 << 4,
389 AVS_IT_SPEAKER_FRONT_RIGHT = 0x2 << 4,
390 AVS_IT_SPEAKER_FRONT_CENTER = 0x4 << 4,
391 AVS_IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4,
392 AVS_IT_SPEAKER_BACK_LEFT = 0x10 << 4,
393 AVS_IT_SPEAKER_BACK_RIGHT = 0x20 << 4,
394 AVS_IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4,
395 AVS_IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4,
396 AVS_IT_SPEAKER_BACK_CENTER = 0x100 << 4,
397 AVS_IT_SPEAKER_SIDE_LEFT = 0x200 << 4,
398 AVS_IT_SPEAKER_SIDE_RIGHT = 0x400 << 4,
399 AVS_IT_SPEAKER_TOP_CENTER = 0x800 << 4,
400 AVS_IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4,
401 AVS_IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4,
402 AVS_IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4,
403 AVS_IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4,
404 AVS_IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4,
405 AVS_IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4,
406 // End of officially defined speaker bits
407 // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further.
408 // Set mask and get mask handles it.
409 AVS_IT_SPEAKER_ALL = 0x40000 << 4,
410 // Mask for the defined 18 bits + SPEAKER_ALL
411 AVS_IT_SPEAKER_BITS_MASK = (AVS_MASK_SPEAKER_DEFINED << 4) | AVS_IT_SPEAKER_ALL,
412 AVS_IT_NEXT_AVAILABLE = 1 << 23
413 };
414
415 enum {
416 AVS_FILTER_TYPE = 1,
417 AVS_FILTER_INPUT_COLORSPACE = 2,
418 AVS_FILTER_OUTPUT_TYPE = 9,
419 AVS_FILTER_NAME = 4,
420 AVS_FILTER_AUTHOR = 5,
421 AVS_FILTER_VERSION = 6,
422 AVS_FILTER_ARGS = 7,
423 AVS_FILTER_ARGS_INFO = 8,
424 AVS_FILTER_ARGS_DESCRIPTION = 10,
425 AVS_FILTER_DESCRIPTION = 11
426 };
427
428 enum { // SUBTYPES
429 AVS_FILTER_TYPE_AUDIO = 1,
430 AVS_FILTER_TYPE_VIDEO = 2,
431 AVS_FILTER_OUTPUT_TYPE_SAME = 3,
432 AVS_FILTER_OUTPUT_TYPE_DIFFERENT = 4
433 };
434
435 enum {
436 AVS_CACHE_25_NOTHING_26_UNUSED = 0,
437 // New 2.6 explicitly defined cache hints.
438 AVS_CACHE_NOTHING = 10, // Do not cache video.
439 AVS_CACHE_WINDOW = 11, // Hard protect up to X frames within a range of X from the current frame N.
440 AVS_CACHE_GENERIC = 12, // LRU cache up to X frames.
441 AVS_CACHE_FORCE_GENERIC = 13, // LRU cache up to X frames, override any previous CACHE_WINDOW.
442
443 AVS_CACHE_GET_POLICY = 30, // Get the current policy.
444 AVS_CACHE_GET_WINDOW = 31, // Get the current window h_span.
445 AVS_CACHE_GET_RANGE = 32, // Get the current generic frame range.
446
447 // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE
448 AVS_CACHE_AUDIO = 50, // Explicitly do cache audio, X byte cache.
449 AVS_CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio.
450 AVS_CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache.
451 AVS_CACHE_AUDIO_AUTO_START_OFF = 52, // synonym
452 AVS_CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache.
453 AVS_CACHE_AUDIO_AUTO_START_ON = 53, // synonym
454
455 // These just returns actual value if clip is cached
456 AVS_CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy.
457 AVS_CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size.
458
459 AVS_CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N.
460 AVS_CACHE_PREFETCH_GO = 101, // n/a Action video prefetches.
461
462 AVS_CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section).
463 AVS_CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start.
464 AVS_CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start.
465 AVS_CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length.
466 AVS_CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section).
467 AVS_CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches.
468
469 AVS_CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode.
470 AVS_CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size.
471
472 // Filters are queried about their desired audio cache mode.
473 // Child can answer them with CACHE_AUDIO_xxx
474 AVS_CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode.
475 AVS_CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size.
476
477 AVS_CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost.
478 AVS_CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only).
479 AVS_CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit).
480 AVS_CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast)
481 AVS_CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time)
482 AVS_CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow)
483
484 AVS_CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safety.
485 AVS_CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default!
486 AVS_CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default!
487 AVS_CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance.
488 AVS_CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded.
489
490 AVS_CACHE_GETCHILD_ACCESS_COST = 260, // Cache ask Child for preferred access pattern.
491 AVS_CACHE_ACCESS_RAND = 261, // Filter is access order agnostic.
492 AVS_CACHE_ACCESS_SEQ0 = 262, // Filter prefers sequential access (low cost)
493 AVS_CACHE_ACCESS_SEQ1 = 263, // Filter needs sequential access (high cost)
494
495 AVS_CACHE_AVSPLUS_CONSTANTS = 500, // Smaller values are reserved for classic Avisynth
496
497 AVS_CACHE_DONT_CACHE_ME = 501, // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request
498 AVS_CACHE_SET_MIN_CAPACITY = 502,
499 AVS_CACHE_SET_MAX_CAPACITY = 503,
500 AVS_CACHE_GET_MIN_CAPACITY = 504,
501 AVS_CACHE_GET_MAX_CAPACITY = 505,
502 AVS_CACHE_GET_SIZE = 506,
503 AVS_CACHE_GET_REQUESTED_CAP = 507,
504 AVS_CACHE_GET_CAPACITY = 508,
505 AVS_CACHE_GET_MTMODE = 509, // Filters specify their desired MT mode, see enum MtMode
506
507 // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache
508 AVS_CACHE_IS_CACHE_REQ = 510,
509 AVS_CACHE_IS_CACHE_ANS = 511,
510 // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard
511 AVS_CACHE_IS_MTGUARD_REQ = 512,
512 AVS_CACHE_IS_MTGUARD_ANS = 513,
513
514 // v12
515 AVS_CACHE_INFORM_NUM_THREADS = 514, // Allows a filter to receive the number of prefetch threads via set_cache_hints
516
517
518 AVS_CACHE_AVSPLUS_CUDA_CONSTANTS = 600,
519
520 AVS_CACHE_GET_DEV_TYPE = 601, // Device types a filter can return
521 AVS_CACHE_GET_CHILD_DEV_TYPE = 602, // Device types a fitler can receive
522
523 AVS_CACHE_USER_CONSTANTS = 1000 // Smaller values are reserved for the core
524 };
525
526
527
528 // enums for frame property functions
529 // AVSPropTypes
530 enum {
531 AVS_PROPTYPE_UNSET = 'u',
532 AVS_PROPTYPE_INT = 'i',
533 AVS_PROPTYPE_FLOAT = 'f',
534 AVS_PROPTYPE_DATA = 's',
535 AVS_PROPTYPE_CLIP = 'c',
536 AVS_PROPTYPE_FRAME = 'v'
537 };
538
539 // AVSGetPropErrors for avs_prop_get_...
540 enum {
541 AVS_GETPROPERROR_SUCCESS = 0,
542 AVS_GETPROPERROR_UNSET = 1,
543 AVS_GETPROPERROR_TYPE = 2,
544 AVS_GETPROPERROR_ERROR = 3,
545 AVS_GETPROPERROR_INDEX = 4
546 };
547
548 // AVSPropAppendMode for avs_prop_set_...
549 enum {
550 AVS_PROPAPPENDMODE_REPLACE = 0,
551 AVS_PROPAPPENDMODE_APPEND = 1,
552 AVS_PROPAPPENDMODE_TOUCH = 2 // n/a
553 };
554
555 // AVSPropDataTypeHint, used with prop_set_data_h
556 enum {
557 AVS_PROPDATATYPEHINT_UNKNOWN = -1, // dtUnknown = -1,
558 AVS_PROPDATATYPEHINT_BINARY = 0, // dtBinary = 0,
559 AVS_PROPDATATYPEHINT_UTF8 = 1 // dtUtf8 = 1
560 };
561
562
563 // AvsEnvProperty for avs_get_env_property
564 enum {
565 AVS_AEP_PHYSICAL_CPUS = 1,
566 AVS_AEP_LOGICAL_CPUS = 2,
567 AVS_AEP_THREADPOOL_THREADS = 3,
568 AVS_AEP_FILTERCHAIN_THREADS = 4,
569 AVS_AEP_THREAD_ID = 5,
570 AVS_AEP_VERSION = 6,
571 AVS_AEP_HOST_SYSTEM_ENDIANNESS = 7,
572 AVS_AEP_INTERFACE_VERSION = 8,
573 AVS_AEP_INTERFACE_BUGFIX = 9,
574 AVS_AEP_CACHESIZE_L2 = 10, // v12
575
576 // Neo additionals
577 AVS_AEP_NUM_DEVICES = 901,
578 AVS_AEP_FRAME_ALIGN = 902,
579 AVS_AEP_PLANE_ALIGN = 903,
580
581 AVS_AEP_SUPPRESS_THREAD = 921,
582 AVS_AEP_GETFRAME_RECURSIVE = 922
583 };
584
585 // enum AvsAllocType for avs_allocate
586 enum {
587 AVS_ALLOCTYPE_NORMAL_ALLOC = 1,
588 AVS_ALLOCTYPE_POOLED_ALLOC = 2
589 };
590
591 // Multithreading behaviour. AVS_Clip avs_set_cache_hints can return them on AVS_CACHE_GET_MTMODE query
592 enum {
593 AVS_MT_INVALID = 0,
594 AVS_MT_NICE_FILTER = 1,
595 AVS_MT_MULTI_INSTANCE = 2,
596 AVS_MT_SERIALIZED = 3,
597 AVS_MT_SPECIAL_MT = 4,
598 AVS_MT_MODE_COUNT = 5
599 };
600
601
602 #ifdef BUILDING_AVSCORE
603 AVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0);
604
605 struct AVS_ScriptEnvironment {
606 IScriptEnvironment * env;
607 const char * error;
608 AVS_ScriptEnvironment(IScriptEnvironment * e = 0)
609 : env(e), error(0) {}
610 };
611 #endif
612
613 typedef struct AVS_Clip AVS_Clip;
614 typedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;
615
616 /////////////////////////////////////////////////////////////////////
617 //
618 // AVS_VideoInfo
619 //
620
621 // AVS_VideoInfo is laid out identically to VideoInfo
622 typedef struct AVS_VideoInfo {
623 int width, height; // width=0 means no video
624 unsigned fps_numerator, fps_denominator;
625 int num_frames;
626
627 int pixel_type;
628
629 int audio_samples_per_second; // 0 means no audio
630 int sample_type;
631 int64_t num_audio_samples;
632 int nchannels;
633
634 // Image type properties
635 // BFF, TFF, FIELDBASED. Also used for storing Channel Mask
636 // Manipulate it through the channelmask interface calls
637 int image_type;
638 } AVS_VideoInfo;
639
640 // useful functions of the above
641 AVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)
642 { return (p->width!=0); }
643
644 AVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)
645 { return (p->audio_samples_per_second!=0); }
646
647 AVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)
648 { return !!(p->pixel_type&AVS_CS_BGR); }
649
650 AVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)
651 { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }
652
653 AVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)
654 { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }
655
656 AVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)
657 { return !!(p->pixel_type&AVS_CS_YUV ); }
658
659 AVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)
660 { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }
661
662 AVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444
663
664 AVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422
665
666 AVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420
667
668 AVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);
669
670 AVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y
671
672 AVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);
673
674 AVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);
675
676 AVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);
677
678 AVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels);
679
680 AVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);
681
682 AVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);
683
684 AVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space);
685
686 // no API for these, inline helper functions
687
688 // this is _not_ for frame properties
689 AVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)
690 {
691 return ((p->image_type & property) == property);
692 }
693
694 AVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)
695 {
696 return !!(p->pixel_type & AVS_CS_PLANAR);
697 }
698
699 AVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)
700 {
701 return !!(p->image_type & AVS_IT_FIELDBASED);
702 }
703
704 AVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)
705 {
706 return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF)));
707 }
708
709 AVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)
710 {
711 return !!(p->image_type & AVS_IT_BFF);
712 }
713
714 AVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)
715 {
716 return !!(p->image_type & AVS_IT_TFF);
717 }
718
719 AVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)
720 { return p->audio_samples_per_second; }
721
722 AVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)
723 {
724 switch (p->sample_type) {
725 case AVS_SAMPLE_INT8: return sizeof(signed char);
726 case AVS_SAMPLE_INT16: return sizeof(signed short);
727 case AVS_SAMPLE_INT24: return 3;
728 case AVS_SAMPLE_INT32: return sizeof(signed int);
729 case AVS_SAMPLE_FLOAT: return sizeof(float);
730 default: return 0;
731 }
732 }
733
734 AVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)
735 { return p->nchannels*avs_bytes_per_channel_sample(p);}
736
737 AVSC_INLINE int64_t avs_audio_samples_from_frames(const AVS_VideoInfo * p, int64_t frames)
738 { return ((int64_t)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }
739
740 AVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)
741 { return (int)(samples * (int64_t)p->fps_numerator / (int64_t)p->fps_denominator / (int64_t)p->audio_samples_per_second); }
742
743 AVSC_INLINE int64_t avs_audio_samples_from_bytes(const AVS_VideoInfo * p, int64_t bytes)
744 { return bytes / avs_bytes_per_audio_sample(p); }
745
746 AVSC_INLINE int64_t avs_bytes_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)
747 { return samples * avs_bytes_per_audio_sample(p); }
748
749 AVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)
750 { return p->nchannels; }
751
752 AVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)
753 { return p->sample_type;}
754
755 // useful mutator
756 // Note: these are video format properties, neither frame properties, nor system properties
757 AVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)
758 { p->image_type|=property; }
759
760 AVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)
761 { p->image_type&=~property; }
762
763 AVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)
764 { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }
765
766 AVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)
767 {
768 unsigned x=numerator, y=denominator;
769 while (y) { // find gcd
770 unsigned t = x%y; x = y; y = t;
771 }
772 p->fps_numerator = numerator/x;
773 p->fps_denominator = denominator/x;
774 }
775
776 #ifndef AVSC_NO_DECLSPEC
777 // this inline function is calling an API function
778 AVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y)
779 {
780 return (x->pixel_type == y->pixel_type)
781 || (avs_is_yv12(x) && avs_is_yv12(y));
782 }
783 #endif
784
785 // AviSynth+ extensions
786 AVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);
787
788 AVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);
789
790 AVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444
791 AVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422
792 AVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420
793 AVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // deprecated, use avs_is_y
794 AVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444
795 AVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422
796 AVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420
797 AVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // deprecated, use avs_is_y
798
799 AVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);
800
801 AVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);
802
803 AVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);
804
805 AVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);
806
807 AVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);
808
809 AVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);
810
811 AVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);
812
813 AVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);
814
815 AVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);
816
817 AVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);
818
819 // V10
820 AVSC_API(bool, avs_is_channel_mask_known)(const AVS_VideoInfo* p);
821
822 AVSC_API(void, avs_set_channel_mask)(const AVS_VideoInfo* p, bool isChannelMaskKnown, unsigned int dwChannelMask);
823
824 AVSC_API(unsigned int, avs_get_channel_mask)(const AVS_VideoInfo* p);
825
826 // end of Avisynth+ specific
827
828 /////////////////////////////////////////////////////////////////////
829 //
830 // AVS_VideoFrame
831 //
832
833 // VideoFrameBuffer holds information about a memory block which is used
834 // for video data. For efficiency, instances of this class are not deleted
835 // when the refcount reaches zero; instead they're stored in a linked list
836 // to be reused. The instances are deleted when the corresponding AVS
837 // file is closed.
838
839 // DEPRECATION WARNING
840 // Note: The V12 API will only define
841 // typedef struct AVS_VideoFrame AVS_VideoFrame;
842 // without including any internals of AVS_VideoFrame and AVS_VideoFrameBuffer.
843
844 // AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer
845 // DO NOT USE THIS STRUCTURE DIRECTLY
846 typedef struct AVS_VideoFrameBuffer {
847 BYTE * data;
848 int data_size;
849 // sequence_number is incremented every time the buffer is changed, so
850 // that stale views can tell they're no longer valid.
851 volatile long sequence_number;
852
853 volatile long refcount;
854
855 void* device; // avs+
856 } AVS_VideoFrameBuffer;
857
858 // VideoFrame holds a "window" into a VideoFrameBuffer.
859
860 // AVS_VideoFrame is laid out identically to VideoFrame
861 // DO NOT USE THIS STRUCTURE DIRECTLY
862 // In V11 header a leading '_' was added to member names intentionally.
863 // Stop direct access and use avs_get_xxx API calls instead!
864 typedef struct AVS_VideoFrame {
865 volatile long _refcount;
866 AVS_VideoFrameBuffer * _vfb;
867 int _offset;
868 // DO NOT USE THEM DIRECTLY
869 // Use avs_get_pitch_p, avs_get_row_size_p, avs_get_height_p
870 int _pitch, _row_size, _height;
871 int _offsetU, _offsetV;
872 int _pitchUV; // U&V offsets are from top of picture.
873 int _row_sizeUV, _heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.
874 // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)
875 // the decision on existence of UV is checked by zero pitch
876 // AVS+ extension, avisynth.h: class does not break plugins if appended here
877 int _offsetA;
878 int _pitchA, _row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none
879 void* _properties; // interface V8: frame properties
880 // DO NOT USE DIRECTLY
881 // Use avs_video_frame_get_pixel_type (and avs_video_frame_amend_pixel_type in special cases)
882 int _pixel_type; // Interface V10: an automatically maintained copy from AVS_VideoInfo
883 } AVS_VideoFrame;
884
885 // Access functions for AVS_VideoFrame
886 AVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);
887
888 AVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);
889
890 AVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);
891
892 AVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);
893
894 AVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);
895
896 // V9
897 AVSC_API(int, avs_is_property_writable)(const AVS_VideoFrame* p);
898
899 AVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane);
900
901 AVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);
902 // makes a shallow copy of a video frame
903 AVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);
904
905 // V10
906 AVSC_API(int, avs_video_frame_get_pixel_type)(const AVS_VideoFrame* p);
907
908 AVSC_API(void, avs_video_frame_amend_pixel_type)(AVS_VideoFrame* p, int new_pixel_type);
909
910 #ifndef AVSC_NO_DECLSPEC
911 #ifdef AVSC_ALLOW_DEPRECATED
912 // Old inline helper functions which are named differently but eventually call API.
913 // Deprecated. If possible, do not use them any more
914 // Get data for plane AVS_DEFAULT_PLANE (Y or packed rgb):
915 AVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) { return avs_get_pitch_p(p, AVS_DEFAULT_PLANE); }
916 AVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) { return avs_get_row_size_p(p, AVS_DEFAULT_PLANE); }
917 AVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) { return avs_get_height_p(p, AVS_DEFAULT_PLANE); }
918 AVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) { return avs_get_read_ptr_p(p, AVS_DEFAULT_PLANE); }
919 AVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) { return avs_get_write_ptr_p(p, AVS_DEFAULT_PLANE); }
920 // named alternatively:
921 AVSC_INLINE void avs_release_frame(AVS_VideoFrame* f) { avs_release_video_frame(f); }
922 AVSC_INLINE AVS_VideoFrame* avs_copy_frame(AVS_VideoFrame* f) { return avs_copy_video_frame(f); }
923 #endif
924 #endif
925
926 // Interface V8: frame properties
927 // AVS_Map is just a placeholder for AVSMap
928 typedef struct AVS_Map {
929 void* data;
930 } AVS_Map;
931
932
933 /////////////////////////////////////////////////////////////////////
934 //
935 // AVS_Value
936 //
937
938 // Treat AVS_Value as a fat pointer. That is use avs_copy_value
939 // and avs_release_value appropriately as you would if AVS_Value was
940 // a pointer.
941
942 // To maintain source code compatibility with future versions of the
943 // avisynth_c API don't use the AVS_Value directly. Use the helper
944 // functions below.
945
946 // AVS_Value is laid out identically to AVSValue
947 typedef struct AVS_Value AVS_Value;
948 struct AVS_Value {
949 short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 'd'ouble, 's'tring, 'v'oid, or 'l'ong, or fu'n'ction
950 // for some function 'e'rror
951 short array_size;
952 union {
953 void * clip; // do not use directly, use avs_take_clip
954 char boolean;
955 int integer;
956 float floating_pt;
957 const char * string;
958 const AVS_Value * array;
959 void * function; // not supported on C interface
960 #if UINTPTR_MAX >= 0xffffffffffffffff
961 // if ever, only x64 will support. It breaks struct size on 32 bit
962 int64_t longlong; // 8 bytes
963 double double_pt; // 8 bytes
964 #else
965 // 32 bit support workaround, pointers dont't break struct size on 32 bit
966 int64_t *longlong_ptr;
967 double *double_pt_ptr;
968 #endif
969 } d;
970 };
971
972 // AVS_Value should be initialized with avs_void.
973 // Should also set to avs_void after the value is released
974 // with avs_copy_value. Consider it the equivalent of setting
975 // a pointer to NULL
976 static const AVS_Value avs_void = {'v', 0, {0}};
977 // see also avs_set_to_void v11 API
978
979 /*******************************
980 * AVS_Value copy through API
981 *******************************/
982 // requires avs_release_value! Can deep copy dyn_arrays.
983 AVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);
984
985 /*******************************
986 * AVS_Value release through API
987 *******************************/
988 AVSC_API(void, avs_release_value)(AVS_Value);
989
990 /*************************************************
991 * AVS_Value -> AVS_Clip get reference through API
992 *************************************************/
993 // requires avs_release_clip!
994 AVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);
995
996 /****************************************************************************
997 * AVS_Value type testers avs_is_xxxx ("baked" inline code) - NOT through API
998 ****************************************************************************/
999 AVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }
1000 AVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }
1001 AVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }
1002 // v11: changed: for 32-bit 'int' or 64-bit 'long' as well
1003 AVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i' || v.type == 'l'; }
1004 // v11: new: for strict 64-bit 'long' content only
1005 AVSC_INLINE int avs_is_long_strict(AVS_Value v) { return v.type == 'l'; }
1006 // v11: changed: for 'double' and 'l'ong along with 'float' and 'int'
1007 AVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'd' || v.type == 'f' || v.type == 'i' || v.type == 'l'; }
1008 // v11: new: for strict 64-bit 'long' content only
1009 AVSC_INLINE int avs_is_floatf_strict(AVS_Value v) { return v.type == 'f'; }
1010 AVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }
1011 AVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }
1012 AVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }
1013
1014 /****************************************************************************
1015 * AVS_Value type testers avs_val_is_xxxx (API)
1016 ****************************************************************************/
1017 AVSC_API(int, avs_val_defined)(AVS_Value v);
1018 AVSC_API(int, avs_val_is_clip)(AVS_Value v);
1019 AVSC_API(int, avs_val_is_bool)(AVS_Value v);
1020 // v11: changed: for 32-bit 'int' or 64-bit 'long' as well
1021 AVSC_API(int, avs_val_is_int)(AVS_Value v);
1022 // v11: new: for strict 64-bit 'long' content only
1023 AVSC_API(int, avs_val_is_long_strict)(AVS_Value v);
1024 // v11: changed: for 'double' and 'l'ong along with 'float' and 'int'
1025 AVSC_API(int, avs_val_is_float)(AVS_Value v);
1026 // v11: new: for strict 32-bit 'float' content only
1027 AVSC_API(int, avs_val_is_floatf_strict)(AVS_Value v);
1028 AVSC_API(int, avs_val_is_string)(AVS_Value v);
1029 AVSC_API(int, avs_val_is_array)(AVS_Value v);
1030 AVSC_API(int, avs_val_is_error)(AVS_Value v);
1031
1032 /***********************************************************
1033 * AVS_Value getters ("baked" inline code) - NOT through API
1034 ***********************************************************/
1035 AVSC_INLINE int avs_as_bool(AVS_Value v) { return v.d.boolean; }
1036 // v11: avs_as_int also valid for 64-bit 'l'ong, but it gets truncated
1037 AVSC_INLINE int avs_as_int(AVS_Value v)
1038 {
1039 // we'll return a casted int64_t as-is
1040 #if UINTPTR_MAX >= 0xffffffffffffffff
1041 return v.type == 'l' ? (int)v.d.longlong : v.d.integer;
1042 #else
1043 return v.type == 'l' ? (int)*v.d.longlong_ptr : v.d.integer;
1044 #endif
1045 }
1046 // v11: new, returns true 64 bit value, even for 32 bit content
1047 AVSC_INLINE int64_t avs_as_long(AVS_Value v)
1048 {
1049 #if UINTPTR_MAX >= 0xffffffffffffffff
1050 return v.type == 'l' ? v.d.longlong : v.d.integer;
1051 #else
1052 return v.type == 'l' ? *v.d.longlong_ptr : v.d.integer;
1053 #endif
1054 }
1055 AVSC_INLINE const char * avs_as_string(AVS_Value v)
1056 { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }
1057
1058 // v11: Extended for 'double' and 'l'ong
1059 AVSC_INLINE double avs_as_float(AVS_Value v)
1060 {
1061 #if UINTPTR_MAX >= 0xffffffffffffffff
1062 return v.type == 'i' ? v.d.integer : v.type=='l' ? v.d.longlong : v.type == 'd' ? v.d.double_pt : v.d.floating_pt;
1063 #else
1064 return v.type == 'i' ? v.d.integer : v.type == 'l' ? *v.d.longlong_ptr : v.type == 'd' ? *v.d.double_pt_ptr : v.d.floating_pt;
1065 #endif
1066 }
1067 AVSC_INLINE const char * avs_as_error(AVS_Value v)
1068 { return avs_is_error(v) ? v.d.string : 0; }
1069 AVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)
1070 { return v.d.array; }
1071
1072 /***********************************************************
1073 * AVS_Value getters - using API v11
1074 ***********************************************************/
1075 // API versions of the above. The AVS_Value is passed by reference everywhere
1076 AVSC_API(int, avs_get_as_bool)(AVS_Value v);
1077 AVSC_API(AVS_Clip *, avs_get_as_clip)(AVS_Value v, AVS_ScriptEnvironment* env); // similar to avs_take_clip
1078 AVSC_API(int, avs_get_as_int)(AVS_Value v);
1079 AVSC_API(int64_t, avs_get_as_long)(AVS_Value v);
1080 AVSC_API(const char*, avs_get_as_string)(AVS_Value v);
1081 AVSC_API(double, avs_get_as_float)(AVS_Value v);
1082 AVSC_API(const char*, avs_get_as_error)(AVS_Value v);
1083 AVSC_API(const AVS_Value*, avs_get_as_array)(AVS_Value v);
1084
1085 /***********************************************************
1086 * AVS_Value array access - using API v11
1087 ***********************************************************/
1088 AVSC_API(AVS_Value, avs_get_array_elt)(AVS_Value v, int index);
1089 AVSC_API(int, avs_get_array_size)(AVS_Value v);
1090
1091 /***********************************************************
1092 * AVS_Value array access - ("baked" inline code) - NOT through API
1093 ***********************************************************/
1094 AVSC_INLINE int avs_array_size(AVS_Value v)
1095 { return avs_is_array(v) ? v.array_size : 1; }
1096 AVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)
1097 { return avs_is_array(v) ? v.d.array[index] : v; }
1098
1099 /*******************************
1100 * AVS_Value setters through API
1101 *******************************/
1102 AVSC_API(void, avs_set_to_clip)(AVS_Value*, AVS_Clip*);
1103 // v11 provides setter APIs for all types beyond 'clip'
1104 AVSC_API(void, avs_set_to_error)(AVS_Value*, const char* v0);
1105 AVSC_API(void, avs_set_to_bool)(AVS_Value*, int v0);
1106 AVSC_API(void, avs_set_to_int)(AVS_Value*, int v0);
1107 AVSC_API(void, avs_set_to_float)(AVS_Value*, float v0);
1108 AVSC_API(void, avs_set_to_string)(AVS_Value*, const char* v0);
1109 AVSC_API(void, avs_set_to_double)(AVS_Value*, double d); // requires avs_release_value, especially on 32 bit proc
1110 AVSC_API(void, avs_set_to_long)(AVS_Value*, int64_t l); // requires avs_release_value, especially on 32 bit proc
1111 AVSC_API(void, avs_set_to_array)(AVS_Value*, AVS_Value* src, int size); // requires avs_release_value, multi-nested deep copied arrays
1112 AVSC_API(void, avs_set_to_void)(AVS_Value*); // void
1113 /***********************************************************
1114 * AVS_Value setters ("baked" inline code) - NOT through API
1115 ***********************************************************/
1116 // Each of these inline 'baked code' setters has API counterparts:
1117 // avs_set_to_error, avs_set_to_bool, avs_set_to_int, avs_set_to_string, avs_set_to_float.
1118 // Only use these functions on an AVS_Value that does not already have
1119 // an active value. Remember, treat AVS_Value as a fat pointer.
1120 // These do not require avs_release_value
1121 AVSC_INLINE AVS_Value avs_new_value_bool(int v0)
1122 { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }
1123 AVSC_INLINE AVS_Value avs_new_value_int(int v0)
1124 { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }
1125 AVSC_INLINE AVS_Value avs_new_value_string(const char * v0)
1126 { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }
1127 AVSC_INLINE AVS_Value avs_new_value_float(float v0)
1128 { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}
1129 AVSC_INLINE AVS_Value avs_new_value_error(const char * v0)
1130 { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }
1131 AVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)
1132 { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; }
1133 /***********************************************************
1134 * AVS_Value setters - inline wrappers using API
1135 ***********************************************************/
1136 #ifndef AVSC_NO_DECLSPEC
1137 // Use avs_release_value / avs_copy_value
1138 AVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip* v0)
1139 { AVS_Value v; avs_set_to_clip(&v, v0); return v; }
1140 #endif
1141 /***********************************************************
1142 * AVS_Value setters - inline wrappers using API v11
1143 * None of them. For Avisynth arrays, 64 bit long and double use API
1144 ***********************************************************/
1145 // No avs_new_value_double => use avs_set_to_double API instead
1146 // No avs_new_value_long => use avs_set_to_long API instead
1147 // for arrays use avs_set_to_array API call for Avisynth deep smart arrays
1148
1149 /////////////////////////////////////////////////////////////////////
1150 //
1151 // AVS_Clip
1152 //
1153
1154 AVSC_API(void, avs_release_clip)(AVS_Clip *);
1155 AVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);
1156
1157 AVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error
1158
1159 AVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);
1160
1161 AVSC_API(int, avs_get_version)(AVS_Clip *);
1162
1163 AVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);
1164 // The returned video frame must be released with avs_release_video_frame
1165
1166 AVSC_API(int, avs_get_parity)(AVS_Clip *, int n);
1167 // return field parity if field_based, else parity of first field in frame
1168
1169 AVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,
1170 int64_t start, int64_t count);
1171 // start and count are in samples
1172
1173 AVSC_API(int, avs_set_cache_hints)(AVS_Clip *,
1174 int cachehints, int frame_range);
1175
1176 // This is the callback type used by avs_add_function
1177 typedef AVS_Value (AVSC_CC * AVS_ApplyFunc)
1178 (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);
1179
1180 // v11 alternative of avs_add_function with return value by reference
1181 // This is the callback type used by avs_add_function_r
1182 typedef void(AVSC_CC* AVS_ApplyFuncR)
1183 (AVS_ScriptEnvironment*, AVS_Value* ret, AVS_Value args, void* user_data);
1184
1185 typedef struct AVS_FilterInfo AVS_FilterInfo;
1186 struct AVS_FilterInfo
1187 {
1188 // these members should not be modified outside of the AVS_ApplyFunc or AVS_ApplyFuncR callback
1189 AVS_Clip * child;
1190 AVS_VideoInfo vi;
1191 AVS_ScriptEnvironment * env;
1192 AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);
1193 int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);
1194 int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,
1195 int64_t start, int64_t count);
1196 int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,
1197 int frame_range);
1198 void (AVSC_CC * free_filter)(AVS_FilterInfo *);
1199
1200 // Should be set when ever there is an error to report.
1201 // It is cleared before any of the above methods are called
1202 const char * error;
1203 // this is to store whatever and may be modified at will
1204 void * user_data;
1205 };
1206
1207 // Create a new filter
1208 // 'fi' is set to point to the AVS_FilterInfo so that you can
1209 // modify it once it is initialized.
1210 // 'store_child' should generally be set to true. If it is not
1211 // set then ALL methods (the function pointers) must be defined
1212 // If it is set then you do not need to worry about freeing the child
1213 // clip.
1214 AVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,
1215 AVS_FilterInfo * * fi,
1216 AVS_Value child, int store_child);
1217
1218 /////////////////////////////////////////////////////////////////////
1219 //
1220 // AVS_ScriptEnvironment
1221 //
1222
1223 // For GetCPUFlags.
1224
1225 // Intel/AMD x86/x86-64 flags
1226
1227 // start with enum, until we reach 32-bit limit
1228 enum {
1229 /* slowest CPU to support extension */
1230 AVS_CPU_FORCE = 0x01, // N/A
1231 AVS_CPU_FPU = 0x02, // 386/486DX
1232 AVS_CPU_MMX = 0x04, // P55C, K6, PII
1233 AVS_CPU_INTEGER_SSE = 0x08, // PIII, Athlon
1234 AVS_CPU_SSE = 0x10, // PIII, Athlon XP/MP
1235 AVS_CPU_SSE2 = 0x20, // PIV, Hammer
1236 AVS_CPU_3DNOW = 0x40, // K6-2
1237 AVS_CPU_3DNOW_EXT = 0x80, // Athlon
1238 AVS_CPU_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2,
1239 // which only Hammer will have anyway)
1240 AVS_CPUF_SSE3 = 0x100, // PIV+, K8 Venice
1241 AVS_CPUF_SSSE3 = 0x200, // Core 2
1242 AVS_CPUF_SSE4 = 0x400, // Penryn, Wolfdale, Yorkfield
1243 AVS_CPUF_SSE4_1 = 0x400,
1244 AVS_CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer
1245 AVS_CPUF_SSE4_2 = 0x1000, // Nehalem
1246 // AVS+
1247 AVS_CPUF_AVX2 = 0x2000, // Haswell
1248 AVS_CPUF_FMA3 = 0x4000,
1249 AVS_CPUF_F16C = 0x8000,
1250 AVS_CPUF_MOVBE = 0x10000, // Big Endian Move
1251 AVS_CPUF_POPCNT = 0x20000,
1252 AVS_CPUF_AES = 0x40000,
1253 AVS_CPUF_FMA4 = 0x80000,
1254
1255 // AVX-512
1256 AVS_CPUF_AVX512F = 0x100000, // F Foundation.
1257 AVS_CPUF_AVX512DQ = 0x200000, // DQ (Double/Quad granular) Instructions
1258 AVS_CPUF_AVX512PF = 0x400000, // PF Prefetch
1259 AVS_CPUF_AVX512ER = 0x800000, // ER Exponential and Reciprocal
1260 AVS_CPUF_AVX512CD = 0x1000000, // CD Conflict Detection
1261 AVS_CPUF_AVX512BW = 0x2000000, // BW (Byte/Word granular) Instructions
1262 AVS_CPUF_AVX512VL = 0x4000000, // VL (128/256 Vector Length) Extensions
1263 AVS_CPUF_AVX512IFMA = 0x8000000, // IFMA integer 52 bit
1264 AVS_CPUF_AVX512VBMI = 0x10000000, // VBMI, byte/word shuffling, sign/zero extension, and general pixel manipulation
1265 // Group feature flags for convenience: checking a single flag for "base" and "fast" AVX512 feature sets.
1266 AVS_CPUF_AVX512_BASE = 0x20000000, // F, CD, BW, DQ, VL all set.
1267 AVS_CPUF_AVX512_FAST = 0x40000000, // Base + VNNI, VBMI, VBMI2, BITALG, VPOPCNTDQ. Spec detection logic excludes older/throttling models that also have these features.
1268 // Last 32-bit flag reserved for future use:
1269 // AVS_CPUF_AVX10 = 0x80000000LL; // AVX10 as one flag, version query needed in distinct function.
1270
1271 // The enum must stop here to remain compatible with a 32-bit int/enum.
1272 };
1273
1274 // features beyond the initial 32 bits(0xFFFFFFFF) must be defined as 64 - bit constants
1275 // and can be returned only by avs_get_cpu_flags_ex (which returns int64_t)
1276
1277 // Intel/AMD x86/x86-64 flags (Continued from 32-bit limit)
1278 #define AVS_CPUF_AVX512VNNI 0x00100000000LL
1279 #define AVS_CPUF_AVX512VBMI2 0x00200000000LL
1280 #define AVS_CPUF_AVX512BITALG 0x00400000000LL
1281 #define AVS_CPUF_AVX512VPOPCNTDQ 0x00800000000LL
1282 #define AVS_CPUF_AVX512FP16 0x01000000000LL
1283 #define AVS_CPUF_AVX512BF16 0x02000000000LL
1284
1285 // ARMv8-A flags
1286 enum {
1287 AVS_CPUF_ARM_NEON = 0x01,
1288 AVS_CPUF_ARM_DOTPROD = 0x02,
1289 AVS_CPUF_ARM_SVE2 = 0x04,
1290 AVS_CPUF_ARM_I8MM = 0x08,
1291 AVS_CPUF_ARM_SVE2_1 = 0x10,
1292 };
1293
1294
1295 AVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error
1296
1297 AVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);
1298 AVSC_API(int64_t, avs_get_cpu_flags_ex)(AVS_ScriptEnvironment *); // V12
1299 AVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);
1300
1301 AVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);
1302 AVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);
1303
1304 AVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val);
1305
1306 // avs_add_function, the callback (apply) returns result as return value (AVS_Value)
1307 AVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,
1308 const char * name, const char * params,
1309 AVS_ApplyFunc apply, void * user_data);
1310
1311 // v11 avs_add_function_r, the callback (apply) returns result in byref parameter (AVS_Value *)
1312 AVSC_API(int, avs_add_function_r)(AVS_ScriptEnvironment*,
1313 const char* name, const char* params,
1314 AVS_ApplyFuncR apply, void* user_data);
1315
1316 AVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);
1317
1318 AVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,
1319 AVS_Value args, const char** arg_names);
1320 // The returned value must be be released with avs_release_value
1321
1322 AVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);
1323 // The returned value must be be released with avs_release_value
1324
1325 AVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);
1326
1327 AVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);
1328
1329 //void avs_push_context(AVS_ScriptEnvironment *, int level=0);
1330 //void avs_pop_context(AVS_ScriptEnvironment *);
1331
1332 // partially deprecated, from V8 use avs_new_video_frame_p_a (frame property copy)
1333 AVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,
1334 const AVS_VideoInfo * vi, int align);
1335 // align should be at least 16 for classic Avisynth
1336 // Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided
1337
1338 // no API for these, inline helper functions
1339 #ifndef AVSC_NO_DECLSPEC
1340 // partially deprecated, from V8 use avs_new_video_frame_p (frame property copy)
1341 // this inline function is calling an API function
1342 AVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,
1343 const AVS_VideoInfo * vi)
1344 {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
1345
1346 // an older compatibility alias
1347 // this inline function is calling an API function
1348 AVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,
1349 const AVS_VideoInfo * vi)
1350 {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}
1351 #endif
1352 // end of inline helper functions
1353
1354 AVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);
1355
1356 // V9
1357 AVSC_API(int, avs_make_property_writable)(AVS_ScriptEnvironment*, AVS_VideoFrame** pvf);
1358
1359 AVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);
1360
1361 typedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);
1362 AVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);
1363
1364 AVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);
1365 // The returned video frame must be be released
1366 AVSC_API(AVS_VideoFrame*, avs_subframe_planar)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV);
1367 // The returned video frame must be be released
1368 // see also avs_subframe_planar_a in interface V8
1369
1370 AVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);
1371
1372 AVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);
1373
1374 // V12
1375 // Acquire a global named lock.
1376 // 'env' is the environment handle, 'name' is the lock identifier (e.g., "fftw").
1377 // Returns 1 on success, 0 on failure.
1378 AVSC_API(int, avs_acquire_global_lock)(AVS_ScriptEnvironment *, const char* name);
1379 // V12
1380 // Release a global named lock.
1381 // 'env' is the environment handle, 'name' is the lock identifier.
1382 AVSC_API(void, avs_release_global_lock)(AVS_ScriptEnvironment *, const char* name);
1383
1384 // avisynth.dll exports this; it's a way to use it as a library, without
1385 // writing an AVS script or without going through AVIFile.
1386 AVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);
1387
1388 // This symbol serves as the entry point for the plugin (up to Avisynth 3.7.3, non-64-bit aware)
1389 AVSC_EXPORT
1390 const char* AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);
1391
1392 // This symbol serves as the entry point for the 64-bit aware plugin. Since V11
1393 AVSC_EXPORT
1394 const char* AVSC_CC avisynth_c_plugin_init2(AVS_ScriptEnvironment* env);
1395
1396 // Either one or both must be defined for a plugin
1397 // avisynth_c_plugin_init2 is checked before avisynth_c_plugin_init
1398
1399 AVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);
1400
1401 ///////////////////////////////////////////////////////////////////////////////
1402 //
1403 // Avisynth+ V8 interface elements
1404 //
1405
1406 AVSC_API(AVS_VideoFrame*, avs_subframe_planar_a)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA);
1407 // The returned video frame must be be released
1408
1409 AVSC_API(void, avs_copy_frame_props)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* src, AVS_VideoFrame* dst);
1410 AVSC_API(const AVS_Map*, avs_get_frame_props_ro)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* frame);
1411 AVSC_API(AVS_Map*, avs_get_frame_props_rw)(AVS_ScriptEnvironment* p, AVS_VideoFrame* frame);
1412 AVSC_API(int, avs_prop_num_keys)(AVS_ScriptEnvironment* p, const AVS_Map* map);
1413 AVSC_API(const char*, avs_prop_get_key)(AVS_ScriptEnvironment* p, const AVS_Map* map, int index);
1414 AVSC_API(int, avs_prop_num_elements)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);
1415
1416 // see AVS_PROPTYPE_... enums
1417 AVSC_API(char, avs_prop_get_type)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);
1418
1419 // see AVS_GETPROPERROR_... enums
1420 AVSC_API(int64_t, avs_prop_get_int)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1421 AVSC_API(double, avs_prop_get_float)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1422 // Note: avs_prop_get_data was fixed in interface V9.1
1423 AVSC_API(const char*, avs_prop_get_data)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1424 AVSC_API(int, avs_prop_get_data_size)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1425 // V11
1426 AVSC_API(int, avs_prop_get_data_type_hint)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1427 AVSC_API(AVS_Clip*, avs_prop_get_clip)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1428 AVSC_API(const AVS_VideoFrame*, avs_prop_get_frame)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1429 // V11
1430 AVSC_API(int, avs_prop_get_int_saturated)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1431 // V11
1432 AVSC_API(float, avs_prop_get_float_saturated)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);
1433
1434 AVSC_API(int, avs_prop_delete_key)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key);
1435
1436 // see AVS_PROPAPPENDMODE_... enums
1437 AVSC_API(int, avs_prop_set_int)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, int64_t i, int append);
1438 AVSC_API(int, avs_prop_set_float)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, double d, int append);
1439 AVSC_API(int, avs_prop_set_data)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const char* d, int length, int append);
1440 // v11
1441 // SEE AVS_PROPDATATYPEHINT_... enums
1442 AVSC_API(int, avs_prop_set_data_h)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const char* d, int length, int type, int append);
1443 AVSC_API(int, avs_prop_set_clip)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, AVS_Clip* clip, int append);
1444 AVSC_API(int, avs_prop_set_frame)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const AVS_VideoFrame* frame, int append);
1445
1446 AVSC_API(const int64_t*, avs_prop_get_int_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);
1447 AVSC_API(const double*, avs_prop_get_float_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);
1448 AVSC_API(int, avs_prop_set_int_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const int64_t* i, int size);
1449 AVSC_API(int, avs_prop_set_float_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const double* d, int size);
1450
1451 AVSC_API(void, avs_clear_map)(AVS_ScriptEnvironment* p, AVS_Map* map);
1452
1453 // with frame property source
1454 AVSC_API(AVS_VideoFrame*, avs_new_video_frame_p)(AVS_ScriptEnvironment*,
1455 const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src);
1456
1457 // with frame property source
1458 AVSC_API(AVS_VideoFrame*, avs_new_video_frame_p_a)(AVS_ScriptEnvironment*,
1459 const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src, int align);
1460
1461 // Generic query to ask for various system properties, see AVS_AEP_xxx enums
1462 AVSC_API(size_t, avs_get_env_property)(AVS_ScriptEnvironment*, int avs_aep_prop);
1463
1464 // buffer pool, see AVS_ALLOCTYPE enums
1465 AVSC_API(void *, avs_pool_allocate)(AVS_ScriptEnvironment*, size_t nBytes, size_t alignment, int avs_alloc_type);
1466 AVSC_API(void, avs_pool_free)(AVS_ScriptEnvironment*, void *ptr);
1467
1468 // Interface V8
1469 // Returns TRUE (1) and the requested variable. If the method fails, returns 0 (FALSE) and does not touch 'val'.
1470 // The returned AVS_Value *val value must be be released with avs_release_value only on success
1471 // AVS_Value *val is not caller allocated
1472 AVSC_API(int, avs_get_var_try)(AVS_ScriptEnvironment*, const char* name, AVS_Value* val);
1473
1474 // Interface V8
1475 // Return the value of the requested variable.
1476 // If the variable was not found or had the wrong type,
1477 // return the supplied default value.
1478 AVSC_API(int, avs_get_var_bool)(AVS_ScriptEnvironment*, const char* name, int def);
1479 AVSC_API(int, avs_get_var_int)(AVS_ScriptEnvironment*, const char* name, int def);
1480 AVSC_API(double, avs_get_var_double)(AVS_ScriptEnvironment*, const char* name, double def);
1481 AVSC_API(const char*, avs_get_var_string)(AVS_ScriptEnvironment*, const char* name, const char* def);
1482 AVSC_API(int64_t, avs_get_var_long)(AVS_ScriptEnvironment*, const char* name, int64_t def);
1483
1484 // This is an example of dynamically loading Avisynth function addresses
1485 // instead of statically linked library. (Windows API)
1486 // In general: define AVSC_NO_DECLSPEC for only API prototypes, then manually load and get
1487 // function addresses from avisynth.dll/libavisynth.so
1488
1489 #if defined(AVS_WINDOWS)
1490 // The following stuff is only relevant for Windows DLL handling; Linux does it completely differently.
1491 #ifdef AVSC_NO_DECLSPEC
1492 // This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)
1493 // When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct
1494 // AVSC_INLINE functions which call onto an API functions should be treated specially (todo)
1495
1496 /*
1497 The following functions needs to have been declared, probably from windows.h
1498
1499 void* malloc(size_t)
1500 void free(void*);
1501
1502 HMODULE LoadLibraryA(const char*);
1503 void* GetProcAddress(HMODULE, const char*);
1504 FreeLibrary(HMODULE);
1505 */
1506
1507 #ifndef EXTERNAL_AVS_C_API_LOADER // If external loader is NOT active, then define these helpers
1508
1509 typedef struct AVS_Library AVS_Library;
1510
1511 #define AVSC_DECLARE_FUNC(name) name##_func name
1512
1513 // AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx
1514 // e.g. "AVSC_DECLARE_FUNC(avs_add_function);"
1515 // is a shortcut for "avs_add_function_func avs_add_function;"
1516
1517 // Note: AVSC_INLINE functions, which call into API,
1518 // are guarded by #ifndef AVSC_NO_DECLSPEC.
1519 // They should call the appropriate library-> API entry.
1520
1521 struct AVS_Library {
1522 HMODULE handle;
1523
1524 AVSC_DECLARE_FUNC(avs_add_function);
1525 AVSC_DECLARE_FUNC(avs_at_exit);
1526 AVSC_DECLARE_FUNC(avs_bit_blt);
1527 AVSC_DECLARE_FUNC(avs_check_version);
1528 AVSC_DECLARE_FUNC(avs_clip_get_error);
1529 AVSC_DECLARE_FUNC(avs_copy_clip);
1530 AVSC_DECLARE_FUNC(avs_copy_value);
1531 AVSC_DECLARE_FUNC(avs_copy_video_frame);
1532 AVSC_DECLARE_FUNC(avs_create_script_environment);
1533 AVSC_DECLARE_FUNC(avs_delete_script_environment);
1534 AVSC_DECLARE_FUNC(avs_function_exists);
1535 AVSC_DECLARE_FUNC(avs_get_audio);
1536 AVSC_DECLARE_FUNC(avs_get_cpu_flags);
1537 AVSC_DECLARE_FUNC(avs_get_frame);
1538 AVSC_DECLARE_FUNC(avs_get_parity);
1539 AVSC_DECLARE_FUNC(avs_get_var);
1540 AVSC_DECLARE_FUNC(avs_get_version);
1541 AVSC_DECLARE_FUNC(avs_get_video_info);
1542 AVSC_DECLARE_FUNC(avs_invoke);
1543 AVSC_DECLARE_FUNC(avs_make_writable);
1544 AVSC_DECLARE_FUNC(avs_new_c_filter);
1545 AVSC_DECLARE_FUNC(avs_new_video_frame_a);
1546 AVSC_DECLARE_FUNC(avs_release_clip);
1547 AVSC_DECLARE_FUNC(avs_release_value);
1548 AVSC_DECLARE_FUNC(avs_release_video_frame);
1549 AVSC_DECLARE_FUNC(avs_save_string);
1550 AVSC_DECLARE_FUNC(avs_set_cache_hints);
1551 AVSC_DECLARE_FUNC(avs_set_global_var);
1552 AVSC_DECLARE_FUNC(avs_set_memory_max);
1553 AVSC_DECLARE_FUNC(avs_set_to_clip);
1554 AVSC_DECLARE_FUNC(avs_set_var);
1555 AVSC_DECLARE_FUNC(avs_set_working_dir);
1556 AVSC_DECLARE_FUNC(avs_sprintf);
1557 AVSC_DECLARE_FUNC(avs_subframe);
1558 AVSC_DECLARE_FUNC(avs_subframe_planar);
1559 AVSC_DECLARE_FUNC(avs_take_clip);
1560 AVSC_DECLARE_FUNC(avs_vsprintf);
1561
1562 AVSC_DECLARE_FUNC(avs_get_error);
1563 AVSC_DECLARE_FUNC(avs_is_yv24);
1564 AVSC_DECLARE_FUNC(avs_is_yv16);
1565 AVSC_DECLARE_FUNC(avs_is_yv12);
1566 AVSC_DECLARE_FUNC(avs_is_yv411);
1567 AVSC_DECLARE_FUNC(avs_is_y8);
1568 AVSC_DECLARE_FUNC(avs_is_color_space);
1569
1570 AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);
1571 AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);
1572 AVSC_DECLARE_FUNC(avs_bits_per_pixel);
1573 AVSC_DECLARE_FUNC(avs_bytes_from_pixels);
1574 AVSC_DECLARE_FUNC(avs_row_size);
1575 AVSC_DECLARE_FUNC(avs_bmp_size);
1576 AVSC_DECLARE_FUNC(avs_get_pitch_p);
1577 AVSC_DECLARE_FUNC(avs_get_row_size_p);
1578 AVSC_DECLARE_FUNC(avs_get_height_p);
1579 AVSC_DECLARE_FUNC(avs_get_read_ptr_p);
1580 AVSC_DECLARE_FUNC(avs_is_writable);
1581 AVSC_DECLARE_FUNC(avs_get_write_ptr_p);
1582
1583 // Avisynth+ specific
1584 // Note: these functions are simulated/use fallback to existing functions
1585 AVSC_DECLARE_FUNC(avs_is_rgb48);
1586 AVSC_DECLARE_FUNC(avs_is_rgb64);
1587 AVSC_DECLARE_FUNC(avs_is_yuv444p16);
1588 AVSC_DECLARE_FUNC(avs_is_yuv422p16);
1589 AVSC_DECLARE_FUNC(avs_is_yuv420p16);
1590 AVSC_DECLARE_FUNC(avs_is_y16);
1591 AVSC_DECLARE_FUNC(avs_is_yuv444ps);
1592 AVSC_DECLARE_FUNC(avs_is_yuv422ps);
1593 AVSC_DECLARE_FUNC(avs_is_yuv420ps);
1594 AVSC_DECLARE_FUNC(avs_is_y32);
1595 AVSC_DECLARE_FUNC(avs_is_444);
1596 AVSC_DECLARE_FUNC(avs_is_422);
1597 AVSC_DECLARE_FUNC(avs_is_420);
1598 AVSC_DECLARE_FUNC(avs_is_y);
1599 AVSC_DECLARE_FUNC(avs_is_yuva);
1600 AVSC_DECLARE_FUNC(avs_is_planar_rgb);
1601 AVSC_DECLARE_FUNC(avs_is_planar_rgba);
1602 AVSC_DECLARE_FUNC(avs_num_components);
1603 AVSC_DECLARE_FUNC(avs_component_size);
1604 AVSC_DECLARE_FUNC(avs_bits_per_component);
1605
1606 ///////////////////////////////////////////////////////////////////////////////
1607 // Avisynth+ new interface elements from interface version 8
1608 // avs_subframe_planar with alpha support
1609 AVSC_DECLARE_FUNC(avs_subframe_planar_a);
1610
1611 // frame properties
1612 AVSC_DECLARE_FUNC(avs_copy_frame_props);
1613 AVSC_DECLARE_FUNC(avs_get_frame_props_ro);
1614 AVSC_DECLARE_FUNC(avs_get_frame_props_rw);
1615 AVSC_DECLARE_FUNC(avs_prop_num_keys);
1616 AVSC_DECLARE_FUNC(avs_prop_get_key);
1617 AVSC_DECLARE_FUNC(avs_prop_num_elements);
1618 AVSC_DECLARE_FUNC(avs_prop_get_type);
1619 AVSC_DECLARE_FUNC(avs_prop_get_int);
1620 AVSC_DECLARE_FUNC(avs_prop_get_float);
1621 AVSC_DECLARE_FUNC(avs_prop_get_data);
1622 AVSC_DECLARE_FUNC(avs_prop_get_data_size);
1623 AVSC_DECLARE_FUNC(avs_prop_get_clip);
1624 AVSC_DECLARE_FUNC(avs_prop_get_frame);
1625 AVSC_DECLARE_FUNC(avs_prop_delete_key);
1626 AVSC_DECLARE_FUNC(avs_prop_set_int);
1627 AVSC_DECLARE_FUNC(avs_prop_set_float);
1628 AVSC_DECLARE_FUNC(avs_prop_set_data);
1629 AVSC_DECLARE_FUNC(avs_prop_set_clip);
1630 AVSC_DECLARE_FUNC(avs_prop_set_frame);
1631
1632 AVSC_DECLARE_FUNC(avs_prop_get_int_array);
1633 AVSC_DECLARE_FUNC(avs_prop_get_float_array);
1634 AVSC_DECLARE_FUNC(avs_prop_set_int_array);
1635 AVSC_DECLARE_FUNC(avs_prop_set_float_array);
1636
1637 AVSC_DECLARE_FUNC(avs_clear_map);
1638
1639 // NewVideoFrame with frame properties
1640 AVSC_DECLARE_FUNC(avs_new_video_frame_p);
1641 AVSC_DECLARE_FUNC(avs_new_video_frame_p_a);
1642
1643 AVSC_DECLARE_FUNC(avs_get_env_property);
1644
1645 AVSC_DECLARE_FUNC(avs_get_var_try);
1646 AVSC_DECLARE_FUNC(avs_get_var_bool);
1647 AVSC_DECLARE_FUNC(avs_get_var_int);
1648 AVSC_DECLARE_FUNC(avs_get_var_double);
1649 AVSC_DECLARE_FUNC(avs_get_var_string);
1650 AVSC_DECLARE_FUNC(avs_get_var_long);
1651
1652 AVSC_DECLARE_FUNC(avs_pool_allocate);
1653 AVSC_DECLARE_FUNC(avs_pool_free);
1654
1655 // V9
1656 AVSC_DECLARE_FUNC(avs_is_property_writable);
1657 AVSC_DECLARE_FUNC(avs_make_property_writable);
1658
1659 // V10
1660 AVSC_DECLARE_FUNC(avs_video_frame_get_pixel_type);
1661 AVSC_DECLARE_FUNC(avs_video_frame_amend_pixel_type);
1662
1663 AVSC_DECLARE_FUNC(avs_is_channel_mask_known);
1664 AVSC_DECLARE_FUNC(avs_set_channel_mask);
1665 AVSC_DECLARE_FUNC(avs_get_channel_mask);
1666
1667 // V11
1668 // setters for all types (except clip, which have already existed)
1669 AVSC_DECLARE_FUNC(avs_set_to_error);
1670 AVSC_DECLARE_FUNC(avs_set_to_bool);
1671 AVSC_DECLARE_FUNC(avs_set_to_int);
1672 AVSC_DECLARE_FUNC(avs_set_to_string);
1673 AVSC_DECLARE_FUNC(avs_set_to_float);
1674 AVSC_DECLARE_FUNC(avs_set_to_long);
1675 AVSC_DECLARE_FUNC(avs_set_to_double);
1676 AVSC_DECLARE_FUNC(avs_set_to_array);
1677 AVSC_DECLARE_FUNC(avs_set_to_void);
1678 // getters for all basic types. note: avs_get_as_float returns double
1679 AVSC_DECLARE_FUNC(avs_get_as_error);
1680 AVSC_DECLARE_FUNC(avs_get_as_array);
1681 AVSC_DECLARE_FUNC(avs_get_as_bool);
1682 AVSC_DECLARE_FUNC(avs_get_as_clip);
1683 AVSC_DECLARE_FUNC(avs_get_as_int);
1684 AVSC_DECLARE_FUNC(avs_get_as_string);
1685 AVSC_DECLARE_FUNC(avs_get_as_float);
1686 AVSC_DECLARE_FUNC(avs_get_as_long);
1687 AVSC_DECLARE_FUNC(avs_get_array_size);
1688 AVSC_DECLARE_FUNC(avs_get_array_elt);
1689 // frame props
1690 AVSC_DECLARE_FUNC(avs_prop_get_int_saturated);
1691 AVSC_DECLARE_FUNC(avs_prop_get_float_saturated);
1692 AVSC_DECLARE_FUNC(avs_prop_get_data_type_hint);
1693 AVSC_DECLARE_FUNC(avs_prop_set_data_h);
1694 // alternative add_function returning data in byref AVS_Value
1695 AVSC_DECLARE_FUNC(avs_add_function_r);
1696 // API AVS_Value type checkers
1697 AVSC_DECLARE_FUNC(avs_val_defined);
1698 AVSC_DECLARE_FUNC(avs_val_is_clip);
1699 AVSC_DECLARE_FUNC(avs_val_is_bool);
1700 AVSC_DECLARE_FUNC(avs_val_is_int);
1701 AVSC_DECLARE_FUNC(avs_val_is_long_strict);
1702 AVSC_DECLARE_FUNC(avs_val_is_float);
1703 AVSC_DECLARE_FUNC(avs_val_is_floatf_strict);
1704 AVSC_DECLARE_FUNC(avs_val_is_string);
1705 AVSC_DECLARE_FUNC(avs_val_is_array);
1706 AVSC_DECLARE_FUNC(avs_val_is_error);
1707 // V12
1708 AVSC_DECLARE_FUNC(avs_acquire_global_lock);
1709 AVSC_DECLARE_FUNC(avs_release_global_lock);
1710 AVSC_DECLARE_FUNC(avs_get_cpu_flags_ex);
1711 };
1712
1713 #undef AVSC_DECLARE_FUNC
1714
1715 #ifdef AVS26_FALLBACK_SIMULATION
1716 // Helper functions for fallback simulation
1717 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1718 AVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p)
1719 {
1720 return 0;
1721 }
1722
1723 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1724 AVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p)
1725 {
1726 switch (p->pixel_type) {
1727 case AVS_CS_UNKNOWN:
1728 return 0;
1729 case AVS_CS_RAW32:
1730 case AVS_CS_Y8:
1731 return 1;
1732 case AVS_CS_BGR32:
1733 return 4; // not planar but return the count
1734 default:
1735 return 3;
1736 }
1737 }
1738
1739 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1740 AVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p)
1741 {
1742 return 1;
1743 }
1744
1745 // Avisynth+ extensions do not exist in classic Avisynth so they are simulated
1746 AVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p)
1747 {
1748 return 8;
1749 }
1750 // End of helper functions for fallback simulation
1751 #endif // AVS26_FALLBACK_SIMULATION
1752
1753 // avs_load_library() allocates an array for API procedure entries
1754 // reads and fills the entries with live procedure addresses.
1755 // AVSC_INLINE helpers which are calling into API procedures are not treated here (todo)
1756
1757 AVSC_INLINE AVS_Library * avs_load_library() {
1758 AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));
1759 if (library == NULL)
1760 return NULL;
1761 library->handle = LoadLibraryA("avisynth");
1762 if (library->handle == NULL)
1763 goto fail;
1764
1765 #define __AVSC_STRINGIFY(x) #x
1766 #define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)
1767 #define AVSC_DO_LOAD_FUNC(name, allow_missing) {\
1768 library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1769 if (!allow_missing && library->name == NULL)\
1770 goto fail;\
1771 }
1772 #define AVSC_LOAD_FUNC(name) AVSC_DO_LOAD_FUNC(name, 0)
1773 #define AVSC_LOAD_FUNC_OPT(name) AVSC_DO_LOAD_FUNC(name, 1)
1774
1775 #ifdef AVS26_FALLBACK_SIMULATION
1776 // When an API function is not loadable, let's try a replacement
1777 // Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods
1778 /*
1779 Avisynth+ When method is missing (classic Avisynth)
1780 avs_is_rgb48 constant false
1781 avs_is_rgb64 constant false
1782 avs_is_444 avs_is_yv24
1783 avs_is_422 avs_is_yv16
1784 avs_is_420 avs_is_yv12
1785 avs_is_y avs_is_y8
1786 avs_is_yuva constant false
1787 avs_is_planar_rgb constant false
1788 avs_is_planar_rgba constant false
1789 avs_num_components special: avs_num_components_fake Y8:1 RGB32:4 else 3
1790 avs_component_size constant 1 (1 bytes/component)
1791 avs_bits_per_component constant 8 (8 bits/component)
1792 */
1793
1794 // try to load an alternative function
1795 #define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\
1796 library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1797 if (library->name == NULL)\
1798 library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\
1799 if (library->name == NULL)\
1800 goto fail;\
1801 }
1802
1803 // try to assign a replacement function
1804 #define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\
1805 library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\
1806 if (library->name == NULL)\
1807 library->name = name2;\
1808 if (library->name == NULL)\
1809 goto fail;\
1810 }
1811 #endif // AVS26_FALLBACK_SIMULATION
1812
1813 AVSC_LOAD_FUNC(avs_add_function);
1814 AVSC_LOAD_FUNC(avs_at_exit);
1815 AVSC_LOAD_FUNC(avs_bit_blt);
1816 AVSC_LOAD_FUNC(avs_check_version);
1817 AVSC_LOAD_FUNC(avs_clip_get_error);
1818 AVSC_LOAD_FUNC(avs_copy_clip);
1819 AVSC_LOAD_FUNC(avs_copy_value);
1820 AVSC_LOAD_FUNC(avs_copy_video_frame);
1821 AVSC_LOAD_FUNC(avs_create_script_environment);
1822 AVSC_LOAD_FUNC(avs_delete_script_environment);
1823 AVSC_LOAD_FUNC(avs_function_exists);
1824 AVSC_LOAD_FUNC(avs_get_audio);
1825 AVSC_LOAD_FUNC(avs_get_cpu_flags);
1826 AVSC_LOAD_FUNC(avs_get_frame);
1827 AVSC_LOAD_FUNC(avs_get_parity);
1828 AVSC_LOAD_FUNC(avs_get_var);
1829 AVSC_LOAD_FUNC(avs_get_version);
1830 AVSC_LOAD_FUNC(avs_get_video_info);
1831 AVSC_LOAD_FUNC(avs_invoke);
1832 AVSC_LOAD_FUNC(avs_make_writable);
1833 AVSC_LOAD_FUNC(avs_new_c_filter);
1834 AVSC_LOAD_FUNC(avs_new_video_frame_a);
1835
1836 AVSC_LOAD_FUNC(avs_release_clip);
1837 AVSC_LOAD_FUNC(avs_release_value);
1838 AVSC_LOAD_FUNC(avs_release_video_frame);
1839 AVSC_LOAD_FUNC(avs_save_string);
1840 AVSC_LOAD_FUNC(avs_set_cache_hints);
1841 AVSC_LOAD_FUNC(avs_set_global_var);
1842 AVSC_LOAD_FUNC(avs_set_memory_max);
1843 AVSC_LOAD_FUNC(avs_set_to_clip);
1844 AVSC_LOAD_FUNC(avs_set_var);
1845 AVSC_LOAD_FUNC(avs_set_working_dir);
1846 AVSC_LOAD_FUNC(avs_sprintf);
1847 AVSC_LOAD_FUNC(avs_subframe);
1848 AVSC_LOAD_FUNC(avs_subframe_planar);
1849 AVSC_LOAD_FUNC(avs_take_clip);
1850 AVSC_LOAD_FUNC(avs_vsprintf);
1851
1852 AVSC_LOAD_FUNC(avs_get_error);
1853 AVSC_LOAD_FUNC(avs_is_yv24);
1854 AVSC_LOAD_FUNC(avs_is_yv16);
1855 AVSC_LOAD_FUNC(avs_is_yv12);
1856 AVSC_LOAD_FUNC(avs_is_yv411);
1857 AVSC_LOAD_FUNC(avs_is_y8);
1858 AVSC_LOAD_FUNC(avs_is_color_space);
1859
1860 AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);
1861 AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);
1862 AVSC_LOAD_FUNC(avs_bits_per_pixel);
1863 AVSC_LOAD_FUNC(avs_bytes_from_pixels);
1864 AVSC_LOAD_FUNC(avs_row_size);
1865 AVSC_LOAD_FUNC(avs_bmp_size);
1866 AVSC_LOAD_FUNC(avs_get_pitch_p);
1867 AVSC_LOAD_FUNC(avs_get_row_size_p);
1868 AVSC_LOAD_FUNC(avs_get_height_p);
1869 AVSC_LOAD_FUNC(avs_get_read_ptr_p);
1870 AVSC_LOAD_FUNC(avs_is_writable);
1871 AVSC_LOAD_FUNC(avs_get_write_ptr_p);
1872
1873 // Avisynth+ specific
1874 #ifdef AVS26_FALLBACK_SIMULATION
1875 // replace with fallback fn when does not exist
1876 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false);
1877 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false);
1878 AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24);
1879 AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16);
1880 AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12);
1881 AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8);
1882 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false);
1883 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false);
1884 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false);
1885 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback);
1886 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback);
1887 AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback);
1888 #else
1889 // Avisynth+ specific
1890 AVSC_LOAD_FUNC_OPT(avs_is_rgb48);
1891 AVSC_LOAD_FUNC_OPT(avs_is_rgb64);
1892 AVSC_LOAD_FUNC_OPT(avs_is_444);
1893 AVSC_LOAD_FUNC_OPT(avs_is_422);
1894 AVSC_LOAD_FUNC_OPT(avs_is_420);
1895 AVSC_LOAD_FUNC_OPT(avs_is_y);
1896 AVSC_LOAD_FUNC_OPT(avs_is_yuva);
1897 AVSC_LOAD_FUNC_OPT(avs_is_planar_rgb);
1898 AVSC_LOAD_FUNC_OPT(avs_is_planar_rgba);
1899 AVSC_LOAD_FUNC_OPT(avs_num_components);
1900 AVSC_LOAD_FUNC_OPT(avs_component_size);
1901 AVSC_LOAD_FUNC_OPT(avs_bits_per_component);
1902 #endif
1903 // Avisynth+ interface V8, no backward compatible simulation
1904 AVSC_LOAD_FUNC_OPT(avs_subframe_planar_a);
1905 // frame properties
1906 AVSC_LOAD_FUNC_OPT(avs_copy_frame_props);
1907 AVSC_LOAD_FUNC_OPT(avs_get_frame_props_ro);
1908 AVSC_LOAD_FUNC_OPT(avs_get_frame_props_rw);
1909 AVSC_LOAD_FUNC_OPT(avs_prop_num_keys);
1910 AVSC_LOAD_FUNC_OPT(avs_prop_get_key);
1911 AVSC_LOAD_FUNC_OPT(avs_prop_num_elements);
1912 AVSC_LOAD_FUNC_OPT(avs_prop_get_type);
1913 AVSC_LOAD_FUNC_OPT(avs_prop_get_int);
1914 AVSC_LOAD_FUNC_OPT(avs_prop_get_float);
1915 AVSC_LOAD_FUNC_OPT(avs_prop_get_data);
1916 AVSC_LOAD_FUNC_OPT(avs_prop_get_data_size);
1917 AVSC_LOAD_FUNC_OPT(avs_prop_get_clip);
1918 AVSC_LOAD_FUNC_OPT(avs_prop_get_frame);
1919 AVSC_LOAD_FUNC_OPT(avs_prop_delete_key);
1920 AVSC_LOAD_FUNC_OPT(avs_prop_set_int);
1921 AVSC_LOAD_FUNC_OPT(avs_prop_set_float);
1922 AVSC_LOAD_FUNC_OPT(avs_prop_set_data);
1923 AVSC_LOAD_FUNC_OPT(avs_prop_set_clip);
1924 AVSC_LOAD_FUNC_OPT(avs_prop_set_frame);
1925
1926 AVSC_LOAD_FUNC_OPT(avs_prop_get_int_array);
1927 AVSC_LOAD_FUNC_OPT(avs_prop_get_float_array);
1928 AVSC_LOAD_FUNC_OPT(avs_prop_set_int_array);
1929 AVSC_LOAD_FUNC_OPT(avs_prop_set_float_array);
1930
1931 AVSC_LOAD_FUNC_OPT(avs_clear_map);
1932
1933 // NewVideoFrame with frame properties
1934 AVSC_LOAD_FUNC_OPT(avs_new_video_frame_p);
1935 AVSC_LOAD_FUNC_OPT(avs_new_video_frame_p_a);
1936
1937 AVSC_LOAD_FUNC_OPT(avs_get_env_property);
1938
1939 AVSC_LOAD_FUNC_OPT(avs_get_var_try);
1940 AVSC_LOAD_FUNC_OPT(avs_get_var_bool);
1941 AVSC_LOAD_FUNC_OPT(avs_get_var_int);
1942 AVSC_LOAD_FUNC_OPT(avs_get_var_double);
1943 AVSC_LOAD_FUNC_OPT(avs_get_var_string);
1944 AVSC_LOAD_FUNC_OPT(avs_get_var_long);
1945
1946 AVSC_LOAD_FUNC_OPT(avs_pool_allocate);
1947 AVSC_LOAD_FUNC_OPT(avs_pool_free);
1948
1949 // V9
1950 AVSC_LOAD_FUNC_OPT(avs_make_property_writable);
1951 AVSC_LOAD_FUNC_OPT(avs_is_property_writable);
1952
1953 // V10
1954 AVSC_LOAD_FUNC_OPT(avs_video_frame_get_pixel_type);
1955 AVSC_LOAD_FUNC_OPT(avs_video_frame_amend_pixel_type);
1956 AVSC_LOAD_FUNC_OPT(avs_is_channel_mask_known);
1957 AVSC_LOAD_FUNC_OPT(avs_set_channel_mask);
1958 AVSC_LOAD_FUNC_OPT(avs_get_channel_mask);
1959
1960 // V11
1961 // setters for all types (avs_set_to_clip already existed)
1962 AVSC_LOAD_FUNC_OPT(avs_set_to_error);
1963 AVSC_LOAD_FUNC_OPT(avs_set_to_bool);
1964 AVSC_LOAD_FUNC_OPT(avs_set_to_int);
1965 AVSC_LOAD_FUNC_OPT(avs_set_to_string);
1966 AVSC_LOAD_FUNC_OPT(avs_set_to_float);
1967 AVSC_LOAD_FUNC_OPT(avs_set_to_long);
1968 AVSC_LOAD_FUNC_OPT(avs_set_to_double);
1969 AVSC_LOAD_FUNC_OPT(avs_set_to_array);
1970 AVSC_LOAD_FUNC_OPT(avs_set_to_void);
1971 // these have inline equivalents as well
1972 AVSC_LOAD_FUNC_OPT(avs_get_as_error);
1973 AVSC_LOAD_FUNC_OPT(avs_get_as_array);
1974 AVSC_LOAD_FUNC_OPT(avs_get_as_bool);
1975 AVSC_LOAD_FUNC_OPT(avs_get_as_clip);
1976 AVSC_LOAD_FUNC_OPT(avs_get_as_int);
1977 AVSC_LOAD_FUNC_OPT(avs_get_as_string);
1978 AVSC_LOAD_FUNC_OPT(avs_get_as_float);
1979 AVSC_LOAD_FUNC_OPT(avs_get_as_long);
1980 AVSC_LOAD_FUNC_OPT(avs_get_array_size);
1981 AVSC_LOAD_FUNC_OPT(avs_get_array_elt);
1982 // frame property
1983 AVSC_LOAD_FUNC_OPT(avs_prop_get_int_saturated);
1984 AVSC_LOAD_FUNC_OPT(avs_prop_get_float_saturated);
1985 AVSC_LOAD_FUNC_OPT(avs_prop_get_data_type_hint);
1986 AVSC_LOAD_FUNC_OPT(avs_prop_set_data_h);
1987 // alternative add_function
1988 AVSC_LOAD_FUNC_OPT(avs_add_function_r);
1989 // API AVS_Value type checkers
1990 AVSC_LOAD_FUNC_OPT(avs_val_defined);
1991 AVSC_LOAD_FUNC_OPT(avs_val_is_clip);
1992 AVSC_LOAD_FUNC_OPT(avs_val_is_bool);
1993 AVSC_LOAD_FUNC_OPT(avs_val_is_int);
1994 AVSC_LOAD_FUNC_OPT(avs_val_is_long_strict);
1995 AVSC_LOAD_FUNC_OPT(avs_val_is_float);
1996 AVSC_LOAD_FUNC_OPT(avs_val_is_floatf_strict);
1997 AVSC_LOAD_FUNC_OPT(avs_val_is_string);
1998 AVSC_LOAD_FUNC_OPT(avs_val_is_array);
1999 AVSC_LOAD_FUNC_OPT(avs_val_is_error);
2000 // V12
2001 AVSC_LOAD_FUNC_OPT(avs_acquire_global_lock);
2002 AVSC_LOAD_FUNC_OPT(avs_release_global_lock);
2003 AVSC_LOAD_FUNC_OPT(avs_get_cpu_flags_ex);
2004
2005 #undef __AVSC_STRINGIFY
2006 #undef AVSC_STRINGIFY
2007 #undef AVSC_DO_LOAD_FUNC
2008 #undef AVSC_LOAD_FUNC
2009 #undef AVSC_LOAD_FUNC_OPT
2010 #undef AVSC_LOAD_FUNC_FALLBACK
2011 #undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED
2012
2013 return library;
2014
2015 fail:
2016 free(library);
2017 return NULL;
2018 }
2019
2020 AVSC_INLINE void avs_free_library(AVS_Library *library) {
2021 if (library == NULL)
2022 return;
2023 FreeLibrary(library->handle);
2024 free(library);
2025 }
2026
2027 #endif // EXTERNAL_AVS_C_API_LOADER
2028
2029 #endif // AVSC_NO_DECLSPEC
2030
2031 #endif // AVS_WINDOWS
2032
2033 #endif
2034