GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 20.0% 4 / 0 / 20
Functions: 16.7% 1 / 0 / 6
Branches: 11.1% 2 / 0 / 18

filters/edit.h
Line Branch Exec Source
1 // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al.
2 // http://avisynth.nl
3
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit
17 // http://www.gnu.org/copyleft/gpl.html .
18 //
19 // Linking Avisynth statically or dynamically with other modules is making a
20 // combined work based on Avisynth. Thus, the terms and conditions of the GNU
21 // General Public License cover the whole combination.
22 //
23 // As a special exception, the copyright holders of Avisynth give you
24 // permission to link Avisynth with independent modules that communicate with
25 // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license
26 // terms of these independent modules, and to copy and distribute the
27 // resulting combined work under terms of your choice, provided that
28 // every copy of the combined work is accompanied by a complete copy of
29 // the source code of Avisynth (the version of Avisynth used to produce the
30 // combined work), being distributed under the terms of the GNU General
31 // Public License plus this exception. An independent module is a module
32 // which is not derived from or based on Avisynth, such as 3rd-party filters,
33 // import and export plugins, or graphical user interfaces.
34
35 #ifndef __Edit_H__
36 #define __Edit_H__
37
38 #include <avisynth.h>
39 #include "../core/internal.h"
40
41 /********************************************************************
42 ********************************************************************/
43
44 class Trim : public GenericVideoFilter
45 /**
46 * Class to select a range of frames from a longer clip
47 **/
48 {
49 public:
50 typedef enum { Invalid = 0, Default, Length, End } trim_mode_e;
51
52 Trim(int _firstframe, int _lastframe, bool _padaudio, PClip _child, trim_mode_e mode, bool _cache, IScriptEnvironment* env);
53 Trim(double starttime, double endtime, PClip _child, trim_mode_e mode, bool _cache, IScriptEnvironment* env);
54 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
55 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) override;
56 bool __stdcall GetParity(int n) override;
57
58 1 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
59 AVS_UNUSED(frame_range);
60
1/4
✓ Branch 2 → 3 taken 1 time.
✗ Branch 2 → 7 not taken.
✗ Branch 2 → 8 not taken.
✗ Branch 2 → 16 not taken.
1 switch (cachehints) {
61 1 case CACHE_DONT_CACHE_ME:
62
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 1 time.
1 return cache ? 0 : 1; // adaptively cache-able
63 case CACHE_GET_MTMODE:
64 return MT_NICE_FILTER;
65 case CACHE_GET_DEV_TYPE:
66 return (child->GetVersion() >= 5) ? child->SetCacheHints(CACHE_GET_DEV_TYPE, 0) : 0;
67 default:
68 return 0;
69 }
70 }
71
72 static AVSValue __cdecl Create(AVSValue args, void* mode, IScriptEnvironment* env);
73 static AVSValue __cdecl CreateA(AVSValue args, void* mode, IScriptEnvironment* env);
74
75 private:
76 int firstframe;
77 int64_t audio_offset;
78 bool cache;
79 };
80
81
82
83
84 class FreezeFrame : public GenericVideoFilter
85 /**
86 * Class to display a single frame for the duration of several
87 **/
88 {
89 public:
90 FreezeFrame(int _first, int _last, int _source, PClip _child);
91 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
92 bool __stdcall GetParity(int n) override;
93
94 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
95 AVS_UNUSED(frame_range);
96 return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
97 }
98
99 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
100
101 private:
102 const int first, last, source;
103 };
104
105
106
107
108 class DeleteFrame : public GenericVideoFilter
109 /**
110 * Class to delete a frame
111 **/
112 {
113 public:
114 DeleteFrame(int _frame, PClip _child);
115 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
116 bool __stdcall GetParity(int n) override;
117
118 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
119 AVS_UNUSED(frame_range);
120 return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
121 }
122
123 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
124
125 private:
126 const int frame;
127 };
128
129
130
131
132 class DuplicateFrame : public GenericVideoFilter
133 /**
134 * Class to duplicate a frame
135 **/
136 {
137 public:
138 DuplicateFrame(int _frame, PClip _child);
139 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
140 bool __stdcall GetParity(int n) override;
141
142 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
143 AVS_UNUSED(frame_range);
144 return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
145 }
146
147 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
148
149 private:
150 const int frame;
151 };
152
153
154
155
156 class Splice : public GenericVideoFilter
157 /**
158 * Class to splice together video clips
159 **/
160 {
161 public:
162 Splice(PClip _child1, PClip _child2, bool realign_sound, bool passCache, IScriptEnvironment* env);
163 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
164 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env);
165 bool __stdcall GetParity(int n);
166 int __stdcall SetCacheHints(int cachehints,int frame_range);
167
168 static AVSValue __cdecl CreateUnaligned(AVSValue args, void*, IScriptEnvironment* env);
169 static AVSValue __cdecl CreateAligned(AVSValue args, void*, IScriptEnvironment* env);
170 static AVSValue __cdecl CreateUnalignedNoCache(AVSValue args, void*, IScriptEnvironment* env);
171 static AVSValue __cdecl CreateAlignedNoCache(AVSValue args, void*, IScriptEnvironment* env);
172
173 private:
174 PClip child2;
175 int video_switchover_point;
176 int64_t audio_switchover_point;
177 const bool passCache;
178 int child_devs;
179 };
180
181
182
183
184 class Dissolve : public GenericVideoFilter
185 /**
186 * Class to smoothly transition from one video clip to another
187 **/
188 {
189 public:
190 Dissolve(PClip _child1, PClip _child2, int _overlap, double fps, IScriptEnvironment* env);
191 virtual ~Dissolve();
192 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
193 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env);
194 bool __stdcall GetParity(int n);
195
196 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
197
198 private:
199 PClip child2;
200 const int overlap;
201 int video_fade_start, video_fade_end;
202 int64_t audio_fade_start, audio_fade_end;
203 int audio_overlap;
204 BYTE* audbuffer;
205 size_t audbufsize;
206 int pixelsize;
207 int bits_per_pixel;
208 void EnsureBuffer(int minsize);
209 };
210
211
212
213
214 class AudioDub : public IClip {
215 /**
216 * Class to mux the audio track of one clip with the video of another
217 **/
218 public:
219 AudioDub(PClip child1, PClip child2, int mode, IScriptEnvironment* env);
220 const VideoInfo& __stdcall GetVideoInfo();
221 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
222 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env);
223 bool __stdcall GetParity(int n);
224 int __stdcall SetCacheHints(int cachehints,int frame_range);
225
226 static AVSValue __cdecl Create(AVSValue args, void* mode, IScriptEnvironment* env);
227
228 private:
229 /*const*/ PClip vchild, achild;
230 VideoInfo vi;
231 };
232
233
234
235
236 class Reverse : public GenericVideoFilter
237 /**
238 * Class to play a clip backwards
239 **/
240 {
241 public:
242 Reverse(PClip _child);
243 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
244 bool __stdcall GetParity(int n) override;
245 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) override;
246
247 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
248 AVS_UNUSED(frame_range);
249 return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
250 }
251
252 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
253 };
254
255
256
257
258 class Loop : public GenericVideoFilter {
259 /**
260 * Class to loop over a range of frames
261 **/
262 public:
263 Loop(PClip _child, int times, int _start, int _end, IScriptEnvironment* env);
264 PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override;
265 bool __stdcall GetParity(int n) override;
266 void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) override;
267
268 int __stdcall SetCacheHints(int cachehints, int frame_range) override {
269 AVS_UNUSED(frame_range);
270 return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0;
271 }
272
273 static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env);
274 private:
275 int frames, start, end;
276 int64_t aud_count, aud_start, aud_end;
277 int convert(int n);
278 };
279
280
281
282
283 /**** A few factory methods ****/
284
285 AVSValue __cdecl Create_Fade(AVSValue args, void* user_data, IScriptEnvironment* env);
286
287
288 #endif // __Edit_H__
289