GCC Code Coverage Report


Directory: avs_core/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 90.9% 10 / 0 / 11
Functions: 100.0% 9 / 0 / 9
Branches: -% 0 / 0 / 0

filters/overlay/overlayfunctions.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 // Overlay (c) 2003, 2004 by Klaus Post
36
37 #ifndef __Overlay_funcs_h
38 #define __Overlay_funcs_h
39
40 #include <avisynth.h>
41 #include <avs/minmax.h>
42 #include "imghelpers.h"
43 #include "blend_common.h"
44
45 enum {
46 OF_Blend = 0,
47 OF_Add,
48 OF_Subtract,
49 OF_Multiply,
50 OF_Chroma,
51 OF_Luma,
52 OF_Lighten,
53 OF_Darken,
54 OF_SoftLight,
55 OF_HardLight,
56 OF_Difference,
57 OF_Exclusion
58 };
59
60 class OverlayFunction {
61 public:
62 47 OverlayFunction() {
63 47 }
64 47 virtual ~OverlayFunction() {};
65 47 void setOpacity(int _opacity, float _opacity_f) { opacity = clamp(_opacity, 0, 256); inv_opacity = 256 - opacity; opacity_f = _opacity_f; inv_opacity_f = 1.0f - _opacity_f; }
66 47 void setEnv(IScriptEnvironment *_env) { env = _env;}
67 47 void setBitsPerPixel(int _bits_per_pixel) { bits_per_pixel = _bits_per_pixel; }
68 47 void setMode(int _of_mode) { of_mode = _of_mode; }
69 47 void setColorSpaceInfo(bool _rgb, bool _greyscale) { rgb = _rgb, greyscale = _greyscale; }
70 // vi: internal working format (currently always YUV444); pl: PLACEMENT_MPEG2 or PLACEMENT_MPEG1
71 47 void setSubsamplingInfo(const VideoInfo& vi, int pl) { vi_internal = vi; placement = pl; }
72 // greymask: Overlay "greymask" parameter — true when mask clip has only luma information.
73 47 void setGreyMask(bool gm) { greymask_mask = gm; }
74
75 virtual void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay) = 0;
76 virtual void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask) = 0;
77 protected:
78 int opacity;
79 int inv_opacity;
80 float opacity_f;
81 float inv_opacity_f;
82 int bits_per_pixel;
83 int of_mode; // add/subtract, etc
84 bool rgb; // add/subtract... overshoot mode is different
85 bool greyscale; // having only one plane
86 bool greymask_mask = false; // Overlay "greymask" param: mask has luma info only
87 IScriptEnvironment *env;
88 VideoInfo vi_internal; // internal working format (always YUV444 currently)
89 int placement = PLACEMENT_MPEG2; // chroma placement (for future subsampled Overlay)
90 };
91
92 class OL_BlendImage : public OverlayFunction {
93 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
94 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
95 template<typename pixel_t>
96 void BlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
97 template<typename pixel_t>
98 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
99 private:
100 };
101
102 // common add/subtract
103 class OL_AddImage : public OverlayFunction {
104 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
105 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
106 template<typename pixel_t, bool maskMode, bool of_add>
107 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
108 template<bool maskMode, bool of_add>
109 void BlendImageMask_float(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
110 template<typename pixel_t, bool maskMode, bool of_add>
111 void BlendImageMask_RGB(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
112 template<bool maskMode, bool of_add>
113 void BlendImageMask_RGB_float(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
114 };
115
116 class OL_MultiplyImage : public OverlayFunction {
117 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
118 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
119 template<typename pixel_t>
120 void BlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
121 template<typename pixel_t>
122 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
123 };
124
125 // common darken/lighten
126 class OL_DarkenImage : public OverlayFunction {
127 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
128 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
129 //template<typename pixel_t>
130 //void BlendImage(Image444* base, Image444* overlay);
131 template<typename pixel_t, bool maskMode, bool of_darken>
132 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
133 };
134
135 class OL_SoftLightImage : public OverlayFunction {
136 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
137 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
138 template<typename pixel_t>
139 void BlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
140 template<typename pixel_t, bool maskMode, bool hardLight>
141 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
142 };
143
144 class OL_DifferenceImage : public OverlayFunction {
145 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
146 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
147 //template<typename pixel_t>
148 //void BlendImage(Image444* base, Image444* overlay);
149 template<typename pixel_t, bool maskMode>
150 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
151 };
152
153 class OL_ExclusionImage : public OverlayFunction {
154 void DoBlendImage(ImageOverlayInternal* base, ImageOverlayInternal* overlay);
155 void DoBlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
156 // template<typename pixel_t>
157 // void BlendImage(Image444* base, Image444* overlay);
158 template<typename pixel_t, bool maskMode>
159 void BlendImageMask(ImageOverlayInternal* base, ImageOverlayInternal* overlay, ImageOverlayInternal* mask);
160 };
161
162 #endif // Overlay_funcs_h
163