GCC Code Coverage Report


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

core/CompatEnvironment.h
Line Branch Exec Source
1 // Avisynth v2.5. Copyright 2002-2009 Ben Rudiak-Gould et al.
2 // http://avisynth.nl
3
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
17 // http://www.gnu.org/copyleft/gpl.html .
18 //
19 // Linking Avisynth statically or dynamically with other modules is making a
20 // combined work based on Avisynth. Thus, the terms and conditions of the GNU
21 // General Public License cover the whole combination.
22 //
23 // As a special exception, the copyright holders of Avisynth give you
24 // permission to link Avisynth with independent modules that communicate with
25 // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
26 // terms of these independent modules, and to copy and distribute the
27 // resulting combined work under terms of your choice, provided that
28 // every copy of the combined work is accompanied by a complete copy of
29 // the source code of Avisynth (the version of Avisynth used to produce the
30 // combined work), being distributed under the terms of the GNU General
31 // Public License plus this exception. An independent module is a module
32 // which is not derived from or based on Avisynth, such as 3rd-party filters,
33 // import and export plugins, or graphical user interfaces.
34
35 #ifndef _AVS_COMPATENVIRONMENT_H_INCLUDED
36 #define _AVS_COMPATENVIRONMENT_H_INCLUDED
37
38 #include <avisynth.h>
39
40 // IScriptEnvironment_Avs25, IScriptEnvironment_AvsPreV11C are used internally.
41 // Entries 100% match with IScriptEnvironment to allow typecasting to IScriptEnvironment_Avs25/AvsPreV11.
42 // While IScriptEnvironment_Avs25 ends at interface V6 changes, PreV11C version is full copy of IScriptEnvironment.
43 // Differences involve three functions:
44 // 1. AddFunction25/PreV11C: Marks the added function as originating from
45 // an Avs2.5/PreV11C plugin, see also: arrays-deep-copy, 64-bit params.
46 // 2. Invoke25/PreV11C: Argument arrays, which must not be deep-freed,
47 // baked AVSValue code incompatible with deep-array concept and 64 bit data.
48 // 3. ManageCache25/PreV11C: Specially returns 1 for key MC_QueryAvs25/PreV11C
49 // to check if called from AVS2.5/PreV11C interface for cache GetFrame/GetAudio.
50
51 // See also: InternalEnvironment interface conversion methods comment.
52
53 // Compatibility camouflage classes are *passed in place of the original IScriptEnvironment,
54 // providing the same function orders to match their VMT tables with the original.
55 // Differently named functions appear at specific indexes to perform different compatibility behaviors.
56 // *In real they all are static casted from InternalEnvironment, where all these pure virtual methods are implemented.
57
58 class IScriptEnvironment_Avs25 {
59 public:
60 2201 virtual ~IScriptEnvironment_Avs25() {}
61
62 virtual /*static*/ int __stdcall GetCPUFlags() = 0;
63
64 virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;
65 virtual char* Sprintf(const char* fmt, ...) = 0;
66 virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;
67
68 #ifdef AVS_WINDOWS
69 __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;
70 #else
71 virtual void ThrowError(const char* fmt, ...) = 0;
72 #endif
73
74 class NotFound /*exception*/ {}; // thrown by Invoke and GetVar
75
76 typedef AVSValue(__cdecl* ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);
77
78 virtual void __stdcall AddFunction25(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;
79 virtual bool __stdcall FunctionExists(const char* name) = 0;
80 virtual AVSValue __stdcall Invoke25(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;
81
82 virtual AVSValue __stdcall GetVar(const char* name) = 0;
83 virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;
84 virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;
85
86 virtual void __stdcall PushContext(int level = 0) = 0;
87 virtual void __stdcall PopContext() = 0;
88
89 virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;
90
91 virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;
92
93 virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;
94
95 typedef void(__cdecl* ShutdownFunc)(void* user_data, IScriptEnvironment* env);
96 virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;
97
98 virtual void __stdcall CheckVersion(int version = AVISYNTH_CLASSIC_INTERFACE_VERSION_25) = 0;
99
100 virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;
101
102 virtual int __stdcall SetMemoryMax(int mem) = 0;
103
104 virtual int __stdcall SetWorkingDir(const char* newdir) = 0;
105
106 // specially returns 1 for key MC_QueryAvs25 to check if called from AVS2.5 interface
107 virtual void* __stdcall ManageCache25(int key, void* data) = 0;
108
109 enum PlanarChromaAlignmentMode {
110 PlanarChromaAlignmentOff,
111 PlanarChromaAlignmentOn,
112 PlanarChromaAlignmentTest
113 };
114
115 virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;
116
117 virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,
118 int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;
119
120 // Despite the name, we provide entries up to V6 in case someone requests
121 // a V3 interface and still wants to use V5-V6 functions
122
123 // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta
124 virtual void __stdcall DeleteScriptEnvironment() = 0;
125
126 virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,
127 int textcolor, int halocolor, int bgcolor) = 0;
128
129 virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;
130
131 // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6
132 // noThrow version of GetVar
133 virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;
134
135 }; // end class IScriptEnvironment_Avs25. Order is important.
136
137
138 // Unlike IScriptEnvironment_Avs25 which ends at the V6 changes,
139 // IScriptEnvironment_AvsPreV11C is a complete copy of IScriptEnvironment,
140 // except the name of the above mentioned three methods.
141 class IScriptEnvironment_AvsPreV11C {
142 public:
143 2194 virtual ~IScriptEnvironment_AvsPreV11C() {}
144
145 virtual int __stdcall GetCPUFlags() = 0;
146
147 virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;
148 virtual char* Sprintf(const char* fmt, ...) = 0;
149 virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;
150
151 #ifdef AVS_WINDOWS
152 __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;
153 #else
154 virtual void ThrowError(const char* fmt, ...) = 0;
155 #endif
156
157 class NotFound /*exception*/ {}; // thrown by Invoke and GetVar
158
159 typedef AVSValue(__cdecl* ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);
160
161 virtual void __stdcall AddFunctionPreV11C(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;
162 virtual bool __stdcall FunctionExists(const char* name) = 0;
163 virtual AVSValue __stdcall InvokePreV11C(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;
164
165 virtual AVSValue __stdcall GetVar(const char* name) = 0;
166 virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;
167 virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;
168
169 virtual void __stdcall PushContext(int level = 0) = 0;
170 virtual void __stdcall PopContext() = 0;
171
172 virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;
173
174 virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;
175
176 virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;
177
178 typedef void(__cdecl* ShutdownFunc)(void* user_data, IScriptEnvironment* env);
179 virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;
180
181 virtual void __stdcall CheckVersion(int version = AVISYNTH_CLASSIC_INTERFACE_VERSION_25) = 0;
182
183 virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;
184
185 virtual int __stdcall SetMemoryMax(int mem) = 0;
186
187 virtual int __stdcall SetWorkingDir(const char* newdir) = 0;
188
189 // specially returns 1 for key MC_QueryAvsPreV11C to check if called from C interface
190 virtual void* __stdcall ManageCachePreV11C(int key, void* data) = 0;
191
192 enum PlanarChromaAlignmentMode {
193 PlanarChromaAlignmentOff,
194 PlanarChromaAlignmentOn,
195 PlanarChromaAlignmentTest
196 };
197
198 virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;
199
200 virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,
201 int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;
202
203 // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta
204 virtual void __stdcall DeleteScriptEnvironment() = 0;
205
206 virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,
207 int textcolor, int halocolor, int bgcolor) = 0;
208
209 virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;
210
211 // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6
212 // noThrow version of GetVar
213 virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;
214
215
216 // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0-
217 virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,
218 int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0;
219
220 virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0;
221 virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0;
222 virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0;
223
224 virtual int __stdcall propNumKeys(const AVSMap* map) = 0;
225
226 virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0;
227 virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0;
228 virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0;
229
230 virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0;
231 virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0;
232 virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0;
233 virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0;
234 virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0;
235 virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0;
236
237 virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0;
238
239 virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0;
240 virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0;
241 virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0;
242 virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0;
243 virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0;
244
245 virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0;
246 virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0;
247 virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0;
248 virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0;
249
250 virtual AVSMap* __stdcall createMap() = 0;
251 virtual void __stdcall freeMap(AVSMap* map) = 0;
252 virtual void __stdcall clearMap(AVSMap* map) = 0;
253
254 // NewVideoFrame with frame property source.
255 virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, const PVideoFrame* prop_src, int align = FRAME_ALIGN) = 0;
256
257 // Generic query to ask for various system properties
258 virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0;
259
260 // Support functions
261 virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0;
262 virtual void __stdcall Free(void* ptr) = 0;
263
264 // these GetVar versions (renamed differently) were moved from IScriptEnvironment2
265
266 // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'.
267 virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool __stdcall GetVar(const char* name, AVSValue* val) const = 0;
268 // Return the value of the requested variable.
269 // If the variable was not found or had the wrong type,
270 // return the supplied default value.
271 virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0;
272 virtual int __stdcall GetVarInt(const char* name, int def) const = 0;
273 virtual double __stdcall GetVarDouble(const char* name, double def) const = 0;
274 virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0;
275 // brand new in v8 - v11: real int64 support
276 virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0;
277
278 // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order
279 // Invoke functions with 'Try' will return false instead of throwing NotFound().
280 // ex-IScriptEnvironment2
281 virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0;
282 // Since V8
283 virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;
284 // Ex-INeo
285 virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;
286 virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;
287 virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;
288
289 // V9
290 virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0;
291
292 // V11
293 virtual int __stdcall propGetIntSaturated(const AVSMap* map, const char* key, int index, int* error) = 0;
294 virtual float __stdcall propGetFloatSaturated(const AVSMap* map, const char* key, int index, int* error) = 0;
295 virtual int __stdcall propGetDataTypeHint(const AVSMap* map, const char* key, int index, int* error) = 0; // returns AVSPropDataTypeHint
296 virtual int __stdcall propSetDataH(AVSMap* map, const char* key, const char* d, int length, int type, int append) = 0;
297
298 // V12
299 // New Global Lock API for cross-plugin synchronization.
300 // Plugins must ensure these calls are balanced (acquire followed by release),
301 virtual bool __stdcall AcquireGlobalLock(const char* name) = 0;
302 virtual void __stdcall ReleaseGlobalLock(const char* name) = 0;
303 virtual void __stdcall ApplyMessageEx(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,
304 int textcolor, int halocolor, int bgcolor, bool utf8) = 0;
305 virtual int64_t __stdcall GetCPUFlagsEx() = 0;
306 }; // end class IScriptEnvironment_AvsPreV11C. Order is important.
307
308 #endif // _AVS_COMPATENVIRONMENT_H_INCLUDED
309