Debian Codegraph @

src/mixer2/sleid0r/sleid0r_wipe-circle.c

raw symbols SCIP
1 /*
2 Copyright (C) 2013 Vadim Druzhin <[email protected]>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdlib.h>
19 #include <stdint.h>
20 #include <string.h>
21 #define _USE_MATH_DEFINEScxx . . $ `src/mixer2/sleid0r/sleid0r_wipe-circle.c:21:9`!
22 #include <math.h>
23 #include <frei0r.h>cxx . . $ `<file>/include/frei0r.h`/
24
25 typedef struct instance_scxx . . $ instance_s#
26 {
27 int wcxx . . $ instance_s#w.;
28 int hcxx . . $ instance_s#h.;
29 double poscxx . . $ instance_s#pos.;
30 int rcxx . . $ instance_s#r.;
31 int bwcxx . . $ instance_s#bw.;
32 int bw_scalecxx . . $ instance_s#bw_scale.;
33 int *bwkcxx . . $ instance_s#bwk.;
34 } instance_tcxx . . $ instance_t#;
35
36 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).(void)
37 {
38 return 1;
39 }
40
41 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).(void) {}
42
43 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t# *info)
44 {
45 info->namecxx . . $ f0r_plugin_info#name. = "wipe-circle";
46 info->authorcxx . . $ f0r_plugin_info#author. = "Vadim Druzhin";
47 info->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_MIXER2cxx . . $ `include/frei0r.h:251:9`!;
48 info->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!;
49 info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!;
50 info->major_versioncxx . . $ f0r_plugin_info#major_version. = 0;
51 info->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 1;
52 info->num_paramscxx . . $ f0r_plugin_info#num_params. = 1;
53 info->explanationcxx . . $ f0r_plugin_info#explanation. = "Circle wipe";
54 }
55
56 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t# *info, int index)
57 {
58 if(0 == index)
59 {
60 info->namecxx . . $ f0r_param_info#name. = "position";
61 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
62 info->explanationcxx . . $ f0r_param_info#explanation. = "Circle size";
63 }
64 }
65
66 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned width, unsigned height)
67 {
68 instance_tcxx . . $ instance_t# *inst;
69 int r;
70 int bw;
71 int i;
72
73 r = (int)(hypotfcxx . . $ hypotf(d59a45cd3bfd2eda).((float)height, (float)width) / 2.0f + 0.5f);
74
75 bw = r / 16;
76
77 inst = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(*inst) + bw * sizeof(*inst->bwkcxx . . $ instance_s#bwk.));
78 if(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! == inst)
79 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
80
81 inst->wcxx . . $ instance_s#w. = width;
82 inst->hcxx . . $ instance_s#h. = height;
83 inst-> poscxx . . $ instance_s#pos. = 0.0;
84 inst->rcxx . . $ instance_s#r. = r;
85 inst->bwcxx . . $ instance_s#bw. = bw;
86 inst->bw_scalecxx . . $ instance_s#bw_scale. = bw * bw;
87 inst->bwkcxx . . $ instance_s#bwk. = (int *)(inst + 1);
88
89 for(i = 0; i < bw; ++i)
90 {
91 if(i < bw / 2)
92 inst->bwkcxx . . $ instance_s#bwk.[i] = i * i * 2;
93 else
94 inst->bwkcxx . . $ instance_s#bwk.[i] = inst->bw_scalecxx . . $ instance_s#bw_scale. - (bw - i) * (bw - i) * 2;
95 }
96
97 return inst;
98 }
99
100 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# inst)
101 {
102 freecxx . . $ free(5d22bdacc48458e8).(inst);
103 }
104
105 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
106 {
107 instance_tcxx . . $ instance_t# *inst = instance;
108
109 if(0 == param_index)
110 inst->poscxx . . $ instance_s#pos. = *(f0r_param_doublecxx . . $ f0r_param_double# *)param;
111 }
112
113 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
114 {
115 instance_tcxx . . $ instance_t# *inst = instance;
116
117 if(0 == param_index)
118 *(f0r_param_doublecxx . . $ f0r_param_double# *)param = inst->poscxx . . $ instance_s#pos.;
119 }
120
121 void f0r_update2cxx . . $ f0r_update2(1b234bc88d3943d5).(
122 f0r_instance_tcxx . . $ f0r_instance_t# instance,
123 double time,
124 const uint32_tcxx . . $ uint32_t#* inframe1,
125 const uint32_tcxx . . $ uint32_t#* inframe2,
126 const uint32_tcxx . . $ uint32_t#* inframe3,
127 uint32_tcxx . . $ uint32_t#* outframe
128 )
129 {
130 instance_tcxx . . $ instance_t# *inst = instance;
131 int x0, y0, r0, r1;
132 int y, x, dy, dx, ox, oy;
133
134 (void)time; /* Unused */
135 (void)inframe3; /* Unused */
136
137 r1 = (int)((inst->rcxx . . $ instance_s#r. + inst->bwcxx . . $ instance_s#bw.) * inst->poscxx . . $ instance_s#pos. + 0.5);
138 r0 = r1 - inst->bwcxx . . $ instance_s#bw.;
139
140 x0 = inst->wcxx . . $ instance_s#w. / 2;
141 y0 = inst->hcxx . . $ instance_s#h. / 2;
142
143 dy = inst->hcxx . . $ instance_s#h. / 2 - r1;
144 dx = inst->wcxx . . $ instance_s#w. / 2 - r1;
145
146 if(r0 > 0)
147 {
148 ox = (int)((float)r0 * (float)M_SQRT1_2cxx . . $ `<external>/11263917310783833665/math.h:1296:10`! + 0.5f);
149 oy = ox;
150
151 if(ox > inst->wcxx . . $ instance_s#w. / 2)
152 ox = inst->wcxx . . $ instance_s#w. / 2;
153
154 if(oy > inst->hcxx . . $ instance_s#h. / 2)
155 oy = inst->hcxx . . $ instance_s#h. / 2;
156 }
157 else
158 {
159 ox = 0;
160 oy = 0;
161 }
162
163 if(ox > 0 && oy > 0)
164 {
165 for(y = y0 - oy; y < y0 + oy; ++y)
166 memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * y + x0 - ox,
167 inframe2 + inst->wcxx . . $ instance_s#w. * y + x0 - ox, ox * 2 * sizeof(*outframe));
168 }
169
170 if(dy > 0)
171 {
172 memcpycxx . . $ memcpy(cc817cb175f282d).(outframe, inframe1, inst->wcxx . . $ instance_s#w. * dy * sizeof(*outframe));
173
174 memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * (y0 + r1), inframe1 + inst->wcxx . . $ instance_s#w. * (y0 + r1),
175 inst->wcxx . . $ instance_s#w. * dy * sizeof(*outframe));
176
177 inframe1 += dy * inst->wcxx . . $ instance_s#w.;
178 inframe2 += dy * inst->wcxx . . $ instance_s#w.;
179 outframe += dy * inst->wcxx . . $ instance_s#w.;
180 }
181 else
182 dy = 0;
183
184 if(dx > 0)
185 {
186 for(y = 0; y < inst->hcxx . . $ instance_s#h. - dy * 2; ++y)
187 {
188 memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * y, inframe1 + inst->wcxx . . $ instance_s#w. * y, dx * sizeof(*outframe));
189
190 memcpycxx . . $ memcpy(cc817cb175f282d).(outframe + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - dx,
191 inframe1 + inst->wcxx . . $ instance_s#w. * y + inst->wcxx . . $ instance_s#w. - dx, dx * sizeof(*outframe));
192 }
193
194 inframe1 += dx;
195 inframe2 += dx;
196 outframe += dx;
197 }
198 else
199 dx = 0;
200
201 for(y = dy; y < inst->hcxx . . $ instance_s#h. - dy; ++y)
202 {
203 for(x = dx; x < inst->wcxx . . $ instance_s#w. - dx; ++x)
204 {
205 if(y < y0 - oy || y >= y0 + oy || x < x0 - ox || x >= x0 + ox)
206 {
207 int r = (int)(hypotfcxx . . $ hypotf(d59a45cd3bfd2eda).((float)(x - x0), (float)(y - y0)) + 0.5f);
208
209 if(r >= r1)
210 *outframe = *inframe1;
211 else if(r < r0)
212 *outframe = *inframe2;
213 else
214 {
215 int k1 = inst->bwkcxx . . $ instance_s#bwk.[r - r0];
216 int k2 = inst->bw_scalecxx . . $ instance_s#bw_scale. - k1;
217 uint8_tcxx . . $ uint8_t# *c1 = (uint8_tcxx . . $ uint8_t# *)inframe1;
218 uint8_tcxx . . $ uint8_t# *c2 = (uint8_tcxx . . $ uint8_t# *)inframe2;
219 uint8_tcxx . . $ uint8_t# *co = (uint8_tcxx . . $ uint8_t# *)outframe;
220
221 co[0] = (c1[0] * k1 + c2[0] * k2 + inst->bw_scalecxx . . $ instance_s#bw_scale. / 2) / inst->bw_scalecxx . . $ instance_s#bw_scale.;
222 co[1] = (c1[1] * k1 + c2[1] * k2 + inst->bw_scalecxx . . $ instance_s#bw_scale. / 2) / inst->bw_scalecxx . . $ instance_s#bw_scale.;
223 co[2] = (c1[2] * k1 + c2[2] * k2 + inst->bw_scalecxx . . $ instance_s#bw_scale. / 2) / inst->bw_scalecxx . . $ instance_s#bw_scale.;
224 co[3] = (c1[3] * k1 + c2[3] * k2 + inst->bw_scalecxx . . $ instance_s#bw_scale. / 2) / inst->bw_scalecxx . . $ instance_s#bw_scale.;
225 }
226 }
227
228 ++inframe1;
229 ++inframe2;
230 ++outframe;
231 }
232
233 inframe1 += dx * 2;
234 inframe2 += dx * 2;
235 outframe += dx * 2;
236 }
237 }
238