filters/combine.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 __Combine_H__ | ||
| 36 | #define __Combine_H__ | ||
| 37 | |||
| 38 | #include <avisynth.h> | ||
| 39 | #include <vector> | ||
| 40 | |||
| 41 | /******************************************************************** | ||
| 42 | ********************************************************************/ | ||
| 43 | class MultiOverlay : public IClip | ||
| 44 | /** | ||
| 45 | * Class to Overlay multiple clips in one pass | ||
| 46 | **/ | ||
| 47 | { | ||
| 48 | private: | ||
| 49 | std::vector<PClip> children; | ||
| 50 | std::vector<int> positions; | ||
| 51 | VideoInfo vi; | ||
| 52 | |||
| 53 | public: | ||
| 54 | MultiOverlay(const std::vector<PClip>& child_array, const std::vector<int>& position_array, IScriptEnvironment* env); | ||
| 55 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 56 | |||
| 57 | ✗ | inline void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { | |
| 58 | ✗ | children[0]->GetAudio(buf, start, count, env); | |
| 59 | ✗ | } | |
| 60 | |||
| 61 | ✗ | inline const VideoInfo& __stdcall GetVideoInfo() { | |
| 62 | ✗ | return vi; | |
| 63 | } | ||
| 64 | |||
| 65 | ✗ | inline bool __stdcall GetParity(int n) { | |
| 66 | ✗ | return children[0]->GetParity(n); | |
| 67 | } | ||
| 68 | |||
| 69 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) { | |
| 70 | AVS_UNUSED(frame_range); | ||
| 71 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 72 | } | ||
| 73 | |||
| 74 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 75 | }; | ||
| 76 | |||
| 77 | |||
| 78 | |||
| 79 | class StackVertical : public IClip | ||
| 80 | /** | ||
| 81 | * Class to stack clips vertically | ||
| 82 | **/ | ||
| 83 | { | ||
| 84 | private: | ||
| 85 | std::vector<PClip> children; | ||
| 86 | VideoInfo vi; | ||
| 87 | int firstchildindex; | ||
| 88 | |||
| 89 | public: | ||
| 90 | StackVertical(const std::vector<PClip>& child_array, IScriptEnvironment* env); | ||
| 91 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 92 | |||
| 93 | ✗ | inline void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { | |
| 94 | ✗ | children[firstchildindex]->GetAudio(buf, start, count, env); | |
| 95 | ✗ | } | |
| 96 | |||
| 97 | ✗ | inline const VideoInfo& __stdcall GetVideoInfo() { | |
| 98 | ✗ | return vi; | |
| 99 | } | ||
| 100 | |||
| 101 | ✗ | inline bool __stdcall GetParity(int n) { | |
| 102 | ✗ | return children[firstchildindex]->GetParity(n); | |
| 103 | } | ||
| 104 | |||
| 105 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) { | |
| 106 | AVS_UNUSED(frame_range); | ||
| 107 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 108 | } | ||
| 109 | |||
| 110 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 111 | }; | ||
| 112 | |||
| 113 | |||
| 114 | |||
| 115 | class StackHorizontal : public IClip | ||
| 116 | /** | ||
| 117 | * Class to stack clips vertically | ||
| 118 | **/ | ||
| 119 | { | ||
| 120 | private: | ||
| 121 | std::vector<PClip> children; | ||
| 122 | VideoInfo vi; | ||
| 123 | |||
| 124 | public: | ||
| 125 | StackHorizontal(const std::vector<PClip>& child_array, IScriptEnvironment* env); | ||
| 126 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 127 | |||
| 128 | ✗ | inline void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { | |
| 129 | ✗ | children[0]->GetAudio(buf, start, count, env); | |
| 130 | ✗ | } | |
| 131 | |||
| 132 | ✗ | inline const VideoInfo& __stdcall GetVideoInfo() { | |
| 133 | ✗ | return vi; | |
| 134 | } | ||
| 135 | |||
| 136 | ✗ | inline bool __stdcall GetParity(int n) { | |
| 137 | ✗ | return children[0]->GetParity(n); | |
| 138 | } | ||
| 139 | |||
| 140 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) { | |
| 141 | AVS_UNUSED(frame_range); | ||
| 142 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 143 | } | ||
| 144 | |||
| 145 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 146 | }; | ||
| 147 | |||
| 148 | |||
| 149 | |||
| 150 | |||
| 151 | class ShowFiveVersions : public IClip | ||
| 152 | /** | ||
| 153 | * Class to show every pulldown combination | ||
| 154 | **/ | ||
| 155 | { | ||
| 156 | public: | ||
| 157 | ShowFiveVersions(PClip* children, IScriptEnvironment* env); | ||
| 158 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 159 | |||
| 160 | ✗ | inline void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) | |
| 161 | ✗ | { child[0]->GetAudio(buf, start, count, env); } | |
| 162 | 1 | inline const VideoInfo& __stdcall GetVideoInfo() | |
| 163 | 1 | { return vi; } | |
| 164 | ✗ | inline bool __stdcall GetParity(int n) | |
| 165 | ✗ | { return child[0]->GetParity(n); } | |
| 166 | ✗ | int __stdcall SetCacheHints(int cachehints,int frame_range) { | |
| 167 | AVS_UNUSED(cachehints); | ||
| 168 | AVS_UNUSED(frame_range); | ||
| 169 | ✗ | return 0; | |
| 170 | }; | ||
| 171 | |||
| 172 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 173 | |||
| 174 | private: | ||
| 175 | PClip child[5]; | ||
| 176 | VideoInfo vi; | ||
| 177 | }; | ||
| 178 | |||
| 179 | |||
| 180 | |||
| 181 | class Animate : public IClip | ||
| 182 | /** | ||
| 183 | * Class to allow recursive animation of multiple clips (see docs) * | ||
| 184 | **/ | ||
| 185 | { | ||
| 186 | enum { cache_size = 3 }; | ||
| 187 | PClip cache[cache_size]; | ||
| 188 | int cache_stage[cache_size]; | ||
| 189 | const int first, last; | ||
| 190 | std::vector<AVSValue> args_before; | ||
| 191 | AVSValue *args_after, *args_now; | ||
| 192 | int num_args; | ||
| 193 | const char* name; | ||
| 194 | bool range_limit; | ||
| 195 | AVSValue custom_fn; | ||
| 196 | public: | ||
| 197 | Animate( PClip context, int _first, int _last, const char* _name, const AVSValue* _args_before, | ||
| 198 | const AVSValue* _args_after, int _num_args, bool _range_limit, const AVSValue& _custom_fn, IScriptEnvironment* env ); | ||
| 199 | ✗ | virtual ~Animate() { } | |
| 200 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env); | ||
| 201 | void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env); | ||
| 202 | |||
| 203 | ✗ | inline const VideoInfo& __stdcall GetVideoInfo() | |
| 204 | ✗ | { return cache[0]->GetVideoInfo(); } | |
| 205 | bool __stdcall GetParity(int n); | ||
| 206 | |||
| 207 | ✗ | int __stdcall SetCacheHints(int cachehints,int frame_range) { | |
| 208 | AVS_UNUSED(frame_range); | ||
| 209 | ✗ | switch (cachehints) | |
| 210 | { | ||
| 211 | ✗ | case CACHE_GET_MTMODE: | |
| 212 | ✗ | return MT_MULTI_INSTANCE; | |
| 213 | } | ||
| 214 | ✗ | return 0; // We do not pass cache requests upwards. | |
| 215 | }; | ||
| 216 | |||
| 217 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 218 | static AVSValue __cdecl Create_Range(AVSValue args, void*, IScriptEnvironment* env); | ||
| 219 | }; | ||
| 220 | |||
| 221 | |||
| 222 | #endif // __Combine_H__ | ||
| 223 |