GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 72.8% 383 / 0 / 526
Functions: 71.7% 157 / 0 / 219
Branches: 57.2% 338 / 0 / 591

core/interface.cpp
Line Branch Exec Source
1 // Avisynth v2.5. Copyright 2002, 2005 Ben Rudiak-Gould et al.
2 // Avisynth v2.6. Copyright 2006 Klaus Post.
3 // Avisynth v2.6. Copyright 2009 Ian Brabham.
4 // http://avisynth.nl
5
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
19 // http://www.gnu.org/copyleft/gpl.html .
20 //
21 // Linking Avisynth statically or dynamically with other modules is making a
22 // combined work based on Avisynth. Thus, the terms and conditions of the GNU
23 // General Public License cover the whole combination.
24 //
25 // As a special exception, the copyright holders of Avisynth give you
26 // permission to link Avisynth with independent modules that communicate with
27 // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
28 // terms of these independent modules, and to copy and distribute the
29 // resulting combined work under terms of your choice, provided that
30 // every copy of the combined work is accompanied by a complete copy of
31 // the source code of Avisynth (the version of Avisynth used to produce the
32 // combined work), being distributed under the terms of the GNU General
33 // Public License plus this exception. An independent module is a module
34 // which is not derived from or based on Avisynth, such as 3rd-party filters,
35 // import and export plugins, or graphical user interfaces.
36
37
38 /* Maintenance notes :-
39 *
40 * All the code here was formally baked into the avisynth.h interface.
41 *
42 * Whenever you modify any code here please keep and mark the original
43 * code with a block comment beginning with the word "Baked"
44 *
45 * Be mindful with changes you do make that previous 2.5 plugins will
46 * still have the original code active. This may require other defensive
47 * or mitigating code elsewhere.
48 */
49
50 #include <avisynth.h>
51
52 #ifdef AVS_WINDOWS
53 #include <avs/win.h>
54 #else
55 #include <avs/posix.h>
56 #endif
57 #include "InternalEnvironment.h"
58 #include "DeviceManager.h"
59 #include "AVSMap.h"
60 #include "function.h"
61 #include "assert.h"
62
63 /**********************************************************************/
64
65 // struct VideoInfo
66
67 // useful functions of the above
68 11 bool VideoInfo::HasVideo() const { return (width!=0); }
69 129 bool VideoInfo::HasAudio() const { return (audio_samples_per_second!=0); }
70 720 bool VideoInfo::IsRGB() const { return !!(pixel_type&CS_BGR); }
71
4/4
✓ Branch 2 → 3 taken 48 times.
✓ Branch 2 → 5 taken 57 times.
✓ Branch 3 → 4 taken 26 times.
✓ Branch 3 → 5 taken 22 times.
105 bool VideoInfo::IsRGB24() const { return ((pixel_type & CS_BGR24) == CS_BGR24) && ((pixel_type & CS_Sample_Bits_Mask) == CS_Sample_Bits_8); } // Clear out additional properties
72
4/4
✓ Branch 2 → 3 taken 30 times.
✓ Branch 2 → 5 taken 111 times.
✓ Branch 3 → 4 taken 23 times.
✓ Branch 3 → 5 taken 7 times.
141 bool VideoInfo::IsRGB32() const { return ((pixel_type & CS_BGR32) == CS_BGR32) && ((pixel_type & CS_Sample_Bits_Mask) == CS_Sample_Bits_8); }
73 2053 bool VideoInfo::IsYUV() const { return !!(pixel_type&CS_YUV ); }
74 3116 bool VideoInfo::IsYUY2() const { return (pixel_type & CS_YUY2) == CS_YUY2; }
75
76 bool VideoInfo::IsYV24() const { return (pixel_type & CS_PLANAR_MASK) == (CS_YV24 & CS_PLANAR_FILTER); }
77 bool VideoInfo::IsYV16() const { return (pixel_type & CS_PLANAR_MASK) == (CS_YV16 & CS_PLANAR_FILTER); }
78 11 bool VideoInfo::IsYV12() const { return (pixel_type & CS_PLANAR_MASK) == (CS_YV12 & CS_PLANAR_FILTER); }
79 5 bool VideoInfo::IsY8() const { return (pixel_type & CS_PLANAR_MASK) == (CS_Y8 & CS_PLANAR_FILTER); }
80
81 9151 bool VideoInfo::IsYV411() const { return (pixel_type & CS_PLANAR_MASK) == (CS_YV411 & CS_PLANAR_FILTER); }
82 //bool VideoInfo::IsYUV9() const { return (pixel_type & CS_PLANAR_MASK) == (CS_YUV9 & CS_PLANAR_FILTER); }
83
84 /* Baked ********************
85 bool VideoInfo::IsColorSpace(int c_space) const { return ((pixel_type & c_space) == c_space); }
86 Baked ********************/
87 bool VideoInfo::IsColorSpace(int c_space) const {
88 // This function will check if the colorspace (VideoInfo.pixel_type) is the same as given c_space (or more general it checks for a Colorspace property (see avisynth.h)).
89 // So it's not only for exact colorspace comparison but checking properties also.
90 return IsPlanar() ? ((pixel_type & CS_PLANAR_MASK) == (c_space & CS_PLANAR_FILTER)) :
91 // support exact individual flag checking
92 c_space == CS_YUVA ? ((c_space & CS_YUVA) == CS_YUVA) :
93 c_space == CS_BGR ? ((c_space & CS_BGR) == CS_BGR) :
94 c_space == CS_YUV ? ((c_space & CS_YUV) == CS_YUV) :
95 c_space == CS_INTERLEAVED ? ((c_space & CS_INTERLEAVED) == CS_INTERLEAVED) :
96 // RGB got sample bits:
97 // In order to work: RGB64.IsColorSpace(RGB32) => false, or else we get true (RGB64 & RGB32 == RGB32)
98 // Simple ((pixel_type & c_space) == c_space) would not work, does not take into account bit depth
99 ( ((pixel_type & ~CS_Sample_Bits_Mask & c_space) == (c_space & ~CS_Sample_Bits_Mask)) &&
100 ((pixel_type & CS_Sample_Bits_Mask) == (c_space & CS_Sample_Bits_Mask)) );
101 }
102
103 bool VideoInfo::Is(int property) const { return ((image_type & property)==property ); }
104 6607 bool VideoInfo::IsPlanar() const { return !!(pixel_type & CS_PLANAR); }
105 61 bool VideoInfo::IsFieldBased() const { return !!(image_type & IT_FIELDBASED); }
106 bool VideoInfo::IsParityKnown() const { return ((image_type & IT_FIELDBASED)&&(image_type & (IT_BFF|IT_TFF))); }
107 4 bool VideoInfo::IsBFF() const { return !!(image_type & IT_BFF); }
108 4 bool VideoInfo::IsTFF() const { return !!(image_type & IT_TFF); }
109
110 /* Baked ********************
111 bool VideoInfo::IsVPlaneFirst() const {return ((pixel_type & CS_YV12) == CS_YV12); } // Don't use this
112 int VideoInfo::BytesFromPixels(int pixels) const { return pixels * (BitsPerPixel()>>3); } // Will not work on planar images, but will return only luma planes
113 int VideoInfo::RowSize() const { return BytesFromPixels(width); } // Also only returns first plane on planar images
114 int VideoInfo::BMPSize() const { if (IsPlanar()) {int p = height * ((RowSize()+3) & ~3); p+=p>>1; return p; } return height * ((RowSize()+3) & ~3); }
115 int64_t VideoInfo::AudioSamplesFromFrames(int64_t frames) const { return (fps_numerator && HasVideo()) ? ((int64_t)(frames) * audio_samples_per_second * fps_denominator / fps_numerator) : 0; }
116 Baked ********************/
117
2/4
✓ Branch 2 → 3 taken 1 time.
✗ Branch 2 → 6 not taken.
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 1 time.
1 int64_t VideoInfo::AudioSamplesFromFrames(int frames) const { return (fps_numerator && HasVideo()) ? ((int64_t)(frames) * audio_samples_per_second * fps_denominator / fps_numerator) : 0; }
118
2/4
✓ Branch 2 → 3 taken 4 times.
✗ Branch 2 → 6 not taken.
✓ Branch 4 → 5 taken 4 times.
✗ Branch 4 → 6 not taken.
4 int VideoInfo::FramesFromAudioSamples(int64_t samples) const { return (fps_denominator && HasAudio()) ? (int)((samples * fps_numerator)/((int64_t)fps_denominator * audio_samples_per_second)) : 0; }
119
1/2
✓ Branch 3 → 4 taken 3 times.
✗ Branch 3 → 6 not taken.
3 int64_t VideoInfo::AudioSamplesFromBytes(int64_t bytes) const { return HasAudio() ? bytes / BytesPerAudioSample() : 0; }
120 248 int64_t VideoInfo::BytesFromAudioSamples(int64_t samples) const { return samples * BytesPerAudioSample(); }
121
2/2
✓ Branch 3 → 4 taken 45 times.
✓ Branch 3 → 5 taken 1 time.
46 int VideoInfo::AudioChannels() const { return HasAudio() ? nchannels : 0; }
122 54 int VideoInfo::SampleType() const{ return sample_type;}
123 14 bool VideoInfo::IsSampleType(int testtype) const{ return !!(sample_type&testtype);}
124 12 int VideoInfo::SamplesPerSecond() const { return audio_samples_per_second; }
125 299 int VideoInfo::BytesPerAudioSample() const { return nchannels*BytesPerChannelSample();}
126
2/2
✓ Branch 2 → 3 taken 9 times.
✓ Branch 2 → 4 taken 5 times.
14 void VideoInfo::SetFieldBased(bool isfieldbased) { if (isfieldbased) image_type|=IT_FIELDBASED; else image_type&=~IT_FIELDBASED; }
127 9 void VideoInfo::Set(int property) { image_type|=property; }
128 9 void VideoInfo::Clear(int property) { image_type&=~property; }
129
130 /* Baked ********************
131 int VideoInfo::BitsPerPixel() const {
132 switch (pixel_type) {
133 case CS_BGR24:
134 return 24;
135 case CS_BGR32:
136 return 32;
137 case CS_YUY2:
138 return 16;
139 case CS_YV12:
140 case CS_I420:
141 return 12;
142 default:
143 return 0;
144 }
145 }
146 Baked ********************/
147
148 307 int VideoInfo::BytesPerChannelSample() const {
149
3/6
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 100 times.
✗ Branch 2 → 5 not taken.
✗ Branch 2 → 6 not taken.
✓ Branch 2 → 7 taken 202 times.
✓ Branch 2 → 8 taken 5 times.
307 switch (sample_type) {
150 case SAMPLE_INT8:
151 return sizeof(unsigned char);
152 100 case SAMPLE_INT16:
153 100 return sizeof(signed short);
154 case SAMPLE_INT24:
155 return 3;
156 case SAMPLE_INT32:
157 return sizeof(signed int);
158 202 case SAMPLE_FLOAT:
159 202 return sizeof(SFLOAT);
160 5 default:
161 _ASSERTE("Audio sample type not recognized!");
162 5 return 0;
163 }
164 }
165
166 580 bool VideoInfo::IsVPlaneFirst() const {
167
4/6
✓ Branch 3 → 4 taken 580 times.
✗ Branch 3 → 8 not taken.
✓ Branch 5 → 6 taken 580 times.
✗ Branch 5 → 8 not taken.
✓ Branch 6 → 7 taken 489 times.
✓ Branch 6 → 8 taken 91 times.
580 return (NumComponents() > 1) && IsPlanar() && (pixel_type & (CS_VPlaneFirst | CS_UPlaneFirst)) == CS_VPlaneFirst; // Shouldn't use this
168 }
169
170 1482 int VideoInfo::BytesFromPixels(int pixels) const {
171 1482 const int componentSizes[8] = {1,2,4,0,0,2,2,2};
172
6/8
✓ Branch 2 → 3 taken 1482 times.
✗ Branch 2 → 12 not taken.
✓ Branch 3 → 4 taken 1372 times.
✓ Branch 3 → 7 taken 110 times.
✓ Branch 5 → 6 taken 1191 times.
✓ Branch 5 → 7 taken 181 times.
✓ Branch 7 → 8 taken 291 times.
✗ Branch 7 → 12 not taken.
2964 return (NumComponents() > 1) && IsPlanar() ? pixels * componentSizes[(pixel_type>>CS_Shift_Sample_Bits) & 7] : pixels * (BitsPerPixel()>>3);
173 // For planar images, will return luma plane
174 }
175
176 1427 int VideoInfo::RowSize(int plane) const {
177 1427 const int rowsize = BytesFromPixels(width);
178
3/8
✓ Branch 3 → 4 taken 489 times.
✗ Branch 3 → 16 not taken.
✗ Branch 3 → 28 not taken.
✓ Branch 3 → 29 taken 182 times.
✗ Branch 3 → 38 not taken.
✗ Branch 3 → 45 not taken.
✗ Branch 3 → 52 not taken.
✓ Branch 3 → 59 taken 756 times.
1427 switch (plane) {
179 489 case PLANAR_U: case PLANAR_V:
180
4/8
✓ Branch 5 → 6 taken 489 times.
✗ Branch 5 → 14 not taken.
✓ Branch 7 → 8 taken 489 times.
✗ Branch 7 → 14 not taken.
✓ Branch 9 → 10 taken 489 times.
✗ Branch 9 → 14 not taken.
✓ Branch 11 → 12 taken 489 times.
✗ Branch 11 → 14 not taken.
489 return ((NumComponents() > 1) && IsPlanar() && !IsPlanarRGB() && !IsPlanarRGBA()) ? rowsize>>GetPlaneWidthSubsampling(plane) : 0;
181
182 case PLANAR_U_ALIGNED: case PLANAR_V_ALIGNED:
183 return ((NumComponents() > 1) && IsPlanar() && !IsPlanarRGB() && !IsPlanarRGBA()) ? ((rowsize>>GetPlaneWidthSubsampling(plane))+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)) : 0; // Aligned rowsize
184
185 case PLANAR_Y_ALIGNED:
186 return (rowsize+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)); // Aligned rowsize
187
188 182 case PLANAR_R: case PLANAR_G: case PLANAR_B:
189
4/6
✓ Branch 30 → 31 taken 182 times.
✗ Branch 30 → 36 not taken.
✓ Branch 32 → 33 taken 40 times.
✓ Branch 32 → 35 taken 142 times.
✓ Branch 34 → 35 taken 40 times.
✗ Branch 34 → 36 not taken.
182 return ((NumComponents() > 1) && (IsPlanarRGB() || IsPlanarRGBA())) ? rowsize : 0;
190
191 case PLANAR_R_ALIGNED: case PLANAR_G_ALIGNED: case PLANAR_B_ALIGNED:
192 return IsPlanarRGB() || IsPlanarRGBA() ? (rowsize+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)) : 0; // Aligned rowsize
193
194 case PLANAR_A:
195 return ((NumComponents() == 4) && IsPlanar()) ? rowsize : 0;
196
197 case PLANAR_A_ALIGNED:
198 return ((NumComponents() == 4) && IsPlanar()) ? (rowsize+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)) : 0; // Aligned rowsize
199
200 }
201 756 return rowsize;
202 }
203
204 int VideoInfo::BMPSize() const {
205 if ((NumComponents() > 1) && IsPlanar()) {
206 if (IsPlanarRGB() || IsPlanarRGBA()) {
207 return ((RowSize(PLANAR_G) + 3) & ~3) * height * NumComponents(); // does it make sense for planar rgb?
208 }
209 // Y plane
210 const int Ybytes = ((RowSize(PLANAR_Y)+3) & ~3) * height;
211 const int UVbytes = Ybytes >> (GetPlaneWidthSubsampling(PLANAR_U)+GetPlaneHeightSubsampling(PLANAR_U));
212 return Ybytes + UVbytes*2;
213 }
214 return height * ((RowSize()+3) & ~3);
215 }
216
217 1516 int VideoInfo::GetPlaneWidthSubsampling(int plane) const { // Subsampling in bitshifts!
218
10/10
✓ Branch 2 → 3 taken 1403 times.
✓ Branch 2 → 7 taken 113 times.
✓ Branch 3 → 4 taken 1386 times.
✓ Branch 3 → 7 taken 17 times.
✓ Branch 4 → 5 taken 1369 times.
✓ Branch 4 → 7 taken 17 times.
✓ Branch 5 → 6 taken 1352 times.
✓ Branch 5 → 7 taken 17 times.
✓ Branch 6 → 7 taken 11 times.
✓ Branch 6 → 8 taken 1341 times.
1516 if (plane == PLANAR_Y || plane == PLANAR_R || plane == PLANAR_G || plane == PLANAR_B || plane == PLANAR_A) // No subsampling
219 175 return 0;
220
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 13 taken 1341 times.
1341 if (NumComponents() == 1)
221 throw AvisynthError("Filter error: GetPlaneWidthSubsampling not available on greyscale pixel type.");
222
3/4
✓ Branch 13 → 14 taken 142 times.
✓ Branch 13 → 15 taken 1199 times.
✓ Branch 14 → 15 taken 142 times.
✗ Branch 14 → 24 not taken.
1341 if (plane == PLANAR_U || plane == PLANAR_V) {
223
1/2
✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 1341 times.
1341 if (IsYUY2())
224 return 1;
225
1/2
✓ Branch 19 → 20 taken 1341 times.
✗ Branch 19 → 21 not taken.
1341 else if (IsPlanar())
226 1341 return ((pixel_type>>CS_Shift_Sub_Width)+1) & 3;
227 else
228 throw AvisynthError("Filter error: GetPlaneWidthSubsampling called with unsupported pixel type.");
229 }
230 throw AvisynthError("Filter error: GetPlaneWidthSubsampling called with unsupported plane.");
231 }
232
233 1519 int VideoInfo::GetPlaneHeightSubsampling(int plane) const { // Subsampling in bitshifts!
234
10/10
✓ Branch 2 → 3 taken 1406 times.
✓ Branch 2 → 7 taken 113 times.
✓ Branch 3 → 4 taken 1389 times.
✓ Branch 3 → 7 taken 17 times.
✓ Branch 4 → 5 taken 1372 times.
✓ Branch 4 → 7 taken 17 times.
✓ Branch 5 → 6 taken 1355 times.
✓ Branch 5 → 7 taken 17 times.
✓ Branch 6 → 7 taken 11 times.
✓ Branch 6 → 8 taken 1344 times.
1519 if (plane == PLANAR_Y || plane == PLANAR_R || plane == PLANAR_G || plane == PLANAR_B || plane == PLANAR_A) // No subsampling
235 175 return 0;
236
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 13 taken 1344 times.
1344 if (NumComponents() == 1)
237 throw AvisynthError("Filter error: GetPlaneHeightSubsampling not available on greyscale pixel type.");
238
3/4
✓ Branch 13 → 14 taken 144 times.
✓ Branch 13 → 15 taken 1200 times.
✓ Branch 14 → 15 taken 144 times.
✗ Branch 14 → 24 not taken.
1344 if (plane == PLANAR_U || plane == PLANAR_V) {
239
1/2
✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 1344 times.
1344 if (IsYUY2())
240 return 0;
241
1/2
✓ Branch 19 → 20 taken 1344 times.
✗ Branch 19 → 21 not taken.
1344 else if (IsPlanar())
242 1344 return ((pixel_type>>CS_Shift_Sub_Height)+1) & 3;
243 else
244 throw AvisynthError("Filter error: GetPlaneHeightSubsampling called with unsupported pixel type.");
245 }
246 throw AvisynthError("Filter error: GetPlaneHeightSubsampling called with unsupported plane.");
247 }
248
249 294 int VideoInfo::BitsPerPixel() const {
250 // Lookup Interleaved, calculate PLANAR's
251 // Remark:
252 // - total bitsize for interleaved/packed types, e.g. RGB48 = 48 = 3x16
253 // - byte size corrected with U-V subsampling factor for Planar YUV/YUVA
254 // - external softwares may use it for calculating buffer size
255 // - use BitsPerComponent instead for returning the pixel component format 8/10/12/14/16/32 bits
256
8/9
✓ Branch 2 → 3 taken 40 times.
✓ Branch 2 → 4 taken 35 times.
✓ Branch 2 → 5 taken 68 times.
✓ Branch 2 → 6 taken 96 times.
✓ Branch 2 → 7 taken 11 times.
✓ Branch 2 → 8 taken 3 times.
✓ Branch 2 → 9 taken 14 times.
✓ Branch 2 → 10 taken 27 times.
✗ Branch 2 → 11 not taken.
294 switch (pixel_type) {
257 40 case CS_BGR24:
258 40 return 24;
259 35 case CS_BGR32:
260 35 return 32;
261 68 case CS_YUY2:
262 68 return 16;
263 96 case CS_Y8:
264 96 return 8;
265 11 case CS_Y10:
266 case CS_Y12:
267 case CS_Y14:
268 case CS_Y16: // AVS16
269 11 return 16;
270 3 case CS_Y32:
271 3 return 32;
272 14 case CS_BGR48:
273 14 return 48;
274 27 case CS_BGR64:
275 27 return 64;
276 }
277 if (IsPlanar()) {
278 const int componentSizes[8] = {1,2,4,0,0,2,2,2};
279 const int S = (IsYUV() || IsYUVA()) ? GetPlaneWidthSubsampling(PLANAR_U) + GetPlaneHeightSubsampling(PLANAR_U) : 0; // planar RGBA: no subsampling
280 const int fullSizePlaneCount = IsYUVA() || IsPlanarRGBA() ? 2 : 1; // alpha plane is always full size
281 return (((fullSizePlaneCount << S) + 2) * (componentSizes[(pixel_type >> CS_Shift_Sample_Bits) & 7]) * 8) >> S;
282 }
283 return 0;
284 }
285
286 // useful mutator
287 4 void VideoInfo::SetFPS(unsigned numerator, unsigned denominator) {
288
2/4
✓ Branch 2 → 3 taken 4 times.
✗ Branch 2 → 4 not taken.
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 4 times.
4 if ((numerator == 0) || (denominator == 0)) {
289 fps_numerator = 0;
290 fps_denominator = 1;
291 }
292 else {
293 4 unsigned x=numerator, y=denominator;
294
2/2
✓ Branch 7 → 6 taken 9 times.
✓ Branch 7 → 8 taken 4 times.
13 while (y) { // find gcd
295 9 unsigned t = x%y; x = y; y = t;
296 }
297 4 fps_numerator = numerator/x;
298 4 fps_denominator = denominator/x;
299 }
300 4 }
301
302 // Range protected multiply-divide of FPS
303 26 void VideoInfo::MulDivFPS(unsigned multiplier, unsigned divisor) {
304 26 uint64_t numerator = UInt32x32To64(fps_numerator, multiplier);
305 26 uint64_t denominator = UInt32x32To64(fps_denominator, divisor);
306
307 26 uint64_t x=numerator, y=denominator;
308
2/2
✓ Branch 4 → 3 taken 34 times.
✓ Branch 4 → 5 taken 26 times.
60 while (y) { // find gcd
309 34 uint64_t t = x%y; x = y; y = t;
310 }
311 26 numerator /= x; // normalize
312 26 denominator /= x;
313
314 26 uint64_t temp = numerator | denominator; // Just looking top bit
315 26 unsigned u = 0;
316
2/2
✓ Branch 7 → 6 taken 1 time.
✓ Branch 7 → 8 taken 26 times.
27 while (temp & 0xffffffff80000000) { // or perhaps > 16777216*2
317 1 temp = Int64ShrlMod32(temp, 1);
318 1 u++;
319 }
320
2/2
✓ Branch 8 → 9 taken 1 time.
✓ Branch 8 → 10 taken 25 times.
26 if (u) { // Scale to fit
321 1 const unsigned round = 1 << (u-1);
322 1 SetFPS( (unsigned)Int64ShrlMod32(numerator + round, u),
323 1 (unsigned)Int64ShrlMod32(denominator + round, u) );
324 }
325 else {
326 25 fps_numerator = (unsigned)numerator;
327 25 fps_denominator = (unsigned)denominator;
328 }
329 26 }
330
331 // Test for same colorspace
332 33 bool VideoInfo::IsSameColorspace(const VideoInfo& vi) const {
333
2/2
✓ Branch 2 → 3 taken 32 times.
✓ Branch 2 → 4 taken 1 time.
33 if (vi.pixel_type == pixel_type) return TRUE;
334
2/6
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 9 taken 1 time.
✗ Branch 7 → 8 not taken.
✗ Branch 7 → 9 not taken.
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 1 time.
1 if (IsYV12() && vi.IsYV12()) return TRUE;
335 1 return FALSE;
336 }
337
338 6491 int VideoInfo::NumComponents() const {
339
340
3/4
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 262 times.
✓ Branch 2 → 5 taken 63 times.
✓ Branch 2 → 6 taken 6166 times.
6491 switch (pixel_type) {
341 case CS_UNKNOWN:
342 return 0;
343 262 case CS_RAW32:
344 case CS_Y8:
345 case CS_Y10:
346 case CS_Y12:
347 case CS_Y14:
348 case CS_Y16:
349 case CS_Y32:
350 262 return 1;
351 63 case CS_BGR32:
352 case CS_BGR64:
353 63 return 4; // these are not planar but return the count
354 6166 default:
355
4/4
✓ Branch 7 → 8 taken 5279 times.
✓ Branch 7 → 10 taken 887 times.
✓ Branch 9 → 10 taken 133 times.
✓ Branch 9 → 11 taken 5146 times.
6166 return (IsYUVA() || IsPlanarRGBA()) ? 4 : 3;
356 // 3: YUV, planar RGB, 24/48 bit RGB
357 // 4: YUVA and PlanarRGBA
358 }
359 }
360
361 286 int VideoInfo::ComponentSize() const {
362 // occupied bytes per one pixel component
363
2/2
✓ Branch 3 → 4 taken 238 times.
✓ Branch 3 → 5 taken 48 times.
286 if(IsPlanar()) {
364 238 const int componentSizes[8] = {1,2,4,0,0,2,2,2};
365 238 return componentSizes[(pixel_type >> CS_Shift_Sample_Bits) & 7];
366 }
367
2/4
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
✓ Branch 5 → 8 taken 16 times.
✓ Branch 5 → 9 taken 32 times.
48 switch (pixel_type) {
368 case CS_UNKNOWN:
369 return 0;
370 case CS_RAW32:
371 return 4;
372 16 case CS_BGR48:
373 case CS_BGR64:
374 16 return 2;
375 32 default: // YUY2, packed 8 bit BGRs
376 32 return 1;
377 }
378 }
379
380 595 int VideoInfo::BitsPerComponent() const {
381 // unlike BitsPerPixel, this returns the real
382 // component size as 8/10/12/14/16/32 bit
383
2/2
✓ Branch 2 → 3 taken 11 times.
✓ Branch 2 → 4 taken 584 times.
595 if (pixel_type == CS_YUY2)
384 11 return 8;
385
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 584 times.
584 else if (pixel_type == CS_RAW32)
386 return 32;
387 // planar YUV/RGB and packed RGB
388 584 const int componentBitSizes[8] = {8,16,32,0,0,10,12,14};
389 584 return componentBitSizes[(pixel_type >> CS_Shift_Sample_Bits) & 7];
390 }
391
392 // bit-depth independent helper functions instead of 8 bit specific IsYV24/16/12/8
393
2/2
✓ Branch 2 → 3 taken 54 times.
✓ Branch 2 → 4 taken 109 times.
217 bool VideoInfo::Is444() const { return ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUV444 & CS_PLANAR_FILTER)) ||
394
2/2
✓ Branch 3 → 4 taken 6 times.
✓ Branch 3 → 5 taken 48 times.
217 ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUVA444 & CS_PLANAR_FILTER)) ; }
395
2/2
✓ Branch 2 → 3 taken 191 times.
✓ Branch 2 → 4 taken 4392 times.
4774 bool VideoInfo::Is422() const { return ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUV422 & CS_PLANAR_FILTER)) ||
396
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 191 times.
4774 ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUVA422 & CS_PLANAR_FILTER)); }
397
2/2
✓ Branch 2 → 3 taken 4606 times.
✓ Branch 2 → 4 taken 4761 times.
13973 bool VideoInfo::Is420() const { return ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUV420 & CS_PLANAR_FILTER)) ||
398
2/2
✓ Branch 3 → 4 taken 27 times.
✓ Branch 3 → 5 taken 4579 times.
13973 ((pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_YUVA420 & CS_PLANAR_FILTER)); }
399 363 bool VideoInfo::IsY() const { return (pixel_type & CS_PLANAR_MASK & ~CS_Sample_Bits_Mask) == (CS_GENERIC_Y & CS_PLANAR_FILTER); }
400
4/4
✓ Branch 2 → 3 taken 26 times.
✓ Branch 2 → 5 taken 62 times.
✓ Branch 3 → 4 taken 21 times.
✓ Branch 3 → 5 taken 5 times.
88 bool VideoInfo::IsRGB48() const { return ((pixel_type & CS_BGR24) == CS_BGR24) && ((pixel_type & CS_Sample_Bits_Mask) == CS_Sample_Bits_16); } // Clear out additional properties
401
3/4
✓ Branch 2 → 3 taken 7 times.
✓ Branch 2 → 5 taken 108 times.
✓ Branch 3 → 4 taken 7 times.
✗ Branch 3 → 5 not taken.
115 bool VideoInfo::IsRGB64() const { return ((pixel_type & CS_BGR32) == CS_BGR32) && ((pixel_type & CS_Sample_Bits_Mask) == CS_Sample_Bits_16); }
402 8656 bool VideoInfo::IsYUVA() const { return !!(pixel_type&CS_YUVA ); }
403
6/6
✓ Branch 2 → 3 taken 1969 times.
✓ Branch 2 → 6 taken 166 times.
✓ Branch 3 → 4 taken 327 times.
✓ Branch 3 → 6 taken 1642 times.
✓ Branch 4 → 5 taken 283 times.
✓ Branch 4 → 6 taken 44 times.
2135 bool VideoInfo::IsPlanarRGB() const { return !!(pixel_type&CS_PLANAR) && !!(pixel_type&CS_BGR) && !!(pixel_type&CS_RGB_TYPE); }
404
6/6
✓ Branch 2 → 3 taken 7299 times.
✓ Branch 2 → 6 taken 322 times.
✓ Branch 3 → 4 taken 903 times.
✓ Branch 3 → 6 taken 6396 times.
✓ Branch 4 → 5 taken 235 times.
✓ Branch 4 → 6 taken 668 times.
7621 bool VideoInfo::IsPlanarRGBA() const { return !!(pixel_type&CS_PLANAR) && !!(pixel_type&CS_BGR) && !!(pixel_type&CS_RGBA_TYPE); }
405 12 bool VideoInfo::IsChannelMaskKnown() const { return !!(image_type & IT_HAS_CHANNELMASK); }
406 // Re-maps and stores channel mask into image_type, sets the 'has channel mask' flag as well
407 36 void VideoInfo::SetChannelMask(bool isChannelMaskKnown, unsigned int dwChannelMask)
408 {
409
2/2
✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 4 taken 32 times.
36 if (isChannelMaskKnown) image_type |= IT_HAS_CHANNELMASK; else image_type &= ~IT_HAS_CHANNELMASK;
410
2/2
✓ Branch 5 → 6 taken 32 times.
✓ Branch 5 → 7 taken 4 times.
36 if (!isChannelMaskKnown) dwChannelMask = 0;
411
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 36 times.
36 if (dwChannelMask & AvsChannelMask::MASK_SPEAKER_ALL) // special mapping due to lack of bits in image_type
412 dwChannelMask = AvsImageTypeFlags::IT_SPEAKER_ALL;
413 else {
414 36 dwChannelMask &= AvsChannelMask::MASK_SPEAKER_DEFINED;
415 36 dwChannelMask <<= 4;
416 }
417 36 image_type &= ~AvsImageTypeFlags::IT_SPEAKER_BITS_MASK;
418 36 image_type |= dwChannelMask;
419 36 }
420
421 6 unsigned int VideoInfo::GetChannelMask() const
422 {
423 // returns zero if not defined
424
2/2
✓ Branch 3 → 4 taken 2 times.
✓ Branch 3 → 5 taken 4 times.
6 if (!IsChannelMaskKnown()) return 0;
425 4 unsigned int dwChannelMask = image_type & AvsImageTypeFlags::IT_SPEAKER_BITS_MASK;
426 // returns the original SPEAKER_ALL constant
427
1/2
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 4 times.
4 if (dwChannelMask == AvsImageTypeFlags::IT_SPEAKER_ALL)
428 return AvsChannelMask::MASK_SPEAKER_ALL;
429 // other SPEAKER bits were simply shifted by 4 bits
430 4 return dwChannelMask >> 4;
431 }
432
433
434 // end struct VideoInfo
435
436 /**********************************************************************/
437
438 // class VideoFrameBuffer
439
440 19523 const BYTE* VideoFrameBuffer::GetReadPtr() const { return data; }
441 /* Baked ********************
442 BYTE* VideoFrameBuffer::GetWritePtr() { ++sequence_number; return data; }
443 Baked ********************/
444 10510 BYTE* VideoFrameBuffer::GetWritePtr() { InterlockedIncrement(&sequence_number); return data; }
445 49 int VideoFrameBuffer::GetDataSize() const { return data_size; }
446 int VideoFrameBuffer::GetSequenceNumber() const { return sequence_number; }
447 8698 int VideoFrameBuffer::GetRefcount() const { return refcount; }
448
449 // end class VideoFrameBuffer
450
451 /**********************************************************************/
452
453 // class VideoFrame
454
455 /* Baked ********************
456 void VideoFrame::AddRef() { InterlockedIncrement((int *)&refcount); }
457 void VideoFrame::Release() { if (refcount==1) InterlockedDecrement(&vfb->refcount); InterlockedDecrement((int *)&refcount); }
458
459 int VideoFrame::GetPitch() const { return pitch; }
460 int VideoFrame::GetPitch(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: return pitchUV;} return pitch; }
461 int VideoFrame::GetRowSize() const { return row_size; }
462
463 int VideoFrame::GetRowSize(int plane) const {
464 switch (plane) {
465 case PLANAR_U: case PLANAR_V: if (pitchUV) return row_size>>1; else return 0;
466 case PLANAR_U_ALIGNED: case PLANAR_V_ALIGNED:
467 if (pitchUV) {
468 int r = ((row_size+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)) )>>1; // Aligned rowsize
469 if (r<=pitchUV)
470 return r;
471 return row_size>>1;
472 } else return 0;
473 case PLANAR_Y_ALIGNED:
474 int r = (row_size+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)); // Aligned rowsize
475 if (r<=pitch)
476 return r;
477 return row_size;
478 }
479 return row_size; }
480
481 int VideoFrame::GetHeight() const { return height; }
482 int VideoFrame::GetHeight(int plane) const { switch (plane) {case PLANAR_U: case PLANAR_V: if (pitchUV) return height>>1; return 0;} return height; }
483
484 // generally you shouldn't use these three
485 VideoFrameBuffer* VideoFrame::GetFrameBuffer() const { return vfb; }
486 int VideoFrame::GetOffset() const { return offset; }
487 int VideoFrame::GetOffset(int plane) const { switch (plane) {case PLANAR_U: return offsetU;case PLANAR_V: return offsetV;default: return offset;}; }
488
489 const BYTE* VideoFrame::GetReadPtr() const { return vfb->GetReadPtr() + offset; }
490 const BYTE* VideoFrame::GetReadPtr(int plane) const { return vfb->GetReadPtr() + GetOffset(plane); }
491
492 bool VideoFrame::IsWritable() const { return (refcount == 1 && vfb->refcount == 1); }
493
494 BYTE* VideoFrame::GetWritePtr() const {
495 if (vfb->GetRefcount()>1) {
496 _ASSERT(FALSE);
497 //throw AvisynthError("Internal Error - refcount was more than one!");
498 }
499 return IsWritable() ? (vfb->GetWritePtr() + offset) : 0;
500 }
501 Baked ********************/
502
503 4649 void VideoFrame::AddRef() { InterlockedIncrement(&refcount); }
504 5589 void VideoFrame::Release() {
505 5589 VideoFrameBuffer* _vfb = vfb;
506
507
2/2
✓ Branch 2 → 3 taken 952 times.
✓ Branch 2 → 4 taken 4637 times.
5589 if (!InterlockedDecrement(&refcount)) {
508 // Do NOT touch 'properties' here. The FrameRegistry (under memory_mutex) is the
509 // sole owner: it clears the AVSMap contents for reuse (winner frames) or deletes
510 // it entirely (discarded frames). Freeing or clearing here without that lock would
511 // race with concurrent FrameRegistry access.
512 #ifdef ALTERNATIVE_VFB_TIMESTAMP
513 if (!InterlockedDecrement(&_vfb->refcount)) {
514 // all VideoFrameBuffer instances are actually VFBStorage, which has way mode admin fields
515 VFBHelper::UpdateVFBFreeTimestamp(_vfb);
516 }
517 #else
518 952 InterlockedDecrement(&_vfb->refcount);
519 #endif
520 }
521 5589 }
522
523
3/3
✓ Branch 2 → 3 taken 9163 times.
✓ Branch 2 → 4 taken 1055 times.
✓ Branch 2 → 5 taken 11467 times.
21685 int VideoFrame::GetPitch(int plane) const { switch (plane) { case PLANAR_U: case PLANAR_V: return pitchUV; case PLANAR_A: return pitchA; } return pitch; }
524
525 9106 int VideoFrame::GetRowSize(int plane) const {
526
6/6
✓ Branch 2 → 3 taken 4810 times.
✓ Branch 2 → 6 taken 15 times.
✓ Branch 2 → 11 taken 4 times.
✓ Branch 2 → 14 taken 444 times.
✓ Branch 2 → 17 taken 3 times.
✓ Branch 2 → 22 taken 3830 times.
9106 switch (plane) {
527
2/2
✓ Branch 3 → 4 taken 4462 times.
✓ Branch 3 → 5 taken 348 times.
4810 case PLANAR_U: case PLANAR_V: if (pitchUV) return row_sizeUV; else return 0;
528 15 case PLANAR_U_ALIGNED: case PLANAR_V_ALIGNED:
529
1/2
✓ Branch 6 → 7 taken 15 times.
✗ Branch 6 → 10 not taken.
15 if (pitchUV) {
530 15 const int r = (row_sizeUV+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)); // Aligned rowsize
531
1/2
✓ Branch 7 → 8 taken 15 times.
✗ Branch 7 → 9 not taken.
15 if (r<=pitchUV)
532 15 return r;
533 return row_sizeUV;
534 }
535 else return 0;
536 4 case PLANAR_ALIGNED: case PLANAR_Y_ALIGNED:
537 case PLANAR_R_ALIGNED: case PLANAR_G_ALIGNED: case PLANAR_B_ALIGNED:
538 {
539 4 const int r = (row_size+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)); // Aligned rowsize
540
1/2
✓ Branch 11 → 12 taken 4 times.
✗ Branch 11 → 13 not taken.
4 if (r<=pitch)
541 4 return r;
542 return row_size;
543 }
544 444 case PLANAR_A:
545
2/2
✓ Branch 14 → 15 taken 417 times.
✓ Branch 14 → 16 taken 27 times.
444 if (pitchA) return row_sizeA; else return 0;
546 3 case PLANAR_A_ALIGNED:
547
1/2
✓ Branch 17 → 18 taken 3 times.
✗ Branch 17 → 21 not taken.
3 if(pitchA) {
548 3 const int r = (row_sizeA+FRAME_ALIGN-1)&(~(FRAME_ALIGN-1)); // Aligned rowsize
549
1/2
✓ Branch 18 → 19 taken 3 times.
✗ Branch 18 → 20 not taken.
3 if (r<=pitchA)
550 3 return r;
551 return row_sizeA;
552 }
553 else return 0;
554 }
555 3830 return row_size; // PLANAR_Y, PLANAR_G, PLANAR_B, PLANAR_R
556 }
557
558 11321 int VideoFrame::GetHeight(int plane) const {
559
3/3
✓ Branch 2 → 3 taken 4566 times.
✓ Branch 2 → 6 taken 444 times.
✓ Branch 2 → 9 taken 6311 times.
11321 switch (plane) {
560
2/2
✓ Branch 3 → 4 taken 4210 times.
✓ Branch 3 → 5 taken 356 times.
4566 case PLANAR_U: case PLANAR_V: if (pitchUV) return heightUV; return 0;
561
2/2
✓ Branch 6 → 7 taken 418 times.
✓ Branch 6 → 8 taken 26 times.
444 case PLANAR_A: if (pitchA) return height; return 0;
562 }
563 6311 return height;
564 }
565
566 int VideoFrame::GetPixelType() const { return pixel_type; }
567 2 void VideoFrame::AmendPixelType(int new_pixel_type) { pixel_type = new_pixel_type; }
568
569 // Generally you should not be using these two
570 258 VideoFrameBuffer* VideoFrame::GetFrameBuffer() const { return vfb; }
571 34677 int VideoFrame::GetOffset(int plane) const {
572
4/4
✓ Branch 2 → 3 taken 7384 times.
✓ Branch 2 → 4 taken 7236 times.
✓ Branch 2 → 5 taken 1611 times.
✓ Branch 2 → 6 taken 18446 times.
34677 switch (plane) {
573 7384 case PLANAR_U: case PLANAR_B: return offsetU; // G is first. Then B,R order like U,V
574 7236 case PLANAR_V: case PLANAR_R: return offsetV;
575 1611 case PLANAR_A: return offsetA;
576 18446 default: return offset; // PLANAR Y, PLANAR_G
577 };
578 }
579
580 19523 const BYTE* VideoFrame::GetReadPtr(int plane) const { return vfb->GetReadPtr() + GetOffset(plane); }
581
582 121 bool VideoFrame::IsWritable() const {
583
5/6
✓ Branch 2 → 3 taken 6 times.
✓ Branch 2 → 5 taken 115 times.
✓ Branch 3 → 4 taken 6 times.
✗ Branch 3 → 5 not taken.
✓ Branch 6 → 7 taken 6 times.
✓ Branch 6 → 9 taken 115 times.
121 if (refcount == 1 && vfb->refcount == 1) {
584 6 vfb->GetWritePtr(); // Bump sequence number
585 6 return true;
586 }
587 115 return false;
588 }
589
590 bool VideoFrame::IsPropertyWritable() const {
591 return (refcount == 1);
592 }
593
594 15114 BYTE* VideoFrame::GetWritePtr(int plane) const {
595
6/6
✓ Branch 2 → 3 taken 9880 times.
✓ Branch 2 → 5 taken 5234 times.
✓ Branch 3 → 4 taken 6848 times.
✓ Branch 3 → 5 taken 3032 times.
✓ Branch 4 → 5 taken 432 times.
✓ Branch 4 → 15 taken 6416 times.
15114 if (!plane || plane == PLANAR_Y || plane == PLANAR_G) { // planar RGB order GBR
596
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 8698 times.
8698 if (vfb->GetRefcount()>1) {
597 _ASSERT(FALSE);
598 // throw AvisynthError("Internal Error - refcount was more than one!");
599 }
600
2/4
✓ Branch 8 → 9 taken 8698 times.
✗ Branch 8 → 13 not taken.
✓ Branch 9 → 10 taken 8698 times.
✗ Branch 9 → 13 not taken.
8698 return (refcount == 1 && vfb->refcount == 1) ? vfb->GetWritePtr() + GetOffset(plane) : 0;
601 }
602 6416 return vfb->data + GetOffset(plane);
603 }
604
605 336 AVSMap& VideoFrame::getProperties() {
606 336 return *properties;
607 }
608
609 97 const AVSMap& VideoFrame::getConstProperties() {
610 97 return *properties;
611 }
612
613 276 void VideoFrame::setProperties(const AVSMap& properties) {
614 276 *(this->properties) = properties;
615 276 }
616
617 PDevice VideoFrame::GetDevice() const {
618 return vfb->device;
619 }
620
621 283 int VideoFrame::CheckMemory() const {
622 #ifdef _DEBUG
623 if (vfb->data && vfb->device->device_type == DEV_TYPE_CPU) {
624 // check buffer overrun
625 int *pInt = (int *)(vfb->data + vfb->data_size);
626 if (pInt[0] != 0xDEADBEEF ||
627 pInt[1] != 0xDEADBEEF ||
628 pInt[2] != 0xDEADBEEF ||
629 pInt[3] != 0xDEADBEEF)
630 {
631 return 1;
632 }
633 return 0;
634 }
635 #endif
636 283 return -1;
637 }
638
639 /* Baked ********************
640 VideoFrame::~VideoFrame() { InterlockedDecrement(&vfb->refcount); }
641 Baked ********************/
642 940 VideoFrame::~VideoFrame() { DESTRUCTOR(); }
643 940 void VideoFrame::DESTRUCTOR() {
644 940 Release();
645 // finally destroyed when removed from FrameRegistry
646
1/2
✓ Branch 3 → 4 taken 940 times.
✗ Branch 3 → 8 not taken.
940 if (properties) {
647
1/2
✓ Branch 4 → 5 taken 940 times.
✗ Branch 4 → 7 not taken.
940 delete properties;
648 940 properties = nullptr;
649 }
650 940 }
651
652 // end class VideoFrame
653
654 /**********************************************************************/
655
656 // class IClip
657
658 /* Baked ********************
659 void IClip::AddRef() { InterlockedIncrement((int *)&refcnt); }
660 void IClip::Release() { InterlockedDecrement((int *)&refcnt); if (!refcnt) delete this; }
661 Baked ********************/
662 3114 void IClip::AddRef() { InterlockedIncrement(&refcnt); }
663
3/4
✓ Branch 2 → 3 taken 616 times.
✓ Branch 2 → 5 taken 2498 times.
✓ Branch 3 → 4 taken 616 times.
✗ Branch 3 → 5 not taken.
3114 void IClip::Release() { if (!InterlockedDecrement(&refcnt)) delete this; }
664
665 // end class IClip
666
667 /**********************************************************************/
668
669 // class PClip
670
671
1/2
✓ Branch 2 → 3 taken 169 times.
✗ Branch 2 → 4 not taken.
169 IClip* PClip::GetPointerWithAddRef() const { if (p) p->AddRef(); return p; }
672
673 2506 void PClip::Init(IClip* x) {
674
2/2
✓ Branch 2 → 3 taken 2376 times.
✓ Branch 2 → 4 taken 130 times.
2506 if (x) x->AddRef();
675 2506 p=x;
676 2506 }
677
678 249 void PClip::Set(IClip* x) {
679
2/2
✓ Branch 2 → 3 taken 187 times.
✓ Branch 2 → 4 taken 62 times.
249 if (x) x->AddRef();
680
2/2
✓ Branch 4 → 5 taken 49 times.
✓ Branch 4 → 6 taken 200 times.
249 if (p) p->Release();
681 249 p=x;
682 249 }
683
684 258 PClip::PClip() { CONSTRUCTOR0(); }
685 258 void PClip::CONSTRUCTOR0() { p = 0; }
686
687 1665 PClip::PClip(const PClip& x) { CONSTRUCTOR1(x); }
688 1665 void PClip::CONSTRUCTOR1(const PClip& x) { Init(x.p); }
689
690 841 PClip::PClip(IClip* x) { CONSTRUCTOR2(x); }
691 841 void PClip::CONSTRUCTOR2(IClip* x) { Init(x); }
692
693 78 void PClip::operator=(IClip* x) { OPERATOR_ASSIGN0(x); }
694 78 void PClip::OPERATOR_ASSIGN0(IClip* x) { Set(x); }
695
696 171 void PClip::operator=(const PClip& x) { OPERATOR_ASSIGN1(x); }
697 171 void PClip::OPERATOR_ASSIGN1(const PClip& x) { Set(x.p); }
698
699 2764 PClip::~PClip() { DESTRUCTOR(); }
700
2/2
✓ Branch 2 → 3 taken 2514 times.
✓ Branch 2 → 4 taken 250 times.
2764 void PClip::DESTRUCTOR() { if (p) p->Release(); }
701
702 // end class PClip
703
704 /**********************************************************************/
705
706 // class PVideoFrame
707
708 3488 void PVideoFrame::Init(VideoFrame* x) {
709
2/2
✓ Branch 2 → 3 taken 3482 times.
✓ Branch 2 → 4 taken 6 times.
3488 if (x) x->AddRef();
710 3488 p=x;
711 3488 }
712
713 1167 void PVideoFrame::Set(VideoFrame* x) {
714
1/2
✓ Branch 2 → 3 taken 1167 times.
✗ Branch 2 → 4 not taken.
1167 if (x) x->AddRef();
715
2/2
✓ Branch 4 → 5 taken 113 times.
✓ Branch 4 → 6 taken 1054 times.
1167 if (p) p->Release();
716 1167 p=x;
717 1167 }
718
719 1094 PVideoFrame::PVideoFrame() { CONSTRUCTOR0(); }
720 1094 void PVideoFrame::CONSTRUCTOR0() { p = 0; }
721
722 2530 PVideoFrame::PVideoFrame(const PVideoFrame& x) { CONSTRUCTOR1(x); }
723 2530 void PVideoFrame::CONSTRUCTOR1(const PVideoFrame& x) { Init(x.p); }
724
725 958 PVideoFrame::PVideoFrame(VideoFrame* x) { CONSTRUCTOR2(x); }
726 958 void PVideoFrame::CONSTRUCTOR2(VideoFrame* x) { Init(x); }
727
728 void PVideoFrame::operator=(VideoFrame* x) { OPERATOR_ASSIGN0(x); }
729 void PVideoFrame::OPERATOR_ASSIGN0(VideoFrame* x) { Set(x); }
730
731 1167 void PVideoFrame::operator=(const PVideoFrame& x) { OPERATOR_ASSIGN1(x); }
732 1167 void PVideoFrame::OPERATOR_ASSIGN1(const PVideoFrame& x) { Set(x.p); }
733
734 4582 PVideoFrame::~PVideoFrame() { DESTRUCTOR(); }
735
2/2
✓ Branch 2 → 3 taken 4536 times.
✓ Branch 2 → 4 taken 46 times.
4582 void PVideoFrame::DESTRUCTOR() { if (p) p->Release(); }
736
737
738 // end class PVideoFrame
739
740 /**********************************************************************/
741
742 // class AVSValue
743
744 8901 AVSValue::AVSValue() { CONSTRUCTOR0(); }
745 8901 void AVSValue::CONSTRUCTOR0() { type = 'v'; array_size = 0; clip = NULL; }
746
747 19 AVSValue::AVSValue(IClip* c) { CONSTRUCTOR1(c); }
748
1/2
✓ Branch 2 → 3 taken 19 times.
✗ Branch 2 → 4 not taken.
19 void AVSValue::CONSTRUCTOR1(IClip* c) { type = 'c'; array_size = 0; clip = c; if (c) c->AddRef(); }
749
750 169 AVSValue::AVSValue(const PClip& c) { CONSTRUCTOR2(c); }
751 169 void AVSValue::CONSTRUCTOR2(const PClip& c) { type = 'c'; array_size = 0; clip = c.GetPointerWithAddRef(); }
752
753 2042 AVSValue::AVSValue(bool b) { CONSTRUCTOR3(b); }
754 2042 void AVSValue::CONSTRUCTOR3(bool b) { type = 'b'; array_size = 0; clip = NULL; boolean = b; }
755
756 6493 AVSValue::AVSValue(int i) { CONSTRUCTOR4(i); }
757 6493 void AVSValue::CONSTRUCTOR4(int i) { type = 'i'; array_size = 0; clip = NULL; integer = i; }
758
759 89 AVSValue::AVSValue(float f) { CONSTRUCTOR5(f); }
760 89 void AVSValue::CONSTRUCTOR5(float f) { type = 'f'; array_size = 0; clip = NULL; floating_pt = f; }
761
762 29 AVSValue::AVSValue(double f) { CONSTRUCTOR6(f); }
763 29 void AVSValue::CONSTRUCTOR6(double f)
764 {
765 29 type = 'd'; array_size = 0; clip = NULL;
766 #if UINTPTR_MAX >= 0xffffffffffffffff
767 // pre-v11: floating_pt = float(f);
768 29 double_pt = f; // v11: real 64 bit double!
769 #else
770 double_pt_ptr = new double;
771 *double_pt_ptr = f;
772 #endif
773 29 }
774
775 257016 AVSValue::AVSValue(const char* s) { CONSTRUCTOR7(s); }
776 257016 void AVSValue::CONSTRUCTOR7(const char* s) { type = 's'; array_size = 0; string = s; }
777
778 /* Baked ********************
779 AVSValue::AVSValue(const AVSValue* a, int size) { type = 'a'; array = a; array_size = size; }
780 Baked ********************/
781 AVSValue::AVSValue(const AVSValue& a, int size) { CONSTRUCTOR8(&a, size); }
782 112 AVSValue::AVSValue(const AVSValue* a, int size) { CONSTRUCTOR8(a, size); }
783 112 void AVSValue::CONSTRUCTOR8(const AVSValue* a, int size)
784 {
785 112 type = 'a';
786 112 array_size = (short)size;
787
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 112 times.
112 if (a == nullptr)
788 size = 0;
789
5/18
✓ Branch 4 → 5 taken 112 times.
✗ Branch 4 → 6 not taken.
✓ Branch 9 → 10 taken 893 times.
✗ Branch 9 → 22 not taken.
✓ Branch 11 → 9 taken 893 times.
✓ Branch 11 → 12 taken 112 times.
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 17 taken 112 times.
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 26 not taken.
✗ Branch 24 → 25 not taken.
✗ Branch 24 → 26 not taken.
✗ Branch 27 → 28 not taken.
✗ Branch 27 → 32 not taken.
✗ Branch 28 → 29 not taken.
✗ Branch 28 → 30 not taken.
1005 array = new AVSValue[size]; // even for size = 0 a valid ptr is given
790
2/2
✓ Branch 20 → 18 taken 893 times.
✓ Branch 20 → 21 taken 112 times.
1005 for (int i = 0; i < size; i++) {
791 893 const_cast<AVSValue*>(array)[i].Assign(&a[i], true); // init from source
792 }
793 112 }
794
795 513034 AVSValue::AVSValue(const AVSValue& v) { CONSTRUCTOR9(v); }
796 513034 void AVSValue::CONSTRUCTOR9(const AVSValue& v) { Assign(&v, true); }
797
798 // from compatibility interface
799 AVSValue::AVSValue(const AVSValue& v, bool no_deep_arrays) { CONSTRUCTOR10(v, no_deep_arrays); }
800 void AVSValue::CONSTRUCTOR10(const AVSValue& v, bool no_deep_arrays) { Assign2(&v, true, no_deep_arrays); }
801
802 AVSValue::AVSValue(const PFunction& n) { CONSTRUCTOR11(n); }
803 void AVSValue::CONSTRUCTOR11(const PFunction& n) { type = 'n'; array_size = 0; function = n.GetPointerWithAddRef(); }
804
805 AVSValue::AVSValue(int64_t l) { CONSTRUCTOR12(l); }
806 void AVSValue::CONSTRUCTOR12(int64_t l) { type = 'l'; array_size = 0; clip = NULL;
807 #if UINTPTR_MAX >= 0xffffffffffffffff
808 longlong = l;
809 #else
810 longlong_ptr = new int64_t;
811 *longlong_ptr = l;
812 #endif
813 }
814
815 787904 AVSValue::~AVSValue() { DESTRUCTOR(); }
816 787904 void AVSValue::DESTRUCTOR()
817 {
818
5/6
✓ Branch 3 → 4 taken 539 times.
✓ Branch 3 → 6 taken 787365 times.
✓ Branch 4 → 5 taken 539 times.
✗ Branch 4 → 6 not taken.
✓ Branch 7 → 8 taken 539 times.
✓ Branch 7 → 9 taken 787365 times.
787904 if (IsClip() && clip)
819 539 clip->Release();
820
2/6
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 13 taken 787904 times.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 787904 times.
787904 if (IsFunction() && function)
821 function->Release();
822 #if !(UINTPTR_MAX >= 0xffffffffffffffff)
823 // 32-bit systems support 64-bit data through dynamic allocation.
824 if (type == 'l' && longlong_ptr) {
825 delete longlong_ptr;
826 longlong_ptr = nullptr;
827 }
828 else if (type == 'd' && double_pt_ptr) {
829 delete double_pt_ptr;
830 double_pt_ptr = nullptr;
831 }
832 #endif
833
5/6
✓ Branch 17 → 18 taken 133 times.
✓ Branch 17 → 20 taken 787771 times.
✓ Branch 18 → 19 taken 133 times.
✗ Branch 18 → 20 not taken.
✓ Branch 21 → 22 taken 133 times.
✓ Branch 21 → 28 taken 787771 times.
787904 if (IsArray() && array) {
834
3/4
✓ Branch 22 → 23 taken 133 times.
✗ Branch 22 → 27 not taken.
✓ Branch 24 → 25 taken 976 times.
✓ Branch 24 → 26 taken 133 times.
1109 delete[] array; // calls AVSValue destructors for all elements
835 133 array = nullptr;
836 }
837 787904 }
838
839 void AVSValue::MarkArrayAsNonDeepCopy()
840 {
841 // Convert AVSValue content to a neutral 'v' type
842 // to prevent destructor from freeing up the allocated array
843 // and its elements.
844 // Set just before releasing AVSValue.
845 if (type == 'a')
846 {
847 type = 'v';
848 array_size = 0;
849 array = nullptr;
850 }
851 }
852
853 270756 AVSValue& AVSValue::operator=(const AVSValue& v) { return OPERATOR_ASSIGN(v); }
854 270756 AVSValue& AVSValue::OPERATOR_ASSIGN(const AVSValue& v) { Assign(&v, false); return *this; }
855
856 // pre-v11: Transparently allow 'int' to be treated as 'float'.
857 // No int<->bool conversions.
858 // v11 64 bit value changes:
859 // - 'long' is int64_t.
860 // - IsInt returns true for both 'long' and 'int'
861 // - IsLong returns true only for exact 64-bit integer type
862 // - Transparently allow 'long' and 'int' to be treated as 'float' or 'double'
863 // - IsFloat returns true for both 'float' and 'double' (old IsFloat + 'double').
864 // - new IsFloatfStrict returns true only for 32-bit floating-point numbers.
865 // - new IsLongStrict returns true only for exact 64-bit integer types.
866
867 // Note: Exact type check is available GetType() with returns AvsValueType enum
868 2074 bool AVSValue::Defined() const { return type != 'v'; }
869 1843905 bool AVSValue::IsClip() const { return type == 'c'; }
870 456 bool AVSValue::IsBool() const { return type == 'b'; }
871
3/4
✓ Branch 2 → 3 taken 17 times.
✓ Branch 2 → 4 taken 151 times.
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 17 times.
168 bool AVSValue::IsInt() const { return type == 'i' || type == 'l'; }
872 bool AVSValue::IsLongStrict() const { return type == 'l'; }
873
7/8
✓ Branch 2 → 3 taken 103 times.
✓ Branch 2 → 6 taken 58 times.
✓ Branch 3 → 4 taken 31 times.
✓ Branch 3 → 6 taken 72 times.
✓ Branch 4 → 5 taken 24 times.
✓ Branch 4 → 6 taken 7 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 24 times.
161 bool AVSValue::IsFloat() const { return type == 'd' || type == 'f' || type == 'i' || type == 'l'; }
874 bool AVSValue::IsFloatfStrict() const { return type == 'f'; }
875 4119 bool AVSValue::IsString() const { return type == 's'; }
876 1845664 bool AVSValue::IsArray() const { return type == 'a'; }
877 1843426 bool AVSValue::IsFunction() const { return type == 'n'; }
878
879
2/4
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 168 times.
✓ Branch 6 → 7 taken 168 times.
✗ Branch 6 → 8 not taken.
168 PClip AVSValue::AsClip() const { _ASSERTE(IsClip()); return IsClip()?clip:0; }
880
881
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 7 times.
7 bool AVSValue::AsBool1() const { _ASSERTE(IsBool()); return boolean; }
882 7 bool AVSValue::AsBool() const { return AsBool1(); }
883
884 29 int AVSValue::AsInt1() const {
885
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 29 times.
29 _ASSERTE(IsInt());
886 // simple typecast, no saturation
887 #if UINTPTR_MAX >= 0xffffffffffffffff
888
1/2
✓ Branch 5 → 6 taken 29 times.
✗ Branch 5 → 7 not taken.
29 return type == 'i' ? integer : (int)longlong;
889 #else
890 return type == 'i' ? integer : (int)*longlong_ptr;
891 #endif
892 }
893
894 29 int AVSValue::AsInt() const { return AsInt1(); }
895
896 int64_t AVSValue::AsLong1() const {
897 _ASSERTE(IsInt());
898 #if UINTPTR_MAX >= 0xffffffffffffffff
899 return type == 'i' ? integer : longlong;
900 #else
901 return type == 'i' ? integer : *longlong_ptr;
902 #endif
903 }
904 int64_t AVSValue::AsLong() const { return AsLong1(); }
905
906
2/4
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 33 times.
✓ Branch 6 → 7 taken 33 times.
✗ Branch 6 → 8 not taken.
33 const char* AVSValue::AsString1() const { _ASSERTE(IsString()); return IsString()?string:0; }
907 33 const char* AVSValue::AsString() const { return AVSValue::AsString1(); }
908
909 30 double AVSValue::AsFloat1() const {
910 #if UINTPTR_MAX >= 0xffffffffffffffff
911
6/8
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 30 times.
✓ Branch 5 → 6 taken 3 times.
✓ Branch 5 → 7 taken 27 times.
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 9 taken 27 times.
✓ Branch 9 → 10 taken 14 times.
✓ Branch 9 → 11 taken 13 times.
30 _ASSERTE(IsFloat()); return type == 'i' ? (double)integer : type == 'l' ? (double)longlong : type == 'f' ? (double)floating_pt : double_pt;
912 #else
913 _ASSERTE(IsFloat()); return type == 'i' ? (double)integer : type == 'l' ? (double)*longlong_ptr : type == 'f' ? (double)floating_pt : *double_pt_ptr;
914 #endif
915 }
916
917 30 double AVSValue::AsFloat() const { return AsFloat1(); }
918
919 float AVSValue::AsFloatf() const {
920 #if UINTPTR_MAX >= 0xffffffffffffffff
921 _ASSERTE(IsFloat()); return type == 'i' ? (float)integer : type == 'l' ? (float)longlong : type == 'f' ? floating_pt : (float)double_pt;
922 #else
923 _ASSERTE(IsFloat()); return type == 'i' ? (float)integer : type == 'l' ? (float)*longlong_ptr : type == 'f' ? floating_pt : (float)*double_pt_ptr;
924 #endif
925 }
926
927
5/6
✓ Branch 3 → 4 taken 18 times.
✓ Branch 3 → 7 taken 203 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 18 times.
✓ Branch 8 → 9 taken 203 times.
✓ Branch 8 → 10 taken 18 times.
221 bool AVSValue::AsBool2(bool def) const { _ASSERTE(IsBool()||!Defined()); return IsBool() ? boolean : def; }
928 221 bool AVSValue::AsBool(bool def) const { return AsBool2(def); }
929
930 127 int AVSValue::AsInt2(int def) const {
931
3/4
✓ Branch 3 → 4 taken 13 times.
✓ Branch 3 → 7 taken 114 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 13 times.
127 _ASSERTE(IsInt()||!Defined());
932 #if UINTPTR_MAX >= 0xffffffffffffffff
933
3/4
✓ Branch 7 → 8 taken 114 times.
✓ Branch 7 → 9 taken 13 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 13 times.
127 return type == 'i' ? integer : type == 'l' ? (int)longlong : def;
934 #else
935 return type == 'i' ? integer : type == 'l' ? (int)*longlong_ptr : def;
936 #endif
937 }
938
939 127 int AVSValue::AsInt(int def) const { return AsInt2(def); }
940 int64_t AVSValue::AsLong2(int64_t def) const {
941 _ASSERTE(IsInt() || !Defined());
942 #if UINTPTR_MAX >= 0xffffffffffffffff
943 return type == 'i' ? integer : type == 'l' ? longlong : def;
944 #else
945 return type == 'i' ? integer : type == 'l' ? *longlong_ptr : def;
946 #endif
947 }
948
949 int64_t AVSValue::AsLong(int64_t def) const {
950 return AsLong2(def);
951 }
952
953 86 double AVSValue::AsDblDef(double def) const {
954
3/4
✓ Branch 3 → 4 taken 16 times.
✓ Branch 3 → 7 taken 70 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 16 times.
86 _ASSERTE(IsFloat()||!Defined());
955 #if UINTPTR_MAX >= 0xffffffffffffffff
956
7/8
✓ Branch 7 → 8 taken 1 time.
✓ Branch 7 → 9 taken 85 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 85 times.
✓ Branch 11 → 12 taken 48 times.
✓ Branch 11 → 13 taken 37 times.
✓ Branch 13 → 14 taken 21 times.
✓ Branch 13 → 15 taken 16 times.
86 return type == 'i' ? (double)integer : type == 'l' ? (double)longlong : type == 'f' ? (double)floating_pt : type == 'd' ? double_pt : def;
957 #else
958 return type == 'i' ? (double)integer : type == 'l' ? (double)*longlong_ptr : type == 'f' ? (double)floating_pt : type == 'd' ? *double_pt_ptr : def;
959 #endif
960 }
961
962 34 double AVSValue::AsFloat2(float def) const {
963
3/4
✓ Branch 3 → 4 taken 7 times.
✓ Branch 3 → 7 taken 27 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 7 times.
34 _ASSERTE(IsFloat()||!Defined());
964 #if UINTPTR_MAX >= 0xffffffffffffffff
965
7/8
✓ Branch 7 → 8 taken 3 times.
✓ Branch 7 → 9 taken 31 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 31 times.
✓ Branch 11 → 12 taken 10 times.
✓ Branch 11 → 13 taken 21 times.
✓ Branch 13 → 14 taken 14 times.
✓ Branch 13 → 15 taken 7 times.
34 return type == 'i' ? integer : type == 'l' ? (double)longlong : type == 'f' ? (double)floating_pt : type == 'd' ? double_pt : (double)def;
966 #else
967 return type == 'i' ? integer : type == 'l' ? (double)*longlong_ptr : type == 'f' ? (double)floating_pt : type == 'd' ? *double_pt_ptr : (double)def;
968 #endif
969 }
970
971 25 double AVSValue::AsFloat(float def) const { return AsFloat2(def); }
972 9 float AVSValue::AsFloatf(float def) const { return float( AsFloat2(def) ); }
973
974
5/6
✓ Branch 3 → 4 taken 1871 times.
✓ Branch 3 → 7 taken 148 times.
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 7 taken 1871 times.
✓ Branch 8 → 9 taken 148 times.
✓ Branch 8 → 10 taken 1871 times.
2019 const char* AVSValue::AsString2(const char* def) const { _ASSERTE(IsString()||!Defined()); return IsString() ? string : def; }
975 2019 const char* AVSValue::AsString(const char* def) const { return AVSValue::AsString2(def); }
976
977 PFunction AVSValue::AsFunction() const { _ASSERTE(IsFunction()); return IsFunction() ? function : 0; }
978
979
2/4
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 56 times.
✓ Branch 6 → 7 taken 56 times.
✗ Branch 6 → 8 not taken.
56 int AVSValue::ArraySize() const { _ASSERTE(IsArray()) ; return IsArray() ? array_size : 1; }
980
981 1022 const AVSValue& AVSValue::operator[](int index) const { return OPERATOR_INDEX(index); }
982 1022 const AVSValue& AVSValue::OPERATOR_INDEX(int index) const {
983
3/6
✓ Branch 3 → 4 taken 1022 times.
✗ Branch 3 → 7 not taken.
✓ Branch 4 → 5 taken 1022 times.
✗ Branch 4 → 7 not taken.
✓ Branch 5 → 6 taken 1022 times.
✗ Branch 5 → 7 not taken.
1022 _ASSERTE(IsArray() && index>=0 && index<array_size);
984
3/6
✓ Branch 9 → 10 taken 1022 times.
✗ Branch 9 → 13 not taken.
✓ Branch 10 → 11 taken 1022 times.
✗ Branch 10 → 13 not taken.
✓ Branch 11 → 12 taken 1022 times.
✗ Branch 11 → 13 not taken.
1022 return (IsArray() && index>=0 && index<array_size) ? array[index] : *this;
985 }
986
987 // This Assign can deep-copy array elements
988 // For compatibility interface, we use Assign2 through CONSTRUCTOR10
989 784766 void AVSValue::Assign(const AVSValue* src, bool init) {
990 784766 Assign2(src, init, false);
991 784766 }
992
993 784766 void AVSValue::Assign2(const AVSValue* src, bool init, bool no_deep_arrays) {
994
5/6
✓ Branch 3 → 4 taken 363 times.
✓ Branch 3 → 6 taken 784403 times.
✓ Branch 4 → 5 taken 363 times.
✗ Branch 4 → 6 not taken.
✓ Branch 7 → 8 taken 363 times.
✓ Branch 7 → 9 taken 784403 times.
784766 if (src->IsClip() && src->clip)
995 363 src->clip->AddRef();
996
2/6
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 13 taken 784766 times.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 784766 times.
784766 if (src->IsFunction() && src->function)
997 src->function->AddRef();
998
999 // The left side of the assignment ("this") will be overwritten by "src",
1000 // so it should be released or freed if necessary.
1001 // The relevant properties must be released/dereferenced at the end:
1002 // clip, array, function, double_pt_ptr and longlong_ptr
1003 // Since they share the same pointer, saving (void*)clip would do it;
1004
5/6
✓ Branch 16 → 17 taken 270756 times.
✓ Branch 16 → 21 taken 514010 times.
✓ Branch 18 → 19 taken 12 times.
✓ Branch 18 → 21 taken 270744 times.
✓ Branch 19 → 20 taken 12 times.
✗ Branch 19 → 21 not taken.
784766 const bool shouldReleaseClip = !init && IsClip() && clip;
1005
3/6
✓ Branch 22 → 23 taken 270756 times.
✓ Branch 22 → 27 taken 514010 times.
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 27 taken 270756 times.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 27 not taken.
784766 const bool shouldReleaseFunction = !init && IsFunction() && function;
1006
3/8
✓ Branch 28 → 29 taken 270756 times.
✓ Branch 28 → 34 taken 514010 times.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 34 taken 270756 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 34 not taken.
✗ Branch 32 → 33 not taken.
✗ Branch 32 → 34 not taken.
784766 const bool shouldReleaseArray = !init && IsArray() && array && !no_deep_arrays;
1007 #if !(UINTPTR_MAX >= 0xffffffffffffffff)
1008 const bool shouldReleaseDouble = !init && type == 'd' && double_pt_ptr;
1009 const bool shouldReleaseLong = !init && type == 'l' && longlong_ptr;
1010 #endif
1011 784766 void* prev_pointer_to_release = (void*)clip;
1012
1013 // common fields
1014 784766 this->type = src->type;
1015 784766 this->array_size = src->array_size;
1016
1017 // no_deep_arrays: compatibility for AVS2.5: don't free or deep copy array elements!
1018
5/6
✓ Branch 36 → 37 taken 21 times.
✓ Branch 36 → 39 taken 784745 times.
✓ Branch 37 → 38 taken 21 times.
✗ Branch 37 → 39 not taken.
✓ Branch 40 → 41 taken 21 times.
✓ Branch 40 → 59 taken 784745 times.
784766 if (src->IsArray() && !no_deep_arrays)
1019 {
1020 // Delay releasing the previous array to avoid the args = args[0] case.
1021 // If an existing array were freed before this point, it would break the
1022 // value = value[x] case where the source value[x] is not an array.
1023 // Even for size == 0, this returns a valid pointer.
1024
5/18
✓ Branch 41 → 42 taken 21 times.
✗ Branch 41 → 43 not taken.
✓ Branch 46 → 47 taken 83 times.
✗ Branch 46 → 71 not taken.
✓ Branch 48 → 46 taken 83 times.
✓ Branch 48 → 49 taken 21 times.
✗ Branch 49 → 50 not taken.
✓ Branch 49 → 54 taken 21 times.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
✗ Branch 71 → 72 not taken.
✗ Branch 71 → 75 not taken.
✗ Branch 73 → 74 not taken.
✗ Branch 73 → 75 not taken.
✗ Branch 76 → 77 not taken.
✗ Branch 76 → 81 not taken.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
104 AVSValue* tmp = new AVSValue[array_size];
1025
2/2
✓ Branch 57 → 55 taken 83 times.
✓ Branch 57 → 58 taken 21 times.
104 for (int i = 0; i < array_size; i++)
1026 83 tmp[i].Assign(&src->array[i], true); // init from source
1027 21 array = tmp;
1028 }
1029 #if !(UINTPTR_MAX >= 0xffffffffffffffff)
1030 // 32 bit Avisynth: new 64 bit types are specially treated
1031 else if (this->type == 'l') {
1032 const uint64_t l = *src->longlong_ptr;
1033 this->longlong_ptr = new int64_t;
1034 *this->longlong_ptr = l;
1035 }
1036 else if (this->type == 'd') {
1037 const double d = *src->double_pt_ptr;
1038 this->double_pt_ptr = new double;
1039 *this->double_pt_ptr = d;
1040 }
1041 #endif
1042 else {
1043 784745 this->clip = (IClip*)((void*)src->clip);
1044 // "clip" is the largest member of the union, making sure we copy everything
1045 }
1046
1047
2/2
✓ Branch 60 → 61 taken 12 times.
✓ Branch 60 → 62 taken 784754 times.
784766 if (shouldReleaseClip)
1048 12 ((IClip*)prev_pointer_to_release)->Release();
1049
1/2
✗ Branch 62 → 63 not taken.
✓ Branch 62 → 64 taken 784766 times.
784766 if (shouldReleaseFunction)
1050 ((IFunction*)prev_pointer_to_release)->Release();
1051
1/2
✗ Branch 64 → 65 not taken.
✓ Branch 64 → 70 taken 784766 times.
784766 if (shouldReleaseArray)
1052 delete[](AVSValue*)(prev_pointer_to_release);
1053 // deallocates former array memory + calls destructor of AVSValue elements
1054 #if !(UINTPTR_MAX >= 0xffffffffffffffff)
1055 if (shouldReleaseDouble)
1056 delete (double*)prev_pointer_to_release;
1057 else if (shouldReleaseLong)
1058 delete (int64_t*)prev_pointer_to_release;
1059 #endif
1060 784766 }
1061
1062 AvsValueType AVSValue::GetType() const { return (AvsValueType)type; }
1063
1064 // end class AVSValue
1065
1066 /**********************************************************************/
1067
1068 PFunction::PFunction() { CONSTRUCTOR0(); }
1069 void PFunction::CONSTRUCTOR0() { Init(0); }
1070
1071 PFunction::PFunction(IFunction* p) { CONSTRUCTOR1(p); }
1072 void PFunction::CONSTRUCTOR1(IFunction* p) { Init(p); }
1073
1074 PFunction::PFunction(const PFunction& p) { CONSTRUCTOR2(p); }
1075 void PFunction::CONSTRUCTOR2(const PFunction& p) { Init(p.e); }
1076
1077 PFunction& PFunction::operator=(IFunction* p) { return OPERATOR_ASSIGN0(p); }
1078 PFunction& PFunction::OPERATOR_ASSIGN0(IFunction* p) { Set(p); return *this; }
1079
1080 PFunction& PFunction::operator=(const PFunction& p) { return OPERATOR_ASSIGN1(p); }
1081 PFunction& PFunction::OPERATOR_ASSIGN1(const PFunction& p) { Set(p.e); return *this; }
1082
1083 PFunction::~PFunction() { DESTRUCTOR(); }
1084 void PFunction::DESTRUCTOR() { if (e) e->Release(); }
1085
1086 IFunction * PFunction::GetPointerWithAddRef() const { if (e) e->AddRef(); return e; }
1087 void PFunction::Init(IFunction* p) { e = p; if (e) e->AddRef(); }
1088 void PFunction::Set(IFunction* p) { if (p) p->AddRef(); if (e) e->Release(); e = p; }
1089
1090 PDevice::PDevice() { CONSTRUCTOR0(); }
1091 void PDevice::CONSTRUCTOR0() { e = 0; }
1092
1093 PDevice::PDevice(Device* p) { CONSTRUCTOR1(p); }
1094 void PDevice::CONSTRUCTOR1(Device* p) { e = p; }
1095
1096 PDevice::PDevice(const PDevice& p) { CONSTRUCTOR2(p); }
1097 void PDevice::CONSTRUCTOR2(const PDevice& p) { e = p.e; }
1098
1099 PDevice& PDevice::operator=(Device* p) { return OPERATOR_ASSIGN0(p); }
1100 PDevice& PDevice::OPERATOR_ASSIGN0(Device* p) { e = p; return *this; }
1101
1102 PDevice& PDevice::operator=(const PDevice& p) { return OPERATOR_ASSIGN1(p); }
1103 PDevice& PDevice::OPERATOR_ASSIGN1(const PDevice& p) { e = p.e; return *this; }
1104
1105 PDevice::~PDevice() { }
1106 void PDevice::DESTRUCTOR() { }
1107
1108 AvsDeviceType PDevice::GetType() const { return e ? e->device_type : DEV_TYPE_NONE; }
1109 int PDevice::GetId() const { return e ? e->device_id : -1; }
1110 int PDevice::GetIndex() const { return e ? e->device_index : -1; }
1111 const char* PDevice::GetName() const { return e ? e->GetName() : nullptr; }
1112
1113 INeoEnv* __stdcall GetAvsEnv(IScriptEnvironment* env) { return static_cast<InternalEnvironment*>(env); }
1114
1115 PNeoEnv::PNeoEnv(IScriptEnvironment* env) : p(static_cast<InternalEnvironment*>(env)) { }
1116 PNeoEnv::operator IScriptEnvironment2* () { return static_cast<InternalEnvironment*>(p); }
1117
1118 /**********************************************************************/
1119
1120 static const AVS_Linkage avs_linkage = { // struct AVS_Linkage {
1121
1122 sizeof(AVS_Linkage), // int Size;
1123
1124 /***************************************************************************************************************/
1125 // struct VideoInfo
1126 &VideoInfo::HasVideo, // bool (VideoInfo::*HasVideo)() const;
1127 &VideoInfo::HasAudio, // bool (VideoInfo::*HasAudio)() const;
1128 &VideoInfo::IsRGB, // bool (VideoInfo::*IsRGB)() const;
1129 &VideoInfo::IsRGB24, // bool (VideoInfo::*IsRGB24)() const;
1130 &VideoInfo::IsRGB32, // bool (VideoInfo::*IsRGB32)() const;
1131 &VideoInfo::IsYUV, // bool (VideoInfo::*IsYUV)() const;
1132 &VideoInfo::IsYUY2, // bool (VideoInfo::*IsYUY2)() const;
1133 &VideoInfo::IsYV24, // bool (VideoInfo::*IsYV24)() const;
1134 &VideoInfo::IsYV16, // bool (VideoInfo::*IsYV16)() const;
1135 &VideoInfo::IsYV12, // bool (VideoInfo::*IsYV12)() const;
1136 &VideoInfo::IsYV411, // bool (VideoInfo::*IsYV411)() const;
1137 &VideoInfo::IsY8, // bool (VideoInfo::*IsY8)() const;
1138 &VideoInfo::IsColorSpace, // bool (VideoInfo::*IsColorSpace)(int c_space) const;
1139 &VideoInfo::Is, // bool (VideoInfo::*Is)(int property) const;
1140 &VideoInfo::IsPlanar, // bool (VideoInfo::*IsPlanar)() const;
1141 &VideoInfo::IsFieldBased, // bool (VideoInfo::*IsFieldBased)() const;
1142 &VideoInfo::IsParityKnown, // bool (VideoInfo::*IsParityKnown)() const;
1143 &VideoInfo::IsBFF, // bool (VideoInfo::*IsBFF)() const;
1144 &VideoInfo::IsTFF, // bool (VideoInfo::*IsTFF)() const;
1145 &VideoInfo::IsVPlaneFirst, // bool (VideoInfo::*IsVPlaneFirst)() const;
1146 &VideoInfo::BytesFromPixels, // int (VideoInfo::*BytesFromPixels)(int pixels) const;
1147 &VideoInfo::RowSize, // int (VideoInfo::*RowSize)(int plane) const;
1148 &VideoInfo::BMPSize, // int (VideoInfo::*BMPSize)() const;
1149 &VideoInfo::AudioSamplesFromFrames, // int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const;
1150 &VideoInfo::FramesFromAudioSamples, // int (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const;
1151 &VideoInfo::AudioSamplesFromBytes, // int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const;
1152 &VideoInfo::BytesFromAudioSamples, // int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const;
1153 &VideoInfo::AudioChannels, // int (VideoInfo::*AudioChannels)() const;
1154 &VideoInfo::SampleType, // int (VideoInfo::*SampleType)() const;
1155 &VideoInfo::IsSampleType, // bool (VideoInfo::*IsSampleType)(int testtype) const;
1156 &VideoInfo::SamplesPerSecond, // int (VideoInfo::*SamplesPerSecond)() const;
1157 &VideoInfo::BytesPerAudioSample, // int (VideoInfo::*BytesPerAudioSample)() const;
1158 &VideoInfo::SetFieldBased, // void (VideoInfo::*SetFieldBased)(bool isfieldbased);
1159 &VideoInfo::Set, // void (VideoInfo::*Set)(int property);
1160 &VideoInfo::Clear, // void (VideoInfo::*Clear)(int property);
1161 &VideoInfo::GetPlaneWidthSubsampling, // int (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const;
1162 &VideoInfo::GetPlaneHeightSubsampling, // int (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const;
1163 &VideoInfo::BitsPerPixel, // int (VideoInfo::*BitsPerPixel)() const;
1164 &VideoInfo::BytesPerChannelSample, // int (VideoInfo::*BytesPerChannelSample)() const;
1165 &VideoInfo::SetFPS, // void (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator)
1166 &VideoInfo::MulDivFPS, // void (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor)
1167 &VideoInfo::IsSameColorspace, // bool (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const;
1168 // end struct VideoInfo
1169 /***************************************************************************************************************/
1170 // class VideoFrameBuffer
1171 &VideoFrameBuffer::GetReadPtr, // const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const;
1172 &VideoFrameBuffer::GetWritePtr, // BYTE* (VideoFrameBuffer::*VFBGetWritePtr)();
1173 &VideoFrameBuffer::GetDataSize, // int (VideoFrameBuffer::*GetDataSize)() const;
1174 &VideoFrameBuffer::GetSequenceNumber, // int (VideoFrameBuffer::*GetSequenceNumber)() const;
1175 &VideoFrameBuffer::GetRefcount, // int (VideoFrameBuffer::*GetRefcount)() const;
1176 // end class VideoFrameBuffer
1177 /***************************************************************************************************************/
1178 // class VideoFrame
1179 &VideoFrame::GetPitch, // int (VideoFrame::*GetPitch)(int plane) const;
1180 &VideoFrame::GetRowSize, // int (VideoFrame::*GetRowSize)(int plane) const;
1181 &VideoFrame::GetHeight, // int (VideoFrame::*GetHeight)(int plane) const;
1182 &VideoFrame::GetFrameBuffer, // VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const;
1183 &VideoFrame::GetOffset, // int (VideoFrame::*GetOffset)(int plane) const;
1184 &VideoFrame::GetReadPtr, // const BYTE* (VideoFrame::*VFGetReadPtr)(int plane) const;
1185 &VideoFrame::IsWritable, // bool (VideoFrame::*IsWritable)() const;
1186 &VideoFrame::GetWritePtr, // BYTE* (VideoFrame::*VFGetWritePtr)(int plane) const;
1187 &VideoFrame::DESTRUCTOR, // void (VideoFrame::*VideoFrame_DESTRUCTOR)();
1188 // end class VideoFrame
1189 /***************************************************************************************************************/
1190 // class IClip
1191 // /* nothing */
1192 // end class IClip
1193 /***************************************************************************************************************/
1194 // class PClip
1195 &PClip::CONSTRUCTOR0, // void (PClip::*PClip_CONSTRUCTOR0)();
1196 &PClip::CONSTRUCTOR1, // void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x);
1197 &PClip::CONSTRUCTOR2, // void (PClip::*PClip_CONSTRUCTOR2)(IClip* x);
1198 &PClip::OPERATOR_ASSIGN0, // void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x);
1199 &PClip::OPERATOR_ASSIGN1, // void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x);
1200 &PClip::DESTRUCTOR, // void (PClip::*PClip_DESTRUCTOR)();
1201 // end class PClip
1202 /***************************************************************************************************************/
1203 // class PVideoFrame
1204 &PVideoFrame::CONSTRUCTOR0, // void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)();
1205 &PVideoFrame::CONSTRUCTOR1, // void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x);
1206 &PVideoFrame::CONSTRUCTOR2, // void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x);
1207 &PVideoFrame::OPERATOR_ASSIGN0, // void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0(VideoFrame* x);
1208 &PVideoFrame::OPERATOR_ASSIGN1, // void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1(const PVideoFrame& x);
1209 &PVideoFrame::DESTRUCTOR, // void (PVideoFrame::*PVideoFrame_DESTRUCTOR)();
1210 // end class PVideoFrame
1211 /***************************************************************************************************************/
1212 // class AVSValue
1213 &AVSValue::CONSTRUCTOR0, // void (AVSValue::*AVSValue_CONSTRUCTOR0)();
1214 &AVSValue::CONSTRUCTOR1, // void (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c);
1215 &AVSValue::CONSTRUCTOR2, // void (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c);
1216 &AVSValue::CONSTRUCTOR3, // void (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b);
1217 &AVSValue::CONSTRUCTOR4, // void (AVSValue::*AVSValue_CONSTRUCTOR4)(int i);
1218 &AVSValue::CONSTRUCTOR5, // void (AVSValue::*AVSValue_CONSTRUCTOR5)(float f);
1219 &AVSValue::CONSTRUCTOR6, // void (AVSValue::*AVSValue_CONSTRUCTOR6)(double f);
1220 &AVSValue::CONSTRUCTOR7, // void (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s);
1221 &AVSValue::CONSTRUCTOR8, // void (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int
1222 &AVSValue::CONSTRUCTOR9, // void (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v);
1223 &AVSValue::DESTRUCTOR, // void (AVSValue::*AVSValue_DESTRUCTOR)();
1224 &AVSValue::OPERATOR_ASSIGN, // AVSValue& (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v);
1225 &AVSValue::OPERATOR_INDEX, // const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const;
1226 &AVSValue::Defined, // bool (AVSValue::*Defined)() const;
1227 &AVSValue::IsClip, // bool (AVSValue::*IsClip)() const;
1228 &AVSValue::IsBool, // bool (AVSValue::*IsBool)() const;
1229 &AVSValue::IsInt, // bool (AVSValue::*IsInt)() const;
1230 &AVSValue::IsFloat, // bool (AVSValue::*IsFloat)() const;
1231 &AVSValue::IsString, // bool (AVSValue::*IsString)() const;
1232 &AVSValue::IsArray, // bool (AVSValue::*IsArray)() const;
1233 &AVSValue::AsClip, // PClip (AVSValue::*AsClip)() const;
1234 &AVSValue::AsBool1, // bool (AVSValue::*AsBool1)() const;
1235 &AVSValue::AsInt1, // int (AVSValue::*AsInt1)() const;
1236 &AVSValue::AsString1, // const char* (AVSValue::*AsString1)() const;
1237 &AVSValue::AsFloat1, // double (AVSValue::*AsFloat1)() const; // AsDouble1
1238 &AVSValue::AsBool2, // bool (AVSValue::*AsBool2)(bool def) const;
1239 &AVSValue::AsInt2, // int (AVSValue::*AsInt2)(int def) const;
1240 &AVSValue::AsDblDef, // double (AVSValue::*AsDblDef)(double def) const; // AsDouble2
1241 &AVSValue::AsFloat2, // double (AVSValue::*AsFloat2)(float def) const;
1242 &AVSValue::AsString2, // const char* (AVSValue::*AsString2)(const char* def) const;
1243 &AVSValue::ArraySize, // int (AVSValue::*ArraySize)() const;
1244 &AVSValue::IsLongStrict, // bool (AVSValue::*IsLongStrict)() const; // v11
1245 &AVSValue::IsFloatfStrict, // bool (AVSValue::*IsFloatfStrict() const; // v11
1246 &AVSValue::AsLong1, // int64_t (AVSValue::*AsLong1)() const; // v11
1247 &AVSValue::AsLong2, // int64_t (AVSValue::*AsLong2)(int64_t def) const; // v11
1248 &AVSValue::CONSTRUCTOR12, // void (AVSValue::*AVSValue_CONSTRUCTOR12)(int64_ l); // v11
1249 // end class AVSValue
1250 /**********************************************************************/
1251 // a single { nullptr } initializes the whole placeholder array
1252 { nullptr }, // void (VideoInfo::* reserved[27])(); // reserved for AVS classic
1253 /**********************************************************************/
1254 // AviSynth+ additions
1255 &VideoInfo::NumComponents, // int (VideoInfo::*NumChannels)() const;
1256 &VideoInfo::ComponentSize, // int (VideoInfo::*ComponentSize)() const;
1257 &VideoInfo::BitsPerComponent, // int (VideoInfo::*BitsPerComponent)() const;
1258 &VideoInfo::Is444, // bool (VideoInfo::*Is444)() const;
1259 &VideoInfo::Is422, // bool (VideoInfo::*Is422)() const;
1260 &VideoInfo::Is420, // bool (VideoInfo::*Is420)() const;
1261 &VideoInfo::IsY, // bool (VideoInfo::*IsY)() const;
1262 &VideoInfo::IsRGB48, // bool (VideoInfo::*IsRGB48)() const;
1263 &VideoInfo::IsRGB64, // bool (VideoInfo::*IsRGB64)() const;
1264 &VideoInfo::IsYUVA, // bool (VideoInfo::*IsYUVA)() const;
1265 &VideoInfo::IsPlanarRGB, // bool (VideoInfo::*IsPlanarRGB)() const;
1266 &VideoInfo::IsPlanarRGBA, // bool (VideoInfo::*IsPlanarRGBA)() const;
1267 /**********************************************************************/
1268 // Frame properties
1269 &VideoFrame::getProperties, // AVSMap& (VideoFrame::* getProperties)();
1270 &VideoFrame::getConstProperties, // const AVSMap& (VideoFrame::* getConstProperties)();
1271 &VideoFrame::setProperties, // void (VideoFrame::* setProperties)(const AVSMap& properties);
1272
1273 // PFunction (Neo)
1274 &AVSValue::CONSTRUCTOR11,
1275 &AVSValue::IsFunction,
1276 &PFunction::CONSTRUCTOR0,
1277 &PFunction::CONSTRUCTOR1,
1278 &PFunction::CONSTRUCTOR2,
1279 &PFunction::OPERATOR_ASSIGN0,
1280 &PFunction::OPERATOR_ASSIGN1,
1281 &PFunction::DESTRUCTOR,
1282 // end PFunction
1283
1284 // VideoFrame extras (Neo)
1285 &VideoFrame::CheckMemory,
1286 &VideoFrame::GetDevice,
1287
1288 // class PDevice (Neo)
1289 &PDevice::CONSTRUCTOR0,
1290 &PDevice::CONSTRUCTOR1,
1291 &PDevice::CONSTRUCTOR2,
1292 &PDevice::OPERATOR_ASSIGN0,
1293 &PDevice::OPERATOR_ASSIGN1,
1294 &PDevice::DESTRUCTOR,
1295 &PDevice::GetType,
1296 &PDevice::GetId,
1297 &PDevice::GetIndex,
1298 &PDevice::GetName,
1299 // end class PDevice
1300
1301 // V9
1302 &VideoFrame::IsPropertyWritable,
1303
1304 // V10
1305 &VideoFrame::GetPixelType, // int (VideoFrame::*VideoFrame_GetPixelType)() const;
1306 &VideoFrame::AmendPixelType, // void (VideoFrame::*VideoFrame_AmendPixelType)();
1307 &VideoFrameBuffer::DESTRUCTOR, // void (VideoFrameBuffer::*VideoFrameBuffer_DESTRUCTOR)();
1308 &AVSValue::GetType, // AvsValueType (AVSValue::*AVSValue_GetType)() const;
1309
1310 // V10.1
1311 &VideoInfo::IsChannelMaskKnown, // bool (VideoInfo::*IsChannelMaskKnown)() const;
1312 &VideoInfo::SetChannelMask, // void (VideoInfo::*SetChannelMask)();
1313 &VideoInfo::GetChannelMask, // int (VideoInfo::*GetChannelMask)() const;
1314
1315 // a single { nullptr } initializes the whole placeholder array
1316 { nullptr }, // void (VideoInfo::* reserved2[64 - 31])(); // Reserve pointer space for Avisynth+
1317
1318 /**********************************************************************/
1319 // AviSynth Neo additions
1320 &GetAvsEnv
1321 // Most Neo linkage entries are moved to standard avs+ place.
1322 // frame property logic has been replaced entirely
1323
1324 // this part should be identical with struct AVS_Linkage in avisynth.h
1325
1326 /**********************************************************************/
1327 }; // }
1328
1329 extern __declspec(dllexport) const AVS_Linkage* const AVS_linkage = &avs_linkage;
1330
1331
1332 /**********************************************************************/
1333 // in UserPlugin.cpp
1334 #if 0
1335
1336 #include "avisynth.h"
1337
1338 /* New 2.6 requirment!!! */
1339 // Declare and initialise server pointers static storage.
1340 const AVS_Linkage *AVS_linkage = 0;
1341
1342 /* New 2.6 requirment!!! */
1343 // DLL entry point called from LoadPlugin() to setup a user plugin.
1344 extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit3(IScriptEnvironment* env, const AVS_Linkage* const vectors) {
1345
1346 /* New 2.6 requirment!!! */
1347 // Save the server pointers.
1348 AVS_linkage = vectors;
1349
1350 // Add the name of our function
1351 env->AddFunction("Plugin", "c", Create_Plugin, 0);
1352
1353 // Return plugin text identifier.
1354 return "Plugin";
1355 }
1356
1357 #endif
1358 /**********************************************************************/
1359
1360