Merge pull request #4 from CBke/pull-request#2

Awesome! Thanks.
This commit is contained in:
Duilio Protti 2016-02-13 12:41:43 -03:00
commit 8584545b27
21 changed files with 1836 additions and 2435 deletions

View File

@ -58,8 +58,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1;
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
case 1:
an = 0.015 * (p1 - 2) + 0.002;
@ -70,8 +70,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
fact = (sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1;
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
case 2:
an = 0.002;
@ -82,8 +82,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1;
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
case 3:
an = (sin(sqrt(a.x * a.x + a.y * a.y) / 20) / 20) + 0.002;
@ -94,8 +94,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1;
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
case 4:
an = 0.002;
@ -106,8 +106,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
fact = -(sqrt(b.x * b.x + b.y * b.y) - circle_size) / speed + 1;
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
case 5:
b.x = a.x * 1.02;
@ -121,8 +121,8 @@ static inline t_complex fct (t_complex a,guint32 n,gint32 p1,gint32 p2) /* p1
fact = 1 + cos(atan(a.x / (a.y + 0.00001)) * 6) * 0.02;
b.x = (co * a.x - si * a.y);
b.y = (si * a.x + co * a.y);
b.x=(b.x*fact);
b.y=(b.y*fact);
b.x *= fact;
b.y *= fact;
break;
default:
b.x = (gfloat)0.0;
@ -187,7 +187,6 @@ static inline void compute_generate_sector (guint32 g, guint32 f, guint32 p1, gu
/*
* Public functions
*/
void compute_init(void)
{
scr_par.width = config_get_xres();
@ -243,11 +242,10 @@ void compute_generate_vector_field (vector_field_t *vector_field)
height = (guint32)vector_field->height;
for (f = 0; f < NB_FCT; f++) {
for (f = 0; f < NB_FCT; f++)
for (i = 0; i < height; i += 10)
compute_generate_sector(f, f, 2, 2, i, 10, vector_field);
}
}
inline byte *compute_surface(t_interpol *vector, gint32 width, gint32 height)
{
@ -325,5 +323,3 @@ inline byte *compute_surface_mmx (t_interpol* vector, gint32 width, gint32 heigh
return surface1;
}
#endif /* MMX_DETECTION */

View File

@ -35,10 +35,8 @@
* Represents the interpollation information.
*/
typedef struct {
guint32 coord; /**< Coordinates of the top left pixel. */
guint32 weight; /**< 32 bits = 4*8 = weights of the four corners */
} t_interpol;
@ -50,11 +48,9 @@ typedef struct {
* because this is actually not true.
*/
typedef struct {
gint32 width; /**< number of vectors */
gint32 height; /**< length of each vector */
t_interpol * vector; /**< pointer to the vector field */
} vector_field_t;

View File

@ -9,7 +9,6 @@
* Here we have all the widgets of config dialog we need to interact to.
*/
typedef struct {
GtkWidget * window_main;
/* General stuff */
@ -23,7 +22,6 @@ typedef struct {
GtkWidget * button_ok; /**< GtkButton */
GtkWidget * button_cancel; /**< GtkButton */
GtkWidget * button_apply; /**< GtkButton */
} ConfigDialog;

View File

@ -53,7 +53,6 @@ int mm_support (void)
if (ebx == 0x756e6547 &&
edx == 0x49656e69 &&
ecx == 0x6c65746e) {
/* intel */
inteltest:
cpuid(1, eax, ebx, ecx, edx);
@ -103,11 +102,11 @@ int mm_support (void)
/* Cyrix Section */
/* See if extended CPUID level 80000001 is supported */
/* The value of CPUID/80000001 for the 6x86MX is undefined
according to the Cyrix CPU Detection Guide (Preliminary
Rev. 1.01 table 1), so we'll check the value of eax for
CPUID/0 to see if standard CPUID level 2 is supported.
According to the table, the only CPU which supports level
2 is also the only one which supports extended CPUID levels.
* according to the Cyrix CPU Detection Guide (Preliminary
* Rev. 1.01 table 1), so we'll check the value of eax for
* CPUID/0 to see if standard CPUID level 2 is supported.
* According to the table, the only CPU which supports level
* 2 is also the only one which supports extended CPUID levels.
*/
if (eax != 2)
goto inteltest;
@ -178,6 +177,5 @@ int mm_support_check_and_show ()
int mmx_ok(void)
{
return ( mm_support() & 0x1 );
return mm_support() & 0x1;
}

View File

@ -1,7 +1,7 @@
/* cputest.h
Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
and R. Fisher). Converted to C and improved by Fabrice Bellard
*
* Cpu detection code, extracted from mmx.h ((c)1997-99 by H. Dietz
* and R. Fisher). Converted to C and improved by Fabrice Bellard
*/
#ifndef _CPUTEST_H_
#define _CPUTEST_H_
@ -14,23 +14,23 @@
#define MM_SSE2 0x0010 /* PIV SSE2 functions */
/* should be defined by architectures supporting
one or more MultiMedia extension */
* one or more MultiMedia extension */
int mm_support(void);
/* return the result of mm_support and show the results
to stdout */
* to stdout */
int mm_support_check_and_show(void);
/* Function to test if mmx instructions are supported...
Returns 1 if MMX instructions are supported, 0 otherwise */
* Returns 1 if MMX instructions are supported, 0 otherwise */
int mmx_ok(void);
extern unsigned int mm_flags;
/*static inline void emms(void)
{
__asm __volatile ("emms;":::"memory");
}*/
* {
* __asm __volatile ("emms;":::"memory");
* }*/
#endif /* _CPUTEST_H_ */

View File

@ -79,14 +79,10 @@ static void generate_colors()
{ { 2.0, 0.0, 0.0 }, { 0.0, 1.0, 1.0 } } };
for (k = 0; k < NB_PALETTES; k++) {
for (i = 0; i < 128; i++)
{
for (i = 0; i < 128; i++) {
color_table[k][i].r = (Uint8)(colors[k][0][0] * i);
color_table[k][i].g = (Uint8)(colors[k][0][1] * i);
color_table[k][i].b = (Uint8)(colors[k][0][2] * i);
}
for (i = 0; i < 128; i++)
{
color_table[k][i + 128].r = (Uint8)(colors[k][0][0] * 127 + colors[k][1][0] * i);
color_table[k][i + 128].g = (Uint8)(colors[k][0][1] * 127 + colors[k][1][1] * i);
color_table[k][i + 128].b = (Uint8)(colors[k][0][2] * 127 + colors[k][1][2] * i);
@ -108,8 +104,9 @@ static void display_surface ()
return;
}
screen_locked = TRUE;
} else
} else {
screen_locked = FALSE;
}
if (scr_par.scale > 1) {
for (i = 0; i < scr_par.height; i++) {
pdest = (gint16 *)(screen->pixels + i * screen->pitch * scr_par.scale);
@ -123,16 +120,16 @@ static void display_surface ()
memcpy(screen->pixels + i * screen->pitch * 2 + screen->pitch,
screen->pixels + i * screen->pitch * 2, screen->pitch);
} /* else {
for (j=1;j<scr_par.width;j++) {
* for (j=1;j<scr_par.width;j++) {
*(pdest++)=current_colors[*psrc++];
*(pdest++)=*(pdest-1);
*(pdest++)=*(pdest-1);
}
memcpy(screen->pixels+i*screen->pitch*3+screen->pitch,
screen->pixels+i*screen->pitch*3,screen->pitch);
memcpy(screen->pixels+i*screen->pitch*3+screen->pitch*2,
screen->pixels+i*screen->pitch*3,screen->pitch);
} */
* }
* memcpy(screen->pixels+i*screen->pitch*3+screen->pitch,
* screen->pixels+i*screen->pitch*3,screen->pitch);
* memcpy(screen->pixels+i*screen->pitch*3+screen->pitch*2,
* screen->pixels+i*screen->pitch*3,screen->pitch);
* } */
} /* for */
} else {
psrc = surface1;
@ -222,7 +219,6 @@ static void line (gint32 x1, gint32 y1, gint32 x2, gint32 y2, gint32 c)
/*
* Public functions
*/
void display_init(void)
{
scr_par.width = config_get_xres();
@ -410,13 +406,14 @@ void spectral (t_effect* current_effect)
}
}
g_return_if_fail(SDL_mutexV(pcm_data_mutex) >= 0);
if (current_effect->mode_spectre==3 || current_effect->mode_spectre==4)
if (current_effect->mode_spectre == 3 || current_effect->mode_spectre == 4) {
line(halfwidth + cosw.f[scr_par.width - step] * (shift + y1),
halfheight + sinw.f[scr_par.width - step] * (shift + y1),
halfwidth - cosw.f[scr_par.width - step] * (shift + y2),
halfheight + sinw.f[scr_par.width - step] * (shift + y2),
current_effect->spectral_color);
}
}
/**
* \todo current_effect->curve_color must be a byte. This is related to

View File

@ -66,12 +66,13 @@ void effects_load_effects (void)
ptr_effect[i + 2] = (byte)d;
ptr_effect[i + 3] = (byte)e;
#endif
} else
} else {
finished = 1;
}
nb_effects+=1;
}
nb_effects -= 1;
nb_effects++;
}
nb_effects--;
fclose(f);
}
@ -87,8 +88,7 @@ void effects_load_random_effect (t_effect *effect)
gint32 num_effect = rand() % nb_effects;
gint32 i;
for (i = 0; i < sizeof(t_effect); i++) {
for (i = 0; i < sizeof(t_effect); i++)
*((byte *)effect + i) = *((byte *)(&effects[num_effect]) + i);
}
}
}

View File

@ -1,20 +1,20 @@
/* Convenience header for conditional use of GNU <libintl.h>.
Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
* Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA. */
#ifndef _LIBGETTEXT_H
#define _LIBGETTEXT_H 1
@ -26,11 +26,11 @@
# include <libintl.h>
/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
chokes if dcgettext is defined as a macro. So include it now, to make
later inclusions of <locale.h> a NOP. We don't include <libintl.h>
as well because people using "gettext.h" will not include <libintl.h>,
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
is OK. */
* chokes if dcgettext is defined as a macro. So include it now, to make
* later inclusions of <locale.h> a NOP. We don't include <libintl.h>
* as well because people using "gettext.h" will not include <libintl.h>,
* and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
* is OK. */
/*#if defined(__sun) || HAVE_LOCALE_H
# include <locale.h>
#endif*/
@ -41,10 +41,10 @@
#else
/* Disabled NLS.
The casts to 'const char *' serve the purpose of producing warnings
for invalid uses of the value returned from these functions.
On pre-ANSI systems without 'const', the config.h file is supposed to
contain "#define const". */
* The casts to 'const char *' serve the purpose of producing warnings
* for invalid uses of the value returned from these functions.
* On pre-ANSI systems without 'const', the config.h file is supposed to
* contain "#define const". */
# define gettext(Msgid) ((const char *)(Msgid))
# define dgettext(Domainname, Msgid) ((const char *)(Msgid))
# define dcgettext(Domainname, Msgid, Category) ((const char *)(Msgid))
@ -61,12 +61,12 @@
#endif
/* A pseudo function call that serves as a marker for the automated
extraction of messages, but does not call gettext(). The run-time
translation is done at a different place in the code.
The argument, String, should be a literal string. Concatenated strings
and other string expressions won't work.
The macro's expansion is not parenthesized, so that it is suitable as
initializer for static 'char[]' or 'const char[]' variables. */
* extraction of messages, but does not call gettext(). The run-time
* translation is done at a different place in the code.
* The argument, String, should be a literal string. Concatenated strings
* and other string expressions won't work.
* The macro's expansion is not parenthesized, so that it is suitable as
* initializer for static 'char[]' or 'const char[]' variables. */
#define gettext_noop(String) String
#define _(String) (gettext(String))

View File

@ -53,7 +53,6 @@ static t_config temp_config;
/*
* Callbacks for config_plugin_config_window
*/
static void scale_value_changed(GtkWidget *widget, gpointer data)
{
temp_config.sres = ((gint32)(GTK_ADJUSTMENT(widget)->value));
@ -84,21 +83,20 @@ static void on_show_title_toggled (GtkWidget *widget, gpointer data)
}
/*static gboolean check_cfg_version (ConfigFile *f)
{
gchar *vstr;
if (xmms_cfg_read_string (f, "infinity", "version", &vstr))
if (!strcmp (vstr, PACKAGE_VERSION))
return TRUE;
return FALSE;
return TRUE;
}*/
* {
* gchar *vstr;
*
* if (xmms_cfg_read_string (f, "infinity", "version", &vstr))
* if (!strcmp (vstr, PACKAGE_VERSION))
* return TRUE;
* return FALSE;
*
* return TRUE;
* }*/
static void sync_options()
{
/*g_message ("Synchronizing options: sres %d, teff %d, tcol %d, fps %d",
temp_config.sres, temp_config.teff, temp_config.tcol, temp_config.fps);*/
* temp_config.sres, temp_config.teff, temp_config.tcol, temp_config.fps);*/
config_set_sres(temp_config.sres);
config_set_teff(temp_config.teff);
config_set_tcol(temp_config.tcol);
@ -200,8 +198,6 @@ static void connect_callbacks (ConfigDialog *configure_dialog)
* Public functions
*
*/
void config_plugin_load_prefs(void)
{
gint value;
@ -218,36 +214,30 @@ void config_plugin_load_prefs (void)
if (TRUE) {
//TODO if (check_cfg_version (f)) {
// g_message("version Ok");
if ((value = g_key_file_get_integer (kf, "Preferences", "xres", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "xres", NULL)) > 0)
config_set_xres(value);
} else {
else
error = TRUE;
}
if ((value = g_key_file_get_integer (kf, "Preferences", "yres", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "yres", NULL)) > 0)
config_set_yres(value);
} else {
else
error = TRUE;
}
if ((value = g_key_file_get_integer (kf, "Preferences", "teff", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "teff", NULL)) > 0)
config_set_teff(value);
} else {
else
error = TRUE;
}
if ((value = g_key_file_get_integer (kf, "Preferences", "tcol", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "tcol", NULL)) > 0)
config_set_tcol(value);
} else {
else
error = TRUE;
}
if ((value = g_key_file_get_integer (kf, "Preferences", "sres", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "sres", NULL)) > 0)
config_set_sres(value);
} else {
else
error = TRUE;
}
if ((value = g_key_file_get_integer (kf, "Preferences", "fps", NULL)) > 0) {
if ((value = g_key_file_get_integer(kf, "Preferences", "fps", NULL)) > 0)
config_set_fps(value);
} else {
else
error = TRUE;
}
//config_set_show_title (g_key_file_get_boolean (kf, "Preferences", "show_title", NULL));
/* FIXME for now these are not used */
@ -293,7 +283,6 @@ void config_plugin_save_prefs (void)
if (!g_file_test(config_dir_path, G_FILE_TEST_EXISTS)) {
g_message(_("Creating Infinity plugin config directory '%s'"), INFINITY_CONFIG_DIR);
if (g_mkdir_with_parents(config_dir_path, S_IRWXU) != 0) {
g_warning(_("Cannot save preferences: unable to create directory '%s'"), config_dir_path);
g_free(config_file_path);
g_free(config_dir_path);
@ -302,9 +291,8 @@ void config_plugin_save_prefs (void)
}
}
}
if (!config_is_initialized ()) {
if (!config_is_initialized())
config_set_default_values();
}
//g_key_file_set_value (kf, "Preferences", "version", PACKAGE_VERSION);
g_key_file_set_integer(kf, "Preferences", "xres", config_get_xres());
g_key_file_set_integer(kf, "Preferences", "yres", config_get_yres());
@ -315,9 +303,8 @@ void config_plugin_save_prefs (void)
//g_key_file_set_boolean (kf, "Preferences", "show_title", config_get_show_title());
preferences = g_key_file_to_data(kf, &length, NULL);
ok = g_file_set_contents(config_file_path, preferences, length, NULL);
if (!ok) {
if (!ok)
g_warning(_("Error saving preferences"));
}
g_free(preferences);
g_free(config_file_path);
g_free(config_dir_path);
@ -342,9 +329,9 @@ gboolean config_is_initialized (void)
{
/* FIXME mhm, ugly thing... */
//return ((config.x > -1) && (config.y > -1) &&
return ((config.xres != 0) && (config.yres != 0) &&
return (config.xres != 0) && (config.yres != 0) &&
(config.sres != 0) && (config.teff != 0) &&
(config.tcol != 0) && (config.fps != 0));
(config.tcol != 0) && (config.fps != 0);
}
@ -363,9 +350,8 @@ void config_plugin_config_window (void)
}
config_plugin_load_prefs();
if (!config_is_initialized ()) {
if (!config_is_initialized())
config_set_default_values();
}
configure_dialog = config_dialog_new();

View File

@ -67,7 +67,8 @@ AUD_VIS_PLUGIN (
.get_widget = NULL
);
static void clear (void) {
static void clear(void)
{
g_message("TODO implement clear()");
}
@ -102,4 +103,3 @@ static void plugin_close (void)
config_plugin_save_prefs();
renderer_finish();
}

View File

@ -1,168 +0,0 @@
/**
* \file main.c
*
* \brief The main module of Infinity plugin.
*
* The only thing that a XMMS visualization plugin has to do
* (from the point of view of XMMS) is to export a function called
* get_vplugin_info() wich returns a pointer to a VisPlugin structure.
* This struct is defined in xmms/plugin.h. It contains pointers to
* functions which will be called on the ocurrence of certain events.
*/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <string.h>
#include <xmms/plugin.h>
#include <xmms/configfile.h>
#include <xmms/util.h>
#include <gtk/gtk.h>
#include "config.h"
#include "infconfig.h"
#include "renderer.h"
#include "gettext.h"
VisPlugin *get_vplugin_info(void);
static void plugin_init (void);
static void plugin_close (void);
static void plugin_about (void);
/**
* Structure shared with XMMS in order to register and get information
* about the plugin.
*
* The \a VisPlugin type is defined on <xmms/plugin.h>. XMMS will
* obtain a reference to this structure calling ::get_vplugin_info()
* when started.
*/
static VisPlugin sdlblur_vp = {
NULL, /**< Handle, filled in by xmms */
NULL, /**< Filename, filled in by xmms */
0, /**< XMMS Session ID, filled in by XMMS */
"Infinity " PACKAGE_VERSION, /**< description */
2, /**< Number of PCM channels wanted */
0, /**< Number of freq channels wanted */
plugin_init, /**< Called when plugin is enabled */
plugin_close, /**< Called when plugin is disabled */
plugin_about, /**< Show the about box */
config_plugin_config_window, /**< Show the configure box */
NULL, /**<
void (*disable_plugin)(struct _VisPlugin *)
Called to disable plugin, filled in by XMMS.
Must be called with a pointer to our plugin
struct to disable the plugin */
NULL, /**< Called when playback starts */
NULL, /**< Called when playback stops */
renderer_set_pcm_data, /**< Render the PCM data */
NULL, /**< Render the freq data */
};
static void plugin_init(void)
{
#if ENABLE_NLS
(void) setlocale (LC_MESSAGES, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
#endif
g_message (_("Infinity commands:\n"
"- Space:\tchange effect.\n"
"- Tab:\t\ttoggle full-screen.\n"
"- Up/Down:\tup/down xmms main volume.\n"
"- Left/Right:\treward/forward actual played song, if any.\n"
"- z:\t\tprevious song.\n"
"- x:\t\tplay.\n"
"- c:\t\tpause.\n"
"- v:\t\tstop.\n"
"- b:\t\tnext song.\n"
"- Enter:\tswitch to interactive mode.\n\t\t(works only if infinity was configured with --enable-debug option)\n"
"- F11:\t\tscreenshot.\n"
"- F12:\t\tchange palette."));
config_plugin_load_prefs ();
renderer_set_plugin_info (&sdlblur_vp);
renderer_init ();
}
static void plugin_close (void)
{
config_plugin_save_prefs ();
renderer_finish ();
}
static void dummy (GtkWidget *widget, gpointer data)
{
}
static void plugin_about (void)
{
GtkWidget *window_about;
#if ENABLE_NLS
(void) setlocale (LC_MESSAGES, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
#endif
window_about = xmms_show_message (_("About Infinity"),
_("\n" PACKAGE_STRING "\n"
"\n<http://infinity-plugin.sf.net>\n"
"\nCopyright (C) 2000, Julien Carme.\n"
"Email: <julien.carme@acm.org>\n"
"\n"
"Duilio J. Protti <dprotti@fceia.unr.edu.ar>\n"
"Actual maintainer\n"
"\n"
"This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 2 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program; if not, write to the Free Software\n"
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\n"
"USA"),
_("Ok"), FALSE, dummy, NULL);
gtk_widget_show (window_about);
}
/*
*
* Public functions
*
*/
/**
* Function to be exported to XMMS in order to register the plugin.
*/
VisPlugin *get_vplugin_info(void)
{
return &sdlblur_vp;
}

108
src/mmx.h
View File

@ -1,27 +1,27 @@
/* mmx.h
MultiMedia eXtensions GCC interface library for IA32.
To use this library, simply include this header file
and compile with GCC. You MUST have inlining enabled
in order for mmx_ok() to work; this can be done by
simply using -O on the GCC command line.
Compiling with -DMMX_TRACE will cause detailed trace
output to be sent to stderr for each mmx operation.
This adds lots of code, and obviously slows execution to
a crawl, but can be very useful for debugging.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR ANY PARTICULAR PURPOSE.
1997-99 by H. Dietz and R. Fisher
Notes:
It appears that the latest gas has the pand problem fixed, therefore
I'll undefine BROKEN_PAND by default.
*
* MultiMedia eXtensions GCC interface library for IA32.
*
* To use this library, simply include this header file
* and compile with GCC. You MUST have inlining enabled
* in order for mmx_ok() to work; this can be done by
* simply using -O on the GCC command line.
*
* Compiling with -DMMX_TRACE will cause detailed trace
* output to be sent to stderr for each mmx operation.
* This adds lots of code, and obviously slows execution to
* a crawl, but can be very useful for debugging.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
* LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR ANY PARTICULAR PURPOSE.
*
* 1997-99 by H. Dietz and R. Fisher
*
* Notes:
* It appears that the latest gas has the pand problem fixed, therefore
* I'll undefine BROKEN_PAND by default.
*/
#ifndef _MMX_H_
@ -29,19 +29,19 @@
/* Warning: at this writing, the version of GAS packaged
with most Linux distributions does not handle the
parallel AND operation mnemonic correctly. If the
symbol BROKEN_PAND is defined, a slower alternative
coding will be used. If execution of mmxtest results
in an illegal instruction fault, define this symbol.
* with most Linux distributions does not handle the
* parallel AND operation mnemonic correctly. If the
* symbol BROKEN_PAND is defined, a slower alternative
* coding will be used. If execution of mmxtest results
* in an illegal instruction fault, define this symbol.
*/
#undef BROKEN_PAND
/* The type of an value that fits in an MMX register
(note that long long constant values MUST be suffixed
by LL and unsigned long long values by ULL, lest
they be truncated by the compiler)
* (note that long long constant values MUST be suffixed
* by LL and unsigned long long values by ULL, lest
* they be truncated by the compiler)
*/
typedef union {
gint64 q; /* Quadword (64-bit) value */
@ -58,10 +58,10 @@ typedef union {
/* Helper functions for the instruction macros that follow...
(note that memory-to-register, m2r, instructions are nearly
as efficient as register-to-register, r2r, instructions;
however, memory-to-memory instructions are really simulated
as a convenience, and are only 1/3 as efficient)
* (note that memory-to-register, m2r, instructions are nearly
* as efficient as register-to-register, r2r, instructions;
* however, memory-to-memory instructions are really simulated
* as a convenience, and are only 1/3 as efficient)
*/
#ifdef MMX_TRACE
@ -205,8 +205,8 @@ typedef union {
/* 1x64 MOVe Quadword
(this is both a load and a store...
in fact, it is the only way to store)
* (this is both a load and a store...
* in fact, it is the only way to store)
*/
#define movq_m2r(var, reg) mmx_m2r(movq, var, reg)
#define movq_r2m(reg, var) mmx_r2m(movq, reg, var)
@ -219,9 +219,9 @@ typedef union {
/* 1x32 MOVe Doubleword
(like movq, this is both load and store...
but is most useful for moving things between
mmx registers and ordinary registers)
* (like movq, this is both load and store...
* but is most useful for moving things between
* mmx registers and ordinary registers)
*/
#define movd_m2r(var, reg) mmx_m2r(movd, var, reg)
#define movd_r2m(reg, var) mmx_r2m(movd, reg, var)
@ -322,8 +322,8 @@ typedef union {
/* 4x16->2x32 Parallel Mul-ADD
(muls like pmullw, then adds adjacent 16-bit fields
in the multiply result to make the final 2x32 result)
* (muls like pmullw, then adds adjacent 16-bit fields
* in the multiply result to make the final 2x32 result)
*/
#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg)
#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd)
@ -379,7 +379,7 @@ typedef union {
/* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
(resulting fields are either 0 or -1)
* (resulting fields are either 0 or -1)
*/
#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg)
#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd)
@ -395,7 +395,7 @@ typedef union {
/* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
(resulting fields are either 0 or -1)
* (resulting fields are either 0 or -1)
*/
#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg)
#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd)
@ -460,7 +460,7 @@ typedef union {
/* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
(packs source and dest fields into dest in that order)
* (packs source and dest fields into dest in that order)
*/
#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg)
#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
@ -472,7 +472,7 @@ typedef union {
/* 4x16->8x8 PACK and Unsigned Saturate
(packs source and dest fields into dest in that order)
* (packs source and dest fields into dest in that order)
*/
#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg)
#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
@ -480,8 +480,8 @@ typedef union {
/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
(interleaves low half of dest with low half of source
as padding in each result field)
* (interleaves low half of dest with low half of source
* as padding in each result field)
*/
#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg)
#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
@ -497,8 +497,8 @@ typedef union {
/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
(interleaves high half of dest with high half of source
as padding in each result field)
* (interleaves high half of dest with high half of source
* as padding in each result field)
*/
#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg)
#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
@ -514,10 +514,10 @@ typedef union {
/* Empty MMx State
(used to clean-up when going from mmx to float use
of the registers that are shared by both; note that
there is no float-to-mmx operation needed, because
only the float tag word info is corruptible)
* (used to clean-up when going from mmx to float use
* of the registers that are shared by both; note that
* there is no float-to-mmx operation needed, because
* only the float tag word info is corruptible)
*/
#ifdef MMX_TRACE

View File

@ -43,8 +43,8 @@
#endif
#define wrap(a) (a < 0 ? 0 : (a > 255 ? 255 : a))
#define next_effect() (t_last_effect += 1)
#define next_color() (t_last_color += 1)
#define next_effect() (t_last_effect++)
#define next_color() (t_last_color++)
typedef struct t_general_parameters {
gint32 t_between_effects;
@ -89,7 +89,6 @@ static void set_title (void);
/*
* Public functions
*/
void renderer_init(void)
{
GError *error = NULL;
@ -196,7 +195,6 @@ void renderer_render_multi_pcm (const float * data, int channels)
/*
* Private functions
*/
static gint32 event_filter(const SDL_Event *event)
{
if (!event) {
@ -252,9 +250,9 @@ static void check_events ()
gint volume;
/*XEvent *xevent;
XWindowChanges changes;
XWindowAttributes attr;
XSetWindowAttributes s_attr;*/
* XWindowChanges changes;
* XWindowAttributes attr;
* XSetWindowAttributes s_attr;*/
if (config_get_show_title()) {
if (g_timer_elapsed(title_timer, NULL) > 1.0) {
@ -263,8 +261,7 @@ static void check_events ()
g_free(current_title);
current_title = g_strdup(aud_playlist_entry_get_title(aud_playlist_get_playing(), aud_playlist_get_position(aud_playlist_get_playing()), FALSE));
set_title();
}
else {
} else {
if (current_title)
g_free(current_title);
current_title = g_strdup("Infinity");
@ -277,31 +274,31 @@ static void check_events ()
while (SDL_PollEvent(&event)) {
switch (event.type) {
/*case SDL_SYSWMEVENT:
g_message ("Infinity: SDL_SYSWMEVENT");
if (event.syswm.msg != NULL) {
if (event.syswm.msg->subsystem == SDL_SYSWM_X11) {
xevent = &(event.syswm.msg->event.xevent);
if (xevent == NULL)
continue;
if (first_xevent) {
changes.x = config_get_x();
changes.y = config_get_y();
XConfigureWindow (xevent->xany.display,
xevent->xany.window,
CWX | CWY, &changes);
first_xevent = FALSE;
g_message ("Infinity: window moved to (%d,%d)",
changes.x, changes.y);
} else {
XGetWindowAttributes (xevent->xany.display,
xevent->xany.window,
&attr);
g_message ("Infinity: GetWindowAttributes (%d,%d)",
attr.x, attr.y);
}
}
}
break;*/
* g_message ("Infinity: SDL_SYSWMEVENT");
* if (event.syswm.msg != NULL) {
* if (event.syswm.msg->subsystem == SDL_SYSWM_X11) {
* xevent = &(event.syswm.msg->event.xevent);
* if (xevent == NULL)
* continue;
* if (first_xevent) {
* changes.x = config_get_x();
* changes.y = config_get_y();
* XConfigureWindow (xevent->xany.display,
* xevent->xany.window,
* CWX | CWY, &changes);
* first_xevent = FALSE;
* g_message ("Infinity: window moved to (%d,%d)",
* changes.x, changes.y);
* } else {
* XGetWindowAttributes (xevent->xany.display,
* xevent->xany.window,
* &attr);
* g_message ("Infinity: GetWindowAttributes (%d,%d)",
* attr.x, attr.y);
* }
* }
* }
* break;*/
case SDL_QUIT:
GDK_THREADS_ENTER();
(void)gtk_idle_add(disable_func, NULL);
@ -362,7 +359,7 @@ static void check_events ()
if (t_last_color > 32) {
t_last_color = 0;
old_color = color;
color = (color + 1) % NB_PALETTES;
color = ++color % NB_PALETTES;
}
break;
case SDLK_SPACE:
@ -454,9 +451,8 @@ static int renderer (void *arg)
display_blur(scr_par.width * scr_par.height * current_effect.num_effect);
spectral(&current_effect);
curve(&current_effect);
if (t_last_color <= 32) {
if (t_last_color <= 32)
change_color(old_color, color, t_last_color * 8);
}
next_color();
next_effect();
if (t_last_effect % gen_par.t_between_effects == 0) {
@ -536,9 +532,8 @@ static int renderer_mmx (void *arg)
display_blur_mmx(scr_par.width * scr_par.height * current_effect.num_effect);
spectral(&current_effect);
curve(&current_effect);
if (t_last_color <= 32) {
if (t_last_color <= 32)
change_color(old_color, color, t_last_color * 8);
}
next_color();
next_effect();
if (t_last_effect % gen_par.t_between_effects == 0) {
@ -586,4 +581,3 @@ static void set_title (void)
{
SDL_WM_SetCaption(current_title, "Infinity");
}

View File

@ -1,396 +0,0 @@
#include <math.h>
#include <xmms/plugin.h>
/*#include "libxmms/util.h"*/
#include <SDL/SDL.h>
#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a ))
#define PI 3.14159
#define WIDTH 400
#define HEIGHT 300
#define INTERPOLATION 0 //0 or 1 to double resolution.
#define NB_FCT 6
#define NB_PALETTES 5
#include "affiche.h"
#define PERIODE_COLORS 64
#define PERIODE_EFFECTS 128
#define VIDEO_FLAGS (SDL_HWSURFACE|SDL_HWPALETTE)
#define BASS_EXT_MEMORY 100
typedef guchar byte;
static void sanalyzer_init(void);
static void sanalyzer_cleanup(void);
static void sanalyzer_playback_start(void);
static void sanalyzer_playback_stop(void);
static void sanalyzer_render_pcm(gint16 data[2][512]);
static void sanalyzer_render_freq(gint16 data[2][256]);
/*
typedef struct coord {
int x,y;
} coord;
typedef struct complex {
float x,y;
} complex;
typedef struct interpol {
coord c; //coordinates of the top left pixel.
int w1,w2,w3,w4;
} interpol;
typedef struct effect {
int addr_effect;
int f1,f2,f3;
int x_curve;
int p_speed,p_rotation;
int color,old_color;
int curve_color;
int spectral_color;
int mode_spectre;
int spectral_shift;
int flash;
} effect;
*/
struct bass_info {
//int mem[SIZE_BASS_MEM];
gint32 max_recent;
gint32 max_old;
gint32 time_last_max;
gint32 min_recent;
gint32 min_old;
gint32 time_last_min;
gint32 activated;
} bass_info;
interpol vector_field[NB_FCT][WIDTH*HEIGHT];
effect current_effect;
gint32 t=0;
VisPlugin sanalyzer_vp =
{
NULL,
NULL,
0,
"Simple spectrum analyzer",
1,
1,
sanalyzer_init,
sanalyzer_cleanup,
NULL,
NULL,
NULL,
sanalyzer_playback_start,
sanalyzer_playback_stop,
sanalyzer_render_pcm,
sanalyzer_render_freq
};
VisPlugin *get_vplugin_info(void)
{
return &sanalyzer_vp;
}
complex fct(complex a,gint32 n,gint32 p1,gint32 p2) //p1 et p2:0-4
{
complex b,b1,b2;
gfloat fact;
gfloat an;
gfloat circle_size;
gfloat speed;
gfloat co,si;
a.x-=WIDTH/2;
a.y-=HEIGHT/2;
switch (n) {
case 0:
an=0.025*(p1-2)+0.002;
co=cos(an);
si=sin(an);
circle_size=HEIGHT*0.25;
speed=2000+p2*500;
b.x=(co*a.x-si*a.y);
b.y=(si*a.x+co*a.y);
fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1;
b.x=(b.x*fact);
b.y=(b.y*fact);
break;
case 1:
an=0.015*(p1-2)+0.002;
co=cos(an);
si=sin(an);
circle_size=HEIGHT*0.45;
speed=4000+p2*1000;
b.x=(co*a.x-si*a.y);
b.y=(si*a.x+co*a.y);
fact=(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1;
b.x=(b.x*fact);
b.y=(b.y*fact);
break;
case 2:
an=0.002;
co=cos(an);
si=sin(an);
circle_size=HEIGHT*0.25;
speed=400+p2*100;
b.x=(co*a.x-si*a.y);
b.y=(si*a.x+co*a.y);
fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1;
b.x=(b.x*fact);
b.y=(b.y*fact);
break;
case 3:
an=(sin(sqrt(a.x*a.x+a.y*a.y)/20)/20)+0.002;
co=cos(an);
si=sin(an);
circle_size=HEIGHT*0.25;
speed=4000;
b.x=(co*a.x-si*a.y);
b.y=(si*a.x+co*a.y);
fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1;
b.x=(b.x*fact);
b.y=(b.y*fact);
break;
case 4:
an=0.002;
co=cos(an);
si=sin(an);
circle_size=HEIGHT*0.25;
speed=sin(sqrt(a.x*a.x+a.y*a.y)/5)*3000+4000;
b.x=(co*a.x-si*a.y);
b.y=(si*a.x+co*a.y);
fact=-(sqrt(b.x*b.x+b.y*b.y)-circle_size)/speed+1;
b.x=(b.x*fact);
b.y=(b.y*fact);
break;
case 5:
b.x=a.x*1.0;
b.y=a.y*1.0;
}
b.x+=WIDTH/2;
b.y+=HEIGHT/2;
if (b.x<0)
b.x=0;
if (b.y<0)
b.y=0;
if (b.x>WIDTH-1)
b.x=WIDTH-1;
if (b.y>HEIGHT-1)
b.y=HEIGHT-1;
return b;
}
void generate_sector(gint32 g,gint32 f,gint32 p1,gint32 p2,gint32 debut,gint32 step)
{
coord c;
complex a;
gfloat fpy;
gint32 rw,lw,add;
gint32 fin=debut+step;
gint32 prop_transmitted=249;
gint32 i,j;
if (fin>HEIGHT)
fin=HEIGHT;
for (c.y=debut;c.y<fin;c.y++)
for (c.x=0;c.x<WIDTH;c.x++) {
a.x=(gfloat)c.x;
a.y=(gfloat)c.y;
a=fct(a,f,p1,p2);
add=c.x+c.y*WIDTH;
vector_field[g][add].c.x=(gint32)(a.x);
vector_field[g][add].c.y=(gint32)(a.y);
fpy=a.y-floor(a.y);
rw=(gint32)((a.x-floor(a.x))*prop_transmitted);
lw=prop_transmitted-rw;
vector_field[g][add].w4=(gint32)(fpy*rw);
vector_field[g][add].w2=rw-vector_field[g][add].w4;
vector_field[g][add].w3=(gint32)(fpy*lw);
vector_field[g][add].w1=lw-vector_field[g][add].w3;
}
}
void generate_vector_field()
{
gint32 f;
gint32 i,p1,p2;
for (f=0;f<NB_FCT;f++) {
p1=2;
p2=2;
for (i=0;i<HEIGHT;i+=10)
generate_sector(f,f,p1,p2,i,10);
}
}
static void sanalyzer_init(void)
{
generate_vector_field();
generate_colors();
}
static void sanalyzer_cleanup(void)
{
SDL_Quit();
}
static void sanalyzer_playback_start(void)
{
init_sdl();
generate_vector_field();
}
static void sanalyzer_playback_stop(void)
{
SDL_Quit();
}
void sanalyzer_render_freq(gint16 data[2][256])
{
gint32 bass=0;
gint32 i;
gint32 step=10;
for (i=0;i<step;i++)
bass+=(data[0][i]>>4)+(data[1][i]>>4);
bass=bass/step/2;
if (bass>bass_info.max_recent)
bass_info.max_recent=bass;
if (bass<bass_info.min_recent)
bass_info.min_recent=bass;
if (t-bass_info.time_last_max>BASS_EXT_MEMORY) {
bass_info.max_old=bass_info.max_recent;
bass_info.max_recent=0;
bass_info.time_last_max=t;
}
if (t-bass_info.time_last_min>BASS_EXT_MEMORY) {
bass_info.min_old=bass_info.min_recent;
bass_info.min_recent=0;
bass_info.time_last_min=t;
}
if (bass>(bass_info.max_old*6+bass_info.min_old*4)/10 && bass_info.activated==0) {
if (current_effect.flash)
flash(255,t);
bass_info.activated=1;
}
if (bass<(bass_info.max_old*4+bass_info.min_old*6)/10 && bass_info.activated==1)
bass_info.activated=0;
}
void sanalyzer_render_pcm(gint16 data[2][512])
{
SDL_Event event;
Uint8 *keystate;
gint32 son=0;
gint32 trace=0;
gfloat x,y,v,vr;
gint32 i;
gint32 t_last_palette=0;
while ( SDL_PollEvent(&event) ) {
if ( event.type == SDL_QUIT )
SDL_Quit();
if (event.type == SDL_KEYDOWN) {
gchar *st;
st=SDL_GetKeyName(event.key.keysym.sym);
if (!strcmp(st,"a"))
current_effect.curve_color=wrap(current_effect.curve_color-32);
if (!strcmp(st,"z"))
current_effect.curve_color=wrap(current_effect.curve_color+32);
if (!strcmp(st,"q"))
current_effect.spectral_color=wrap(current_effect.spectral_color-32);
if (!strcmp(st,"s"))
current_effect.spectral_color=wrap(current_effect.spectral_color+32);
if (!strcmp(st,"w"))
current_effect.mode_spectre=(current_effect.mode_spectre+1)%5;
if (!strcmp(st,"x"))
current_effect.flash=(current_effect.flash+1)%2;
}
}
keystate = SDL_GetKeyState(NULL);
if ( keystate[SDLK_ESCAPE] )
ToggleFullScreen();
for (i=0;i<10;i++)
if ( keystate[SDLK_F1+i])
current_effect.addr_effect=i%NB_FCT;
if (keystate[SDLK_F11]) {
current_effect.color=(current_effect.color-1)%NB_PALETTES;
t_last_palette=0;
}
if (keystate[SDLK_F12]) {
current_effect.color=(current_effect.color+1)%NB_PALETTES;
t_last_palette=0;
}
if (keystate[SDLK_e]) {
current_effect.spectral_shift=(current_effect.spectral_shift-10)%HEIGHT;
}
if (keystate[SDLK_r]) {
current_effect.spectral_shift=(current_effect.spectral_shift+10)%HEIGHT;
}
if (t_last_palette<8)
change_color(current_effect.color,(current_effect.color+1)%NB_PALETTES,(t_last_palette+1)*32);
/*
if (t%PERIODE_EFFECTS==0) {
// while (current_effect.f1==current_effect.f2) {
// current_effect.f2=current_effect.f1;
//current_effect.f1=rand()%NB_TYPE_FCT;
//}
//current_effect.p_rotation=2;
//current_effect.p_speed=rand()%5;
current_effect.addr_effect=(current_effect.addr_effect+1)%NB_FCT;
}*/
/*
generate_sector(1-current_effect.addr_effect,current_effect.f1,
current_effect.p_rotation,current_effect.p_speed,
(t%PERIODE_EFFECTS)*(HEIGHT/PERIODE_EFFECTS+1),
(HEIGHT/PERIODE_EFFECTS+1));
*/
affiche(current_effect.addr_effect,vector_field);
spectral(data,current_effect);
curve(&current_effect);
t+=1;
t_last_palette+=1;
}