7 #include "goom_config.h"
9 #include "goom_plugin_info.h"
11 #include "drawmethods.h"
16 #if defined (HAVE_CPU_PPC64) || defined (HAVE_CPU_PPC)
17 #include <sys/types.h>
18 #include <sys/sysctl.h>
19 #include "ppc_zoom_ultimate.h"
20 #include "ppc_drawings.h"
21 #endif /* HAVE_CPU_PPC64 || HAVE_CPU_PPC */
28 #include <liboil/liboil.h>
29 #include <liboil/liboilfunction.h>
30 #include <liboil/liboilcpu.h>
32 GST_DEBUG_CATEGORY_EXTERN (goom_debug);
33 #define GST_CAT_DEFAULT goom_debug
36 setOptimizedMethods (PluginInfo * p)
39 unsigned int cpuFlavour = oil_cpu_get_flags ();
41 /* set default methods */
42 p->methods.draw_line = draw_line;
43 p->methods.zoom_filter = zoom_filter_c;
44 /* p->methods.create_output_with_brightness = create_output_with_brightness;*/
46 GST_INFO ("liboil cpu flags: 0x%08x", cpuFlavour);
48 /* FIXME: what about HAVE_CPU_X86_64 ? */
51 GST_INFO ("have an x86");
52 if (cpuFlavour & OIL_IMPL_FLAG_MMXEXT) {
53 GST_INFO ("Extended MMX detected. Using the fastest methods!");
54 p->methods.draw_line = draw_line_xmmx;
55 p->methods.zoom_filter = zoom_filter_xmmx;
56 } else if (cpuFlavour & OIL_IMPL_FLAG_MMX) {
57 GST_INFO ("MMX detected. Using fast methods!");
58 p->methods.draw_line = draw_line_mmx;
59 p->methods.zoom_filter = zoom_filter_mmx;
61 GST_INFO ("Too bad ! No SIMD optimization available for your CPU.");
64 #endif /* HAVE_CPU_I386 */
66 /* disable all PPC stuff until someone finds out what to use here instead of
67 * CPU_OPTION_64_BITS, and until someone fixes the assembly build for ppc */
70 if ((cpuFlavour & CPU_OPTION_64_BITS) != 0) {
71 /* p->methods.create_output_with_brightness = ppc_brightness_G5; */
72 p->methods.zoom_filter = ppc_zoom_generic;
74 #endif /* HAVE_CPU_PPC64 */
77 if ((cpuFlavour & OIL_IMPL_FLAG_ALTIVEC) != 0) {
78 /* p->methods.create_output_with_brightness = ppc_brightness_G4; */
79 p->methods.zoom_filter = ppc_zoom_G4;
81 /* p->methods.create_output_with_brightness = ppc_brightness_generic;*/
82 p->methods.zoom_filter = ppc_zoom_generic;
84 #endif /* HAVE_CPU_PPC */
87 cpuFlavour = 0; /* trick compiler into thinking variable is used */
91 plugin_info_init (PluginInfo * pp, int nbVisuals)
97 p.sound.speedvar = p.sound.accelvar = p.sound.totalgoom = 0;
99 p.sound.goom_limit = 1;
100 p.sound.allTimesMax = 1;
101 p.sound.timeSinceLastGoom = 1;
102 p.sound.timeSinceLastBigGoom = 1;
105 p.sound.volume_p = secure_f_feedback ("Sound Volume");
106 p.sound.accel_p = secure_f_feedback ("Sound Acceleration");
107 p.sound.speed_p = secure_f_feedback ("Sound Speed");
108 p.sound.goom_limit_p = secure_f_feedback ("Goom Limit");
109 p.sound.last_goom_p = secure_f_feedback ("Goom Detection");
110 p.sound.last_biggoom_p = secure_f_feedback ("Big Goom Detection");
111 p.sound.goom_power_p = secure_f_feedback ("Goom Power");
113 p.sound.biggoom_speed_limit_p = secure_i_param ("Big Goom Speed Limit");
114 IVAL (p.sound.biggoom_speed_limit_p) = 10;
115 IMIN (p.sound.biggoom_speed_limit_p) = 0;
116 IMAX (p.sound.biggoom_speed_limit_p) = 100;
117 ISTEP (p.sound.biggoom_speed_limit_p) = 1;
119 p.sound.biggoom_factor_p = secure_i_param ("Big Goom Factor");
120 IVAL (p.sound.biggoom_factor_p) = 10;
121 IMIN (p.sound.biggoom_factor_p) = 0;
122 IMAX (p.sound.biggoom_factor_p) = 100;
123 ISTEP (p.sound.biggoom_factor_p) = 1;
125 p.sound.params = plugin_parameters ("Sound", 11);
129 p.nbVisuals = nbVisuals;
130 p.visuals = (VisualFX **) malloc (sizeof (VisualFX *) * nbVisuals);
133 pp->sound.params.params[0] = &pp->sound.biggoom_speed_limit_p;
134 pp->sound.params.params[1] = &pp->sound.biggoom_factor_p;
135 pp->sound.params.params[2] = 0;
136 pp->sound.params.params[3] = &pp->sound.volume_p;
137 pp->sound.params.params[4] = &pp->sound.accel_p;
138 pp->sound.params.params[5] = &pp->sound.speed_p;
139 pp->sound.params.params[6] = 0;
140 pp->sound.params.params[7] = &pp->sound.goom_limit_p;
141 pp->sound.params.params[8] = &pp->sound.goom_power_p;
142 pp->sound.params.params[9] = &pp->sound.last_goom_p;
143 pp->sound.params.params[10] = &pp->sound.last_biggoom_p;
145 pp->statesNumber = 8;
146 pp->statesRangeMax = 510;
148 GoomState states[8] = {
149 {1, 0, 0, 1, 4, 0, 100}
151 {1, 0, 0, 0, 1, 101, 140}
153 {1, 0, 0, 1, 2, 141, 200}
155 {0, 1, 0, 1, 2, 201, 260}
157 {0, 1, 0, 1, 0, 261, 330}
159 {0, 1, 1, 1, 4, 331, 400}
161 {0, 0, 1, 0, 5, 401, 450}
163 {0, 0, 1, 1, 1, 451, 510}
165 for (i = 0; i < 8; ++i)
166 pp->states[i] = states[i];
168 pp->curGState = &(pp->states[6]);
170 /* datas for the update loop */
171 pp->update.lockvar = 0;
172 pp->update.goomvar = 0;
173 pp->update.loopvar = 0;
174 pp->update.stop_lines = 0;
175 pp->update.ifs_incr = 1; /* dessiner l'ifs (0 = non: > = increment) */
176 pp->update.decay_ifs = 0; /* disparition de l'ifs */
177 pp->update.recay_ifs = 0; /* dedisparition de l'ifs */
178 pp->update.cyclesSinceLastChange = 0;
179 pp->update.drawLinesDuration = 80;
180 pp->update.lineMode = pp->update.drawLinesDuration;
182 pp->update.switchMultAmount = (29.0f / 30.0f);
183 pp->update.switchIncrAmount = 0x7f;
184 pp->update.switchMult = 1.0f;
185 pp->update.switchIncr = pp->update.switchIncrAmount;
187 pp->update.stateSelectionRnd = 0;
188 pp->update.stateSelectionBlocker = 0;
189 pp->update.previousZoomSpeed = 128;
192 ZoomFilterData zfd = {
194 1, 1, 0, NORMAL_MODE,
197 pp->update.zoomFilterData = zfd;
200 setOptimizedMethods (pp);
202 for (i = 0; i < 0xffff; i++) {
204 (int) (1024 * sin ((double) i * 360 / (sizeof (pp->sintable) /
205 sizeof (pp->sintable[0]) - 1) * 3.141592 / 180) + .5);
206 /* sintable [us] = (int)(1024.0f * sin (us*2*3.31415f/0xffff)) ; */
211 plugin_info_add_visual (PluginInfo * p, int i, VisualFX * visual)
213 p->visuals[i] = visual;
214 if (i == p->nbVisuals - 1) {
218 if (p->visuals[i]->params)
222 (PluginParameters *) malloc (sizeof (PluginParameters) * p->nbParams);
225 p->params[0] = p->sound.params;
227 if (p->visuals[i]->params)
228 p->params[p->nbParams++] = *(p->visuals[i]->params);
234 plugin_info_free (PluginInfo * p)
236 goom_plugin_parameters_free (&p->sound.params);