2 * Copyright (C) <2003> iOS-Software
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library 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 GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #include "goom_config.h"
27 #include "goom_plugin_info.h"
29 #include "drawmethods.h"
37 #if defined (HAVE_CPU_PPC64) || defined (HAVE_CPU_PPC)
38 #include <sys/types.h>
39 #include <sys/sysctl.h>
40 #include "ppc_zoom_ultimate.h"
41 #include "ppc_drawings.h"
42 #endif /* HAVE_CPU_PPC64 || HAVE_CPU_PPC */
51 GST_DEBUG_CATEGORY_EXTERN (goom_debug);
52 #define GST_CAT_DEFAULT goom_debug
55 setOptimizedMethods (PluginInfo * p)
58 unsigned int cpuFlavour =
59 orc_target_get_default_flags (orc_target_get_by_name ("mmx"));
61 unsigned int cpuFlavour = 0;
64 /* set default methods */
65 p->methods.draw_line = draw_line;
66 p->methods.zoom_filter = zoom_filter_c;
67 /* p->methods.create_output_with_brightness = create_output_with_brightness;*/
69 GST_INFO ("orc cpu flags: 0x%08x", cpuFlavour);
71 /* FIXME: what about HAVE_CPU_X86_64 ? */
75 GST_INFO ("have an x86");
76 if (cpuFlavour & ORC_TARGET_MMX_MMXEXT) {
77 GST_INFO ("Extended MMX detected. Using the fastest methods!");
78 p->methods.draw_line = draw_line_xmmx;
79 p->methods.zoom_filter = zoom_filter_xmmx;
80 } else if (cpuFlavour & ORC_TARGET_MMX_MMX) {
81 GST_INFO ("MMX detected. Using fast methods!");
82 p->methods.draw_line = draw_line_mmx;
83 p->methods.zoom_filter = zoom_filter_mmx;
85 GST_INFO ("Too bad ! No SIMD optimization available for your CPU.");
89 #endif /* HAVE_CPU_I386 */
91 /* disable all PPC stuff until someone finds out what to use here instead of
92 * CPU_OPTION_64_BITS, and until someone fixes the assembly build for ppc */
95 if ((cpuFlavour & CPU_OPTION_64_BITS) != 0) {
96 /* p->methods.create_output_with_brightness = ppc_brightness_G5; */
97 p->methods.zoom_filter = ppc_zoom_generic;
99 #endif /* HAVE_CPU_PPC64 */
102 if ((cpuFlavour & ORC_TARGET_ALTIVEC_ALTIVEC) != 0) {
103 /* p->methods.create_output_with_brightness = ppc_brightness_G4; */
104 p->methods.zoom_filter = ppc_zoom_G4;
106 /* p->methods.create_output_with_brightness = ppc_brightness_generic;*/
107 p->methods.zoom_filter = ppc_zoom_generic;
109 #endif /* HAVE_CPU_PPC */
112 cpuFlavour = 0; /* trick compiler into thinking variable is used */
116 plugin_info_init (PluginInfo * pp, int nbVisuals)
121 memset (pp, 0, sizeof (PluginInfo));
123 pp->sound.speedvar = pp->sound.accelvar = pp->sound.totalgoom = 0;
124 pp->sound.prov_max = 0;
125 pp->sound.goom_limit = 1;
126 pp->sound.allTimesMax = 1;
127 pp->sound.timeSinceLastGoom = 1;
128 pp->sound.timeSinceLastBigGoom = 1;
131 secure_f_feedback (&pp->sound.volume_p, "Sound Volume");
132 secure_f_feedback (&pp->sound.accel_p, "Sound Acceleration");
133 secure_f_feedback (&pp->sound.speed_p, "Sound Speed");
134 secure_f_feedback (&pp->sound.goom_limit_p, "Goom Limit");
135 secure_f_feedback (&pp->sound.last_goom_p, "Goom Detection");
136 secure_f_feedback (&pp->sound.last_biggoom_p, "Big Goom Detection");
137 secure_f_feedback (&pp->sound.goom_power_p, "Goom Power");
139 secure_i_param (&pp->sound.biggoom_speed_limit_p, "Big Goom Speed Limit");
140 IVAL (pp->sound.biggoom_speed_limit_p) = 10;
141 IMIN (pp->sound.biggoom_speed_limit_p) = 0;
142 IMAX (pp->sound.biggoom_speed_limit_p) = 100;
143 ISTEP (pp->sound.biggoom_speed_limit_p) = 1;
145 secure_i_param (&pp->sound.biggoom_factor_p, "Big Goom Factor");
146 IVAL (pp->sound.biggoom_factor_p) = 10;
147 IMIN (pp->sound.biggoom_factor_p) = 0;
148 IMAX (pp->sound.biggoom_factor_p) = 100;
149 ISTEP (pp->sound.biggoom_factor_p) = 1;
151 plugin_parameters (&pp->sound.params, "Sound", 11);
155 pp->nbVisuals = nbVisuals;
156 pp->visuals = (VisualFX **) malloc (sizeof (VisualFX *) * nbVisuals);
158 pp->sound.params.params[0] = &pp->sound.biggoom_speed_limit_p;
159 pp->sound.params.params[1] = &pp->sound.biggoom_factor_p;
160 pp->sound.params.params[2] = 0;
161 pp->sound.params.params[3] = &pp->sound.volume_p;
162 pp->sound.params.params[4] = &pp->sound.accel_p;
163 pp->sound.params.params[5] = &pp->sound.speed_p;
164 pp->sound.params.params[6] = 0;
165 pp->sound.params.params[7] = &pp->sound.goom_limit_p;
166 pp->sound.params.params[8] = &pp->sound.goom_power_p;
167 pp->sound.params.params[9] = &pp->sound.last_goom_p;
168 pp->sound.params.params[10] = &pp->sound.last_biggoom_p;
170 pp->statesNumber = 8;
171 pp->statesRangeMax = 510;
173 GoomState states[8] = {
174 {1, 0, 0, 1, 4, 0, 100}
176 {1, 0, 0, 0, 1, 101, 140}
178 {1, 0, 0, 1, 2, 141, 200}
180 {0, 1, 0, 1, 2, 201, 260}
182 {0, 1, 0, 1, 0, 261, 330}
184 {0, 1, 1, 1, 4, 331, 400}
186 {0, 0, 1, 0, 5, 401, 450}
188 {0, 0, 1, 1, 1, 451, 510}
190 for (i = 0; i < 8; ++i)
191 pp->states[i] = states[i];
193 pp->curGState = &(pp->states[6]);
195 /* datas for the update loop */
196 pp->update.lockvar = 0;
197 pp->update.goomvar = 0;
198 pp->update.loopvar = 0;
199 pp->update.stop_lines = 0;
200 pp->update.ifs_incr = 1; /* dessiner l'ifs (0 = non: > = increment) */
201 pp->update.decay_ifs = 0; /* disparition de l'ifs */
202 pp->update.recay_ifs = 0; /* dedisparition de l'ifs */
203 pp->update.cyclesSinceLastChange = 0;
204 pp->update.drawLinesDuration = 80;
205 pp->update.lineMode = pp->update.drawLinesDuration;
207 pp->update.switchMultAmount = (29.0f / 30.0f);
208 pp->update.switchIncrAmount = 0x7f;
209 pp->update.switchMult = 1.0f;
210 pp->update.switchIncr = pp->update.switchIncrAmount;
212 pp->update.stateSelectionRnd = 0;
213 pp->update.stateSelectionBlocker = 0;
214 pp->update.previousZoomSpeed = 128;
217 ZoomFilterData zfd = {
219 1, 1, 0, NORMAL_MODE,
222 pp->update.zoomFilterData = zfd;
225 setOptimizedMethods (pp);
227 for (i = 0; i < 0xffff; i++) {
229 (int) (1024 * sin ((double) i * 360 / (sizeof (pp->sintable) /
230 sizeof (pp->sintable[0]) - 1) * 3.141592 / 180) + .5);
231 /* sintable [us] = (int)(1024.0f * sin (us*2*3.31415f/0xffff)) ; */
236 plugin_info_add_visual (PluginInfo * p, int i, VisualFX * visual)
238 p->visuals[i] = visual;
239 if (i == p->nbVisuals - 1) {
243 if (p->visuals[i]->params)
247 (PluginParameters *) malloc (sizeof (PluginParameters) * p->nbParams);
250 p->params[0] = p->sound.params;
252 if (p->visuals[i]->params)
253 p->params[p->nbParams++] = *(p->visuals[i]->params);
259 plugin_info_free (PluginInfo * p)
261 goom_plugin_parameters_free (&p->sound.params);