-
Notifications
You must be signed in to change notification settings - Fork 1
/
avisynth.h
1907 lines (1546 loc) · 85 KB
/
avisynth.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
// Avisynth v2.6. Copyright 2006 Klaus Post.
// Avisynth v2.6. Copyright 2009 Ian Brabham.
// Avisynth+ project
// 20160613: new 16 bit planar pixel_type constants go live!
// 20160725: pixel_type constants 10-12-14 bit + planar RGB + BRG48/64
// 20161005: Fallback of VideoInfo functions to defaults if no function exists
// 20170117: global variables for VfW output OPT_xxxx
// 20170310: new MT mode: MT_SPECIAL_MT
// 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64)
// 20171207: C++ Standard Conformance (no change for plugin writers)
// 20180525: AVS_UNUSED define to supress parameter not used warnings
// 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h
// 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list
// 20200330: removed __stdcall from variadic argument functions (Sprintf)
// (remove test SIZETMOD define for clarity)
// Integrate Avisynth Neo structures and interface, PFunction, PDevice
// 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment.
// move some former IScriptEnvironment2 functions to IScriptEnvironment:
// GetEnvProperty (system prop), Allocate, Free (buffer pool)
// GetVarTry, GetVarBool/Int/String/Double/Long
// Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try
// Interface Version to 8 (classic 2.6 = 6)
// 20200527 Add IScriptEnvironment_Avs25, used internally
// 20200607 AVS frame property enums to match existing Avisynth enum style
// http://www.avisynth.org
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
// http://www.gnu.org/copyleft/gpl.html .
//
// Linking Avisynth statically or dynamically with other modules is making
// a combined work based on Avisynth. Thus, the terms and conditions of
// the GNU General Public License cover the whole combination.
//
// As a special exception, the copyright holders of Avisynth give you
// permission to link Avisynth with independent modules that communicate
// with Avisynth solely through the interfaces defined in avisynth.h,
// regardless of the license terms of these independent modules, and to
// copy and distribute the resulting combined work under terms of your
// choice, provided that every copy of the combined work is accompanied
// by a complete copy of the source code of Avisynth (the version of
// Avisynth used to produce the combined work), being distributed under
// the terms of the GNU General Public License plus this exception. An
// independent module is a module which is not derived from or based on
// Avisynth, such as 3rd-party filters, import and export plugins, or
// graphical user interfaces.
#ifndef __AVISYNTH_8_H__
#define __AVISYNTH_8_H__
#include "avs/config.h"
#include "avs/capi.h"
#include "avs/types.h"
#ifdef AVS_POSIX
# include "avs/posix.h"
#endif
#if defined(AVS_POSIX)
#define __stdcall
#define __cdecl
#endif
// Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change:
// Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt.
// Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h:
// Use the new frame property features adaptively after querying that at least v8 is supported
// AviSynth property support can be queried (cpp iface example):
// has_at_least_v8 = true;
// try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; }
// and use it:
// if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi);
enum {
AVISYNTH_CLASSIC_INTERFACE_VERSION_25 = 3,
AVISYNTH_CLASSIC_INTERFACE_VERSION_26BETA = 5,
AVISYNTH_CLASSIC_INTERFACE_VERSION = 6,
AVISYNTH_INTERFACE_VERSION = 8
};
/* Compiler-specific crap */
// Tell MSVC to stop precompiling here
#if defined(_MSC_VER) && !defined(__clang__)
#pragma hdrstop
#endif
// Set up debugging macros for MS compilers; for others, step down to the
// standard <assert.h> interface
#ifdef _MSC_VER
#include <crtdbg.h>
#else
#undef _RPT0
#undef _RPT1
#undef _RPT2
#undef _RPT3
#undef _RPT4
#undef _RPT5
#define _RPT0(a,b) ((void)0)
#define _RPT1(a,b,c) ((void)0)
#define _RPT2(a,b,c,d) ((void)0)
#define _RPT3(a,b,c,d,e) ((void)0)
#define _RPT4(a,b,c,d,e,f) ((void)0)
#define _RPT5(a,b,c,d,e,f,g) ((void)0)
#include <cassert>
#undef _ASSERTE
#undef _ASSERT
#define _ASSERTE(x) assert(x)
#define _ASSERT(x) assert(x)
#endif
// I had problems with Premiere wanting 1-byte alignment for its structures,
// so I now set the Avisynth struct alignment explicitly here.
#pragma pack(push,8)
// The VideoInfo struct holds global information about a clip (i.e.
// information that does not depend on the frame number). The GetVideoInfo
// method in IClip returns this struct.
enum {SAMPLE_INT8 = 1<<0,
SAMPLE_INT16 = 1<<1,
SAMPLE_INT24 = 1<<2, // Int24 is a very stupid thing to code, but it's supported by some hardware.
SAMPLE_INT32 = 1<<3,
SAMPLE_FLOAT = 1<<4};
enum {
PLANAR_Y=1<<0,
PLANAR_U=1<<1,
PLANAR_V=1<<2,
PLANAR_ALIGNED=1<<3,
PLANAR_Y_ALIGNED=PLANAR_Y|PLANAR_ALIGNED,
PLANAR_U_ALIGNED=PLANAR_U|PLANAR_ALIGNED,
PLANAR_V_ALIGNED=PLANAR_V|PLANAR_ALIGNED,
PLANAR_A=1<<4,
PLANAR_R=1<<5,
PLANAR_G=1<<6,
PLANAR_B=1<<7,
PLANAR_A_ALIGNED=PLANAR_A|PLANAR_ALIGNED,
PLANAR_R_ALIGNED=PLANAR_R|PLANAR_ALIGNED,
PLANAR_G_ALIGNED=PLANAR_G|PLANAR_ALIGNED,
PLANAR_B_ALIGNED=PLANAR_B|PLANAR_ALIGNED,
};
class AvisynthError /* exception */ {
public:
const char* const msg;
AvisynthError(const char* _msg) : msg(_msg) {}
// Ensure AvisynthError cannot be publicly assigned!
private:
AvisynthError& operator=(const AvisynthError&);
}; // end class AvisynthError
enum AvsDeviceType {
DEV_TYPE_NONE = 0,
DEV_TYPE_CPU = 1,
DEV_TYPE_CUDA = 2,
DEV_TYPE_ANY = 0xFFFF
};
/* Forward references */
#if defined(MSVC)
#define SINGLE_INHERITANCE __single_inheritance
#else
#define SINGLE_INHERITANCE
#endif
struct SINGLE_INHERITANCE VideoInfo;
class SINGLE_INHERITANCE VideoFrameBuffer;
class SINGLE_INHERITANCE VideoFrame;
class IClip;
class SINGLE_INHERITANCE PClip;
class SINGLE_INHERITANCE PVideoFrame;
class IScriptEnvironment;
class SINGLE_INHERITANCE AVSValue;
class INeoEnv;
class IFunction;
class SINGLE_INHERITANCE PFunction;
class Device;
class SINGLE_INHERITANCE PDevice;
class AVSMap;
/*
* Avisynth C++ plugin API code function pointers.
*
* In order to maintain binary compatibility with
* future version do not change the order of the
* existing function pointers. It will be baked
* into all existing plugins.
*
* Add new function pointers to the end of the
* structure. The linkage macros generate some
* protection code to ensure newer plugin do not
* call non-existing functions in an older host.
*/
struct AVS_Linkage {
int Size;
/**********************************************************************/
// struct VideoInfo
bool (VideoInfo::*HasVideo)() const;
bool (VideoInfo::*HasAudio)() const;
bool (VideoInfo::*IsRGB)() const;
bool (VideoInfo::*IsRGB24)() const;
bool (VideoInfo::*IsRGB32)() const;
bool (VideoInfo::*IsYUV)() const;
bool (VideoInfo::*IsYUY2)() const;
bool (VideoInfo::*IsYV24)() const;
bool (VideoInfo::*IsYV16)() const;
bool (VideoInfo::*IsYV12)() const;
bool (VideoInfo::*IsYV411)() const;
bool (VideoInfo::*IsY8)() const;
bool (VideoInfo::*IsColorSpace)(int c_space) const;
bool (VideoInfo::*Is)(int property) const;
bool (VideoInfo::*IsPlanar)() const;
bool (VideoInfo::*IsFieldBased)() const;
bool (VideoInfo::*IsParityKnown)() const;
bool (VideoInfo::*IsBFF)() const;
bool (VideoInfo::*IsTFF)() const;
bool (VideoInfo::*IsVPlaneFirst)() const;
int (VideoInfo::*BytesFromPixels)(int pixels) const;
int (VideoInfo::*RowSize)(int plane) const;
int (VideoInfo::*BMPSize)() const;
int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const;
int (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const;
int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const;
int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const;
int (VideoInfo::*AudioChannels)() const;
int (VideoInfo::*SampleType)() const;
bool (VideoInfo::*IsSampleType)(int testtype) const;
int (VideoInfo::*SamplesPerSecond)() const;
int (VideoInfo::*BytesPerAudioSample)() const;
void (VideoInfo::*SetFieldBased)(bool isfieldbased);
void (VideoInfo::*Set)(int property);
void (VideoInfo::*Clear)(int property);
int (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const;
int (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const;
int (VideoInfo::*BitsPerPixel)() const;
int (VideoInfo::*BytesPerChannelSample)() const;
void (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator);
void (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor);
bool (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const;
// end struct VideoInfo
/**********************************************************************/
// class VideoFrameBuffer
const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const;
BYTE* (VideoFrameBuffer::*VFBGetWritePtr)();
int (VideoFrameBuffer::*GetDataSize)() const;
int (VideoFrameBuffer::*GetSequenceNumber)() const;
int (VideoFrameBuffer::*GetRefcount)() const;
// end class VideoFrameBuffer
/**********************************************************************/
// class VideoFrame
int (VideoFrame::*GetPitch)(int plane) const;
int (VideoFrame::*GetRowSize)(int plane) const;
int (VideoFrame::*GetHeight)(int plane) const;
VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const;
int (VideoFrame::*GetOffset)(int plane) const;
const BYTE* (VideoFrame::*VFGetReadPtr)(int plane) const;
bool (VideoFrame::*IsWritable)() const;
BYTE* (VideoFrame::*VFGetWritePtr)(int plane) const;
void (VideoFrame::*VideoFrame_DESTRUCTOR)();
// end class VideoFrame
/**********************************************************************/
// class IClip
/* nothing */
// end class IClip
/**********************************************************************/
// class PClip
void (PClip::*PClip_CONSTRUCTOR0)();
void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x);
void (PClip::*PClip_CONSTRUCTOR2)(IClip* x);
void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x);
void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x);
void (PClip::*PClip_DESTRUCTOR)();
// end class PClip
/**********************************************************************/
// class PVideoFrame
void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)();
void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x);
void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x);
void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0)(VideoFrame* x);
void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1)(const PVideoFrame& x);
void (PVideoFrame::*PVideoFrame_DESTRUCTOR)();
// end class PVideoFrame
/**********************************************************************/
// class AVSValue
void (AVSValue::*AVSValue_CONSTRUCTOR0)();
void (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c);
void (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c);
void (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b);
void (AVSValue::*AVSValue_CONSTRUCTOR4)(int i);
void (AVSValue::*AVSValue_CONSTRUCTOR5)(float f);
void (AVSValue::*AVSValue_CONSTRUCTOR6)(double f);
void (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s);
void (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int size);
void (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v);
void (AVSValue::*AVSValue_DESTRUCTOR)();
AVSValue& (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v);
const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const;
bool (AVSValue::*Defined)() const;
bool (AVSValue::*IsClip)() const;
bool (AVSValue::*IsBool)() const;
bool (AVSValue::*IsInt)() const;
bool (AVSValue::*IsFloat)() const;
bool (AVSValue::*IsString)() const;
bool (AVSValue::*IsArray)() const;
PClip (AVSValue::*AsClip)() const;
bool (AVSValue::*AsBool1)() const;
int (AVSValue::*AsInt1)() const;
const char* (AVSValue::*AsString1)() const;
double (AVSValue::*AsFloat1)() const;
bool (AVSValue::*AsBool2)(bool def) const;
int (AVSValue::*AsInt2)(int def) const;
double (AVSValue::*AsDblDef)(double def) const;
double (AVSValue::*AsFloat2)(float def) const;
const char* (AVSValue::*AsString2)(const char* def) const;
int (AVSValue::*ArraySize)() const;
// end class AVSValue
/**********************************************************************/
// Reserve pointer space so that we can keep compatibility with Avs "classic" even if it adds functions on its own
void (VideoInfo::*reserved[32])();
/**********************************************************************/
// AviSynth+ additions
int (VideoInfo::*NumComponents)() const;
int (VideoInfo::*ComponentSize)() const;
int (VideoInfo::*BitsPerComponent)() const;
bool (VideoInfo::*Is444)() const;
bool (VideoInfo::*Is422)() const;
bool (VideoInfo::*Is420)() const;
bool (VideoInfo::*IsY)() const;
bool (VideoInfo::*IsRGB48)() const;
bool (VideoInfo::*IsRGB64)() const;
bool (VideoInfo::*IsYUVA)() const;
bool (VideoInfo::*IsPlanarRGB)() const;
bool (VideoInfo::*IsPlanarRGBA)() const;
/**********************************************************************/
// frame property access
AVSMap& (VideoFrame::* getProperties)();
const AVSMap& (VideoFrame::* getConstProperties)();
void (VideoFrame::* setProperties)(const AVSMap& properties);
// PFunction
void (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o);
bool (AVSValue::* IsFunction)() const;
void (PFunction::* PFunction_CONSTRUCTOR0)();
void (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p);
void (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p);
PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other);
PFunction& (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other);
void (PFunction::* PFunction_DESTRUCTOR)();
// end PFunction
// extra VideoFrame functions
int (VideoFrame::* VideoFrame_CheckMemory)() const;
PDevice (VideoFrame::* VideoFrame_GetDevice)() const;
// class PDevice, even if only CPU device
void (PDevice::* PDevice_CONSTRUCTOR0)();
void (PDevice::* PDevice_CONSTRUCTOR1)(Device* p);
void (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p);
PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other);
PDevice& (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other);
void (PDevice::* PDevice_DESTRUCTOR)();
AvsDeviceType (PDevice::* PDevice_GetType)() const;
int (PDevice::* PDevice_GetId)() const;
int (PDevice::* PDevice_GetIndex)() const;
const char* (PDevice::* PDevice_GetName)() const;
// end class PDevice
/**********************************************************************/
// Reserve pointer space for Avisynth+
void (VideoInfo::* reserved2[64 - 23])();
/**********************************************************************/
// AviSynth Neo additions
INeoEnv* (__stdcall *GetNeoEnv)(IScriptEnvironment* env);
// As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place.
/**********************************************************************/
// this part should be identical with AVS_Linkage entries in interface.cpp
};
#ifdef BUILDING_AVSCORE
/* Macro resolution for code inside Avisynth.dll */
# define AVS_BakedCode(arg) ;
# define AVS_LinkCall(arg)
# define AVS_LinkCallV(arg)
# define AVS_LinkCallOpt(arg, argOpt) AVSLinkCall(arg)
# define AVS_LinkCallOptDefault(arg, argDefaultValue) AVSLinkCall(arg())
# define CALL_MEMBER_FN(object,ptrToMember)
#else
/* Macro resolution for code inside user plugin */
# ifdef AVS_LINKAGE_DLLIMPORT
extern __declspec(dllimport) const AVS_Linkage* const AVS_linkage;
# else
extern const AVS_Linkage* AVS_linkage;
# endif
# ifndef offsetof
# include <stddef.h>
# endif
# define AVS_BakedCode(arg) { arg ; }
# define AVS_LinkCall(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? 0 : (this->*(AVS_linkage->arg))
# define AVS_LinkCall_Void(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? (void)0 : (this->*(AVS_linkage->arg))
# define AVS_LinkCallV(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? *this : (this->*(AVS_linkage->arg))
// Helper macros for fallback option when a function does not exists
#define CALL_MEMBER_FN(object,ptrToMember) ((object)->*(ptrToMember))
#define AVS_LinkCallOpt(arg, argOpt) !AVS_linkage ? 0 : \
( offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? \
(offsetof(AVS_Linkage, argOpt) >= AVS_linkage->Size ? 0 : CALL_MEMBER_FN(this, AVS_linkage->argOpt)() ) : \
CALL_MEMBER_FN(this, AVS_linkage->arg)() )
// AVS_LinkCallOptDefault puts automatically () only after arg
# define AVS_LinkCallOptDefault(arg, argDefaultValue) !AVS_linkage || offsetof(AVS_Linkage, arg) >= AVS_linkage->Size ? (argDefaultValue) : ((this->*(AVS_linkage->arg))())
#endif
class PDevice
{
public:
PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)())
PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p))
PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p))
PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p))
PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p))
~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)())
int operator!() const { return !e; }
operator void*() const { return e; }
Device* operator->() const { return e; }
AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE))
int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)())
int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)())
const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)())
private:
Device * e;
#ifdef BUILDING_AVSCORE
public:
void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */
void CONSTRUCTOR1(Device* p);
void CONSTRUCTOR2(const PDevice& p);
PDevice& OPERATOR_ASSIGN0(Device* p);
PDevice& OPERATOR_ASSIGN1(const PDevice& p);
void DESTRUCTOR();
#endif
};
struct VideoInfo {
int width, height; // width=0 means no video
unsigned fps_numerator, fps_denominator;
int num_frames;
// This is more extensible than previous versions. More properties can be added seeminglesly.
// Colorspace properties.
/*
Planar match mask 1111.1000.0000.0111.0000.0111.0000.0111
Planar signature 10xx.1000.0000.00xx.0000.00xx.00xx.00xx ?
Planar signature 10xx.1000.0000.0xxx.0000.00xx.000x.x0xx ? *new
Planar filter mask 1111.1111.1111.1111.1111.1111.1110.0111 (typo from old header fixed)
pixel_type mapping
==================
pixel_type bit-map PIYB.Z000.0???.0SSS.0000.0???.????.????
planar YUV CCC HHH.000u.vWWW
planar RGB(A) CCC AR
nonplanar CCC 000.00wx xyAR
Legend
======
Planar YUV:
Code Bits Remark
W 0-2 Planar Width Subsampling bits
Use (X+1) & 3 for GetPlaneWidthSubsampling
000 => 1 YV12, YV16, YUV420, YUV422
001 => 2 YV411, YUV9
010 => reserved
011 => 0 YV24, YUV444, RGBP
1xx => reserved
v 3 VPlaneFirst YV12, YV16, YV24, YV411, YUV9
u 4 UPlaneFirst I420
H 7-9 Planar Height Subsampling bits
Use ((X>>8)+1) & 3 for GetPlaneHeightSubsampling
000 => 1 YV12, YUV420
001 => 2 YUV9
010 => reserved
011 => 0 YV16, YV24, YV411, YUV422, YUV444, RGBP
1xx => reserved
Planar RGB
Code Bits Remark
R 0 BGR, (with SSS bits for 8/16 bit/sample or float)
A 1 BGRA, (with SSS bits for 8/16 bit/sample or float)
Not Planar, Interleaved (I flag)
Code Bits Remark
R 0 BGR24, and BGRx in future (with SSS bits for 8/16 bit/sample or float)
A 1 BGR32, and BGRAx in future (with SSS bits for 8/16 bit/sample or float)
y 2 YUY2
x 3-4 reserved
w 5 Raw32
General
Code Bits Remark
S 16-18 Sample resolution bits
000 => 8
001 => 16
010 => 32 (float)
011,100 => reserved
101 => 10 bits
110 => 12 bits
111 => 14 bits
for packed RGB(A): only 8 and 16 bits are valid
Other YV12 specific (not used?)
C 20-22 Chroma Placement values 0-4 see CS_xxx_CHROMA_PLACEMENT
Color family and layout
Packed Planar Planar Planar
Code Bits Remark RGB/RGBA YUV YUY2 Y_Grey RGB/RGBA YUVA
R 0 1/0 - 0 - 1/0 -
A 1 0/1 - 0 - 0/1 -
y 2 - - 1 - 0 -
Z 27 YUVA 0 0 0 0 1 1
B 28 BGR 1 0 0 0 1* 0
Y 29 YUV 0 1 1 1 0 0
I 30 Interleaved 1 0 1 1 0 0
P 31 Planar 0 1 0 1 1 1
* Planar RGB plane order: G,B,R(,A)
*/
enum {
CS_YUVA = 1<<27,
CS_BGR = 1<<28,
CS_YUV = 1<<29,
CS_INTERLEAVED = 1<<30,
CS_PLANAR = 1<<31,
CS_Shift_Sub_Width = 0,
CS_Shift_Sub_Height = 8,
CS_Shift_Sample_Bits = 16,
CS_Sub_Width_Mask = 7 << CS_Shift_Sub_Width,
CS_Sub_Width_1 = 3 << CS_Shift_Sub_Width, // YV24
CS_Sub_Width_2 = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16
CS_Sub_Width_4 = 1 << CS_Shift_Sub_Width, // YUV9, YV411
CS_VPlaneFirst = 1 << 3, // YV12, YV16, YV24, YV411, YUV9
CS_UPlaneFirst = 1 << 4, // I420
CS_Sub_Height_Mask = 7 << CS_Shift_Sub_Height,
CS_Sub_Height_1 = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411
CS_Sub_Height_2 = 0 << CS_Shift_Sub_Height, // YV12, I420
CS_Sub_Height_4 = 1 << CS_Shift_Sub_Height, // YUV9
CS_Sample_Bits_Mask = 7 << CS_Shift_Sample_Bits,
CS_Sample_Bits_8 = 0 << CS_Shift_Sample_Bits,
CS_Sample_Bits_10 = 5 << CS_Shift_Sample_Bits,
CS_Sample_Bits_12 = 6 << CS_Shift_Sample_Bits,
CS_Sample_Bits_14 = 7 << CS_Shift_Sample_Bits,
CS_Sample_Bits_16 = 1 << CS_Shift_Sample_Bits,
CS_Sample_Bits_32 = 2 << CS_Shift_Sample_Bits,
CS_PLANAR_MASK = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_YUVA | CS_Sample_Bits_Mask
| CS_Sub_Height_Mask | CS_Sub_Width_Mask,
CS_PLANAR_FILTER = ~( CS_VPlaneFirst | CS_UPlaneFirst ),
CS_RGB_TYPE = 1 << 0,
CS_RGBA_TYPE = 1 << 1,
// Specific colorformats
CS_UNKNOWN = 0,
CS_BGR24 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED,
CS_BGR32 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED,
CS_YUY2 = 1<<2 | CS_YUV | CS_INTERLEAVED,
// CS_YV12 = 1<<3 Reserved
// CS_I420 = 1<<4 Reserved
CS_RAW32 = 1<<5 | CS_INTERLEAVED,
// YV12 must be 0xA000008 2.5 Baked API will see all new planar as YV12
// I420 must be 0xA000010
CS_GENERIC_YUV420 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // 4:2:0 planar
CS_GENERIC_YUV422 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // 4:2:2 planar
CS_GENERIC_YUV444 = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // 4:4:4 planar
CS_GENERIC_Y = CS_PLANAR | CS_INTERLEAVED | CS_YUV, // Y only (4:0:0)
CS_GENERIC_RGBP = CS_PLANAR | CS_BGR | CS_RGB_TYPE, // planar RGB. Though name is RGB but plane order G,B,R
CS_GENERIC_RGBAP = CS_PLANAR | CS_BGR | CS_RGBA_TYPE, // planar RGBA
CS_GENERIC_YUVA420 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // 4:2:0:A planar
CS_GENERIC_YUVA422 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_2, // 4:2:2:A planar
CS_GENERIC_YUVA444 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_1, // 4:4:4:A planar
CS_YV24 = CS_GENERIC_YUV444 | CS_Sample_Bits_8, // YVU 4:4:4 planar
CS_YV16 = CS_GENERIC_YUV422 | CS_Sample_Bits_8, // YVU 4:2:2 planar
CS_YV12 = CS_GENERIC_YUV420 | CS_Sample_Bits_8, // YVU 4:2:0 planar
CS_I420 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Height_2 | CS_Sub_Width_2, // YUV 4:2:0 planar
CS_IYUV = CS_I420,
CS_YUV9 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_4 | CS_Sub_Width_4, // YUV 4:1:0 planar
CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Height_1 | CS_Sub_Width_4, // YUV 4:1:1 planar
CS_Y8 = CS_GENERIC_Y | CS_Sample_Bits_8, // Y 4:0:0 planar
//-------------------------
// AVS16: new planar constants go live! Experimental PF 160613
// 10-12-14 bit + planar RGB + BRG48/64 160725
CS_YUV444P10 = CS_GENERIC_YUV444 | CS_Sample_Bits_10, // YUV 4:4:4 10bit samples
CS_YUV422P10 = CS_GENERIC_YUV422 | CS_Sample_Bits_10, // YUV 4:2:2 10bit samples
CS_YUV420P10 = CS_GENERIC_YUV420 | CS_Sample_Bits_10, // YUV 4:2:0 10bit samples
CS_Y10 = CS_GENERIC_Y | CS_Sample_Bits_10, // Y 4:0:0 10bit samples
CS_YUV444P12 = CS_GENERIC_YUV444 | CS_Sample_Bits_12, // YUV 4:4:4 12bit samples
CS_YUV422P12 = CS_GENERIC_YUV422 | CS_Sample_Bits_12, // YUV 4:2:2 12bit samples
CS_YUV420P12 = CS_GENERIC_YUV420 | CS_Sample_Bits_12, // YUV 4:2:0 12bit samples
CS_Y12 = CS_GENERIC_Y | CS_Sample_Bits_12, // Y 4:0:0 12bit samples
CS_YUV444P14 = CS_GENERIC_YUV444 | CS_Sample_Bits_14, // YUV 4:4:4 14bit samples
CS_YUV422P14 = CS_GENERIC_YUV422 | CS_Sample_Bits_14, // YUV 4:2:2 14bit samples
CS_YUV420P14 = CS_GENERIC_YUV420 | CS_Sample_Bits_14, // YUV 4:2:0 14bit samples
CS_Y14 = CS_GENERIC_Y | CS_Sample_Bits_14, // Y 4:0:0 14bit samples
CS_YUV444P16 = CS_GENERIC_YUV444 | CS_Sample_Bits_16, // YUV 4:4:4 16bit samples
CS_YUV422P16 = CS_GENERIC_YUV422 | CS_Sample_Bits_16, // YUV 4:2:2 16bit samples
CS_YUV420P16 = CS_GENERIC_YUV420 | CS_Sample_Bits_16, // YUV 4:2:0 16bit samples
CS_Y16 = CS_GENERIC_Y | CS_Sample_Bits_16, // Y 4:0:0 16bit samples
// 32 bit samples (float)
CS_YUV444PS = CS_GENERIC_YUV444 | CS_Sample_Bits_32, // YUV 4:4:4 32bit samples
CS_YUV422PS = CS_GENERIC_YUV422 | CS_Sample_Bits_32, // YUV 4:2:2 32bit samples
CS_YUV420PS = CS_GENERIC_YUV420 | CS_Sample_Bits_32, // YUV 4:2:0 32bit samples
CS_Y32 = CS_GENERIC_Y | CS_Sample_Bits_32, // Y 4:0:0 32bit samples
// RGB packed
CS_BGR48 = CS_RGB_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 3x16 bit
CS_BGR64 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 4x16 bit
// no packed 32 bit (float) support for these legacy types
// RGB planar
CS_RGBP = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples
CS_RGBP8 = CS_GENERIC_RGBP | CS_Sample_Bits_8, // Planar RGB 8 bit samples
CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples
CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples
CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples
CS_RGBP16 = CS_GENERIC_RGBP | CS_Sample_Bits_16, // Planar RGB 16bit samples
CS_RGBPS = CS_GENERIC_RGBP | CS_Sample_Bits_32, // Planar RGB 32bit samples
// RGBA planar
CS_RGBAP = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples
CS_RGBAP8 = CS_GENERIC_RGBAP | CS_Sample_Bits_8, // Planar RGBA 8 bit samples
CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples
CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples
CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples
CS_RGBAP16 = CS_GENERIC_RGBAP | CS_Sample_Bits_16, // Planar RGBA 16bit samples
CS_RGBAPS = CS_GENERIC_RGBAP | CS_Sample_Bits_32, // Planar RGBA 32bit samples
// Planar YUVA
CS_YUVA444 = CS_GENERIC_YUVA444 | CS_Sample_Bits_8, // YUVA 4:4:4 8bit samples
CS_YUVA422 = CS_GENERIC_YUVA422 | CS_Sample_Bits_8, // YUVA 4:2:2 8bit samples
CS_YUVA420 = CS_GENERIC_YUVA420 | CS_Sample_Bits_8, // YUVA 4:2:0 8bit samples
CS_YUVA444P10 = CS_GENERIC_YUVA444 | CS_Sample_Bits_10, // YUVA 4:4:4 10bit samples
CS_YUVA422P10 = CS_GENERIC_YUVA422 | CS_Sample_Bits_10, // YUVA 4:2:2 10bit samples
CS_YUVA420P10 = CS_GENERIC_YUVA420 | CS_Sample_Bits_10, // YUVA 4:2:0 10bit samples
CS_YUVA444P12 = CS_GENERIC_YUVA444 | CS_Sample_Bits_12, // YUVA 4:4:4 12bit samples
CS_YUVA422P12 = CS_GENERIC_YUVA422 | CS_Sample_Bits_12, // YUVA 4:2:2 12bit samples
CS_YUVA420P12 = CS_GENERIC_YUVA420 | CS_Sample_Bits_12, // YUVA 4:2:0 12bit samples
CS_YUVA444P14 = CS_GENERIC_YUVA444 | CS_Sample_Bits_14, // YUVA 4:4:4 14bit samples
CS_YUVA422P14 = CS_GENERIC_YUVA422 | CS_Sample_Bits_14, // YUVA 4:2:2 14bit samples
CS_YUVA420P14 = CS_GENERIC_YUVA420 | CS_Sample_Bits_14, // YUVA 4:2:0 14bit samples
CS_YUVA444P16 = CS_GENERIC_YUVA444 | CS_Sample_Bits_16, // YUVA 4:4:4 16bit samples
CS_YUVA422P16 = CS_GENERIC_YUVA422 | CS_Sample_Bits_16, // YUVA 4:2:2 16bit samples
CS_YUVA420P16 = CS_GENERIC_YUVA420 | CS_Sample_Bits_16, // YUVA 4:2:0 16bit samples
CS_YUVA444PS = CS_GENERIC_YUVA444 | CS_Sample_Bits_32, // YUVA 4:4:4 32bit samples
CS_YUVA422PS = CS_GENERIC_YUVA422 | CS_Sample_Bits_32, // YUVA 4:2:2 32bit samples
CS_YUVA420PS = CS_GENERIC_YUVA420 | CS_Sample_Bits_32, // YUVA 4:2:0 32bit samples
};
int pixel_type; // changed to int as of 2.5
int audio_samples_per_second; // 0 means no audio
int sample_type; // as of 2.5
int64_t num_audio_samples; // changed as of 2.5
int nchannels; // as of 2.5
// Imagetype properties
int image_type;
enum {
IT_BFF = 1<<0,
IT_TFF = 1<<1,
IT_FIELDBASED = 1<<2
};
// Chroma placement bits 20 -> 23 ::FIXME:: Really want a Class to support this
enum {
CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,
CS_MPEG1_CHROMA_PLACEMENT = 1 << 20,
CS_MPEG2_CHROMA_PLACEMENT = 2 << 20,
CS_YUY2_CHROMA_PLACEMENT = 3 << 20,
CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20
};
// useful functions of the above
bool HasVideo() const AVS_BakedCode(return AVS_LinkCall(HasVideo)())
bool HasAudio() const AVS_BakedCode(return AVS_LinkCall(HasAudio)())
bool IsRGB() const AVS_BakedCode(return AVS_LinkCall(IsRGB)())
bool IsRGB24() const AVS_BakedCode(return AVS_LinkCall(IsRGB24)())
bool IsRGB32() const AVS_BakedCode(return AVS_LinkCall(IsRGB32)())
bool IsYUV() const AVS_BakedCode(return AVS_LinkCall(IsYUV)())
bool IsYUY2() const AVS_BakedCode(return AVS_LinkCall(IsYUY2)())
bool IsYV24() const AVS_BakedCode(return AVS_LinkCall(IsYV24)())
bool IsYV16() const AVS_BakedCode(return AVS_LinkCall(IsYV16)())
bool IsYV12() const AVS_BakedCode(return AVS_LinkCall(IsYV12)())
bool IsYV411() const AVS_BakedCode(return AVS_LinkCall(IsYV411)())
//bool IsYUV9() const;
bool IsY8() const AVS_BakedCode(return AVS_LinkCall(IsY8)())
bool IsColorSpace(int c_space) const AVS_BakedCode(return AVS_LinkCall(IsColorSpace)(c_space))
bool Is(int property) const AVS_BakedCode(return AVS_LinkCall(Is)(property))
bool IsPlanar() const AVS_BakedCode(return AVS_LinkCall(IsPlanar)())
bool IsFieldBased() const AVS_BakedCode(return AVS_LinkCall(IsFieldBased)())
bool IsParityKnown() const AVS_BakedCode(return AVS_LinkCall(IsParityKnown)())
bool IsBFF() const AVS_BakedCode(return AVS_LinkCall(IsBFF)())
bool IsTFF() const AVS_BakedCode(return AVS_LinkCall(IsTFF)())
bool IsVPlaneFirst() const AVS_BakedCode(return AVS_LinkCall(IsVPlaneFirst)()) // Don't use this
// Will not work on planar images, but will return only luma planes
int BytesFromPixels(int pixels) const AVS_BakedCode(return AVS_LinkCall(BytesFromPixels)(pixels))
int RowSize(int plane = 0) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane))
int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)())
int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames))
int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples))
int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes))
int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples))
int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)())
int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)())
bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype))
int SamplesPerSecond() const AVS_BakedCode(return AVS_LinkCall(SamplesPerSecond)())
int BytesPerAudioSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerAudioSample)())
void SetFieldBased(bool isfieldbased) AVS_BakedCode(AVS_LinkCall_Void(SetFieldBased)(isfieldbased))
void Set(int property) AVS_BakedCode(AVS_LinkCall_Void(Set)(property))
void Clear(int property) AVS_BakedCode(AVS_LinkCall_Void(Clear)(property))
// Subsampling in bitshifts!
int GetPlaneWidthSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneWidthSubsampling)(plane))
int GetPlaneHeightSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneHeightSubsampling)(plane))
int BitsPerPixel() const AVS_BakedCode(return AVS_LinkCall(BitsPerPixel)())
int BytesPerChannelSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerChannelSample)())
// useful mutator
void SetFPS(unsigned numerator, unsigned denominator) AVS_BakedCode(AVS_LinkCall_Void(SetFPS)(numerator, denominator))
// Range protected multiply-divide of FPS
void MulDivFPS(unsigned multiplier, unsigned divisor) AVS_BakedCode(AVS_LinkCall_Void(MulDivFPS)(multiplier, divisor))
// Test for same colorspace
bool IsSameColorspace(const VideoInfo& vi) const AVS_BakedCode(return AVS_LinkCall(IsSameColorspace)(vi))
// AVS+ extensions
// 20161005:
// Mapping of AVS+ extensions to classic 2.6 functions.
// In order to use these extended AVS+ functions for plugins that should work
// either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an
// automatic fallback mechanism.
// From AVS+'s point of view these are not "baked" codes, the primary functions should exist.
// Examples:
// Is444() is mapped to IsYV24() for classic AVS2.6
// ComponentSize() returns constant 1 (1 bytes per pixel component)
// BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only)
// Returns the number of color channels or planes in a frame
int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) )
// Returns the size in bytes of a single component of a pixel
int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1))
// Returns the bit depth of a single component of a pixel
int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8))
// like IsYV24, but bit-depth independent also for YUVA
bool Is444() const AVS_BakedCode(return AVS_LinkCallOpt(Is444, IsYV24) )
// like IsYV16, but bit-depth independent also for YUVA
bool Is422() const AVS_BakedCode(return AVS_LinkCallOpt(Is422, IsYV16) )
// like IsYV12, but bit-depth independent also for YUVA
bool Is420() const AVS_BakedCode( return AVS_LinkCallOpt(Is420, IsYV12) )
// like IsY8, but bit-depth independent
bool IsY() const AVS_BakedCode( return AVS_LinkCallOpt(IsY, IsY8) )
// like IsRGB24 for 16 bit samples
bool IsRGB48() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB48, false) )
// like IsRGB32 for 16 bit samples
bool IsRGB64() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB64, false) )
// YUVA?
bool IsYUVA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsYUVA, false) )
// Planar RGB?
bool IsPlanarRGB() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGB, false) )
// Planar RGBA?
bool IsPlanarRGBA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGBA, false) )
}; // end struct VideoInfo
// VideoFrameBuffer holds information about a memory block which is used
// for video data. For efficiency, instances of this class are not deleted
// when the refcount reaches zero; instead they're stored in a linked list
// to be reused. The instances are deleted when the corresponding AVS
// file is closed.
class VideoFrameBuffer {
BYTE* data;
int data_size;
// sequence_number is incremented every time the buffer is changed, so
// that stale views can tell they're no longer valid.
volatile long sequence_number;
friend class VideoFrame;
friend class Cache;
friend class ScriptEnvironment;
volatile long refcount;
// AVS+CUDA extension, does not break plugins if appended here
Device* device;
protected:
VideoFrameBuffer(int size, int margin, Device* device);
VideoFrameBuffer();
~VideoFrameBuffer();
public:
const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() )
BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() )
int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() )
int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() )
int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() )
// Ensure VideoFrameBuffer cannot be publicly assigned
private:
VideoFrameBuffer& operator=(const VideoFrameBuffer&);
}; // end class VideoFrameBuffer
// smart pointer to VideoFrame
class PVideoFrame {
VideoFrame* p;
void Init(VideoFrame* x);
void Set(VideoFrame* x);
public:
PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)())
PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x))
PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x))
void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x))
void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x))
VideoFrame* operator->() const { return p; }
// for conditional expressions
operator void*() const { return p; }
bool operator!() const { return !p; }
~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)())
#ifdef BUILDING_AVSCORE
public:
void CONSTRUCTOR0(); /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */
void CONSTRUCTOR1(const PVideoFrame& x);
void CONSTRUCTOR2(VideoFrame* x);
void OPERATOR_ASSIGN0(VideoFrame* x);
void OPERATOR_ASSIGN1(const PVideoFrame& x);
void DESTRUCTOR();
#endif
}; // end class PVideoFrame
// VideoFrame holds a "window" into a VideoFrameBuffer. Operator new
// is overloaded to recycle class instances.
class VideoFrame {
volatile long refcount;
VideoFrameBuffer* vfb;
// Due to technical reasons these members are not const, but should be treated as such.
// That means do not modify them once the class has been constructed.
int offset;
int pitch, row_size, height;
int offsetU, offsetV; // U&V offsets are from top of picture.
int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.
// for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)
// the decision on existance of UV is checked by zero pitch
// AVS+ extension, does not break plugins if appended here
int offsetA;
int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none
AVSMap *properties;
friend class PVideoFrame;
void AddRef();
void Release();
friend class ScriptEnvironment;
friend class Cache;
VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height);
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);
// for Alpha
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);
void* operator new(size_t size);
// TESTME: OFFSET U/V may be switched to what could be expected from AVI standard!
public:
int GetPitch(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetPitch)(plane) )
int GetRowSize(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetRowSize)(plane) )
int GetHeight(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetHeight)(plane) )
// generally you shouldn't use these three
VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() )
int GetOffset(int plane=0) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) )
// in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh!
VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const;
VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV) const;
// for Alpha
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;
const BYTE* GetReadPtr(int plane=0) const AVS_BakedCode( return AVS_LinkCall(VFGetReadPtr)(plane) )
bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() )
BYTE* GetWritePtr(int plane=0) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) )
AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0))
const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0))
void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties))
PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)())
// 0: OK, 1: NG, -1: disabled or non CPU frame
int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)())
~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() )
#ifdef BUILDING_AVSCORE
public: