include/avisynth.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. | ||
| 2 | // Avisynth v2.6. Copyright 2006 Klaus Post. | ||
| 3 | // Avisynth v2.6. Copyright 2009 Ian Brabham. | ||
| 4 | // Avisynth+ project | ||
| 5 | // 20160613: new 16 bit planar pixel_type constants go live! | ||
| 6 | // 20160725: pixel_type constants 10-12-14 bit + planar RGB + BRG48/64 | ||
| 7 | // 20161005: Fallback of VideoInfo functions to defaults if no function exists | ||
| 8 | // 20170117: global variables for VfW output OPT_xxxx | ||
| 9 | // 20170310: new MT mode: MT_SPECIAL_MT | ||
| 10 | // 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64) | ||
| 11 | // 20171207: C++ Standard Conformance (no change for plugin writers) | ||
| 12 | // 20180525: AVS_UNUSED define to supress parameter not used warnings | ||
| 13 | // 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h | ||
| 14 | // 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list | ||
| 15 | // 20200330: removed __stdcall from variadic argument functions (Sprintf) | ||
| 16 | // (remove test SIZETMOD define for clarity) | ||
| 17 | // Integrate Avisynth Neo structures and interface, PFunction, PDevice | ||
| 18 | // 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment. | ||
| 19 | // move some former IScriptEnvironment2 functions to IScriptEnvironment: | ||
| 20 | // GetEnvProperty (system prop), Allocate, Free (buffer pool) | ||
| 21 | // GetVarTry, GetVarBool/Int/String/Double/Long | ||
| 22 | // Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try | ||
| 23 | // Interface Version to 8 (classic 2.6 = 6) | ||
| 24 | // 20200527 Add IScriptEnvironment_Avs25, used internally | ||
| 25 | // 20200607 AVS frame property enums to match existing Avisynth enum style | ||
| 26 | // 202112xx V9-MakePropertyWritable, IsPropertyWritable | ||
| 27 | // 2023 V10 | ||
| 28 | // prop_src parameter made as const in NewVideoFrameP (non-breaking cosmetics) | ||
| 29 | // Add all enums of public C++ API a name | ||
| 30 | // Add DEFAULT_PLANE as 0 to AvsPlane enum | ||
| 31 | // Made `VideoFrameBuffer` destructor public | ||
| 32 | // Introduce pixel_type to VideoFrame struct | ||
| 33 | // VideoFrame::GetPixelType,VideoFrame::AmendPixelType | ||
| 34 | // AVSValue::GetType | ||
| 35 | // Add enum AvsChannelMask::MASK_SPEAKER_xxx, AvsImageTypeFlags::IT_SPEAKER_xxx | ||
| 36 | // Audio channel mask support for VideoInfo: | ||
| 37 | // Use 20 bits in VideoInfo::image_type for channel mask mapping | ||
| 38 | // IsChannelMaskKnown, SetChannelMask, GetChannelMask in VideoInfo | ||
| 39 | // 20250214 V11 | ||
| 40 | // 64 bit data types in AVSValue: double and long (int64_t), also for 32 bit Avisynth! | ||
| 41 | // changed: AVSValue::IsFloat true for any 32/64 bit floating point or integer types | ||
| 42 | // changed: AVSValue::IsInt true for any 32/64 bit integer types | ||
| 43 | // new: AVSValue::IsFloatfStrict: returns true only if AVSValue is strictly 32 bit float | ||
| 44 | // new: AVSValue::IsLongStrict : returns true only if AVSValue is strictly 64 bit integer | ||
| 45 | // new: AVSValue::AsLong : returns int64_t | ||
| 46 | // new: AVSValue::AsLong(int64_t def) | ||
| 47 | // (AsFloat returned double --> no AsDouble needed) | ||
| 48 | // new AVSValue constructors for 64 bit types | ||
| 49 | // Simplify this header, remove internally used IScriptEnvironment_Avs25 from here | ||
| 50 | // Frame property changes backported from VapourSynth API4 | ||
| 51 | // - New propGetIntSaturated and propGetFloatSaturated | ||
| 52 | // - New enum: AVSPropDataTypeHint (VSAPI4: VSDataTypeHint) | ||
| 53 | // - New propGetDataTypeHint (VSAPI4: mapGetDataTypeHint) | ||
| 54 | // - New propSetDataH, like propSetData but with optional data type hint (byte/string) | ||
| 55 | // (VSAPI4: mapSetData, our propSetData became VSAPI4: mapSetData3) | ||
| 56 | // 20250415 V11.1 Fix AVS_Value 64 bit data member declaration for 64-bit non Intel (other than X86_X64) systems. | ||
| 57 | // 20250601 V12 Global lock aquire and release: AcquireGlobalLock, ReleaseGlobalLock | ||
| 58 | // New ApplyMessageEx | ||
| 59 | // 20251127 V12 CACHE_INFORM_NUM_THREADS CachePolicyHint enum to inform the filter about the number of threads by SetCacheHints | ||
| 60 | // New env property AEP_CACHESIZE_L2 | ||
| 61 | // 20251202 GetCPUFlagsEx returning full 64 bit flags, new AVX-512 group flags, ARM64 CPU flags. | ||
| 62 | |||
| 63 | // http://avisynth.nl | ||
| 64 | |||
| 65 | // This program is free software; you can redistribute it and/or modify | ||
| 66 | // it under the terms of the GNU General Public License as published by | ||
| 67 | // the Free Software Foundation; either version 2 of the License, or | ||
| 68 | // (at your option) any later version. | ||
| 69 | // | ||
| 70 | // This program is distributed in the hope that it will be useful, | ||
| 71 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 72 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 73 | // GNU General Public License for more details. | ||
| 74 | // | ||
| 75 | // You should have received a copy of the GNU General Public License | ||
| 76 | // along with this program; if not, write to the Free Software | ||
| 77 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | ||
| 78 | // http://www.gnu.org/copyleft/gpl.html . | ||
| 79 | // | ||
| 80 | // Linking Avisynth statically or dynamically with other modules is making | ||
| 81 | // a combined work based on Avisynth. Thus, the terms and conditions of | ||
| 82 | // the GNU General Public License cover the whole combination. | ||
| 83 | // | ||
| 84 | // As a special exception, the copyright holders of Avisynth give you | ||
| 85 | // permission to link Avisynth with independent modules that communicate | ||
| 86 | // with Avisynth solely through the interfaces defined in avisynth.h, | ||
| 87 | // regardless of the license terms of these independent modules, and to | ||
| 88 | // copy and distribute the resulting combined work under terms of your | ||
| 89 | // choice, provided that every copy of the combined work is accompanied | ||
| 90 | // by a complete copy of the source code of Avisynth (the version of | ||
| 91 | // Avisynth used to produce the combined work), being distributed under | ||
| 92 | // the terms of the GNU General Public License plus this exception. An | ||
| 93 | // independent module is a module which is not derived from or based on | ||
| 94 | // Avisynth, such as 3rd-party filters, import and export plugins, or | ||
| 95 | // graphical user interfaces. | ||
| 96 | |||
| 97 | |||
| 98 | #ifndef __AVISYNTH_12_H__ | ||
| 99 | #define __AVISYNTH_12_H__ | ||
| 100 | |||
| 101 | #include "avs/config.h" | ||
| 102 | #include "avs/capi.h" | ||
| 103 | #include "avs/types.h" | ||
| 104 | |||
| 105 | #ifdef AVS_POSIX | ||
| 106 | # include "avs/posix.h" | ||
| 107 | #endif | ||
| 108 | |||
| 109 | #if defined(AVS_POSIX) | ||
| 110 | #if defined(AVS_HAIKU) | ||
| 111 | #undef __stdcall | ||
| 112 | #undef __cdecl | ||
| 113 | #endif | ||
| 114 | #define __stdcall | ||
| 115 | #define __cdecl | ||
| 116 | #endif | ||
| 117 | |||
| 118 | // Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change: | ||
| 119 | // Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt. | ||
| 120 | // Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h: | ||
| 121 | // Use the new frame property features adaptively after querying that at least v8 is supported | ||
| 122 | // AviSynth property support can be queried (cpp iface example): | ||
| 123 | // has_at_least_v8 = true; | ||
| 124 | // try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; } | ||
| 125 | // and use it: | ||
| 126 | // if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi); | ||
| 127 | |||
| 128 | enum AvsVersion { | ||
| 129 | AVISYNTH_CLASSIC_INTERFACE_VERSION_25 = 3, | ||
| 130 | AVISYNTH_CLASSIC_INTERFACE_VERSION_26BETA = 5, | ||
| 131 | AVISYNTH_CLASSIC_INTERFACE_VERSION = 6, | ||
| 132 | AVISYNTH_INTERFACE_VERSION = 12, | ||
| 133 | AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps | ||
| 134 | }; | ||
| 135 | |||
| 136 | /* Compiler-specific crap */ | ||
| 137 | |||
| 138 | // Tell MSVC to stop precompiling here | ||
| 139 | #if defined(_MSC_VER) && !defined(__clang__) | ||
| 140 | #pragma hdrstop | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // Set up debugging macros for MS compilers; for others, step down to the | ||
| 144 | // standard <assert.h> interface | ||
| 145 | #ifdef _MSC_VER | ||
| 146 | #include <crtdbg.h> | ||
| 147 | #else | ||
| 148 | #undef _RPT0 | ||
| 149 | #undef _RPT1 | ||
| 150 | #undef _RPT2 | ||
| 151 | #undef _RPT3 | ||
| 152 | #undef _RPT4 | ||
| 153 | #undef _RPT5 | ||
| 154 | #define _RPT0(a,b) ((void)0) | ||
| 155 | #define _RPT1(a,b,c) ((void)0) | ||
| 156 | #define _RPT2(a,b,c,d) ((void)0) | ||
| 157 | #define _RPT3(a,b,c,d,e) ((void)0) | ||
| 158 | #define _RPT4(a,b,c,d,e,f) ((void)0) | ||
| 159 | #define _RPT5(a,b,c,d,e,f,g) ((void)0) | ||
| 160 | |||
| 161 | #include <cassert> | ||
| 162 | #undef _ASSERTE | ||
| 163 | #undef _ASSERT | ||
| 164 | #define _ASSERTE(x) assert(x) | ||
| 165 | #define _ASSERT(x) assert(x) | ||
| 166 | #endif | ||
| 167 | |||
| 168 | |||
| 169 | |||
| 170 | // I had problems with Premiere wanting 1-byte alignment for its structures, | ||
| 171 | // so I now set the Avisynth struct alignment explicitly here. | ||
| 172 | #pragma pack(push,8) | ||
| 173 | |||
| 174 | // The VideoInfo struct holds global information about a clip (i.e. | ||
| 175 | // information that does not depend on the frame number). The GetVideoInfo | ||
| 176 | // method in IClip returns this struct. | ||
| 177 | |||
| 178 | enum AvsSampleType { | ||
| 179 | SAMPLE_INT8 = 1 << 0, | ||
| 180 | SAMPLE_INT16 = 1 << 1, | ||
| 181 | SAMPLE_INT24 = 1 << 2, // Int24 is a very stupid thing to code, but it's supported by some hardware. | ||
| 182 | SAMPLE_INT32 = 1 << 3, | ||
| 183 | SAMPLE_FLOAT = 1 << 4 | ||
| 184 | }; | ||
| 185 | |||
| 186 | enum AvsPlane { | ||
| 187 | DEFAULT_PLANE = 0, | ||
| 188 | PLANAR_Y = 1 << 0, | ||
| 189 | PLANAR_U = 1 << 1, | ||
| 190 | PLANAR_V = 1 << 2, | ||
| 191 | PLANAR_ALIGNED = 1 << 3, | ||
| 192 | PLANAR_Y_ALIGNED = PLANAR_Y | PLANAR_ALIGNED, | ||
| 193 | PLANAR_U_ALIGNED = PLANAR_U | PLANAR_ALIGNED, | ||
| 194 | PLANAR_V_ALIGNED = PLANAR_V | PLANAR_ALIGNED, | ||
| 195 | PLANAR_A = 1 << 4, | ||
| 196 | PLANAR_R = 1 << 5, | ||
| 197 | PLANAR_G = 1 << 6, | ||
| 198 | PLANAR_B = 1 << 7, | ||
| 199 | PLANAR_A_ALIGNED = PLANAR_A | PLANAR_ALIGNED, | ||
| 200 | PLANAR_R_ALIGNED = PLANAR_R | PLANAR_ALIGNED, | ||
| 201 | PLANAR_G_ALIGNED = PLANAR_G | PLANAR_ALIGNED, | ||
| 202 | PLANAR_B_ALIGNED = PLANAR_B | PLANAR_ALIGNED, | ||
| 203 | }; | ||
| 204 | |||
| 205 | class AvisynthError /* exception */ { | ||
| 206 | public: | ||
| 207 | const char* const msg; | ||
| 208 | 34 | AvisynthError(const char* _msg) : msg(_msg) {} | |
| 209 | |||
| 210 | // Ensure AvisynthError cannot be publicly assigned! | ||
| 211 | private: | ||
| 212 | AvisynthError& operator=(const AvisynthError&); | ||
| 213 | }; // end class AvisynthError | ||
| 214 | |||
| 215 | enum AvsDeviceType { | ||
| 216 | DEV_TYPE_NONE = 0, | ||
| 217 | DEV_TYPE_CPU = 1, | ||
| 218 | DEV_TYPE_CUDA = 2, | ||
| 219 | DEV_TYPE_ANY = 0xFFFF | ||
| 220 | }; | ||
| 221 | |||
| 222 | enum AvsValueType { | ||
| 223 | VALUE_TYPE_UNDEFINED = 'v', | ||
| 224 | VALUE_TYPE_BOOL = 'b', | ||
| 225 | VALUE_TYPE_INT = 'i', | ||
| 226 | VALUE_TYPE_LONG = 'l', | ||
| 227 | VALUE_TYPE_FLOAT = 'f', | ||
| 228 | VALUE_TYPE_DOUBLE = 'd', | ||
| 229 | VALUE_TYPE_STRING = 's', | ||
| 230 | VALUE_TYPE_CLIP = 'c', | ||
| 231 | VALUE_TYPE_FUNCTION = 'n', | ||
| 232 | VALUE_TYPE_ARRAY = 'a' | ||
| 233 | }; | ||
| 234 | |||
| 235 | /* Forward references */ | ||
| 236 | #if defined(MSVC) | ||
| 237 | #define SINGLE_INHERITANCE __single_inheritance | ||
| 238 | #else | ||
| 239 | #define SINGLE_INHERITANCE | ||
| 240 | #endif | ||
| 241 | struct SINGLE_INHERITANCE VideoInfo; | ||
| 242 | class SINGLE_INHERITANCE VideoFrameBuffer; | ||
| 243 | class SINGLE_INHERITANCE VideoFrame; | ||
| 244 | class IClip; | ||
| 245 | class SINGLE_INHERITANCE PClip; | ||
| 246 | class SINGLE_INHERITANCE PVideoFrame; | ||
| 247 | class IScriptEnvironment; | ||
| 248 | class SINGLE_INHERITANCE AVSValue; | ||
| 249 | class INeoEnv; | ||
| 250 | class IFunction; | ||
| 251 | class SINGLE_INHERITANCE PFunction; | ||
| 252 | class Device; | ||
| 253 | class SINGLE_INHERITANCE PDevice; | ||
| 254 | struct AVSMap; | ||
| 255 | |||
| 256 | |||
| 257 | |||
| 258 | /* | ||
| 259 | * Avisynth C++ plugin API code function pointers. | ||
| 260 | * | ||
| 261 | * In order to maintain binary compatibility with | ||
| 262 | * future version do not change the order of the | ||
| 263 | * existing function pointers. It will be baked | ||
| 264 | * into all existing plugins. | ||
| 265 | * | ||
| 266 | * Add new function pointers to the end of the | ||
| 267 | * structure. The linkage macros generate some | ||
| 268 | * protection code to ensure newer plugin do not | ||
| 269 | * call non-existing functions in an older host. | ||
| 270 | */ | ||
| 271 | |||
| 272 | struct AVS_Linkage { | ||
| 273 | |||
| 274 | int Size; | ||
| 275 | |||
| 276 | /**********************************************************************/ | ||
| 277 | |||
| 278 | // struct VideoInfo | ||
| 279 | bool (VideoInfo::*HasVideo)() const; | ||
| 280 | bool (VideoInfo::*HasAudio)() const; | ||
| 281 | bool (VideoInfo::*IsRGB)() const; | ||
| 282 | bool (VideoInfo::*IsRGB24)() const; | ||
| 283 | bool (VideoInfo::*IsRGB32)() const; | ||
| 284 | bool (VideoInfo::*IsYUV)() const; | ||
| 285 | bool (VideoInfo::*IsYUY2)() const; | ||
| 286 | bool (VideoInfo::*IsYV24)() const; | ||
| 287 | bool (VideoInfo::*IsYV16)() const; | ||
| 288 | bool (VideoInfo::*IsYV12)() const; | ||
| 289 | bool (VideoInfo::*IsYV411)() const; | ||
| 290 | bool (VideoInfo::*IsY8)() const; | ||
| 291 | bool (VideoInfo::*IsColorSpace)(int c_space) const; | ||
| 292 | bool (VideoInfo::*Is)(int property) const; | ||
| 293 | bool (VideoInfo::*IsPlanar)() const; | ||
| 294 | bool (VideoInfo::*IsFieldBased)() const; | ||
| 295 | bool (VideoInfo::*IsParityKnown)() const; | ||
| 296 | bool (VideoInfo::*IsBFF)() const; | ||
| 297 | bool (VideoInfo::*IsTFF)() const; | ||
| 298 | bool (VideoInfo::*IsVPlaneFirst)() const; | ||
| 299 | int (VideoInfo::*BytesFromPixels)(int pixels) const; | ||
| 300 | int (VideoInfo::*RowSize)(int plane) const; | ||
| 301 | int (VideoInfo::*BMPSize)() const; | ||
| 302 | int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const; | ||
| 303 | int (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const; | ||
| 304 | int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const; | ||
| 305 | int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const; | ||
| 306 | int (VideoInfo::*AudioChannels)() const; | ||
| 307 | int (VideoInfo::*SampleType)() const; | ||
| 308 | bool (VideoInfo::*IsSampleType)(int testtype) const; | ||
| 309 | int (VideoInfo::*SamplesPerSecond)() const; | ||
| 310 | int (VideoInfo::*BytesPerAudioSample)() const; | ||
| 311 | void (VideoInfo::*SetFieldBased)(bool isfieldbased); | ||
| 312 | void (VideoInfo::*Set)(int property); | ||
| 313 | void (VideoInfo::*Clear)(int property); | ||
| 314 | int (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const; | ||
| 315 | int (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const; | ||
| 316 | int (VideoInfo::*BitsPerPixel)() const; | ||
| 317 | int (VideoInfo::*BytesPerChannelSample)() const; | ||
| 318 | void (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator); | ||
| 319 | void (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor); | ||
| 320 | bool (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const; | ||
| 321 | // end struct VideoInfo | ||
| 322 | |||
| 323 | /**********************************************************************/ | ||
| 324 | |||
| 325 | // class VideoFrameBuffer | ||
| 326 | const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const; | ||
| 327 | BYTE* (VideoFrameBuffer::*VFBGetWritePtr)(); | ||
| 328 | int (VideoFrameBuffer::*GetDataSize)() const; | ||
| 329 | int (VideoFrameBuffer::*GetSequenceNumber)() const; | ||
| 330 | int (VideoFrameBuffer::*GetRefcount)() const; | ||
| 331 | // end class VideoFrameBuffer | ||
| 332 | |||
| 333 | /**********************************************************************/ | ||
| 334 | |||
| 335 | // class VideoFrame | ||
| 336 | int (VideoFrame::*GetPitch)(int plane) const; | ||
| 337 | int (VideoFrame::*GetRowSize)(int plane) const; | ||
| 338 | int (VideoFrame::*GetHeight)(int plane) const; | ||
| 339 | VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const; | ||
| 340 | int (VideoFrame::*GetOffset)(int plane) const; | ||
| 341 | const BYTE* (VideoFrame::*VFGetReadPtr)(int plane) const; | ||
| 342 | bool (VideoFrame::*IsWritable)() const; | ||
| 343 | BYTE* (VideoFrame::*VFGetWritePtr)(int plane) const; | ||
| 344 | void (VideoFrame::*VideoFrame_DESTRUCTOR)(); | ||
| 345 | // end class VideoFrame | ||
| 346 | |||
| 347 | /**********************************************************************/ | ||
| 348 | |||
| 349 | // class IClip | ||
| 350 | /* nothing */ | ||
| 351 | // end class IClip | ||
| 352 | |||
| 353 | /**********************************************************************/ | ||
| 354 | |||
| 355 | // class PClip | ||
| 356 | void (PClip::*PClip_CONSTRUCTOR0)(); | ||
| 357 | void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x); | ||
| 358 | void (PClip::*PClip_CONSTRUCTOR2)(IClip* x); | ||
| 359 | void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x); | ||
| 360 | void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x); | ||
| 361 | void (PClip::*PClip_DESTRUCTOR)(); | ||
| 362 | // end class PClip | ||
| 363 | |||
| 364 | /**********************************************************************/ | ||
| 365 | |||
| 366 | // class PVideoFrame | ||
| 367 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)(); | ||
| 368 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x); | ||
| 369 | void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x); | ||
| 370 | void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0)(VideoFrame* x); | ||
| 371 | void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1)(const PVideoFrame& x); | ||
| 372 | void (PVideoFrame::*PVideoFrame_DESTRUCTOR)(); | ||
| 373 | // end class PVideoFrame | ||
| 374 | |||
| 375 | /**********************************************************************/ | ||
| 376 | |||
| 377 | // class AVSValue | ||
| 378 | void (AVSValue::*AVSValue_CONSTRUCTOR0)(); | ||
| 379 | void (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c); | ||
| 380 | void (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c); | ||
| 381 | void (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b); | ||
| 382 | void (AVSValue::*AVSValue_CONSTRUCTOR4)(int i); | ||
| 383 | void (AVSValue::*AVSValue_CONSTRUCTOR5)(float f); | ||
| 384 | void (AVSValue::*AVSValue_CONSTRUCTOR6)(double f); | ||
| 385 | void (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s); | ||
| 386 | void (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int size); | ||
| 387 | void (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v); | ||
| 388 | void (AVSValue::*AVSValue_DESTRUCTOR)(); | ||
| 389 | AVSValue& (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v); | ||
| 390 | const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const; | ||
| 391 | bool (AVSValue::*Defined)() const; | ||
| 392 | bool (AVSValue::*IsClip)() const; | ||
| 393 | bool (AVSValue::*IsBool)() const; | ||
| 394 | bool (AVSValue::*IsInt)() const; | ||
| 395 | bool (AVSValue::*IsFloat)() const; | ||
| 396 | bool (AVSValue::*IsString)() const; | ||
| 397 | bool (AVSValue::*IsArray)() const; | ||
| 398 | PClip (AVSValue::*AsClip)() const; | ||
| 399 | bool (AVSValue::*AsBool1)() const; | ||
| 400 | int (AVSValue::*AsInt1)() const; | ||
| 401 | const char* (AVSValue::*AsString1)() const; | ||
| 402 | double (AVSValue::*AsFloat1)() const; // AsDouble1 | ||
| 403 | bool (AVSValue::*AsBool2)(bool def) const; | ||
| 404 | int (AVSValue::*AsInt2)(int def) const; | ||
| 405 | double (AVSValue::*AsDblDef)(double def) const; // AsDouble2 | ||
| 406 | double (AVSValue::*AsFloat2)(float def) const; | ||
| 407 | const char* (AVSValue::*AsString2)(const char* def) const; | ||
| 408 | int (AVSValue::*ArraySize)() const; | ||
| 409 | // v11 | ||
| 410 | bool (AVSValue::*IsLongStrict)() const; | ||
| 411 | bool (AVSValue::*IsFloatfStrict)() const; | ||
| 412 | int64_t (AVSValue::*AsLong1)() const; | ||
| 413 | int64_t (AVSValue::*AsLong2)(int64_t def) const; | ||
| 414 | void (AVSValue::*AVSValue_CONSTRUCTOR12)(int64_t l); | ||
| 415 | // end class AVSValue | ||
| 416 | |||
| 417 | /**********************************************************************/ | ||
| 418 | // Reserve pointer space, once used to keep compatibility with Avs "classic" even if it adds functions on its own | ||
| 419 | void (VideoInfo::*reserved[27])(); | ||
| 420 | /**********************************************************************/ | ||
| 421 | // AviSynth+ additions | ||
| 422 | int (VideoInfo::*NumComponents)() const; | ||
| 423 | int (VideoInfo::*ComponentSize)() const; | ||
| 424 | int (VideoInfo::*BitsPerComponent)() const; | ||
| 425 | bool (VideoInfo::*Is444)() const; | ||
| 426 | bool (VideoInfo::*Is422)() const; | ||
| 427 | bool (VideoInfo::*Is420)() const; | ||
| 428 | bool (VideoInfo::*IsY)() const; | ||
| 429 | bool (VideoInfo::*IsRGB48)() const; | ||
| 430 | bool (VideoInfo::*IsRGB64)() const; | ||
| 431 | bool (VideoInfo::*IsYUVA)() const; | ||
| 432 | bool (VideoInfo::*IsPlanarRGB)() const; | ||
| 433 | bool (VideoInfo::*IsPlanarRGBA)() const; | ||
| 434 | /**********************************************************************/ | ||
| 435 | |||
| 436 | // frame property access | ||
| 437 | AVSMap& (VideoFrame::* getProperties)(); | ||
| 438 | const AVSMap& (VideoFrame::* getConstProperties)(); | ||
| 439 | void (VideoFrame::* setProperties)(const AVSMap& properties); | ||
| 440 | |||
| 441 | // PFunction | ||
| 442 | void (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o); | ||
| 443 | bool (AVSValue::* IsFunction)() const; | ||
| 444 | void (PFunction::* PFunction_CONSTRUCTOR0)(); | ||
| 445 | void (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p); | ||
| 446 | void (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p); | ||
| 447 | PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other); | ||
| 448 | PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other); | ||
| 449 | void (PFunction::* PFunction_DESTRUCTOR)(); | ||
| 450 | // end PFunction | ||
| 451 | |||
| 452 | // extra VideoFrame functions | ||
| 453 | int (VideoFrame::* VideoFrame_CheckMemory)() const; | ||
| 454 | PDevice (VideoFrame::* VideoFrame_GetDevice)() const; | ||
| 455 | |||
| 456 | // class PDevice, even if only CPU device | ||
| 457 | void (PDevice::* PDevice_CONSTRUCTOR0)(); | ||
| 458 | void (PDevice::* PDevice_CONSTRUCTOR1)(Device* p); | ||
| 459 | void (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p); | ||
| 460 | PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other); | ||
| 461 | PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other); | ||
| 462 | void (PDevice::* PDevice_DESTRUCTOR)(); | ||
| 463 | AvsDeviceType (PDevice::* PDevice_GetType)() const; | ||
| 464 | int (PDevice::* PDevice_GetId)() const; | ||
| 465 | int (PDevice::* PDevice_GetIndex)() const; | ||
| 466 | const char* (PDevice::* PDevice_GetName)() const; | ||
| 467 | // end class PDevice | ||
| 468 | |||
| 469 | // V9: VideoFrame helper | ||
| 470 | bool (VideoFrame::*IsPropertyWritable)() const; | ||
| 471 | |||
| 472 | // V10 | ||
| 473 | int (VideoFrame::*VideoFrame_GetPixelType)() const; | ||
| 474 | void (VideoFrame::*VideoFrame_AmendPixelType)(int new_pixel_type); | ||
| 475 | void (VideoFrameBuffer::*VideoFrameBuffer_DESTRUCTOR)(); | ||
| 476 | AvsValueType (AVSValue::*AVSValue_GetType)() const; | ||
| 477 | |||
| 478 | // V10.1 | ||
| 479 | bool (VideoInfo::* IsChannelMaskKnown)() const; | ||
| 480 | void (VideoInfo::* SetChannelMask)(bool isChannelMaskKnown, unsigned int dwChannelMask); | ||
| 481 | unsigned int (VideoInfo::* GetChannelMask)() const; | ||
| 482 | |||
| 483 | /**********************************************************************/ | ||
| 484 | // Reserve pointer space for Avisynth+ | ||
| 485 | void (VideoInfo::* reserved2[64 - 31])(); | ||
| 486 | /**********************************************************************/ | ||
| 487 | |||
| 488 | // AviSynth Neo additions | ||
| 489 | INeoEnv* (__stdcall *GetNeoEnv)(IScriptEnvironment* env); | ||
| 490 | // As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place. | ||
| 491 | /**********************************************************************/ | ||
| 492 | |||
| 493 | // This part should be identical with AVS_Linkage entries in interface.cpp | ||
| 494 | }; | ||
| 495 | |||
| 496 | #if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB) | ||
| 497 | /* Macro resolution for code inside Avisynth.dll */ | ||
| 498 | # define AVS_BakedCode(arg) ; | ||
| 499 | # define AVS_LinkCall(arg) | ||
| 500 | # define AVS_LinkCallV(arg) | ||
| 501 | # define AVS_LinkCallOpt(arg, argOpt) AVSLinkCall(arg) | ||
| 502 | # define AVS_LinkCallOptDefault(arg, argDefaultValue) AVSLinkCall(arg()) | ||
| 503 | # define CALL_MEMBER_FN(object,ptrToMember) | ||
| 504 | |||
| 505 | #else | ||
| 506 | /* Macro resolution for code inside user plugin */ | ||
| 507 | # ifdef AVS_LINKAGE_DLLIMPORT | ||
| 508 | extern __declspec(dllimport) const AVS_Linkage* const AVS_linkage; | ||
| 509 | # else | ||
| 510 | extern const AVS_Linkage* AVS_linkage; | ||
| 511 | # endif | ||
| 512 | |||
| 513 | # ifndef offsetof | ||
| 514 | # include <stddef.h> | ||
| 515 | # endif | ||
| 516 | |||
| 517 | # define AVS_BakedCode(arg) { arg ; } | ||
| 518 | # define AVS_LinkCall(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? 0 : (this->*(AVS_linkage->arg)) | ||
| 519 | # define AVS_LinkCall_Void(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? (void)0 : (this->*(AVS_linkage->arg)) | ||
| 520 | # define AVS_LinkCallV(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? *this : (this->*(AVS_linkage->arg)) | ||
| 521 | // Helper macros for fallback option when a function does not exists | ||
| 522 | #define CALL_MEMBER_FN(object,ptrToMember) ((object)->*(ptrToMember)) | ||
| 523 | #define AVS_LinkCallOpt(arg, argOpt) !AVS_linkage ? 0 : \ | ||
| 524 | ( offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? \ | ||
| 525 | (offsetof(AVS_Linkage, argOpt) >= (size_t)AVS_linkage->Size ? 0 : CALL_MEMBER_FN(this, AVS_linkage->argOpt)() ) : \ | ||
| 526 | CALL_MEMBER_FN(this, AVS_linkage->arg)() ) | ||
| 527 | // AVS_LinkCallOptDefault puts automatically () only after arg | ||
| 528 | # define AVS_LinkCallOptDefault(arg, argDefaultValue) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? (argDefaultValue) : ((this->*(AVS_linkage->arg))()) | ||
| 529 | |||
| 530 | #endif | ||
| 531 | |||
| 532 | class PDevice | ||
| 533 | { | ||
| 534 | public: | ||
| 535 | PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)()) | ||
| 536 | PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p)) | ||
| 537 | PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p)) | ||
| 538 | PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p)) | ||
| 539 | PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p)) | ||
| 540 | ~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)()) | ||
| 541 | |||
| 542 | int operator!() const { return !e; } | ||
| 543 | ✗ | operator void*() const { return e; } | |
| 544 | Device* operator->() const { return e; } | ||
| 545 | |||
| 546 | AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE)) | ||
| 547 | int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)()) | ||
| 548 | int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)()) | ||
| 549 | const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)()) | ||
| 550 | |||
| 551 | private: | ||
| 552 | Device * e; | ||
| 553 | |||
| 554 | #ifdef BUILDING_AVSCORE | ||
| 555 | public: | ||
| 556 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 557 | void CONSTRUCTOR1(Device* p); | ||
| 558 | void CONSTRUCTOR2(const PDevice& p); | ||
| 559 | PDevice& OPERATOR_ASSIGN0(Device* p); | ||
| 560 | PDevice& OPERATOR_ASSIGN1(const PDevice& p); | ||
| 561 | void DESTRUCTOR(); | ||
| 562 | #endif | ||
| 563 | }; | ||
| 564 | |||
| 565 | // Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE | ||
| 566 | // in AvsImageTypeFlags they are shifted by 4 bits | ||
| 567 | enum AvsChannelMask { | ||
| 568 | MASK_SPEAKER_FRONT_LEFT = 0x1, | ||
| 569 | MASK_SPEAKER_FRONT_RIGHT = 0x2, | ||
| 570 | MASK_SPEAKER_FRONT_CENTER = 0x4, | ||
| 571 | MASK_SPEAKER_LOW_FREQUENCY = 0x8, | ||
| 572 | MASK_SPEAKER_BACK_LEFT = 0x10, | ||
| 573 | MASK_SPEAKER_BACK_RIGHT = 0x20, | ||
| 574 | MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40, | ||
| 575 | MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80, | ||
| 576 | MASK_SPEAKER_BACK_CENTER = 0x100, | ||
| 577 | MASK_SPEAKER_SIDE_LEFT = 0x200, | ||
| 578 | MASK_SPEAKER_SIDE_RIGHT = 0x400, | ||
| 579 | MASK_SPEAKER_TOP_CENTER = 0x800, | ||
| 580 | MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000, | ||
| 581 | MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000, | ||
| 582 | MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000, | ||
| 583 | MASK_SPEAKER_TOP_BACK_LEFT = 0x8000, | ||
| 584 | MASK_SPEAKER_TOP_BACK_CENTER = 0x10000, | ||
| 585 | MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000, | ||
| 586 | // Bit mask locations used up for the above positions | ||
| 587 | MASK_SPEAKER_DEFINED = 0x0003FFFF, | ||
| 588 | // Bit mask locations reserved for future use | ||
| 589 | MASK_SPEAKER_RESERVED = 0x7FFC0000, | ||
| 590 | // Used to specify that any possible permutation of speaker configurations | ||
| 591 | // Due to lack of available bits this one is put differently into image_type | ||
| 592 | MASK_SPEAKER_ALL = 0x80000000 | ||
| 593 | }; | ||
| 594 | |||
| 595 | struct VideoInfo { | ||
| 596 | int width, height; // width 0 means no video | ||
| 597 | unsigned fps_numerator, fps_denominator; | ||
| 598 | int num_frames; | ||
| 599 | // This is more extensible than previous versions. More properties can be added seamlessly. | ||
| 600 | |||
| 601 | // Colorspace properties. | ||
| 602 | /* | ||
| 603 | Planar match mask 1111.1000.0000.0111.0000.0111.0000.0111 | ||
| 604 | Planar signature 10xx.1000.0000.00xx.0000.00xx.00xx.00xx ? | ||
| 605 | Planar signature 10xx.1000.0000.0xxx.0000.00xx.000x.x0xx ? *new | ||
| 606 | Planar filter mask 1111.1111.1111.1111.1111.1111.1110.0111 (typo from old header fixed) | ||
| 607 | |||
| 608 | pixel_type mapping | ||
| 609 | ================== | ||
| 610 | pixel_type bit-map PIYB.Z000.0???.0SSS.0000.0???.????.???? | ||
| 611 | planar YUV CCC HHH.000u.vWWW | ||
| 612 | planar RGB(A) CCC AR | ||
| 613 | nonplanar CCC 000.00wx xyAR | ||
| 614 | Legend | ||
| 615 | ====== | ||
| 616 | Planar YUV: | ||
| 617 | Code Bits Remark | ||
| 618 | W 0-2 Planar Width Subsampling bits | ||
| 619 | Use (X+1) & 3 for GetPlaneWidthSubsampling | ||
| 620 | 000 => 1 YV12, YV16, YUV420, YUV422 | ||
| 621 | 001 => 2 YV411, YUV9 | ||
| 622 | 010 => reserved | ||
| 623 | 011 => 0 YV24, YUV444, RGBP | ||
| 624 | 1xx => reserved | ||
| 625 | v 3 VPlaneFirst YV12, YV16, YV24, YV411, YUV9 | ||
| 626 | u 4 UPlaneFirst I420 | ||
| 627 | H 7-9 Planar Height Subsampling bits | ||
| 628 | Use ((X>>8)+1) & 3 for GetPlaneHeightSubsampling | ||
| 629 | 000 => 1 YV12, YUV420 | ||
| 630 | 001 => 2 YUV9 | ||
| 631 | 010 => reserved | ||
| 632 | 011 => 0 YV16, YV24, YV411, YUV422, YUV444, RGBP | ||
| 633 | 1xx => reserved | ||
| 634 | |||
| 635 | Planar RGB | ||
| 636 | Code Bits Remark | ||
| 637 | R 0 BGR, (with SSS bits for 8/16 bit/sample or float) | ||
| 638 | A 1 BGRA, (with SSS bits for 8/16 bit/sample or float) | ||
| 639 | |||
| 640 | |||
| 641 | Not Planar, Interleaved (I flag) | ||
| 642 | Code Bits Remark | ||
| 643 | R 0 BGR24, and BGRx in future (with SSS bits for 8/16 bit/sample or float) | ||
| 644 | A 1 BGR32, and BGRAx in future (with SSS bits for 8/16 bit/sample or float) | ||
| 645 | y 2 YUY2 | ||
| 646 | x 3-4 reserved | ||
| 647 | w 5 Raw32 | ||
| 648 | |||
| 649 | General | ||
| 650 | Code Bits Remark | ||
| 651 | S 16-18 Sample resolution bits | ||
| 652 | 000 => 8 | ||
| 653 | 001 => 16 | ||
| 654 | 010 => 32 (float) | ||
| 655 | 011,100 => reserved | ||
| 656 | 101 => 10 bits | ||
| 657 | 110 => 12 bits | ||
| 658 | 111 => 14 bits | ||
| 659 | for packed RGB(A): only 8 and 16 bits are valid | ||
| 660 | |||
| 661 | Other YV12 specific (will never be used) | ||
| 662 | C 20-23 Chroma Placement values 0-4; see CS_xxx_CHROMA_PLACEMENT | ||
| 663 | |||
| 664 | Color family and layout | ||
| 665 | Packed Planar Planar Planar | ||
| 666 | Code Bits Remark RGB/RGBA YUV YUY2 Y_Grey RGB/RGBA YUVA | ||
| 667 | R 0 1/0 - 0 - 1/0 - | ||
| 668 | A 1 0/1 - 0 - 0/1 - | ||
| 669 | y 2 - - 1 - 0 - | ||
| 670 | Z 27 YUVA 0 0 0 0 1 1 | ||
| 671 | B 28 BGR 1 0 0 0 1* 0 | ||
| 672 | Y 29 YUV 0 1 1 1 0 0 | ||
| 673 | I 30 Interleaved 1 0 1 1 0 0 | ||
| 674 | P 31 Planar 0 1 0 1 1 1 | ||
| 675 | * Planar RGB plane order: G,B,R(,A) | ||
| 676 | */ | ||
| 677 | enum AvsColorFormat { | ||
| 678 | CS_YUVA = 1 << 27, | ||
| 679 | CS_BGR = 1 << 28, | ||
| 680 | CS_YUV = 1 << 29, | ||
| 681 | CS_INTERLEAVED = 1 << 30, | ||
| 682 | CS_PLANAR = 1 << 31, | ||
| 683 | |||
| 684 | CS_Shift_Sub_Width = 0, | ||
| 685 | CS_Shift_Sub_Height = 8, | ||
| 686 | CS_Shift_Sample_Bits = 16, | ||
| 687 | |||
| 688 | CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width, | ||
| 689 | CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24 | ||
| 690 | CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16 | ||
| 691 | CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411 | ||
| 692 | |||
| 693 | CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9 | ||
| 694 | CS_UPlaneFirst = 1 << 4, // I420 | ||
| 695 | |||
| 696 | CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height, | ||
| 697 | CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411 | ||
| 698 | CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420 | ||
| 699 | CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9 | ||
| 700 | |||
| 701 | CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits, | ||
| 702 | CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits, | ||
| 703 | CS_Sample_Bits_10 = 5 << CS_Shift_Sample_Bits, | ||
| 704 | CS_Sample_Bits_12 = 6 << CS_Shift_Sample_Bits, | ||
| 705 | CS_Sample_Bits_14 = 7 << CS_Shift_Sample_Bits, | ||
| 706 | CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits, | ||
| 707 | CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits, | ||
| 708 | |||
| 709 | CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_YUVA | ||
| 710 | | CS_Sample_Bits_Mask | CS_Sub_Width_Mask | CS_Sub_Height_Mask, | ||
| 711 | CS_PLANAR_FILTER = ~(CS_VPlaneFirst | CS_UPlaneFirst), | ||
| 712 | |||
| 713 | CS_RGB_TYPE = 1 << 0, | ||
| 714 | CS_RGBA_TYPE = 1 << 1, | ||
| 715 | |||
| 716 | // Specific colorformats | ||
| 717 | CS_UNKNOWN = 0, | ||
| 718 | |||
| 719 | CS_BGR24 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED, | ||
| 720 | CS_BGR32 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED, | ||
| 721 | CS_YUY2 = 1 << 2 | CS_YUV | CS_INTERLEAVED, | ||
| 722 | // CS_YV12 = 1 << 3 Reserved | ||
| 723 | // CS_I420 = 1 << 4 Reserved | ||
| 724 | CS_RAW32 = 1 << 5 | CS_INTERLEAVED, | ||
| 725 | |||
| 726 | // YV12 must be 0xA0000008. v2.5 Baked API will see all new planar as YV12. | ||
| 727 | // I420 must be 0xA0000010. | ||
| 728 | |||
| 729 | CS_GENERIC_YUV444 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1, // 4:4:4 planar | ||
| 730 | CS_GENERIC_YUV422 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1, // 4:2:2 planar | ||
| 731 | CS_GENERIC_YUV420 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2, // 4:2:0 planar | ||
| 732 | CS_GENERIC_Y = CS_PLANAR | CS_INTERLEAVED | CS_YUV, // Y only (4:0:0) | ||
| 733 | CS_GENERIC_RGBP = CS_PLANAR | CS_BGR | CS_RGB_TYPE, // planar RGB. Though name is RGB but plane order G,B,R | ||
| 734 | CS_GENERIC_RGBAP = CS_PLANAR | CS_BGR | CS_RGBA_TYPE, // planar RGBA | ||
| 735 | CS_GENERIC_YUVA444 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1, // 4:4:4:A planar | ||
| 736 | CS_GENERIC_YUVA422 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1, // 4:2:2:A planar | ||
| 737 | CS_GENERIC_YUVA420 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2, // 4:2:0:A planar | ||
| 738 | |||
| 739 | CS_YV24 = CS_GENERIC_YUV444 | CS_Sample_Bits_8, // YVU 4:4:4 planar | ||
| 740 | CS_YV16 = CS_GENERIC_YUV422 | CS_Sample_Bits_8, // YVU 4:2:2 planar | ||
| 741 | CS_YV12 = CS_GENERIC_YUV420 | CS_Sample_Bits_8, // YVU 4:2:0 planar | ||
| 742 | CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2, // YUV 4:2:0 planar | ||
| 743 | CS_IYUV = CS_I420, | ||
| 744 | CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_4, // YUV 4:1:0 planar | ||
| 745 | CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_1, // YUV 4:1:1 planar | ||
| 746 | |||
| 747 | CS_Y8 = CS_GENERIC_Y | CS_Sample_Bits_8, // Y 4:0:0 planar | ||
| 748 | |||
| 749 | //------------------------- | ||
| 750 | // AVS16: new planar constants go live! Experimental PF 160613 | ||
| 751 | // 10-12-14 bit + planar RGB + BRG48/64 160725 | ||
| 752 | |||
| 753 | CS_YUV444P10 = CS_GENERIC_YUV444 | CS_Sample_Bits_10, // YUV 4:4:4 10bit samples | ||
| 754 | CS_YUV422P10 = CS_GENERIC_YUV422 | CS_Sample_Bits_10, // YUV 4:2:2 10bit samples | ||
| 755 | CS_YUV420P10 = CS_GENERIC_YUV420 | CS_Sample_Bits_10, // YUV 4:2:0 10bit samples | ||
| 756 | CS_Y10 = CS_GENERIC_Y | CS_Sample_Bits_10, // Y 4:0:0 10bit samples | ||
| 757 | |||
| 758 | CS_YUV444P12 = CS_GENERIC_YUV444 | CS_Sample_Bits_12, // YUV 4:4:4 12bit samples | ||
| 759 | CS_YUV422P12 = CS_GENERIC_YUV422 | CS_Sample_Bits_12, // YUV 4:2:2 12bit samples | ||
| 760 | CS_YUV420P12 = CS_GENERIC_YUV420 | CS_Sample_Bits_12, // YUV 4:2:0 12bit samples | ||
| 761 | CS_Y12 = CS_GENERIC_Y | CS_Sample_Bits_12, // Y 4:0:0 12bit samples | ||
| 762 | |||
| 763 | CS_YUV444P14 = CS_GENERIC_YUV444 | CS_Sample_Bits_14, // YUV 4:4:4 14bit samples | ||
| 764 | CS_YUV422P14 = CS_GENERIC_YUV422 | CS_Sample_Bits_14, // YUV 4:2:2 14bit samples | ||
| 765 | CS_YUV420P14 = CS_GENERIC_YUV420 | CS_Sample_Bits_14, // YUV 4:2:0 14bit samples | ||
| 766 | CS_Y14 = CS_GENERIC_Y | CS_Sample_Bits_14, // Y 4:0:0 14bit samples | ||
| 767 | |||
| 768 | CS_YUV444P16 = CS_GENERIC_YUV444 | CS_Sample_Bits_16, // YUV 4:4:4 16bit samples | ||
| 769 | CS_YUV422P16 = CS_GENERIC_YUV422 | CS_Sample_Bits_16, // YUV 4:2:2 16bit samples | ||
| 770 | CS_YUV420P16 = CS_GENERIC_YUV420 | CS_Sample_Bits_16, // YUV 4:2:0 16bit samples | ||
| 771 | CS_Y16 = CS_GENERIC_Y | CS_Sample_Bits_16, // Y 4:0:0 16bit samples | ||
| 772 | |||
| 773 | // 32 bit samples (float) | ||
| 774 | CS_YUV444PS = CS_GENERIC_YUV444 | CS_Sample_Bits_32, // YUV 4:4:4 32bit samples | ||
| 775 | CS_YUV422PS = CS_GENERIC_YUV422 | CS_Sample_Bits_32, // YUV 4:2:2 32bit samples | ||
| 776 | CS_YUV420PS = CS_GENERIC_YUV420 | CS_Sample_Bits_32, // YUV 4:2:0 32bit samples | ||
| 777 | CS_Y32 = CS_GENERIC_Y | CS_Sample_Bits_32, // Y 4:0:0 32bit samples | ||
| 778 | |||
| 779 | // RGB packed | ||
| 780 | CS_BGR48 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 3x16 bit | ||
| 781 | CS_BGR64 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 4x16 bit | ||
| 782 | // no packed 32 bit (float) support for these legacy types | ||
| 783 | |||
| 784 | // RGB planar | ||
| 785 | CS_RGBP = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples | ||
| 786 | CS_RGBP8 = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples | ||
| 787 | CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples | ||
| 788 | CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples | ||
| 789 | CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples | ||
| 790 | CS_RGBP16 = CS_GENERIC_RGBP | CS_Sample_Bits_16, // Planar RGB 16bit samples | ||
| 791 | CS_RGBPS = CS_GENERIC_RGBP | CS_Sample_Bits_32, // Planar RGB 32bit samples | ||
| 792 | |||
| 793 | // RGBA planar | ||
| 794 | CS_RGBAP = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples | ||
| 795 | CS_RGBAP8 = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples | ||
| 796 | CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples | ||
| 797 | CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples | ||
| 798 | CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples | ||
| 799 | CS_RGBAP16 = CS_GENERIC_RGBAP | CS_Sample_Bits_16, // Planar RGBA 16bit samples | ||
| 800 | CS_RGBAPS = CS_GENERIC_RGBAP | CS_Sample_Bits_32, // Planar RGBA 32bit samples | ||
| 801 | |||
| 802 | // Planar YUVA | ||
| 803 | CS_YUVA444 = CS_GENERIC_YUVA444 | CS_Sample_Bits_8, // YUVA 4:4:4 8bit samples | ||
| 804 | CS_YUVA422 = CS_GENERIC_YUVA422 | CS_Sample_Bits_8, // YUVA 4:2:2 8bit samples | ||
| 805 | CS_YUVA420 = CS_GENERIC_YUVA420 | CS_Sample_Bits_8, // YUVA 4:2:0 8bit samples | ||
| 806 | |||
| 807 | CS_YUVA444P10 = CS_GENERIC_YUVA444 | CS_Sample_Bits_10, // YUVA 4:4:4 10bit samples | ||
| 808 | CS_YUVA422P10 = CS_GENERIC_YUVA422 | CS_Sample_Bits_10, // YUVA 4:2:2 10bit samples | ||
| 809 | CS_YUVA420P10 = CS_GENERIC_YUVA420 | CS_Sample_Bits_10, // YUVA 4:2:0 10bit samples | ||
| 810 | |||
| 811 | CS_YUVA444P12 = CS_GENERIC_YUVA444 | CS_Sample_Bits_12, // YUVA 4:4:4 12bit samples | ||
| 812 | CS_YUVA422P12 = CS_GENERIC_YUVA422 | CS_Sample_Bits_12, // YUVA 4:2:2 12bit samples | ||
| 813 | CS_YUVA420P12 = CS_GENERIC_YUVA420 | CS_Sample_Bits_12, // YUVA 4:2:0 12bit samples | ||
| 814 | |||
| 815 | CS_YUVA444P14 = CS_GENERIC_YUVA444 | CS_Sample_Bits_14, // YUVA 4:4:4 14bit samples | ||
| 816 | CS_YUVA422P14 = CS_GENERIC_YUVA422 | CS_Sample_Bits_14, // YUVA 4:2:2 14bit samples | ||
| 817 | CS_YUVA420P14 = CS_GENERIC_YUVA420 | CS_Sample_Bits_14, // YUVA 4:2:0 14bit samples | ||
| 818 | |||
| 819 | CS_YUVA444P16 = CS_GENERIC_YUVA444 | CS_Sample_Bits_16, // YUVA 4:4:4 16bit samples | ||
| 820 | CS_YUVA422P16 = CS_GENERIC_YUVA422 | CS_Sample_Bits_16, // YUVA 4:2:2 16bit samples | ||
| 821 | CS_YUVA420P16 = CS_GENERIC_YUVA420 | CS_Sample_Bits_16, // YUVA 4:2:0 16bit samples | ||
| 822 | |||
| 823 | CS_YUVA444PS = CS_GENERIC_YUVA444 | CS_Sample_Bits_32, // YUVA 4:4:4 32bit samples | ||
| 824 | CS_YUVA422PS = CS_GENERIC_YUVA422 | CS_Sample_Bits_32, // YUVA 4:2:2 32bit samples | ||
| 825 | CS_YUVA420PS = CS_GENERIC_YUVA420 | CS_Sample_Bits_32, // YUVA 4:2:0 32bit samples | ||
| 826 | }; | ||
| 827 | |||
| 828 | int pixel_type; // changed to int as of 2.5 | ||
| 829 | |||
| 830 | int audio_samples_per_second; // 0 means no audio | ||
| 831 | int sample_type; // as of 2.5 | ||
| 832 | int64_t num_audio_samples; // changed as of 2.5 | ||
| 833 | int nchannels; // as of 2.5 | ||
| 834 | |||
| 835 | // BFF, TFF, FIELDBASED. Also used for storing Channel Mask | ||
| 836 | int image_type; | ||
| 837 | |||
| 838 | enum AvsImageTypeFlags { | ||
| 839 | IT_BFF = 1 << 0, | ||
| 840 | IT_TFF = 1 << 1, | ||
| 841 | IT_FIELDBASED = 1 << 2, | ||
| 842 | |||
| 843 | // Audio channel mask support | ||
| 844 | IT_HAS_CHANNELMASK = 1 << 3, | ||
| 845 | // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask | ||
| 846 | // otherwise same as AvsChannelMask | ||
| 847 | IT_SPEAKER_FRONT_LEFT = 0x1 << 4, | ||
| 848 | IT_SPEAKER_FRONT_RIGHT = 0x2 << 4, | ||
| 849 | IT_SPEAKER_FRONT_CENTER = 0x4 << 4, | ||
| 850 | IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4, | ||
| 851 | IT_SPEAKER_BACK_LEFT = 0x10 << 4, | ||
| 852 | IT_SPEAKER_BACK_RIGHT = 0x20 << 4, | ||
| 853 | IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4, | ||
| 854 | IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4, | ||
| 855 | IT_SPEAKER_BACK_CENTER = 0x100 << 4, | ||
| 856 | IT_SPEAKER_SIDE_LEFT = 0x200 << 4, | ||
| 857 | IT_SPEAKER_SIDE_RIGHT = 0x400 << 4, | ||
| 858 | IT_SPEAKER_TOP_CENTER = 0x800 << 4, | ||
| 859 | IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4, | ||
| 860 | IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4, | ||
| 861 | IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4, | ||
| 862 | IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4, | ||
| 863 | IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4, | ||
| 864 | IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4, | ||
| 865 | // End of officially defined speaker bits | ||
| 866 | // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further. | ||
| 867 | // Set mask and get mask handles it. | ||
| 868 | IT_SPEAKER_ALL = 0x40000 << 4, | ||
| 869 | // Mask for the defined 18 bits + SPEAKER_ALL | ||
| 870 | IT_SPEAKER_BITS_MASK = (AvsChannelMask::MASK_SPEAKER_DEFINED << 4) | IT_SPEAKER_ALL, | ||
| 871 | IT_NEXT_AVAILABLE = 1 << 23 | ||
| 872 | }; | ||
| 873 | |||
| 874 | // Chroma placement bits 20 -> 23 ::FIXME:: Really want a Class to support this | ||
| 875 | enum AvsChromaPlacement { | ||
| 876 | CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20, | ||
| 877 | CS_MPEG1_CHROMA_PLACEMENT = 1 << 20, | ||
| 878 | CS_MPEG2_CHROMA_PLACEMENT = 2 << 20, | ||
| 879 | CS_YUY2_CHROMA_PLACEMENT = 3 << 20, | ||
| 880 | CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20 | ||
| 881 | }; | ||
| 882 | |||
| 883 | // useful functions of the above | ||
| 884 | bool HasVideo() const AVS_BakedCode(return AVS_LinkCall(HasVideo)()) | ||
| 885 | bool HasAudio() const AVS_BakedCode(return AVS_LinkCall(HasAudio)()) | ||
| 886 | bool IsRGB() const AVS_BakedCode(return AVS_LinkCall(IsRGB)()) | ||
| 887 | bool IsRGB24() const AVS_BakedCode(return AVS_LinkCall(IsRGB24)()) | ||
| 888 | bool IsRGB32() const AVS_BakedCode(return AVS_LinkCall(IsRGB32)()) | ||
| 889 | bool IsYUV() const AVS_BakedCode(return AVS_LinkCall(IsYUV)()) | ||
| 890 | bool IsYUY2() const AVS_BakedCode(return AVS_LinkCall(IsYUY2)()) | ||
| 891 | |||
| 892 | bool IsYV24() const AVS_BakedCode(return AVS_LinkCall(IsYV24)()) | ||
| 893 | bool IsYV16() const AVS_BakedCode(return AVS_LinkCall(IsYV16)()) | ||
| 894 | bool IsYV12() const AVS_BakedCode(return AVS_LinkCall(IsYV12)()) | ||
| 895 | bool IsYV411() const AVS_BakedCode(return AVS_LinkCall(IsYV411)()) | ||
| 896 | //bool IsYUV9() const; | ||
| 897 | bool IsY8() const AVS_BakedCode(return AVS_LinkCall(IsY8)()) | ||
| 898 | |||
| 899 | bool IsColorSpace(int c_space) const AVS_BakedCode(return AVS_LinkCall(IsColorSpace)(c_space)) | ||
| 900 | |||
| 901 | bool Is(int property) const AVS_BakedCode(return AVS_LinkCall(Is)(property)) | ||
| 902 | bool IsPlanar() const AVS_BakedCode(return AVS_LinkCall(IsPlanar)()) | ||
| 903 | bool IsFieldBased() const AVS_BakedCode(return AVS_LinkCall(IsFieldBased)()) | ||
| 904 | bool IsParityKnown() const AVS_BakedCode(return AVS_LinkCall(IsParityKnown)()) | ||
| 905 | bool IsBFF() const AVS_BakedCode(return AVS_LinkCall(IsBFF)()) | ||
| 906 | bool IsTFF() const AVS_BakedCode(return AVS_LinkCall(IsTFF)()) | ||
| 907 | |||
| 908 | bool IsVPlaneFirst() const AVS_BakedCode(return AVS_LinkCall(IsVPlaneFirst)()) // Don't use this | ||
| 909 | // Will not work on planar images, but will return only luma planes | ||
| 910 | int BytesFromPixels(int pixels) const AVS_BakedCode(return AVS_LinkCall(BytesFromPixels)(pixels)) | ||
| 911 | int RowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane)) | ||
| 912 | int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)()) | ||
| 913 | |||
| 914 | int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames)) | ||
| 915 | int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples)) | ||
| 916 | int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes)) | ||
| 917 | int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples)) | ||
| 918 | int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)()) | ||
| 919 | int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)()) | ||
| 920 | bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype)) | ||
| 921 | int SamplesPerSecond() const AVS_BakedCode(return AVS_LinkCall(SamplesPerSecond)()) | ||
| 922 | int BytesPerAudioSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerAudioSample)()) | ||
| 923 | void SetFieldBased(bool isfieldbased) AVS_BakedCode(AVS_LinkCall_Void(SetFieldBased)(isfieldbased)) | ||
| 924 | void Set(int property) AVS_BakedCode(AVS_LinkCall_Void(Set)(property)) | ||
| 925 | void Clear(int property) AVS_BakedCode(AVS_LinkCall_Void(Clear)(property)) | ||
| 926 | // Subsampling in bitshifts! | ||
| 927 | int GetPlaneWidthSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneWidthSubsampling)(plane)) | ||
| 928 | int GetPlaneHeightSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneHeightSubsampling)(plane)) | ||
| 929 | int BitsPerPixel() const AVS_BakedCode(return AVS_LinkCall(BitsPerPixel)()) | ||
| 930 | |||
| 931 | int BytesPerChannelSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerChannelSample)()) | ||
| 932 | |||
| 933 | // useful mutator | ||
| 934 | void SetFPS(unsigned numerator, unsigned denominator) AVS_BakedCode(AVS_LinkCall_Void(SetFPS)(numerator, denominator)) | ||
| 935 | |||
| 936 | // Range protected multiply-divide of FPS | ||
| 937 | void MulDivFPS(unsigned multiplier, unsigned divisor) AVS_BakedCode(AVS_LinkCall_Void(MulDivFPS)(multiplier, divisor)) | ||
| 938 | |||
| 939 | // Test for same colorspace | ||
| 940 | bool IsSameColorspace(const VideoInfo& vi) const AVS_BakedCode(return AVS_LinkCall(IsSameColorspace)(vi)) | ||
| 941 | |||
| 942 | // AVS+ extensions | ||
| 943 | // 20161005: | ||
| 944 | // Mapping of AVS+ extensions to classic 2.6 functions. | ||
| 945 | // In order to use these extended AVS+ functions for plugins that should work | ||
| 946 | // either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an | ||
| 947 | // automatic fallback mechanism. | ||
| 948 | // From AVS+'s point of view these are not "baked" codes, the primary functions should exist. | ||
| 949 | // Examples: | ||
| 950 | // Is444() is mapped to IsYV24() for classic AVS2.6 | ||
| 951 | // ComponentSize() returns constant 1 (1 bytes per pixel component) | ||
| 952 | // BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only) | ||
| 953 | |||
| 954 | // Returns the number of color channels or planes in a frame | ||
| 955 | int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) ) | ||
| 956 | |||
| 957 | // Returns the size in bytes of a single component of a pixel | ||
| 958 | int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1)) | ||
| 959 | |||
| 960 | // Returns the bit depth of a single component of a pixel | ||
| 961 | int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8)) | ||
| 962 | |||
| 963 | // like IsYV24, but bit-depth independent also for YUVA | ||
| 964 | bool Is444() const AVS_BakedCode(return AVS_LinkCallOpt(Is444, IsYV24) ) | ||
| 965 | |||
| 966 | // like IsYV16, but bit-depth independent also for YUVA | ||
| 967 | bool Is422() const AVS_BakedCode(return AVS_LinkCallOpt(Is422, IsYV16) ) | ||
| 968 | |||
| 969 | // like IsYV12, but bit-depth independent also for YUVA | ||
| 970 | bool Is420() const AVS_BakedCode( return AVS_LinkCallOpt(Is420, IsYV12) ) | ||
| 971 | |||
| 972 | // like IsY8, but bit-depth independent | ||
| 973 | bool IsY() const AVS_BakedCode( return AVS_LinkCallOpt(IsY, IsY8) ) | ||
| 974 | |||
| 975 | // like IsRGB24 for 16 bit samples | ||
| 976 | bool IsRGB48() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB48, false) ) | ||
| 977 | |||
| 978 | // like IsRGB32 for 16 bit samples | ||
| 979 | bool IsRGB64() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB64, false) ) | ||
| 980 | |||
| 981 | // YUVA? | ||
| 982 | bool IsYUVA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsYUVA, false) ) | ||
| 983 | |||
| 984 | // Planar RGB? | ||
| 985 | bool IsPlanarRGB() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGB, false) ) | ||
| 986 | |||
| 987 | // Planar RGBA? | ||
| 988 | bool IsPlanarRGBA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGBA, false) ) | ||
| 989 | |||
| 990 | // v10.1 interface: audio channel masks | ||
| 991 | bool IsChannelMaskKnown() const AVS_BakedCode(return AVS_LinkCallOptDefault(IsChannelMaskKnown, false) ) | ||
| 992 | void SetChannelMask(bool isChannelMaskKnown, unsigned int dwChannelMask) AVS_BakedCode(AVS_LinkCall_Void(SetChannelMask)(isChannelMaskKnown, dwChannelMask)) | ||
| 993 | unsigned int GetChannelMask() const AVS_BakedCode(return AVS_LinkCallOptDefault(GetChannelMask, 0) ) | ||
| 994 | |||
| 995 | }; // end struct VideoInfo | ||
| 996 | |||
| 997 | |||
| 998 | |||
| 999 | |||
| 1000 | // VideoFrameBuffer holds information about a memory block which is used | ||
| 1001 | // for video data. For efficiency, instances of this class are not deleted | ||
| 1002 | // when the refcount reaches zero; instead they're stored in a linked list | ||
| 1003 | // to be reused. The instances are deleted when the corresponding AVS | ||
| 1004 | // file is closed. | ||
| 1005 | |||
| 1006 | class VideoFrameBuffer { | ||
| 1007 | BYTE* data; | ||
| 1008 | int data_size; | ||
| 1009 | // sequence_number is incremented every time the buffer is changed, so | ||
| 1010 | // that stale views can tell they're no longer valid. | ||
| 1011 | volatile long sequence_number; | ||
| 1012 | |||
| 1013 | friend class VideoFrame; | ||
| 1014 | friend class AvsCache; | ||
| 1015 | friend class ScriptEnvironment; | ||
| 1016 | volatile long refcount; | ||
| 1017 | |||
| 1018 | // AVS+CUDA extension, does not break plugins if appended here | ||
| 1019 | Device* device; | ||
| 1020 | |||
| 1021 | protected: | ||
| 1022 | VideoFrameBuffer(int size, int margin, Device* device); | ||
| 1023 | VideoFrameBuffer(); | ||
| 1024 | |||
| 1025 | public: | ||
| 1026 | ~VideoFrameBuffer() AVS_BakedCode(AVS_LinkCall_Void(VideoFrameBuffer_DESTRUCTOR)()) | ||
| 1027 | |||
| 1028 | const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() ) | ||
| 1029 | BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() ) | ||
| 1030 | int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() ) | ||
| 1031 | int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() ) | ||
| 1032 | int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() ) | ||
| 1033 | |||
| 1034 | // Ensure VideoFrameBuffer cannot be publicly assigned | ||
| 1035 | private: | ||
| 1036 | VideoFrameBuffer& operator=(const VideoFrameBuffer&); | ||
| 1037 | |||
| 1038 | #ifdef BUILDING_AVSCORE | ||
| 1039 | public: | ||
| 1040 | void DESTRUCTOR(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1041 | #endif | ||
| 1042 | }; // end class VideoFrameBuffer | ||
| 1043 | |||
| 1044 | |||
| 1045 | // smart pointer to VideoFrame | ||
| 1046 | class PVideoFrame { | ||
| 1047 | |||
| 1048 | VideoFrame* p; | ||
| 1049 | |||
| 1050 | void Init(VideoFrame* x); | ||
| 1051 | void Set(VideoFrame* x); | ||
| 1052 | |||
| 1053 | public: | ||
| 1054 | PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)()) | ||
| 1055 | PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x)) | ||
| 1056 | PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x)) | ||
| 1057 | void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x)) | ||
| 1058 | void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x)) | ||
| 1059 | |||
| 1060 | 78322 | VideoFrame* operator->() const { return p; } | |
| 1061 | |||
| 1062 | // for conditional expressions | ||
| 1063 | 114 | operator void*() const { return p; } | |
| 1064 | 2857 | bool operator!() const { return !p; } | |
| 1065 | |||
| 1066 | ~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)()) | ||
| 1067 | #ifdef BUILDING_AVSCORE | ||
| 1068 | public: | ||
| 1069 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1070 | void CONSTRUCTOR1(const PVideoFrame& x); | ||
| 1071 | void CONSTRUCTOR2(VideoFrame* x); | ||
| 1072 | void OPERATOR_ASSIGN0(VideoFrame* x); | ||
| 1073 | void OPERATOR_ASSIGN1(const PVideoFrame& x); | ||
| 1074 | void DESTRUCTOR(); | ||
| 1075 | #endif | ||
| 1076 | }; // end class PVideoFrame | ||
| 1077 | |||
| 1078 | |||
| 1079 | // VideoFrame holds a "window" into a VideoFrameBuffer. Operator new | ||
| 1080 | // is overloaded to recycle class instances. | ||
| 1081 | |||
| 1082 | class VideoFrame { | ||
| 1083 | volatile long refcount; | ||
| 1084 | VideoFrameBuffer* vfb; | ||
| 1085 | |||
| 1086 | // Due to technical reasons these members are not const, but should be treated as such. | ||
| 1087 | // That means do not modify them once the class has been constructed. | ||
| 1088 | int offset; | ||
| 1089 | int pitch, row_size, height; | ||
| 1090 | int offsetU, offsetV; // U&V offsets are from top of picture. | ||
| 1091 | int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane. | ||
| 1092 | // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable) | ||
| 1093 | // the decision on existance of UV is checked by zero pitch | ||
| 1094 | // AVS+ extension, does not break plugins if appended here | ||
| 1095 | int offsetA; | ||
| 1096 | int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none | ||
| 1097 | |||
| 1098 | AVSMap *properties; | ||
| 1099 | |||
| 1100 | // this one is changable by AmendPixelType in rare cases | ||
| 1101 | int pixel_type; // V10 - Copy from VideoInfo | ||
| 1102 | |||
| 1103 | friend class PVideoFrame; | ||
| 1104 | void AddRef(); | ||
| 1105 | void Release(); | ||
| 1106 | |||
| 1107 | friend class ScriptEnvironment; | ||
| 1108 | friend class AvsCache; | ||
| 1109 | |||
| 1110 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _pixel_type); | ||
| 1111 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _pixel_type); | ||
| 1112 | // for Alpha | ||
| 1113 | VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA, int _pixel_type); | ||
| 1114 | void* operator new(size_t size); | ||
| 1115 | // TESTME: OFFSET U/V may be switched to what could be expected from AVI standard! | ||
| 1116 | public: | ||
| 1117 | int GetPitch(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetPitch)(plane) ) | ||
| 1118 | int GetRowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetRowSize)(plane) ) | ||
| 1119 | int GetHeight(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetHeight)(plane) ) | ||
| 1120 | |||
| 1121 | // generally you shouldn't use these three | ||
| 1122 | VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() ) | ||
| 1123 | int GetOffset(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) ) | ||
| 1124 | |||
| 1125 | // in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh! | ||
| 1126 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const; | ||
| 1127 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV) const; | ||
| 1128 | // for Alpha | ||
| 1129 | VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV, int rel_offsetA) const; | ||
| 1130 | |||
| 1131 | const BYTE* GetReadPtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetReadPtr)(plane) ) | ||
| 1132 | bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() ) | ||
| 1133 | BYTE* GetWritePtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) ) | ||
| 1134 | |||
| 1135 | AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0)) | ||
| 1136 | const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0)) | ||
| 1137 | void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties)) | ||
| 1138 | |||
| 1139 | PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)()) | ||
| 1140 | |||
| 1141 | // 0: OK, 1: NG, -1: disabled or non CPU frame | ||
| 1142 | int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)()) | ||
| 1143 | |||
| 1144 | bool IsPropertyWritable() const AVS_BakedCode(return AVS_LinkCall(IsPropertyWritable)()) | ||
| 1145 | |||
| 1146 | ~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() ) | ||
| 1147 | |||
| 1148 | int GetPixelType() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetPixelType)()) | ||
| 1149 | // Changes the color format metadata on this frame. Using it on a frame that isn't writable leads | ||
| 1150 | // to an inconsistent state, because other filters depend on it. So, use MakeWritable() before. | ||
| 1151 | // Only for rare cases where a plugin makes frame bytes pose as another color format. | ||
| 1152 | void AmendPixelType(int new_pixel_type) AVS_BakedCode(return AVS_LinkCall_Void(VideoFrame_AmendPixelType)(new_pixel_type)) | ||
| 1153 | |||
| 1154 | #ifdef BUILDING_AVSCORE | ||
| 1155 | public: | ||
| 1156 | void DESTRUCTOR(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1157 | #endif | ||
| 1158 | |||
| 1159 | // Ensure VideoFrame cannot be publicly assigned | ||
| 1160 | private: | ||
| 1161 | VideoFrame& operator=(const VideoFrame&); | ||
| 1162 | |||
| 1163 | }; // end class VideoFrame | ||
| 1164 | |||
| 1165 | enum CachePolicyHint { | ||
| 1166 | CACHE_25_NOTHING_26_UNUSED_0 = 0, | ||
| 1167 | // Values 0 to 5 are reserved for old 2.5 plugins | ||
| 1168 | // do not use them in new plugins | ||
| 1169 | |||
| 1170 | // New 2.6 explicitly defined cache hints. | ||
| 1171 | CACHE_NOTHING = 10, // Do not cache video. | ||
| 1172 | CACHE_WINDOW = 11, // Hard protect upto X frames within a range of X from the current frame N. | ||
| 1173 | CACHE_GENERIC = 12, // LRU cache upto X frames. | ||
| 1174 | CACHE_FORCE_GENERIC = 13, // LRU cache upto X frames, override any previous CACHE_WINDOW. | ||
| 1175 | |||
| 1176 | CACHE_GET_POLICY = 30, // Get the current policy. | ||
| 1177 | CACHE_GET_WINDOW = 31, // Get the current window h_span. | ||
| 1178 | CACHE_GET_RANGE = 32, // Get the current generic frame range. | ||
| 1179 | |||
| 1180 | // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE | ||
| 1181 | CACHE_AUDIO = 50, // Explicitly cache audio, X byte cache. | ||
| 1182 | CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio. | ||
| 1183 | CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache. | ||
| 1184 | CACHE_AUDIO_AUTO_START_OFF = 52, // synonym | ||
| 1185 | CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache. | ||
| 1186 | CACHE_AUDIO_AUTO_START_ON = 53, // synonym | ||
| 1187 | |||
| 1188 | // These just returns actual value if clip is cached | ||
| 1189 | CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy. | ||
| 1190 | CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size. | ||
| 1191 | |||
| 1192 | CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N. | ||
| 1193 | CACHE_PREFETCH_GO = 101, // n/a Action video prefetches. | ||
| 1194 | |||
| 1195 | CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section). | ||
| 1196 | CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start. | ||
| 1197 | CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start. | ||
| 1198 | CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length. | ||
| 1199 | CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section). | ||
| 1200 | CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches. | ||
| 1201 | |||
| 1202 | CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode. | ||
| 1203 | CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size. | ||
| 1204 | |||
| 1205 | // Filters are queried about their desired audio cache mode. | ||
| 1206 | // Child can answer them with CACHE_AUDIO_xxx | ||
| 1207 | CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode. | ||
| 1208 | CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size. | ||
| 1209 | |||
| 1210 | CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost. | ||
| 1211 | CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only). | ||
| 1212 | CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit). | ||
| 1213 | CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast) | ||
| 1214 | CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time) | ||
| 1215 | CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow) | ||
| 1216 | |||
| 1217 | CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safetyness. | ||
| 1218 | CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default! | ||
| 1219 | CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default! | ||
| 1220 | CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance. | ||
| 1221 | CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded. | ||
| 1222 | |||
| 1223 | CACHE_GETCHILD_ACCESS_COST = 260, // n/a Cache ask Child for preferred access pattern. | ||
| 1224 | CACHE_ACCESS_RAND = 261, // n/a Filter is access order agnostic. | ||
| 1225 | CACHE_ACCESS_SEQ0 = 262, // n/a Filter prefers sequential access (low cost) | ||
| 1226 | CACHE_ACCESS_SEQ1 = 263, // n/a Filter needs sequential access (high cost) | ||
| 1227 | |||
| 1228 | CACHE_AVSPLUS_CONSTANTS = 500, // Smaller values are reserved for classic Avisynth | ||
| 1229 | |||
| 1230 | CACHE_DONT_CACHE_ME, // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request | ||
| 1231 | CACHE_SET_MIN_CAPACITY, | ||
| 1232 | CACHE_SET_MAX_CAPACITY, | ||
| 1233 | CACHE_GET_MIN_CAPACITY, | ||
| 1234 | CACHE_GET_MAX_CAPACITY, | ||
| 1235 | CACHE_GET_SIZE, | ||
| 1236 | CACHE_GET_REQUESTED_CAP, | ||
| 1237 | CACHE_GET_CAPACITY, | ||
| 1238 | CACHE_GET_MTMODE, // Filters specify their desired MT mode, see enum MtMode | ||
| 1239 | |||
| 1240 | // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache | ||
| 1241 | CACHE_IS_CACHE_REQ, | ||
| 1242 | CACHE_IS_CACHE_ANS, | ||
| 1243 | // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard | ||
| 1244 | CACHE_IS_MTGUARD_REQ, | ||
| 1245 | CACHE_IS_MTGUARD_ANS, | ||
| 1246 | |||
| 1247 | // v12 | ||
| 1248 | CACHE_INFORM_NUM_THREADS, // Allows a filter to receive the number of prefetch threads via SetCacheHints | ||
| 1249 | |||
| 1250 | CACHE_AVSPLUS_CUDA_CONSTANTS = 600, | ||
| 1251 | |||
| 1252 | CACHE_GET_DEV_TYPE, // Device types a filter can return | ||
| 1253 | CACHE_GET_CHILD_DEV_TYPE, // Device types a filter can receive | ||
| 1254 | |||
| 1255 | CACHE_USER_CONSTANTS = 1000 // Smaller values are reserved for the core | ||
| 1256 | }; | ||
| 1257 | |||
| 1258 | // Base class for all filters. | ||
| 1259 | class IClip { | ||
| 1260 | friend class PClip; | ||
| 1261 | friend class AVSValue; | ||
| 1262 | volatile long refcnt; | ||
| 1263 | void AddRef(); | ||
| 1264 | #if BUILDING_AVSCORE | ||
| 1265 | public: | ||
| 1266 | #endif | ||
| 1267 | void Release(); | ||
| 1268 | public: | ||
| 1269 | 963 | IClip() : refcnt(0) {} | |
| 1270 | 104 | virtual int __stdcall GetVersion() { return AVISYNTH_INTERFACE_VERSION; } | |
| 1271 | virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) = 0; | ||
| 1272 | virtual bool __stdcall GetParity(int n) = 0; // return field parity if field_based, else parity of first field in frame | ||
| 1273 | virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) = 0; // start and count are in samples | ||
| 1274 | /* Need to check GetVersion first, pre v5 will return random crap from EAX reg. */ | ||
| 1275 | virtual int __stdcall SetCacheHints(int cachehints,int frame_range) = 0 ; // We do not pass cache requests upwards, only to the next filter. | ||
| 1276 | virtual const VideoInfo& __stdcall GetVideoInfo() = 0; | ||
| 1277 | 963 | virtual ~IClip() {} | |
| 1278 | }; // end class IClip | ||
| 1279 | |||
| 1280 | |||
| 1281 | // smart pointer to IClip | ||
| 1282 | class PClip { | ||
| 1283 | |||
| 1284 | IClip* p; | ||
| 1285 | |||
| 1286 | IClip* GetPointerWithAddRef() const; | ||
| 1287 | friend class AVSValue; | ||
| 1288 | friend class VideoFrame; | ||
| 1289 | |||
| 1290 | void Init(IClip* x); | ||
| 1291 | void Set(IClip* x); | ||
| 1292 | |||
| 1293 | public: | ||
| 1294 | PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR0)() ) | ||
| 1295 | PClip(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR1)(x) ) | ||
| 1296 | PClip(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR2)(x) ) | ||
| 1297 | void operator=(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN0)(x) ) | ||
| 1298 | void operator=(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN1)(x) ) | ||
| 1299 | |||
| 1300 | 1925 | IClip* operator->() const { return p; } | |
| 1301 | |||
| 1302 | // useful in conditional expressions | ||
| 1303 | 371 | operator void*() const { return p; } | |
| 1304 | 83 | bool operator!() const { return !p; } | |
| 1305 | |||
| 1306 | ~PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_DESTRUCTOR)() ) | ||
| 1307 | #ifdef BUILDING_AVSCORE | ||
| 1308 | public: | ||
| 1309 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1310 | void CONSTRUCTOR1(const PClip& x); | ||
| 1311 | void CONSTRUCTOR2(IClip* x); | ||
| 1312 | void OPERATOR_ASSIGN0(IClip* x); | ||
| 1313 | void OPERATOR_ASSIGN1(const PClip& x); | ||
| 1314 | void DESTRUCTOR(); | ||
| 1315 | #endif | ||
| 1316 | }; // end class PClip | ||
| 1317 | |||
| 1318 | enum AVSPropTypes { | ||
| 1319 | PROPTYPE_UNSET = 'u', // ptUnset | ||
| 1320 | PROPTYPE_INT = 'i', // ptInt | ||
| 1321 | PROPTYPE_FLOAT = 'f', // ptFloat | ||
| 1322 | PROPTYPE_DATA = 's', // ptData | ||
| 1323 | PROPTYPE_CLIP = 'c', // ptClip | ||
| 1324 | PROPTYPE_FRAME = 'v' // ptFrame | ||
| 1325 | // ptFunction = 'm' | ||
| 1326 | }; | ||
| 1327 | |||
| 1328 | enum AVSGetPropErrors { | ||
| 1329 | GETPROPERROR_SUCCESS = 0, | ||
| 1330 | GETPROPERROR_UNSET = 1, // peUnset | ||
| 1331 | GETPROPERROR_TYPE = 2, // peType | ||
| 1332 | GETPROPERROR_ERROR = 3, // map has error state set | ||
| 1333 | GETPROPERROR_INDEX = 4 // peIndex | ||
| 1334 | }; | ||
| 1335 | |||
| 1336 | enum AVSPropAppendMode { | ||
| 1337 | PROPAPPENDMODE_REPLACE = 0, // paReplace | ||
| 1338 | PROPAPPENDMODE_APPEND = 1, // paAppend | ||
| 1339 | PROPAPPENDMODE_TOUCH = 2 // paTouch | ||
| 1340 | }; | ||
| 1341 | |||
| 1342 | enum AVSPropDataTypeHint { | ||
| 1343 | PROPDATATYPEHINT_UNKNOWN = -1, // dtUnknown = -1, | ||
| 1344 | PROPDATATYPEHINT_BINARY = 0, // dtBinary = 0, | ||
| 1345 | PROPDATATYPEHINT_UTF8 = 1 // dtUtf8 = 1 | ||
| 1346 | }; | ||
| 1347 | |||
| 1348 | class AVSValue { | ||
| 1349 | public: | ||
| 1350 | |||
| 1351 | AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR0)() ) | ||
| 1352 | AVSValue(IClip* c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR1)(c) ) | ||
| 1353 | AVSValue(const PClip& c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR2)(c) ) | ||
| 1354 | AVSValue(bool b) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR3)(b) ) | ||
| 1355 | AVSValue(int i) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR4)(i) ) | ||
| 1356 | AVSValue(float f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR5)(f) ) | ||
| 1357 | AVSValue(double f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR6)(f) ) | ||
| 1358 | AVSValue(const char* s) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR7)(s) ) | ||
| 1359 | AVSValue(const AVSValue* a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(a, size) ) | ||
| 1360 | AVSValue(const AVSValue& a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(&a, size) ) | ||
| 1361 | AVSValue(const AVSValue& v) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR9)(v) ) | ||
| 1362 | AVSValue(const PFunction& n) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR11)(n)) | ||
| 1363 | AVSValue(int64_t l) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR12)(l)) | ||
| 1364 | |||
| 1365 | ~AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_DESTRUCTOR)() ) | ||
| 1366 | AVSValue& operator=(const AVSValue& v) AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_ASSIGN)(v) ) | ||
| 1367 | |||
| 1368 | // Transparently allow 'long' (v11) and 'int' to be treated as 'float'. | ||
| 1369 | // v11: Transparently allow 'long', 'int' and 'float' to be treated as 'double'. | ||
| 1370 | // There are no int<->bool conversions, though. | ||
| 1371 | |||
| 1372 | bool Defined() const AVS_BakedCode( return AVS_LinkCall(Defined)() ) | ||
| 1373 | bool IsClip() const AVS_BakedCode( return AVS_LinkCall(IsClip)() ) | ||
| 1374 | bool IsBool() const AVS_BakedCode( return AVS_LinkCall(IsBool)() ) | ||
| 1375 | bool IsInt() const AVS_BakedCode( return AVS_LinkCall(IsInt)() ) | ||
| 1376 | bool IsLongStrict() const AVS_BakedCode(return AVS_LinkCall(IsLongStrict)()) // v11 | ||
| 1377 | bool IsFloat() const AVS_BakedCode( return AVS_LinkCall(IsFloat)() ) | ||
| 1378 | bool IsFloatfStrict() const AVS_BakedCode( return AVS_LinkCall(IsFloatfStrict)() ) // v11 | ||
| 1379 | bool IsString() const AVS_BakedCode( return AVS_LinkCall(IsString)() ) | ||
| 1380 | bool IsArray() const AVS_BakedCode( return AVS_LinkCall(IsArray)() ) | ||
| 1381 | bool IsFunction() const AVS_BakedCode( return AVS_LinkCall(IsFunction)() ) | ||
| 1382 | |||
| 1383 | PClip AsClip() const AVS_BakedCode( return AVS_LinkCall(AsClip)() ) | ||
| 1384 | bool AsBool() const AVS_BakedCode( return AVS_LinkCall(AsBool1)() ) | ||
| 1385 | int AsInt() const AVS_BakedCode( return AVS_LinkCall(AsInt1)() ) | ||
| 1386 | int64_t AsLong() const AVS_BakedCode(return AVS_LinkCall(AsLong1)()) // v11 | ||
| 1387 | const char* AsString() const AVS_BakedCode( return AVS_LinkCall(AsString1)() ) | ||
| 1388 | double AsFloat() const AVS_BakedCode( return AVS_LinkCall(AsFloat1)() ) | ||
| 1389 | float AsFloatf() const AVS_BakedCode( return float( AVS_LinkCall(AsFloat1)() ) ) | ||
| 1390 | |||
| 1391 | bool AsBool(bool def) const AVS_BakedCode( return AVS_LinkCall(AsBool2)(def) ) | ||
| 1392 | int AsInt(int def) const AVS_BakedCode( return AVS_LinkCall(AsInt2)(def) ) | ||
| 1393 | int64_t AsLong(int64_t def) const AVS_BakedCode( return AVS_LinkCall(AsLong2)(def) ) // v11 | ||
| 1394 | double AsDblDef(double def) const AVS_BakedCode( return AVS_LinkCall(AsDblDef)(def) ) | ||
| 1395 | double AsFloat(float def) const AVS_BakedCode( return AVS_LinkCall(AsFloat2)(def) ) | ||
| 1396 | float AsFloatf(float def) const AVS_BakedCode( return float( AVS_LinkCall(AsFloat2)(def) ) ) | ||
| 1397 | const char* AsString(const char* def) const AVS_BakedCode( return AVS_LinkCall(AsString2)(def) ) | ||
| 1398 | PFunction AsFunction() const; // internal use only | ||
| 1399 | |||
| 1400 | int ArraySize() const AVS_BakedCode( return AVS_LinkCall(ArraySize)() ) | ||
| 1401 | |||
| 1402 | const AVSValue& operator[](int index) const AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_INDEX)(index) ) | ||
| 1403 | |||
| 1404 | private: | ||
| 1405 | |||
| 1406 | short type; // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, fu'n'ction, 'l'ong, 'd'ouble | ||
| 1407 | short array_size; | ||
| 1408 | union { | ||
| 1409 | IClip* clip; | ||
| 1410 | bool boolean; | ||
| 1411 | int integer; | ||
| 1412 | float floating_pt; | ||
| 1413 | const char* string; | ||
| 1414 | const AVSValue* array; | ||
| 1415 | IFunction* function; | ||
| 1416 | #if UINTPTR_MAX >= 0xffffffffffffffff | ||
| 1417 | int64_t longlong; // 8 bytes | ||
| 1418 | double double_pt; // 8 bytes | ||
| 1419 | #else | ||
| 1420 | // 32 bit support trick, pointers dont't break struct size on 32 bit | ||
| 1421 | int64_t* longlong_ptr; | ||
| 1422 | double* double_pt_ptr; | ||
| 1423 | #endif | ||
| 1424 | }; | ||
| 1425 | |||
| 1426 | void Assign(const AVSValue* src, bool init); | ||
| 1427 | |||
| 1428 | public: | ||
| 1429 | AvsValueType GetType() const AVS_BakedCode( return AVS_LinkCallOptDefault(AVSValue_GetType, VALUE_TYPE_UNDEFINED) ) | ||
| 1430 | |||
| 1431 | #ifdef BUILDING_AVSCORE | ||
| 1432 | public: | ||
| 1433 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1434 | void CONSTRUCTOR1(IClip* c); | ||
| 1435 | void CONSTRUCTOR2(const PClip& c); | ||
| 1436 | void CONSTRUCTOR3(bool b); | ||
| 1437 | void CONSTRUCTOR4(int i); | ||
| 1438 | void CONSTRUCTOR5(float f); | ||
| 1439 | void CONSTRUCTOR6(double f); | ||
| 1440 | void CONSTRUCTOR7(const char* s); | ||
| 1441 | void CONSTRUCTOR8(const AVSValue* a, int size); | ||
| 1442 | void CONSTRUCTOR9(const AVSValue& v); | ||
| 1443 | void CONSTRUCTOR11(const PFunction& n); | ||
| 1444 | void CONSTRUCTOR12(int64_t l); | ||
| 1445 | void DESTRUCTOR(); | ||
| 1446 | AVSValue& OPERATOR_ASSIGN(const AVSValue& v); | ||
| 1447 | const AVSValue& OPERATOR_INDEX(int index) const; | ||
| 1448 | |||
| 1449 | bool AsBool1() const; | ||
| 1450 | int AsInt1() const; | ||
| 1451 | const char* AsString1() const; | ||
| 1452 | double AsFloat1() const; // AsDouble1 | ||
| 1453 | int64_t AsLong1() const; // v11 | ||
| 1454 | |||
| 1455 | bool AsBool2(bool def) const; | ||
| 1456 | int AsInt2(int def) const; | ||
| 1457 | double AsFloat2(float def) const; | ||
| 1458 | const char* AsString2(const char* def) const; | ||
| 1459 | int64_t AsLong2(int64_t def) const; // v11 | ||
| 1460 | |||
| 1461 | void MarkArrayAsNonDeepCopy(); // for Avs25 compatibility interface, no deep-copy and deep-free | ||
| 1462 | void CONSTRUCTOR10(const AVSValue& v, bool no_deep_arrays); | ||
| 1463 | AVSValue(const AVSValue& v, bool no_deep_arrays); | ||
| 1464 | void Assign2(const AVSValue* src, bool init, bool no_deep_arrays); | ||
| 1465 | |||
| 1466 | #endif | ||
| 1467 | }; // end class AVSValue | ||
| 1468 | |||
| 1469 | #define AVS_UNUSED(x) (void)(x) | ||
| 1470 | |||
| 1471 | // instantiable null filter | ||
| 1472 | class GenericVideoFilter : public IClip { | ||
| 1473 | protected: | ||
| 1474 | PClip child; | ||
| 1475 | VideoInfo vi; | ||
| 1476 | public: | ||
| 1477 |
2/4✓ Branch 3 → 4 taken 415 times.
✗ Branch 3 → 9 not taken.
✓ Branch 5 → 6 taken 415 times.
✗ Branch 5 → 7 not taken.
|
415 | GenericVideoFilter(PClip _child) : child(_child) { vi = child->GetVideoInfo(); } |
| 1478 | 28 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return child->GetFrame(n, env); } | |
| 1479 | 5 | void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); } | |
| 1480 | 260 | const VideoInfo& __stdcall GetVideoInfo() { return vi; } | |
| 1481 | 5 | bool __stdcall GetParity(int n) { return child->GetParity(n); } | |
| 1482 | 7 | int __stdcall SetCacheHints(int cachehints, int frame_range) { AVS_UNUSED(cachehints); AVS_UNUSED(frame_range); return 0; } // We do not pass cache requests upwards, only to the next filter. | |
| 1483 | }; | ||
| 1484 | |||
| 1485 | |||
| 1486 | class PFunction | ||
| 1487 | { | ||
| 1488 | public: | ||
| 1489 | PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR0)()) | ||
| 1490 | PFunction(IFunction* p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR1)(p)) | ||
| 1491 | PFunction(const PFunction& p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR2)(p)) | ||
| 1492 | PFunction& operator=(IFunction* p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN0)(p)) | ||
| 1493 | PFunction& operator=(const PFunction& p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN1)(p)) | ||
| 1494 | ~PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_DESTRUCTOR)()) | ||
| 1495 | |||
| 1496 | int operator!() const { return !e; } | ||
| 1497 | ✗ | operator void*() const { return e; } | |
| 1498 | ✗ | IFunction* operator->() const { return e; } | |
| 1499 | |||
| 1500 | private: | ||
| 1501 | IFunction * e; | ||
| 1502 | |||
| 1503 | friend class AVSValue; | ||
| 1504 | IFunction * GetPointerWithAddRef() const; | ||
| 1505 | void Init(IFunction* p); | ||
| 1506 | void Set(IFunction* p); | ||
| 1507 | |||
| 1508 | #ifdef BUILDING_AVSCORE | ||
| 1509 | public: | ||
| 1510 | void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */ | ||
| 1511 | void CONSTRUCTOR1(IFunction* p); | ||
| 1512 | void CONSTRUCTOR2(const PFunction& p); | ||
| 1513 | PFunction& OPERATOR_ASSIGN0(IFunction* p); | ||
| 1514 | PFunction& OPERATOR_ASSIGN1(const PFunction& p); | ||
| 1515 | void DESTRUCTOR(); | ||
| 1516 | #endif | ||
| 1517 | }; | ||
| 1518 | |||
| 1519 | |||
| 1520 | #undef CALL_MEMBER_FN | ||
| 1521 | #undef AVS_LinkCallOptDefault | ||
| 1522 | #undef AVS_LinkCallOpt | ||
| 1523 | #undef AVS_LinkCallV | ||
| 1524 | #undef AVS_LinkCall | ||
| 1525 | #undef AVS_BakedCode | ||
| 1526 | |||
| 1527 | |||
| 1528 | #include "avs/cpuid.h" | ||
| 1529 | |||
| 1530 | // IScriptEnvironment GetEnvProperty | ||
| 1531 | enum AvsEnvProperty { | ||
| 1532 | AEP_PHYSICAL_CPUS = 1, | ||
| 1533 | AEP_LOGICAL_CPUS = 2, | ||
| 1534 | AEP_THREADPOOL_THREADS = 3, | ||
| 1535 | AEP_FILTERCHAIN_THREADS = 4, | ||
| 1536 | AEP_THREAD_ID = 5, | ||
| 1537 | AEP_VERSION = 6, | ||
| 1538 | AEP_HOST_SYSTEM_ENDIANNESS = 7, | ||
| 1539 | AEP_INTERFACE_VERSION = 8, | ||
| 1540 | AEP_INTERFACE_BUGFIX = 9, | ||
| 1541 | AEP_CACHESIZE_L2 = 10, | ||
| 1542 | |||
| 1543 | // Neo additionals | ||
| 1544 | AEP_NUM_DEVICES = 901, | ||
| 1545 | AEP_FRAME_ALIGN = 902, | ||
| 1546 | AEP_PLANE_ALIGN = 903, | ||
| 1547 | |||
| 1548 | AEP_SUPPRESS_THREAD = 921, | ||
| 1549 | AEP_GETFRAME_RECURSIVE = 922, | ||
| 1550 | }; | ||
| 1551 | |||
| 1552 | // IScriptEnvironment::Allocate() | ||
| 1553 | enum AvsAllocType { | ||
| 1554 | AVS_NORMAL_ALLOC = 1, | ||
| 1555 | AVS_POOLED_ALLOC = 2 | ||
| 1556 | }; | ||
| 1557 | |||
| 1558 | |||
| 1559 | // Important note (Windows, MSVC): | ||
| 1560 | // When extending IScriptEnvironment, do not declare existing names again | ||
| 1561 | // with different parameters. Methods with the same name will be grouped | ||
| 1562 | // together in the vtable. This results in shifting all vtable method pointers | ||
| 1563 | // after such grouping and breaks all plugins who expect the old order. | ||
| 1564 | // E.g. ApplyMessage will be called instead of GetAVSLinkage. | ||
| 1565 | // As long as the declaration is compatible with COM interop, the order of | ||
| 1566 | // declaration is sequential. But if not, overloads in the same class are grouped | ||
| 1567 | // together in the vtable in the reverse order of declaration. | ||
| 1568 | class IScriptEnvironment { | ||
| 1569 | public: | ||
| 1570 | 2181 | virtual ~IScriptEnvironment() {} | |
| 1571 | |||
| 1572 | virtual /*static*/ int __stdcall GetCPUFlags() = 0; | ||
| 1573 | |||
| 1574 | virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; | ||
| 1575 | virtual char* Sprintf(const char* fmt, ...) = 0; | ||
| 1576 | // note: val is really a va_list; I hope everyone typedefs va_list to a pointer | ||
| 1577 | // 20200305: (void *) changed back to va_list | ||
| 1578 | virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; | ||
| 1579 | |||
| 1580 | #ifdef AVS_WINDOWS | ||
| 1581 | __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; | ||
| 1582 | #else | ||
| 1583 | virtual void ThrowError(const char* fmt, ...) = 0; | ||
| 1584 | #endif | ||
| 1585 | |||
| 1586 | class NotFound /*exception*/ {}; // thrown by Invoke and GetVar | ||
| 1587 | |||
| 1588 | typedef AVSValue (__cdecl *ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env); | ||
| 1589 | |||
| 1590 | virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; | ||
| 1591 | virtual bool __stdcall FunctionExists(const char* name) = 0; | ||
| 1592 | virtual AVSValue __stdcall Invoke(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1593 | |||
| 1594 | virtual AVSValue __stdcall GetVar(const char* name) = 0; | ||
| 1595 | virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; | ||
| 1596 | virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; | ||
| 1597 | |||
| 1598 | virtual void __stdcall PushContext(int level = 0) = 0; | ||
| 1599 | virtual void __stdcall PopContext() = 0; | ||
| 1600 | |||
| 1601 | // note v8: use NewVideoFrameP is possible | ||
| 1602 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0; | ||
| 1603 | |||
| 1604 | virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; | ||
| 1605 | |||
| 1606 | virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; | ||
| 1607 | |||
| 1608 | typedef void (__cdecl *ShutdownFunc)(void* user_data, IScriptEnvironment* env); | ||
| 1609 | virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; | ||
| 1610 | |||
| 1611 | virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0; | ||
| 1612 | |||
| 1613 | virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; | ||
| 1614 | |||
| 1615 | virtual int __stdcall SetMemoryMax(int mem) = 0; | ||
| 1616 | |||
| 1617 | virtual int __stdcall SetWorkingDir(const char * newdir) = 0; | ||
| 1618 | |||
| 1619 | virtual void* __stdcall ManageCache(int key, void* data) = 0; | ||
| 1620 | |||
| 1621 | enum PlanarChromaAlignmentMode { | ||
| 1622 | PlanarChromaAlignmentOff, | ||
| 1623 | PlanarChromaAlignmentOn, | ||
| 1624 | PlanarChromaAlignmentTest | ||
| 1625 | }; | ||
| 1626 | |||
| 1627 | virtual bool __stdcall PlanarChromaAlignment(PlanarChromaAlignmentMode key) = 0; | ||
| 1628 | |||
| 1629 | virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, | ||
| 1630 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; | ||
| 1631 | |||
| 1632 | // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta | ||
| 1633 | virtual void __stdcall DeleteScriptEnvironment() = 0; | ||
| 1634 | |||
| 1635 | virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, | ||
| 1636 | int textcolor, int halocolor, int bgcolor) = 0; | ||
| 1637 | |||
| 1638 | virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; | ||
| 1639 | |||
| 1640 | // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6 | ||
| 1641 | // noThrow version of GetVar | ||
| 1642 | virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; | ||
| 1643 | |||
| 1644 | // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0- | ||
| 1645 | virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, | ||
| 1646 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; | ||
| 1647 | |||
| 1648 | virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; | ||
| 1649 | virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; | ||
| 1650 | virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; | ||
| 1651 | |||
| 1652 | virtual int __stdcall propNumKeys(const AVSMap* map) = 0; | ||
| 1653 | |||
| 1654 | virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; | ||
| 1655 | virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; | ||
| 1656 | virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; | ||
| 1657 | |||
| 1658 | virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1659 | virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1660 | virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1661 | virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1662 | virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1663 | virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1664 | |||
| 1665 | virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; | ||
| 1666 | |||
| 1667 | virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; | ||
| 1668 | virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; | ||
| 1669 | virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; | ||
| 1670 | virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; | ||
| 1671 | virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; | ||
| 1672 | |||
| 1673 | virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; | ||
| 1674 | virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; | ||
| 1675 | virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; | ||
| 1676 | virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; | ||
| 1677 | |||
| 1678 | virtual AVSMap* __stdcall createMap() = 0; | ||
| 1679 | virtual void __stdcall freeMap(AVSMap* map) = 0; | ||
| 1680 | virtual void __stdcall clearMap(AVSMap* map) = 0; | ||
| 1681 | |||
| 1682 | // NewVideoFrame with frame property source. | ||
| 1683 | virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, const PVideoFrame* prop_src, int align = FRAME_ALIGN) = 0; | ||
| 1684 | |||
| 1685 | // Generic query to ask for various system properties | ||
| 1686 | virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; | ||
| 1687 | |||
| 1688 | // Support functions | ||
| 1689 | virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; | ||
| 1690 | virtual void __stdcall Free(void* ptr) = 0; | ||
| 1691 | |||
| 1692 | // these GetVar versions (renamed differently) were moved from IScriptEnvironment2 | ||
| 1693 | |||
| 1694 | // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. | ||
| 1695 | virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool __stdcall GetVar(const char* name, AVSValue* val) const = 0; | ||
| 1696 | // Return the value of the requested variable. | ||
| 1697 | // If the variable was not found or had the wrong type, | ||
| 1698 | // return the supplied default value. | ||
| 1699 | virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; | ||
| 1700 | virtual int __stdcall GetVarInt(const char* name, int def) const = 0; | ||
| 1701 | virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; | ||
| 1702 | virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; | ||
| 1703 | // brand new in v8 - v11: real int64 support | ||
| 1704 | virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; | ||
| 1705 | |||
| 1706 | // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order | ||
| 1707 | // Invoke functions with 'Try' will return false instead of throwing NotFound(). | ||
| 1708 | // ex-IScriptEnvironment2 | ||
| 1709 | virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; | ||
| 1710 | // Since V8 | ||
| 1711 | virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1712 | // Ex-INeo | ||
| 1713 | virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1714 | virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1715 | virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1716 | |||
| 1717 | // V9 | ||
| 1718 | virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0; | ||
| 1719 | |||
| 1720 | // V11 | ||
| 1721 | virtual int __stdcall propGetIntSaturated(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1722 | virtual float __stdcall propGetFloatSaturated(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1723 | virtual int __stdcall propGetDataTypeHint(const AVSMap* map, const char* key, int index, int* error) = 0; // returns AVSPropDataTypeHint | ||
| 1724 | virtual int __stdcall propSetDataH(AVSMap* map, const char* key, const char* d, int length, int type, int append) = 0; | ||
| 1725 | |||
| 1726 | // V12 | ||
| 1727 | // New Global Lock API for cross-plugin synchronization. | ||
| 1728 | // Plugins must ensure these calls are balanced (acquire followed by release), | ||
| 1729 | virtual bool __stdcall AcquireGlobalLock(const char* name) = 0; | ||
| 1730 | virtual void __stdcall ReleaseGlobalLock(const char* name) = 0; | ||
| 1731 | virtual void __stdcall ApplyMessageEx(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, | ||
| 1732 | int textcolor, int halocolor, int bgcolor, bool utf8) = 0; | ||
| 1733 | virtual int64_t __stdcall GetCPUFlagsEx() = 0; | ||
| 1734 | }; // end class IScriptEnvironment. Order is important. Avoid overloads with the same name. | ||
| 1735 | |||
| 1736 | |||
| 1737 | |||
| 1738 | // Multithreading behaviour. IClip SetCacheHints can return them on CACHE_GET_MTMODE query | ||
| 1739 | enum MtMode { | ||
| 1740 | MT_INVALID = 0, | ||
| 1741 | MT_NICE_FILTER = 1, | ||
| 1742 | MT_MULTI_INSTANCE = 2, | ||
| 1743 | MT_SERIALIZED = 3, | ||
| 1744 | MT_SPECIAL_MT = 4, | ||
| 1745 | MT_MODE_COUNT = 5 | ||
| 1746 | }; | ||
| 1747 | |||
| 1748 | class IJobCompletion | ||
| 1749 | { | ||
| 1750 | public: | ||
| 1751 | |||
| 1752 | ✗ | virtual ~IJobCompletion() {} | |
| 1753 | virtual void __stdcall Wait() = 0; | ||
| 1754 | virtual AVSValue __stdcall Get(size_t i) = 0; | ||
| 1755 | virtual size_t __stdcall Size() const = 0; | ||
| 1756 | virtual size_t __stdcall Capacity() const = 0; | ||
| 1757 | virtual void __stdcall Reset() = 0; | ||
| 1758 | virtual void __stdcall Destroy() = 0; | ||
| 1759 | }; | ||
| 1760 | |||
| 1761 | class IScriptEnvironment2; | ||
| 1762 | class IScriptEnvironment_Avs25; | ||
| 1763 | class IScriptEnvironment_AvsPreV11C; | ||
| 1764 | class Prefetcher; | ||
| 1765 | typedef AVSValue (*ThreadWorkerFuncPtr)(IScriptEnvironment2* env, void* data); | ||
| 1766 | |||
| 1767 | |||
| 1768 | /* ----------------------------------------------------------------------------- | ||
| 1769 | Note to plugin authors: The interface in IScriptEnvironment2 is | ||
| 1770 | preliminary / under construction / only for testing / non-final etc.! | ||
| 1771 | As long as you see this note here, IScriptEnvironment2 might still change, | ||
| 1772 | in which case your plugin WILL break. This also means that you are welcome | ||
| 1773 | to test it and give your feedback about any ideas, improvements, or issues | ||
| 1774 | you might have. | ||
| 1775 | ----------------------------------------------------------------------------- */ | ||
| 1776 | class IScriptEnvironment2 : public IScriptEnvironment{ | ||
| 1777 | public: | ||
| 1778 | 2210 | virtual ~IScriptEnvironment2() {} | |
| 1779 | |||
| 1780 | // Plugin functions | ||
| 1781 | virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; | ||
| 1782 | virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0; | ||
| 1783 | virtual void __stdcall ClearAutoloadDirs() = 0; | ||
| 1784 | virtual void __stdcall AutoloadPlugins() = 0; | ||
| 1785 | virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0; | ||
| 1786 | virtual bool __stdcall InternalFunctionExists(const char* name) = 0; | ||
| 1787 | |||
| 1788 | // Threading | ||
| 1789 | virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; // If filter is "DEFAULT_MT_MODE", sets the default MT mode | ||
| 1790 | virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; | ||
| 1791 | virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; | ||
| 1792 | |||
| 1793 | // These lines are needed so that we can overload the older functions from IScriptEnvironment. | ||
| 1794 | using IScriptEnvironment::Invoke; | ||
| 1795 | using IScriptEnvironment::AddFunction; | ||
| 1796 | |||
| 1797 | }; // end class IScriptEnvironment2 | ||
| 1798 | |||
| 1799 | |||
| 1800 | // To allow Avisynth+ add functions to IScriptEnvironment2, | ||
| 1801 | // Neo defines another new interface, INeoEnv. | ||
| 1802 | // INeoEnv and the legacy interfaces (IScriptEnvironment/IScriptEnvironment2) | ||
| 1803 | // share the same ScriptEnvironment instance. The function with the same signature | ||
| 1804 | // is exactly identical and there is no limitation to switch interfaces. | ||
| 1805 | // You can use any interface you like. | ||
| 1806 | // Note to plugin authors : The interface is not stable, see comments in IScriptEnvironment2 | ||
| 1807 | |||
| 1808 | // The order of functions are arbitrary, no need to keep the VMT table compatibility and match | ||
| 1809 | // with the strict IScriptEnvironment order. | ||
| 1810 | class INeoEnv { | ||
| 1811 | public: | ||
| 1812 | 2187 | virtual ~INeoEnv() {} | |
| 1813 | |||
| 1814 | typedef IScriptEnvironment::NotFound NotFound; | ||
| 1815 | typedef IScriptEnvironment::ApplyFunc ApplyFunc; | ||
| 1816 | typedef IScriptEnvironment::ShutdownFunc ShutdownFunc; | ||
| 1817 | |||
| 1818 | virtual void __stdcall DeleteScriptEnvironment() = 0; | ||
| 1819 | |||
| 1820 | virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0; | ||
| 1821 | |||
| 1822 | // Get legacy interface (Avisynth+) | ||
| 1823 | virtual IScriptEnvironment2* __stdcall GetEnv2() = 0; | ||
| 1824 | // Get compatibility interface for AVS CPP 2.5 plugins | ||
| 1825 | virtual IScriptEnvironment_Avs25* __stdcall GetEnv25() = 0; | ||
| 1826 | // Get compatibility interface for older AVS C plugins | ||
| 1827 | virtual IScriptEnvironment_AvsPreV11C* __stdcall GetEnvPreV11C() = 0; | ||
| 1828 | |||
| 1829 | // Generic system to ask for various properties | ||
| 1830 | virtual size_t __stdcall GetEnvProperty(AvsEnvProperty prop) = 0; | ||
| 1831 | virtual int __stdcall GetCPUFlags() = 0; | ||
| 1832 | |||
| 1833 | // Plugin functions | ||
| 1834 | virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0; | ||
| 1835 | virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0; | ||
| 1836 | virtual void __stdcall ClearAutoloadDirs() = 0; | ||
| 1837 | virtual char* __stdcall ListAutoloadDirs() = 0; | ||
| 1838 | virtual void __stdcall AutoloadPlugins() = 0; | ||
| 1839 | |||
| 1840 | virtual void __stdcall AddFunction( | ||
| 1841 | const char* name, const char* params, ApplyFunc apply, void* user_data) = 0; | ||
| 1842 | virtual void __stdcall AddFunction( | ||
| 1843 | const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0; | ||
| 1844 | virtual bool __stdcall FunctionExists(const char* name) = 0; | ||
| 1845 | virtual bool __stdcall InternalFunctionExists(const char* name) = 0; | ||
| 1846 | |||
| 1847 | // Invoke function. Throws NotFound exception when the specified function does not exist. | ||
| 1848 | virtual AVSValue __stdcall Invoke( | ||
| 1849 | const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1850 | virtual AVSValue __stdcall Invoke2( | ||
| 1851 | const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1852 | virtual AVSValue __stdcall Invoke3( | ||
| 1853 | const AVSValue& implicit_last, | ||
| 1854 | const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1855 | |||
| 1856 | // These versions of Invoke will return false instead of throwing NotFound(). | ||
| 1857 | virtual bool __stdcall InvokeTry( | ||
| 1858 | AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0; | ||
| 1859 | virtual bool __stdcall Invoke2Try( | ||
| 1860 | AVSValue* result, const AVSValue& implicit_last, | ||
| 1861 | const char* name, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1862 | virtual bool __stdcall Invoke3Try( | ||
| 1863 | AVSValue* result, const AVSValue& implicit_last, | ||
| 1864 | const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0; | ||
| 1865 | |||
| 1866 | // V9 | ||
| 1867 | virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0; | ||
| 1868 | |||
| 1869 | // Throws exception when the requested variable is not found. | ||
| 1870 | virtual AVSValue __stdcall GetVar(const char* name) = 0; | ||
| 1871 | |||
| 1872 | // noThrow version of GetVar | ||
| 1873 | virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0; | ||
| 1874 | |||
| 1875 | // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'. | ||
| 1876 | virtual bool __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; | ||
| 1877 | |||
| 1878 | // Return the value of the requested variable. | ||
| 1879 | // If the variable was not found or had the wrong type, | ||
| 1880 | // return the supplied default value. | ||
| 1881 | virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0; | ||
| 1882 | virtual int __stdcall GetVarInt(const char* name, int def) const = 0; | ||
| 1883 | virtual double __stdcall GetVarDouble(const char* name, double def) const = 0; | ||
| 1884 | virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0; | ||
| 1885 | virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0; | ||
| 1886 | |||
| 1887 | virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0; | ||
| 1888 | virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0; | ||
| 1889 | |||
| 1890 | // Switch local variables | ||
| 1891 | virtual void __stdcall PushContext(int level = 0) = 0; | ||
| 1892 | virtual void __stdcall PopContext() = 0; | ||
| 1893 | |||
| 1894 | // Global variable frame support | ||
| 1895 | virtual void __stdcall PushContextGlobal() = 0; | ||
| 1896 | virtual void __stdcall PopContextGlobal() = 0; | ||
| 1897 | |||
| 1898 | // Allocate new video frame | ||
| 1899 | // in PNeoEnv: align parameter is no longer supported | ||
| 1900 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi) = 0; // current device is used | ||
| 1901 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device) = 0; | ||
| 1902 | // as above but with property sources | ||
| 1903 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PVideoFrame *prop_src) = 0; // current device is used + frame property source | ||
| 1904 | virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device, const PVideoFrame* prop_src) = 0; // current device is used + frame property source | ||
| 1905 | |||
| 1906 | // Frame related operations | ||
| 1907 | virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0; | ||
| 1908 | virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0; | ||
| 1909 | |||
| 1910 | virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0; | ||
| 1911 | virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, | ||
| 1912 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0; | ||
| 1913 | virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, | ||
| 1914 | int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0; | ||
| 1915 | |||
| 1916 | // frame properties support | ||
| 1917 | virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0; | ||
| 1918 | virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0; | ||
| 1919 | virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0; | ||
| 1920 | |||
| 1921 | virtual int __stdcall propNumKeys(const AVSMap* map) = 0; | ||
| 1922 | virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0; | ||
| 1923 | virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0; | ||
| 1924 | virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0; | ||
| 1925 | |||
| 1926 | virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1927 | virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1928 | virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1929 | virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1930 | virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1931 | virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1932 | |||
| 1933 | virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0; | ||
| 1934 | |||
| 1935 | virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0; | ||
| 1936 | virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0; | ||
| 1937 | virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0; | ||
| 1938 | virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0; | ||
| 1939 | virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0; | ||
| 1940 | |||
| 1941 | virtual const int64_t *__stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0; | ||
| 1942 | virtual const double *__stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0; | ||
| 1943 | virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0; | ||
| 1944 | virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0; | ||
| 1945 | |||
| 1946 | virtual int __stdcall propGetIntSaturated(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1947 | virtual float __stdcall propGetFloatSaturated(const AVSMap* map, const char* key, int index, int* error) = 0; | ||
| 1948 | virtual int __stdcall propGetDataTypeHint(const AVSMap* map, const char* key, int index, int* error) = 0; /* returns AVSPropDataTypeHint */ | ||
| 1949 | virtual int __stdcall propSetDataH(AVSMap* map, const char* key, const char* d, int length, int type, int append) = 0; | ||
| 1950 | |||
| 1951 | virtual AVSMap* __stdcall createMap() = 0; | ||
| 1952 | virtual void __stdcall freeMap(AVSMap* map) = 0; | ||
| 1953 | virtual void __stdcall clearMap(AVSMap* map) = 0; | ||
| 1954 | |||
| 1955 | // Support functions | ||
| 1956 | virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0; | ||
| 1957 | virtual void __stdcall Free(void* ptr) = 0; | ||
| 1958 | |||
| 1959 | virtual bool __stdcall AcquireGlobalLock(const char* name) = 0; | ||
| 1960 | virtual void __stdcall ReleaseGlobalLock(const char* name) = 0; | ||
| 1961 | |||
| 1962 | virtual char* __stdcall SaveString(const char* s, int length = -1) = 0; | ||
| 1963 | virtual char* __stdcall SaveString(const char* s, int length, bool escape) = 0; | ||
| 1964 | virtual char* Sprintf(const char* fmt, ...) = 0; | ||
| 1965 | virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0; | ||
| 1966 | |||
| 1967 | __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0; | ||
| 1968 | |||
| 1969 | virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, | ||
| 1970 | int textcolor, int halocolor, int bgcolor) = 0; | ||
| 1971 | // V12 | ||
| 1972 | virtual void __stdcall ApplyMessageEx(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size, | ||
| 1973 | int textcolor, int halocolor, int bgcolor, bool utf8) = 0; | ||
| 1974 | |||
| 1975 | // Setting | ||
| 1976 | virtual int __stdcall SetMemoryMax(int mem) = 0; | ||
| 1977 | virtual int __stdcall SetMemoryMax(AvsDeviceType type, int index, int mem) = 0; | ||
| 1978 | |||
| 1979 | virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0; | ||
| 1980 | virtual int __stdcall SetWorkingDir(const char * newdir) = 0; | ||
| 1981 | virtual void* __stdcall ManageCache(int key, void* data) = 0; | ||
| 1982 | |||
| 1983 | virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0; | ||
| 1984 | virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0; | ||
| 1985 | |||
| 1986 | // Threading | ||
| 1987 | virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; | ||
| 1988 | virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0; | ||
| 1989 | virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0; | ||
| 1990 | |||
| 1991 | // CUDA Support | ||
| 1992 | virtual PDevice __stdcall GetDevice(AvsDeviceType dev_type, int dev_index) const = 0; | ||
| 1993 | virtual PDevice __stdcall GetDevice() const = 0; // get current device | ||
| 1994 | virtual AvsDeviceType __stdcall GetDeviceType() const = 0; | ||
| 1995 | virtual int __stdcall GetDeviceId() const = 0; | ||
| 1996 | virtual int __stdcall GetDeviceIndex() const = 0; | ||
| 1997 | virtual void* __stdcall GetDeviceStream() const = 0; | ||
| 1998 | virtual void __stdcall DeviceAddCallback(void(*cb)(void*), void* user_data) = 0; | ||
| 1999 | |||
| 2000 | virtual PVideoFrame __stdcall GetFrame(PClip c, int n, const PDevice& device) = 0; | ||
| 2001 | |||
| 2002 | }; | ||
| 2003 | |||
| 2004 | // support interface conversion | ||
| 2005 | struct PNeoEnv { | ||
| 2006 | INeoEnv* p; | ||
| 2007 | PNeoEnv() : p() { } | ||
| 2008 | PNeoEnv(IScriptEnvironment* env) | ||
| 2009 | #if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB) | ||
| 2010 | ; | ||
| 2011 | #else | ||
| 2012 | : p(!AVS_linkage || offsetof(AVS_Linkage, GetNeoEnv) >= (size_t)AVS_linkage->Size ? 0 : AVS_linkage->GetNeoEnv(env)) { } | ||
| 2013 | #endif | ||
| 2014 | |||
| 2015 | int operator!() const { return !p; } | ||
| 2016 | operator void*() const { return p; } | ||
| 2017 | INeoEnv* operator->() const { return p; } | ||
| 2018 | #ifdef BUILDING_AVSCORE | ||
| 2019 | inline operator IScriptEnvironment2*(); | ||
| 2020 | inline operator IScriptEnvironment_Avs25* (); | ||
| 2021 | inline operator IScriptEnvironment_AvsPreV11C* (); | ||
| 2022 | #else | ||
| 2023 | operator IScriptEnvironment2*() { return p->GetEnv2(); } | ||
| 2024 | operator IScriptEnvironment_Avs25* () { return p->GetEnv25(); } | ||
| 2025 | operator IScriptEnvironment_AvsPreV11C* () { return p->GetEnvPreV11C(); } | ||
| 2026 | #endif | ||
| 2027 | }; | ||
| 2028 | |||
| 2029 | |||
| 2030 | // avisynth.dll exports this; it's a way to use it as a library, without | ||
| 2031 | // writing an AVS script or without going through AVIFile. | ||
| 2032 | AVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_INTERFACE_VERSION); | ||
| 2033 | |||
| 2034 | |||
| 2035 | // These are some global variables you can set in your script to change AviSynth's behavior. | ||
| 2036 | #define VARNAME_AllowFloatAudio "OPT_AllowFloatAudio" // Allow WAVE_FORMAT_IEEE_FLOAT audio output | ||
| 2037 | #define VARNAME_VDubPlanarHack "OPT_VDubPlanarHack" // Hack YV16 and YV24 chroma plane order for old VDub's | ||
| 2038 | #define VARNAME_AVIPadScanlines "OPT_AVIPadScanlines" // Have scanlines mod4 padded in all pixel formats | ||
| 2039 | #define VARNAME_UseWaveExtensible "OPT_UseWaveExtensible" // Use WAVEFORMATEXTENSIBLE when describing audio to Windows | ||
| 2040 | #define VARNAME_dwChannelMask "OPT_dwChannelMask" // Integer audio channel mask. See description of WAVEFORMATEXTENSIBLE for more info. | ||
| 2041 | #define VARNAME_Enable_V210 "OPT_Enable_V210" // AVS+ use V210 instead of P210 (VfW) | ||
| 2042 | #define VARNAME_Enable_Y3_10_10 "OPT_Enable_Y3_10_10" // AVS+ use Y3[10][10] instead of P210 (VfW) | ||
| 2043 | #define VARNAME_Enable_Y3_10_16 "OPT_Enable_Y3_10_16" // AVS+ use Y3[10][16] instead of P216 (VfW) | ||
| 2044 | #define VARNAME_Enable_b64a "OPT_Enable_b64a" // AVS+ use b64a instead of BRA[64] (VfW) | ||
| 2045 | #define VARNAME_Enable_PlanarToPackedRGB "OPT_Enable_PlanarToPackedRGB" // AVS+ convert Planar RGB to packed RGB (VfW) | ||
| 2046 | |||
| 2047 | // C exports | ||
| 2048 | #include "avs/capi.h" | ||
| 2049 | AVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION); | ||
| 2050 | |||
| 2051 | #ifndef BUILDING_AVSCORE | ||
| 2052 | #undef AVS_UNUSED | ||
| 2053 | #endif | ||
| 2054 | |||
| 2055 | #pragma pack(pop) | ||
| 2056 | |||
| 2057 | #endif //__AVISYNTH_12_H__ | ||
| 2058 |