Debian Codegraph @

src/filter/tehroxx0r/tehroxx0r.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/filter/tehroxx0r/tehroxx0r.c`/include "frei0r.h"cxx . . $ `<file>/include/frei0r.h`/
2 #include <stdlib.h>
3 #include <assert.h>
4 #include <limits.h>
5 #include <string.h>
6
7 /**
8 * This is our instance.
9 * It has a buffer allocated to place a small version of the incoming
10 * frame into.
11 */
12 typedef struct teh_roxx0rcxx . . $ teh_roxx0r#
13 {
14 unsigned int widthcxx . . $ teh_roxx0r#width.; // frame size in x-dimension
15 unsigned int heightcxx . . $ teh_roxx0r#height.; // frame size in y-dimension
16 unsigned int block_sizecxx . . $ teh_roxx0r#block_size.; // x/y size of one block
17
18 double change_speedcxx . . $ teh_roxx0r#change_speed.;
19 double last_timecxx . . $ teh_roxx0r#last_time.;
20 double time_stackcxx . . $ teh_roxx0r#time_stack.;
21
22 uint32_tcxx . . $ uint32_t#* small_blockcxx . . $ teh_roxx0r#small_block.; // buffer to write downscaled frame
23
24 } tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#;
25
26
27 // returns greatest common divisor of to int numbers
28 int gcdcxx . . $ gcd(9b79fb6aee4c0440).(int a, int b);
29
30 int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).()
31 {
32 return 1;
33 }
34
35 void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).()
36 { /* no initialization required */ }
37
38 void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* tehRoxx0rInfo)
39 {
40 tehRoxx0rInfo->namecxx . . $ f0r_plugin_info#name. = "TehRoxx0r";
41 tehRoxx0rInfo->authorcxx . . $ f0r_plugin_info#author. = "Coma";
42 tehRoxx0rInfo->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_FILTERcxx . . $ `include/frei0r.h:247:9`!;
43 tehRoxx0rInfo->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_PACKED32cxx . . $ `include/frei0r.h:322:9`!;
44 tehRoxx0rInfo->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!;
45 tehRoxx0rInfo->major_versioncxx . . $ f0r_plugin_info#major_version. = 0;
46 tehRoxx0rInfo->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 9;
47 tehRoxx0rInfo->num_paramscxx . . $ f0r_plugin_info#num_params. = 1;
48 tehRoxx0rInfo->explanationcxx . . $ f0r_plugin_info#explanation. = "Something videowall-ish";
49 }
50
51 void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index)
52 {
53
54 info->namecxx . . $ f0r_param_info#name. = "Interval";
55 info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!;
56 info->explanationcxx . . $ f0r_param_info#explanation. = "Changing speed of small blocks";
57 }
58
59 f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height)
60 {
61 int blocksize;
62 tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#* inst = (tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*inst));
63 inst->widthcxx . . $ teh_roxx0r#width. = width; inst->heightcxx . . $ teh_roxx0r#height. = height;
64 inst->change_speedcxx . . $ teh_roxx0r#change_speed. = 0.01;
65
66 // get greatest common divisor
67 blocksize = gcdcxx . . $ gcd(9b79fb6aee4c0440).(width, height);
68 // this will sometimes be to large, so roughly estimate a check
69 if(blocksize >= (width/3) || blocksize >= (height/3))
70 blocksize /= 2;
71
72 inst->block_sizecxx . . $ teh_roxx0r#block_size. = blocksize;
73
74 inst->small_blockcxx . . $ teh_roxx0r#small_block. =
75 (uint32_tcxx . . $ uint32_t#*)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(sizeof(uint32_tcxx . . $ uint32_t#)*inst->block_sizecxx . . $ teh_roxx0r#block_size.*inst->block_sizecxx . . $ teh_roxx0r#block_size.);
76
77 return (f0r_instance_tcxx . . $ f0r_instance_t#)inst;
78 }
79
80 void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance)
81 {
82 tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#* inst = (tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#*)instance;
83 freecxx . . $ free(5d22bdacc48458e8).(inst->small_blockcxx . . $ teh_roxx0r#small_block.);
84 freecxx . . $ free(5d22bdacc48458e8).(inst);
85 }
86
87 void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
88 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
89 {
90 tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#* inst = (tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t# *)instance;
91 // (tehRoxx0r_instance_t*)malloc(sizeof(tehRoxx0r_instance_t));
92
93 switch(param_index)
94 {
95 case 0:
96 inst->change_speedcxx . . $ teh_roxx0r#change_speed. = *((double*)param);
97 break;
98 };
99 }
100
101 void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance,
102 f0r_param_tcxx . . $ f0r_param_t# param, int param_index)
103 {
104 tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#* inst = (tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t# *)instance;
105 // (tehRoxx0r_instance_t*)malloc(sizeof(tehRoxx0r_instance_t));
106
107 switch(param_index)
108 {
109 case 0:
110 *((double*)param) = inst->change_speedcxx . . $ teh_roxx0r#change_speed.;
111 break;
112 };
113 }
114
115
116 void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance, double time,
117 const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe)
118 {
119 assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance);
120 tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#* inst = (tehRoxx0r_instance_tcxx . . $ tehRoxx0r_instance_t#*)instance;
121 unsigned int w = inst->widthcxx . . $ teh_roxx0r#width.;
122 unsigned int h = inst->heightcxx . . $ teh_roxx0r#height.;
123 uint32_tcxx . . $ uint32_t#* dst;
124 const uint32_tcxx . . $ uint32_t#* src;
125 uint32_tcxx . . $ uint32_t#* small_block = inst->small_blockcxx . . $ teh_roxx0r#small_block.;
126 unsigned int x,y;
127 unsigned int small_x, small_y;
128 unsigned int small_w, small_h;
129 double step_x, step_y;
130 unsigned int pos_w, pos_h;
131
132 // get x/y-size of middle block
133 small_w = w-2*inst->block_sizecxx . . $ teh_roxx0r#block_size.;
134 small_h = h-2*inst->block_sizecxx . . $ teh_roxx0r#block_size.;
135
136 // get interpolation step for that
137 step_x = (double)w / (double)small_w;
138 step_y = (double)h / (double)small_h;
139
140 // make background black transparent
141 memsetcxx . . $ memset(d1de1e4fb215f1c6).(outframe, 0, w * h * sizeof(uint32_tcxx . . $ uint32_t#));
142
143 // copy a downscaled version into the middle of the result frame
144 // (blocksize to x-blocksize and blocksize to y-blocksize)
145 for(y = 0, small_y=inst->block_sizecxx . . $ teh_roxx0r#block_size.;small_y<h-inst->block_sizecxx . . $ teh_roxx0r#block_size.;small_y++,
146 y=step_y*(small_y-inst->block_sizecxx . . $ teh_roxx0r#block_size.))
147 {
148 src = inframe + y*w;
149 dst = outframe + small_y*w + inst->block_sizecxx . . $ teh_roxx0r#block_size.;
150 for(x=0;x<w-2*inst->block_sizecxx . . $ teh_roxx0r#block_size.;x++)
151 {
152 *dst++ = *(src + (int)(x*step_x));
153 }
154 }
155
156 // add elapsed time to timestack
157 inst->time_stackcxx . . $ teh_roxx0r#time_stack. += (time-inst->last_timecxx . . $ teh_roxx0r#last_time.);
158
159
160 // get interpolation step size
161 step_x = w / inst->block_sizecxx . . $ teh_roxx0r#block_size.;
162 step_y = h / inst->block_sizecxx . . $ teh_roxx0r#block_size.;
163
164 // create a small picture
165 for(y=0,small_y=0; small_y<inst->block_sizecxx . . $ teh_roxx0r#block_size.; small_y++,y+=step_y)
166 {
167 src = inframe + y*w;
168 dst = small_block + small_y*inst->block_sizecxx . . $ teh_roxx0r#block_size.;
169 for(x=0,small_x = 0; small_x<inst->block_sizecxx . . $ teh_roxx0r#block_size.; small_x++)//,x+=step_x)
170 {
171 *dst++ = *src;
172 src += (unsigned int)step_x;
173 }
174 }
175 // do we actually changed anything?
176 if(inst->time_stackcxx . . $ teh_roxx0r#time_stack. > inst->change_speedcxx . . $ teh_roxx0r#change_speed.)
177 {
178 // get random position
179 pos_w = inst->block_sizecxx . . $ teh_roxx0r#block_size. *
180 (unsigned int)(randcxx . . $ rand(b126dc7c1de90089).()/(double)RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:91:9`! * ((w / inst->block_sizecxx . . $ teh_roxx0r#block_size.)));
181 pos_h = inst->block_sizecxx . . $ teh_roxx0r#block_size. *
182 (unsigned int)(randcxx . . $ rand(b126dc7c1de90089).()/(double)RAND_MAXcxx . . $ `<external>/10696550936717951914/stdlib.h:91:9`! * ((h / inst->block_sizecxx . . $ teh_roxx0r#block_size.)));
183
184 // now copy to some (random) places along the border of
185 // the incoming frame.....
186 dst = outframe + pos_w;
187 src = small_block;
188 for(x=0; x<inst->block_sizecxx . . $ teh_roxx0r#block_size.;
189 x++, dst += w, src += inst->block_sizecxx . . $ teh_roxx0r#block_size.)
190 memcpycxx . . $ memcpy(cc817cb175f282d).(dst, src, sizeof(int32_tcxx . . $ int32_t#)*inst->block_sizecxx . . $ teh_roxx0r#block_size.);
191
192 dst = outframe + pos_h * w;
193 src = small_block;
194 for(x=0; x<inst->block_sizecxx . . $ teh_roxx0r#block_size.;
195 x++, dst += w, src += inst->block_sizecxx . . $ teh_roxx0r#block_size.)
196 memcpycxx . . $ memcpy(cc817cb175f282d).(dst, src, sizeof(int32_tcxx . . $ int32_t#)*inst->block_sizecxx . . $ teh_roxx0r#block_size.);
197
198 dst = outframe + pos_h* w + w - inst->block_sizecxx . . $ teh_roxx0r#block_size.;
199 src = small_block;
200 for(x=0; x<inst->block_sizecxx . . $ teh_roxx0r#block_size.;
201 x++, dst += w, src += inst->block_sizecxx . . $ teh_roxx0r#block_size.)
202 memcpycxx . . $ memcpy(cc817cb175f282d).(dst, src, sizeof(int32_tcxx . . $ int32_t#)*inst->block_sizecxx . . $ teh_roxx0r#block_size.);
203
204
205 dst = outframe + (h-inst->block_sizecxx . . $ teh_roxx0r#block_size.) *w + pos_w;
206 src = small_block;
207 for(x=0; x<inst->block_sizecxx . . $ teh_roxx0r#block_size.;
208 x++, dst += w, src += inst->block_sizecxx . . $ teh_roxx0r#block_size.)
209 memcpycxx . . $ memcpy(cc817cb175f282d).(dst, src, sizeof(int32_tcxx . . $ int32_t#)*inst->block_sizecxx . . $ teh_roxx0r#block_size.);
210
211
212 // reset timestack
213 inst->time_stackcxx . . $ teh_roxx0r#time_stack. = 0.0;
214 }
215
216
217 inst->last_timecxx . . $ teh_roxx0r#last_time. = time;
218 }
219
220 // greatest common divisor. this will never become smaller than 8.
221 int gcdcxx . . $ gcd(9b79fb6aee4c0440).(int a, int b)
222 {
223 if(b==0) return a;
224 else return gcdcxx . . $ gcd(9b79fb6aee4c0440).(b, a%b);
225 }