mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
gst/goom/: Make goom reentrant by moving all important static variables into instance structures.
Original commit message from CVS: * gst/goom/filters.c: (zoomFilterNew), (calculatePXandPY), (setPixelRGB), (setPixelRGB_), (getPixelRGB), (getPixelRGB_), (zoomFilterSetResolution), (zoomFilterDestroy), (zoomFilterFastRGB), (pointFilter): * gst/goom/filters.h: * gst/goom/goom_core.c: (goom_init), (goom_set_resolution), (goom_update), (goom_close): * gst/goom/goom_core.h: * gst/goom/goom_tools.h: * gst/goom/graphic.c: * gst/goom/gstgoom.c: (gst_goom_class_init), (gst_goom_init), (gst_goom_dispose), (gst_goom_src_setcaps), (gst_goom_chain): * gst/goom/gstgoom.h: * gst/goom/lines.c: (goom_lines): * gst/goom/lines.h: Make goom reentrant by moving all important static variables into instance structures. (Fixes #329181)
This commit is contained in:
parent
4b5490014f
commit
07c1dceae0
11 changed files with 569 additions and 465 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2006-02-05 Jan Schmidt <thaytan@mad.scientist.com>
|
||||
|
||||
* gst/goom/filters.c: (zoomFilterNew), (calculatePXandPY),
|
||||
(setPixelRGB), (setPixelRGB_), (getPixelRGB), (getPixelRGB_),
|
||||
(zoomFilterSetResolution), (zoomFilterDestroy),
|
||||
(zoomFilterFastRGB), (pointFilter):
|
||||
* gst/goom/filters.h:
|
||||
* gst/goom/goom_core.c: (goom_init), (goom_set_resolution),
|
||||
(goom_update), (goom_close):
|
||||
* gst/goom/goom_core.h:
|
||||
* gst/goom/goom_tools.h:
|
||||
* gst/goom/graphic.c:
|
||||
* gst/goom/gstgoom.c: (gst_goom_class_init), (gst_goom_init),
|
||||
(gst_goom_dispose), (gst_goom_src_setcaps), (gst_goom_chain):
|
||||
* gst/goom/gstgoom.h:
|
||||
* gst/goom/lines.c: (goom_lines):
|
||||
* gst/goom/lines.h:
|
||||
Make goom reentrant by moving all important static variables
|
||||
into instance structures.
|
||||
(Fixes #329181)
|
||||
|
||||
2006-02-04 Tim-Philipp Müller <tim at centricular dot net>
|
||||
|
||||
* gst/avi/gstavidemux.c: (gst_avi_demux_parse_stream),
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "filters.h"
|
||||
#include "graphic.h"
|
||||
#include "goom_tools.h"
|
||||
#include "goom_core.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
@ -37,9 +38,6 @@
|
|||
#endif
|
||||
|
||||
|
||||
extern volatile guint32 resolx;
|
||||
extern volatile guint32 resoly;
|
||||
|
||||
#ifdef USE_ASM
|
||||
|
||||
#ifdef MMX
|
||||
|
@ -54,25 +52,44 @@ extern void ppc_zoom_altivec (void);
|
|||
unsigned int ppcsize4;
|
||||
#endif /* PowerPC */
|
||||
|
||||
|
||||
unsigned int *coeffs = 0, *freecoeffs = 0;
|
||||
guint32 *expix1 = 0; /* pointeur exporte vers p1 */
|
||||
guint32 *expix2 = 0; /* pointeur exporte vers p2 */
|
||||
guint32 zoom_width;
|
||||
|
||||
#endif /* ASM */
|
||||
|
||||
|
||||
static int firstTime = 1;
|
||||
static int sintable[0xffff];
|
||||
static int vitesse = 127;
|
||||
static char theMode = AMULETTE_MODE;
|
||||
static int vPlaneEffect = 0;
|
||||
static int hPlaneEffect = 0;
|
||||
static char noisify = 2;
|
||||
static int middleX, middleY;
|
||||
static unsigned char sqrtperte = 16;
|
||||
|
||||
static int *firedec = 0;
|
||||
ZoomFilterData *
|
||||
zoomFilterNew ()
|
||||
{
|
||||
ZoomFilterData *zf = malloc (sizeof (ZoomFilterData));
|
||||
|
||||
zf->vitesse = 128;
|
||||
zf->pertedec = 8;
|
||||
zf->sqrtperte = 16;
|
||||
zf->middleX = 1;
|
||||
zf->middleY = 1;
|
||||
zf->reverse = 0;
|
||||
zf->mode = WAVE_MODE;
|
||||
zf->hPlaneEffect = 0;
|
||||
zf->vPlaneEffect = 0;
|
||||
zf->noisify = 0;
|
||||
zf->buffsize = 0;
|
||||
zf->res_x = 0;
|
||||
zf->res_y = 0;
|
||||
|
||||
zf->buffer = NULL;
|
||||
zf->firedec = NULL;
|
||||
|
||||
zf->wave = 0;
|
||||
zf->wavesp = 0;
|
||||
|
||||
return zf;
|
||||
}
|
||||
|
||||
/* retourne x>>s , en testant le signe de x */
|
||||
static inline int
|
||||
|
@ -90,43 +107,56 @@ ShiftRight (int x, const unsigned char s)
|
|||
(valeur * 16)
|
||||
*/
|
||||
void
|
||||
calculatePXandPY (int x, int y, int *px, int *py)
|
||||
calculatePXandPY (GoomData * gd, int x, int y, int *px, int *py)
|
||||
{
|
||||
if (theMode == WATER_MODE) {
|
||||
static int wave = 0;
|
||||
static int wavesp = 0;
|
||||
int yy;
|
||||
ZoomFilterData *zf = gd->zfd;
|
||||
int middleX, middleY;
|
||||
guint32 resoly = zf->res_y;
|
||||
int vPlaneEffect = zf->vPlaneEffect;
|
||||
int hPlaneEffect = zf->hPlaneEffect;
|
||||
int vitesse = zf->vitesse;
|
||||
char theMode = zf->mode;
|
||||
|
||||
yy = y + RAND () % 4 + wave / 10;
|
||||
yy -= RAND () % 4;
|
||||
if (theMode == WATER_MODE) {
|
||||
int wavesp = zf->wavesp;
|
||||
int wave = zf->wave;
|
||||
int yy = y + RAND (gd) % 4 + wave / 10;
|
||||
|
||||
yy -= RAND (gd) % 4;
|
||||
if (yy < 0)
|
||||
yy = 0;
|
||||
if (yy >= resoly)
|
||||
yy = resoly - 1;
|
||||
|
||||
*px = (x << 4) + firedec[yy] + (wave / 10);
|
||||
*px = (x << 4) + zf->firedec[yy] + (wave / 10);
|
||||
*py = (y << 4) + 132 - ((vitesse < 132) ? vitesse : 131);
|
||||
|
||||
wavesp += RAND () % 3;
|
||||
wavesp -= RAND () % 3;
|
||||
wavesp += RAND (gd) % 3;
|
||||
wavesp -= RAND (gd) % 3;
|
||||
if (wave < -10)
|
||||
wavesp += 2;
|
||||
if (wave > 10)
|
||||
wavesp -= 2;
|
||||
wave += (wavesp / 10) + RAND () % 3;
|
||||
wave -= RAND () % 3;
|
||||
wave += (wavesp / 10) + RAND (gd) % 3;
|
||||
wave -= RAND (gd) % 3;
|
||||
if (wavesp > 100)
|
||||
wavesp = (wavesp * 9) / 10;
|
||||
|
||||
zf->wavesp = wavesp;
|
||||
zf->wave = wave;
|
||||
} else {
|
||||
int dist;
|
||||
register int vx, vy;
|
||||
int fvitesse = vitesse << 4;
|
||||
|
||||
if (noisify) {
|
||||
x += RAND () % noisify;
|
||||
x -= RAND () % noisify;
|
||||
y += RAND () % noisify;
|
||||
y -= RAND () % noisify;
|
||||
middleX = zf->middleX;
|
||||
middleY = zf->middleY;
|
||||
|
||||
if (zf->noisify) {
|
||||
x += RAND (gd) % zf->noisify;
|
||||
x -= RAND (gd) % zf->noisify;
|
||||
y += RAND (gd) % zf->noisify;
|
||||
y -= RAND (gd) % zf->noisify;
|
||||
}
|
||||
|
||||
if (hPlaneEffect)
|
||||
|
@ -183,7 +213,8 @@ calculatePXandPY (int x, int y, int *px, int *py)
|
|||
/*#define _DEBUG */
|
||||
|
||||
static inline void
|
||||
setPixelRGB (Uint * buffer, Uint x, Uint y, Color c)
|
||||
setPixelRGB (Uint * buffer, Uint x, Uint y, Color c,
|
||||
guint32 resolx, guint32 resoly)
|
||||
{
|
||||
/* buffer[ y*WIDTH + x ] = (c.r<<16)|(c.v<<8)|c.b */
|
||||
#ifdef _DEBUG_PIXEL
|
||||
|
@ -202,7 +233,7 @@ setPixelRGB (Uint * buffer, Uint x, Uint y, Color c)
|
|||
|
||||
|
||||
static inline void
|
||||
setPixelRGB_ (Uint * buffer, Uint x, Color c)
|
||||
setPixelRGB_ (Uint * buffer, Uint x, Color c, guint32 resolx, guint32 resoly)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (x >= resolx * resoly) {
|
||||
|
@ -221,7 +252,8 @@ setPixelRGB_ (Uint * buffer, Uint x, Color c)
|
|||
|
||||
|
||||
static inline void
|
||||
getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c)
|
||||
getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c,
|
||||
guint32 resolx, guint32 resoly)
|
||||
{
|
||||
register unsigned char *tmp8;
|
||||
|
||||
|
@ -251,7 +283,7 @@ getPixelRGB (Uint * buffer, Uint x, Uint y, Color * c)
|
|||
|
||||
|
||||
static inline void
|
||||
getPixelRGB_ (Uint * buffer, Uint x, Color * c)
|
||||
getPixelRGB_ (Uint * buffer, Uint x, Color * c, guint32 resolx, guint32 resoly)
|
||||
{
|
||||
register unsigned char *tmp8;
|
||||
|
||||
|
@ -270,26 +302,132 @@ getPixelRGB_ (Uint * buffer, Uint x, Color * c)
|
|||
|
||||
#else
|
||||
/* ATTENTION AU PETIT INDIEN */
|
||||
c->b = *(unsigned char *) (tmp8 = (unsigned char *) (buffer + x));
|
||||
c->v = *(unsigned char *) (++tmp8);
|
||||
c->r = *(unsigned char *) (++tmp8);
|
||||
tmp8 = (unsigned char *) (buffer + x);
|
||||
c->b = *(unsigned char *) (tmp8++);
|
||||
c->v = *(unsigned char *) (tmp8++);
|
||||
c->r = *(unsigned char *) (tmp8);
|
||||
/* *c = (Color) buffer[x+y*WIDTH] ; */
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
zoomFilterSetResolution (GoomData * gd, ZoomFilterData * zf)
|
||||
{
|
||||
unsigned short us;
|
||||
|
||||
if (zf->buffsize >= gd->buffsize) {
|
||||
zf->res_x = gd->resolx;
|
||||
zf->res_y = gd->resoly;
|
||||
zf->middleX = gd->resolx / 2;
|
||||
zf->middleY = gd->resoly - 1;
|
||||
|
||||
return;
|
||||
}
|
||||
#ifndef USE_ASM
|
||||
if (zf->buffer)
|
||||
free (zf->buffer);
|
||||
zf->buffer = 0;
|
||||
#else
|
||||
if (coeffs)
|
||||
free (freecoeffs);
|
||||
coeffs = 0;
|
||||
#endif
|
||||
zf->middleX = gd->resolx / 2;
|
||||
zf->middleY = gd->resoly - 1;
|
||||
zf->res_x = gd->resolx;
|
||||
zf->res_y = gd->resoly;
|
||||
|
||||
if (zf->firedec)
|
||||
free (zf->firedec);
|
||||
zf->firedec = 0;
|
||||
|
||||
zf->buffsize = gd->resolx * gd->resoly * sizeof (unsigned int);
|
||||
|
||||
#ifdef USE_ASM
|
||||
freecoeffs = (unsigned int *)
|
||||
malloc (resx * resy * 2 * sizeof (unsigned int) + 128);
|
||||
coeffs = (guint32 *) ((1 + ((unsigned int) (freecoeffs)) / 128) * 128);
|
||||
|
||||
#else
|
||||
zf->buffer = malloc (sizeof (guint32) * zf->buffsize * 5);
|
||||
zf->pos10 = zf->buffer;
|
||||
zf->c[0] = zf->pos10 + zf->buffsize;
|
||||
zf->c[1] = zf->c[0] + zf->buffsize;
|
||||
zf->c[2] = zf->c[1] + zf->buffsize;
|
||||
zf->c[3] = zf->c[2] + zf->buffsize;
|
||||
#endif
|
||||
zf->firedec = (int *) malloc (zf->res_y * sizeof (int));
|
||||
|
||||
if (firstTime) {
|
||||
firstTime = 0;
|
||||
|
||||
/* generation d'une table de sinus */
|
||||
for (us = 0; us < 0xffff; us++) {
|
||||
sintable[us] = (int) (1024.0f * sin (us * 2 * 3.31415f / 0xffff));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int loopv;
|
||||
|
||||
for (loopv = zf->res_y; loopv != 0;) {
|
||||
int decc = 0;
|
||||
int spdc = 0;
|
||||
int accel = 0;
|
||||
|
||||
loopv--;
|
||||
zf->firedec[loopv] = decc;
|
||||
decc += spdc / 10;
|
||||
spdc += RAND (gd) % 3;
|
||||
spdc -= RAND (gd) % 3;
|
||||
|
||||
if (decc > 4)
|
||||
spdc -= 1;
|
||||
if (decc < -4)
|
||||
spdc += 1;
|
||||
|
||||
if (spdc > 30)
|
||||
spdc = spdc - RAND (gd) % 3 + accel / 10;
|
||||
if (spdc < -30)
|
||||
spdc = spdc + RAND (gd) % 3 + accel / 10;
|
||||
|
||||
if (decc > 8 && spdc > 1)
|
||||
spdc -= RAND (gd) % 3 - 2;
|
||||
|
||||
if (decc < -8 && spdc < -1)
|
||||
spdc += RAND (gd) % 3 + 2;
|
||||
|
||||
if (decc > 8 || decc < -8)
|
||||
decc = decc * 8 / 9;
|
||||
|
||||
accel += RAND (gd) % 2;
|
||||
accel -= RAND (gd) % 2;
|
||||
if (accel > 20)
|
||||
accel -= 2;
|
||||
if (accel < -20)
|
||||
accel += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zoomFilterDestroy (ZoomFilterData * zf)
|
||||
{
|
||||
if (zf)
|
||||
free (zf);
|
||||
}
|
||||
|
||||
/*===============================================================*/
|
||||
void
|
||||
zoomFilterFastRGB (Uint * pix1,
|
||||
Uint * pix2, ZoomFilterData * zf, Uint resx, Uint resy)
|
||||
zoomFilterFastRGB (GoomData * goomdata, ZoomFilterData * zf, int zfd_update)
|
||||
{
|
||||
static guint32 prevX = 0, prevY = 0;
|
||||
guint32 prevX = goomdata->resolx;
|
||||
guint32 prevY = goomdata->resoly;
|
||||
|
||||
static char reverse = 0; /*vitesse inversé..(zoom out) */
|
||||
|
||||
/* static int perte = 100; // 100 = normal */
|
||||
static unsigned char pertedec = 8;
|
||||
static char firstTime = 1;
|
||||
guint32 *pix1 = goomdata->p1;
|
||||
guint32 *pix2 = goomdata->p2;
|
||||
unsigned int *pos10;
|
||||
unsigned int **c;
|
||||
|
||||
Uint x, y;
|
||||
|
||||
|
@ -302,147 +440,49 @@ zoomFilterFastRGB (Uint * pix1,
|
|||
Color couleur;
|
||||
Color col1, col2, col3, col4;
|
||||
Uint position;
|
||||
|
||||
static unsigned int *pos10 = 0;
|
||||
static unsigned int *c1 = 0, *c2 = 0, *c3 = 0, *c4 = 0;
|
||||
#endif
|
||||
|
||||
if ((prevX != resx) || (prevY != resy)) {
|
||||
prevX = resx;
|
||||
prevY = resy;
|
||||
#ifndef USE_ASM
|
||||
if (c1)
|
||||
free (c1);
|
||||
if (c2)
|
||||
free (c2);
|
||||
if (c3)
|
||||
free (c3);
|
||||
if (c4)
|
||||
free (c4);
|
||||
if (pos10)
|
||||
free (pos10);
|
||||
c1 = c2 = c3 = c4 = pos10 = 0;
|
||||
#else
|
||||
if (coeffs)
|
||||
free (freecoeffs);
|
||||
coeffs = 0;
|
||||
#endif
|
||||
middleX = resx / 2;
|
||||
middleY = resy - 1;
|
||||
firstTime = 1;
|
||||
if (firedec)
|
||||
free (firedec);
|
||||
firedec = 0;
|
||||
if ((goomdata->resolx != zf->res_x) || (goomdata->resoly != zf->res_y)) {
|
||||
zoomFilterSetResolution (goomdata, zf);
|
||||
}
|
||||
|
||||
if (zf) {
|
||||
reverse = zf->reverse;
|
||||
vitesse = zf->vitesse;
|
||||
if (reverse)
|
||||
vitesse = 256 - vitesse;
|
||||
#ifndef USE_ASM
|
||||
sqrtperte = zf->sqrtperte;
|
||||
#endif
|
||||
pertedec = zf->pertedec;
|
||||
middleX = zf->middleX;
|
||||
middleY = zf->middleY;
|
||||
theMode = zf->mode;
|
||||
hPlaneEffect = zf->hPlaneEffect;
|
||||
vPlaneEffect = zf->vPlaneEffect;
|
||||
noisify = zf->noisify;
|
||||
}
|
||||
pos10 = zf->pos10;
|
||||
c = zf->c;
|
||||
|
||||
if (firstTime || zf) {
|
||||
|
||||
/* generation d'une table de sinus */
|
||||
if (firstTime) {
|
||||
unsigned short us;
|
||||
|
||||
firstTime = 0;
|
||||
#ifdef USE_ASM
|
||||
freecoeffs = (unsigned int *)
|
||||
malloc (resx * resy * 2 * sizeof (unsigned int) + 128);
|
||||
coeffs = (guint32 *) ((1 + ((unsigned int) (freecoeffs)) / 128) * 128);
|
||||
|
||||
#else
|
||||
pos10 = (unsigned int *) malloc (resx * resy * sizeof (unsigned int));
|
||||
c1 = (unsigned int *) malloc (resx * resy * sizeof (unsigned int));
|
||||
c2 = (unsigned int *) malloc (resx * resy * sizeof (unsigned int));
|
||||
c3 = (unsigned int *) malloc (resx * resy * sizeof (unsigned int));
|
||||
c4 = (unsigned int *) malloc (resx * resy * sizeof (unsigned int));
|
||||
#endif
|
||||
for (us = 0; us < 0xffff; us++) {
|
||||
sintable[us] = (int) (1024.0f * sin (us * 2 * 3.31415f / 0xffff));
|
||||
}
|
||||
|
||||
{
|
||||
int loopv;
|
||||
firedec = (int *) malloc (prevY * sizeof (int));
|
||||
for (loopv = prevY; loopv != 0;) {
|
||||
static int decc = 0;
|
||||
static int spdc = 0;
|
||||
static int accel = 0;
|
||||
|
||||
loopv--;
|
||||
firedec[loopv] = decc;
|
||||
decc += spdc / 10;
|
||||
spdc += RAND () % 3;
|
||||
spdc -= RAND () % 3;
|
||||
|
||||
if (decc > 4)
|
||||
spdc -= 1;
|
||||
if (decc < -4)
|
||||
spdc += 1;
|
||||
|
||||
if (spdc > 30)
|
||||
spdc = spdc - RAND () % 3 + accel / 10;
|
||||
if (spdc < -30)
|
||||
spdc = spdc + RAND () % 3 + accel / 10;
|
||||
|
||||
if (decc > 8 && spdc > 1)
|
||||
spdc -= RAND () % 3 - 2;
|
||||
|
||||
if (decc < -8 && spdc < -1)
|
||||
spdc += RAND () % 3 + 2;
|
||||
|
||||
if (decc > 8 || decc < -8)
|
||||
decc = decc * 8 / 9;
|
||||
|
||||
accel += RAND () % 2;
|
||||
accel -= RAND () % 2;
|
||||
if (accel > 20)
|
||||
accel -= 2;
|
||||
if (accel < -20)
|
||||
accel += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (zfd_update) {
|
||||
guchar sqrtperte = zf->sqrtperte;
|
||||
gint start_y = 0;
|
||||
|
||||
if (zf->reverse)
|
||||
zf->vitesse = 256 - zf->vitesse;
|
||||
|
||||
/* generation du buffer */
|
||||
for (y = 0; y < prevY; y++)
|
||||
for (x = 0; x < prevX; x++) {
|
||||
int px, py;
|
||||
unsigned char coefv, coefh;
|
||||
for (y = 0; y < zf->res_y; y++) {
|
||||
gint y_16 = y << 4;
|
||||
gint max_px = (prevX - 1) * sqrtperte;
|
||||
gint max_py = (prevY - 1) * sqrtperte;
|
||||
|
||||
for (x = 0; x < zf->res_x; x++) {
|
||||
gint px, py;
|
||||
guchar coefv, coefh;
|
||||
|
||||
/* calculer px et py en fonction de */
|
||||
/* x,y,middleX,middleY et theMode */
|
||||
calculatePXandPY (x, y, &px, &py);
|
||||
if ((px == x << 4) && (py == y << 4))
|
||||
calculatePXandPY (goomdata, x, y, &px, &py);
|
||||
|
||||
if ((px == x << 4) && (py == y_16))
|
||||
py += 8;
|
||||
|
||||
if ((py < 0) || (px < 0) ||
|
||||
(py >= (prevY - 1) * sqrtperte) ||
|
||||
(px >= (prevX - 1) * sqrtperte)) {
|
||||
if ((py < 0) || (px < 0) || (py >= max_py) || (px >= max_px)) {
|
||||
#ifdef USE_ASM
|
||||
coeffs[(y * prevX + x) * 2] = 0;
|
||||
coeffs[(y * prevX + x) * 2 + 1] = 0;
|
||||
#else
|
||||
pos10[y * prevX + x] = 0;
|
||||
c1[y * prevX + x] = 0;
|
||||
c2[y * prevX + x] = 0;
|
||||
c3[y * prevX + x] = 0;
|
||||
c4[y * prevX + x] = 0;
|
||||
pos10[start_y + x] = 0;
|
||||
c[0][start_y + x] = 0;
|
||||
c[1][start_y + x] = 0;
|
||||
c[2][start_y + x] = 0;
|
||||
c[3][start_y + x] = 0;
|
||||
#endif
|
||||
} else {
|
||||
int npx10;
|
||||
|
@ -470,23 +510,25 @@ zoomFilterFastRGB (Uint * pix1,
|
|||
coeffs[pos + 1] |= ((sqrtperte - coefh) * coefv) << 16;
|
||||
coeffs[pos + 1] |= (coefh * coefv) << 24;
|
||||
#else
|
||||
pos = y * prevX + x;
|
||||
pos = start_y + x;
|
||||
pos10[pos] = npx10 + prevX * npy10;
|
||||
|
||||
if (!(coefh || coefv))
|
||||
c1[pos] = sqrtperte * sqrtperte - 1;
|
||||
c[0][pos] = sqrtperte * sqrtperte - 1;
|
||||
else
|
||||
c1[pos] = (sqrtperte - coefh) * (sqrtperte - coefv);
|
||||
c[0][pos] = (sqrtperte - coefh) * (sqrtperte - coefv);
|
||||
|
||||
c2[pos] = coefh * (sqrtperte - coefv);
|
||||
c3[pos] = (sqrtperte - coefh) * coefv;
|
||||
c4[pos] = coefh * coefv;
|
||||
c[1][pos] = coefh * (sqrtperte - coefv);
|
||||
c[2][pos] = (sqrtperte - coefh) * coefv;
|
||||
c[3][pos] = coefh * coefv;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* Advance start of line index */
|
||||
start_y += prevX;
|
||||
}
|
||||
}
|
||||
#ifdef USE_ASM
|
||||
|
||||
#ifdef MMX
|
||||
zoom_width = prevX;
|
||||
mmx_zoom_size = prevX * prevY;
|
||||
|
@ -505,47 +547,54 @@ zoomFilterFastRGB (Uint * pix1,
|
|||
#endif
|
||||
#else
|
||||
for (position = 0; position < prevX * prevY; position++) {
|
||||
getPixelRGB_ (pix1, pos10[position], &col1);
|
||||
getPixelRGB_ (pix1, pos10[position] + 1, &col2);
|
||||
getPixelRGB_ (pix1, pos10[position] + prevX, &col3);
|
||||
getPixelRGB_ (pix1, pos10[position] + prevX + 1, &col4);
|
||||
getPixelRGB_ (pix1, pos10[position], &col1, goomdata->resolx,
|
||||
goomdata->resoly);
|
||||
getPixelRGB_ (pix1, pos10[position] + 1, &col2, goomdata->resolx,
|
||||
goomdata->resoly);
|
||||
getPixelRGB_ (pix1, pos10[position] + prevX, &col3, goomdata->resolx,
|
||||
goomdata->resoly);
|
||||
getPixelRGB_ (pix1, pos10[position] + prevX + 1, &col4, goomdata->resolx,
|
||||
goomdata->resoly);
|
||||
|
||||
couleur.r = col1.r * c1[position]
|
||||
+ col2.r * c2[position]
|
||||
+ col3.r * c3[position]
|
||||
+ col4.r * c4[position];
|
||||
couleur.r >>= pertedec;
|
||||
couleur.r = col1.r * c[0][position]
|
||||
+ col2.r * c[1][position]
|
||||
+ col3.r * c[2][position]
|
||||
+ col4.r * c[3][position];
|
||||
couleur.r >>= zf->pertedec;
|
||||
|
||||
couleur.v = col1.v * c1[position]
|
||||
+ col2.v * c2[position]
|
||||
+ col3.v * c3[position]
|
||||
+ col4.v * c4[position];
|
||||
couleur.v >>= pertedec;
|
||||
couleur.v = col1.v * c[0][position]
|
||||
+ col2.v * c[1][position]
|
||||
+ col3.v * c[2][position]
|
||||
+ col4.v * c[3][position];
|
||||
couleur.v >>= zf->pertedec;
|
||||
|
||||
couleur.b = col1.b * c1[position]
|
||||
+ col2.b * c2[position]
|
||||
+ col3.b * c3[position]
|
||||
+ col4.b * c4[position];
|
||||
couleur.b >>= pertedec;
|
||||
couleur.b = col1.b * c[0][position]
|
||||
+ col2.b * c[1][position]
|
||||
+ col3.b * c[2][position]
|
||||
+ col4.b * c[3][position];
|
||||
couleur.b >>= zf->pertedec;
|
||||
|
||||
setPixelRGB_ (pix2, position, couleur);
|
||||
setPixelRGB_ (pix2, position, couleur, goomdata->resolx, goomdata->resoly);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
pointFilter (Uint * pix1, Color c,
|
||||
pointFilter (GoomData * goomdata, Color c,
|
||||
float t1, float t2, float t3, float t4, Uint cycle)
|
||||
{
|
||||
Uint x = (Uint) ((int) middleX + (int) (t1 * cos ((float) cycle / t3)));
|
||||
Uint y = (Uint) ((int) middleY + (int) (t2 * sin ((float) cycle / t4)));
|
||||
Uint *pix1 = goomdata->p1;
|
||||
ZoomFilterData *zf = goomdata->zfd;
|
||||
Uint x = (Uint) (zf->middleX + (int) (t1 * cos ((float) cycle / t3)));
|
||||
Uint y = (Uint) (zf->middleY + (int) (t2 * sin ((float) cycle / t4)));
|
||||
|
||||
if ((x > 1) && (y > 1) && (x < resolx - 2) && (y < resoly - 2)) {
|
||||
setPixelRGB (pix1, x + 1, y, c);
|
||||
setPixelRGB (pix1, x, y + 1, c);
|
||||
setPixelRGB (pix1, x + 1, y + 1, WHITE);
|
||||
setPixelRGB (pix1, x + 2, y + 1, c);
|
||||
setPixelRGB (pix1, x + 1, y + 2, c);
|
||||
if ((x > 1) && (y > 1) && (x < goomdata->resolx - 2)
|
||||
&& (y < goomdata->resoly - 2)) {
|
||||
setPixelRGB (pix1, x + 1, y, c, goomdata->resolx, goomdata->resoly);
|
||||
setPixelRGB (pix1, x, y + 1, c, goomdata->resolx, goomdata->resoly);
|
||||
setPixelRGB (pix1, x + 1, y + 1, WHITE, goomdata->resolx, goomdata->resoly);
|
||||
setPixelRGB (pix1, x + 2, y + 1, c, goomdata->resolx, goomdata->resoly);
|
||||
setPixelRGB (pix1, x + 1, y + 2, c, goomdata->resolx, goomdata->resoly);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,21 +4,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include "graphic.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int vitesse ;
|
||||
unsigned char pertedec ;
|
||||
unsigned char sqrtperte ;
|
||||
int middleX,middleY ;
|
||||
char reverse ;
|
||||
char mode ;
|
||||
/** @since June 2001 */
|
||||
int hPlaneEffect ;
|
||||
int vPlaneEffect ;
|
||||
char noisify ;
|
||||
} ZoomFilterData ;
|
||||
|
||||
#include "goom_core.h"
|
||||
|
||||
#define NORMAL_MODE 0
|
||||
#define WAVE_MODE 1
|
||||
|
@ -27,7 +13,34 @@ typedef struct
|
|||
#define AMULETTE_MODE 4
|
||||
#define WATER_MODE 5
|
||||
|
||||
void pointFilter(guint32 *pix1, Color c,
|
||||
struct ZoomFilterData
|
||||
{
|
||||
int vitesse;
|
||||
unsigned char pertedec;
|
||||
unsigned char sqrtperte;
|
||||
int middleX;
|
||||
int middleY;
|
||||
char reverse;
|
||||
char mode;
|
||||
/** @since June 2001 */
|
||||
int hPlaneEffect;
|
||||
int vPlaneEffect;
|
||||
char noisify;
|
||||
|
||||
guint32 res_x;
|
||||
guint32 res_y;
|
||||
guint32 buffsize;
|
||||
|
||||
guint32 *buffer;
|
||||
guint32 *pos10;
|
||||
guint32 *c[4];
|
||||
int *firedec;
|
||||
|
||||
int wave;
|
||||
int wavesp;
|
||||
};
|
||||
|
||||
void pointFilter(GoomData *goomdata, Color c,
|
||||
float t1, float t2, float t3, float t4,
|
||||
guint32 cycle);
|
||||
|
||||
|
@ -42,11 +55,10 @@ Uint middleX,
|
|||
Uint middleY);
|
||||
*/
|
||||
|
||||
void zoomFilterFastRGB (guint32 *pix1,
|
||||
guint32 *pix2,
|
||||
ZoomFilterData *zf,
|
||||
guint32 resx, guint32 resy);
|
||||
|
||||
ZoomFilterData *zoomFilterNew ();
|
||||
void zoomFilterDestroy (ZoomFilterData *zf);
|
||||
void zoomFilterFastRGB (GoomData *goomdata, ZoomFilterData *zf,
|
||||
int zfd_update);
|
||||
|
||||
/* filtre sin :
|
||||
le contenu de pix1 est copie dans pix2, avec l'effet appliqué
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include <glib.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "goom_core.h"
|
||||
|
@ -13,67 +18,69 @@
|
|||
|
||||
#define STOP_SPEED 128
|
||||
|
||||
|
||||
/**-----------------------------------------------------**
|
||||
** SHARED DATA **
|
||||
**-----------------------------------------------------**/
|
||||
static guint32 *pixel;
|
||||
static guint32 *back;
|
||||
static guint32 *p1, *p2, *tmp;
|
||||
static guint32 cycle;
|
||||
|
||||
guint32 resolx, resoly, buffsize;
|
||||
|
||||
void
|
||||
goom_init (guint32 resx, guint32 resy)
|
||||
goom_init (GoomData * goomdata, guint32 resx, guint32 resy)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
printf ("GOOM: init (%d, %d);\n", resx, resy);
|
||||
#endif
|
||||
resolx = resx;
|
||||
resoly = resy;
|
||||
buffsize = resx * resy;
|
||||
goomdata->resolx = 0;
|
||||
goomdata->resoly = 0;
|
||||
goomdata->buffsize = 0;
|
||||
|
||||
pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
RAND_INIT (GPOINTER_TO_INT (pixel));
|
||||
cycle = 0;
|
||||
goomdata->pixel = NULL;
|
||||
goomdata->back = NULL;
|
||||
goomdata->p1 = NULL;
|
||||
goomdata->p2 = NULL;
|
||||
|
||||
p1 = (void *) (((unsigned long) pixel + 0x7f) & (~0x7f));
|
||||
p2 = (void *) (((unsigned long) back + 0x7f) & (~0x7f));
|
||||
goom_set_resolution (goomdata, resx, resy);
|
||||
RAND_INIT (goomdata, GPOINTER_TO_INT (goomdata->pixel));
|
||||
goomdata->cycle = 0;
|
||||
|
||||
|
||||
goomdata->goomlimit = 2; /* sensibilité du goom */
|
||||
goomdata->zfd = zoomFilterNew ();
|
||||
goomdata->lockvar = 0; /* pour empecher de nouveaux changements */
|
||||
goomdata->goomvar = 0; /* boucle des gooms */
|
||||
goomdata->totalgoom = 0; /* nombre de gooms par seconds */
|
||||
goomdata->agoom = 0; /* un goom a eu lieu.. */
|
||||
goomdata->loopvar = 0; /* mouvement des points */
|
||||
goomdata->speedvar = 0; /* vitesse des particules */
|
||||
goomdata->lineMode = 0; /* l'effet lineaire a dessiner */
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
goom_set_resolution (guint32 resx, guint32 resy)
|
||||
goom_set_resolution (GoomData * goomdata, guint32 resx, guint32 resy)
|
||||
{
|
||||
free (pixel);
|
||||
free (back);
|
||||
guint32 buffsize = resx * resy;
|
||||
|
||||
resolx = resx;
|
||||
resoly = resy;
|
||||
buffsize = resx * resy;
|
||||
if ((goomdata->resolx == resx) && (goomdata->resoly == resy))
|
||||
return;
|
||||
|
||||
pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
memset (pixel, 0, buffsize * sizeof (guint32) + 128);
|
||||
back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
memset (back, 0, buffsize * sizeof (guint32) + 128);
|
||||
if (goomdata->buffsize < buffsize) {
|
||||
if (goomdata->pixel)
|
||||
free (goomdata->pixel);
|
||||
if (goomdata->back)
|
||||
free (goomdata->back);
|
||||
goomdata->pixel = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
goomdata->back = (guint32 *) malloc (buffsize * sizeof (guint32) + 128);
|
||||
goomdata->buffsize = buffsize;
|
||||
|
||||
p1 = (void *) (((unsigned long) pixel + 0x7f) & (~0x7f));
|
||||
p2 = (void *) (((unsigned long) back + 0x7f) & (~0x7f));
|
||||
goomdata->p1 =
|
||||
(void *) (((unsigned long) goomdata->pixel + 0x7f) & (~0x7f));
|
||||
goomdata->p2 = (void *) (((unsigned long) goomdata->back + 0x7f) & (~0x7f));
|
||||
}
|
||||
|
||||
goomdata->resolx = resx;
|
||||
goomdata->resoly = resy;
|
||||
|
||||
memset (goomdata->pixel, 0, buffsize * sizeof (guint32) + 128);
|
||||
memset (goomdata->back, 0, buffsize * sizeof (guint32) + 128);
|
||||
}
|
||||
|
||||
|
||||
guint32 *
|
||||
goom_update (gint16 data[2][512])
|
||||
goom_update (GoomData * goomdata, gint16 data[2][512])
|
||||
{
|
||||
static int lockvar = 0; /* pour empecher de nouveaux changements */
|
||||
static int goomvar = 0; /* boucle des gooms */
|
||||
static int totalgoom = 0; /* nombre de gooms par seconds */
|
||||
static int agoom = 0; /* un goom a eu lieu.. */
|
||||
static int loopvar = 0; /* mouvement des points */
|
||||
static int speedvar = 0; /* vitesse des particules */
|
||||
static int lineMode = 0; /* l'effet lineaire a dessiner */
|
||||
guint32 *return_val;
|
||||
guint32 pointWidth;
|
||||
guint32 pointHeight;
|
||||
|
@ -81,16 +88,14 @@ goom_update (gint16 data[2][512])
|
|||
int accelvar; /* acceleration des particules */
|
||||
int i;
|
||||
float largfactor; /* elargissement de l'intervalle d'évolution des points */
|
||||
static char goomlimit = 2; /* sensibilité du goom */
|
||||
static ZoomFilterData zfd = {
|
||||
128, 8, 16,
|
||||
1, 1, 0, WAVE_MODE,
|
||||
0, 0, 0
|
||||
};
|
||||
|
||||
ZoomFilterData *pzfd;
|
||||
int zfd_update = 0;
|
||||
int resolx = goomdata->resolx;
|
||||
int resoly = goomdata->resoly;
|
||||
ZoomFilterData *pzfd = goomdata->zfd;
|
||||
guint32 *tmp;
|
||||
|
||||
/* test if the config has changed, update it if so */
|
||||
|
||||
pointWidth = (resolx * 2) / 5;
|
||||
pointHeight = (resoly * 2) / 5;
|
||||
|
||||
|
@ -102,308 +107,303 @@ goom_update (gint16 data[2][512])
|
|||
}
|
||||
|
||||
accelvar = incvar / 5000;
|
||||
if (speedvar > 5) {
|
||||
if (goomdata->speedvar > 5) {
|
||||
accelvar--;
|
||||
if (speedvar > 20)
|
||||
if (goomdata->speedvar > 20)
|
||||
accelvar--;
|
||||
if (speedvar > 40)
|
||||
speedvar = 40;
|
||||
if (goomdata->speedvar > 40)
|
||||
goomdata->speedvar = 40;
|
||||
}
|
||||
accelvar--;
|
||||
speedvar += accelvar;
|
||||
goomdata->speedvar += accelvar;
|
||||
|
||||
if (speedvar < 0)
|
||||
speedvar = 0;
|
||||
if (speedvar > 40)
|
||||
speedvar = 40;
|
||||
if (goomdata->speedvar < 0)
|
||||
goomdata->speedvar = 0;
|
||||
if (goomdata->speedvar > 40)
|
||||
goomdata->speedvar = 40;
|
||||
|
||||
|
||||
/* ! calcul du deplacement des petits points ... */
|
||||
|
||||
largfactor = ((float) speedvar / 40.0f + (float) incvar / 50000.0f) / 1.5f;
|
||||
largfactor =
|
||||
((float) goomdata->speedvar / 40.0f + (float) incvar / 50000.0f) / 1.5f;
|
||||
if (largfactor > 1.5f)
|
||||
largfactor = 1.5f;
|
||||
|
||||
for (i = 1; i * 15 <= speedvar + 15; i++) {
|
||||
loopvar += speedvar + 1;
|
||||
for (i = 1; i * 15 <= goomdata->speedvar + 15; i++) {
|
||||
goomdata->loopvar += goomdata->speedvar + 1;
|
||||
|
||||
pointFilter (p1,
|
||||
pointFilter (goomdata,
|
||||
YELLOW,
|
||||
((pointWidth - 6.0f) * largfactor + 5.0f),
|
||||
((pointHeight - 6.0f) * largfactor + 5.0f),
|
||||
i * 152.0f, 128.0f, loopvar + i * 2032);
|
||||
pointFilter (p1, ORANGE,
|
||||
i * 152.0f, 128.0f, goomdata->loopvar + i * 2032);
|
||||
pointFilter (goomdata, ORANGE,
|
||||
((pointWidth / 2) * largfactor) / i + 10.0f * i,
|
||||
((pointHeight / 2) * largfactor) / i + 10.0f * i,
|
||||
96.0f, i * 80.0f, loopvar / i);
|
||||
pointFilter (p1, VIOLET,
|
||||
96.0f, i * 80.0f, goomdata->loopvar / i);
|
||||
pointFilter (goomdata, VIOLET,
|
||||
((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i,
|
||||
((pointHeight / 3 + 5.0f) * largfactor) / i + 10.0f * i,
|
||||
i + 122.0f, 134.0f, loopvar / i);
|
||||
pointFilter (p1, BLACK,
|
||||
i + 122.0f, 134.0f, goomdata->loopvar / i);
|
||||
pointFilter (goomdata, BLACK,
|
||||
((pointHeight / 3) * largfactor + 20.0f),
|
||||
((pointHeight / 3) * largfactor + 20.0f),
|
||||
58.0f, i * 66.0f, loopvar / i);
|
||||
pointFilter (p1, WHITE,
|
||||
58.0f, i * 66.0f, goomdata->loopvar / i);
|
||||
pointFilter (goomdata, WHITE,
|
||||
(pointHeight * largfactor + 10.0f * i) / i,
|
||||
(pointHeight * largfactor + 10.0f * i) / i,
|
||||
66.0f, 74.0f, loopvar + i * 500);
|
||||
66.0f, 74.0f, goomdata->loopvar + i * 500);
|
||||
}
|
||||
|
||||
/* par défaut pas de changement de zoom */
|
||||
pzfd = NULL;
|
||||
|
||||
/* diminuer de 1 le temps de lockage */
|
||||
/* note pour ceux qui n'ont pas suivis : le lockvar permet d'empecher un */
|
||||
/* changement d'etat du plugins juste apres un autre changement d'etat. oki ? */
|
||||
if (--lockvar < 0)
|
||||
lockvar = 0;
|
||||
if (--goomdata->lockvar < 0)
|
||||
goomdata->lockvar = 0;
|
||||
|
||||
/* temps du goom */
|
||||
if (--agoom < 0)
|
||||
agoom = 0;
|
||||
if (--goomdata->agoom < 0)
|
||||
goomdata->agoom = 0;
|
||||
|
||||
/* on verifie qu'il ne se pas un truc interressant avec le son. */
|
||||
if ((accelvar > goomlimit) || (accelvar < -goomlimit)) {
|
||||
if ((accelvar > goomdata->goomlimit) || (accelvar < -goomdata->goomlimit)) {
|
||||
/* UN GOOM !!! YAHOO ! */
|
||||
totalgoom++;
|
||||
agoom = 20; /* mais pdt 20 cycles, il n'y en aura plus. */
|
||||
lineMode = (lineMode + 1) % 20; /* Tous les 10 gooms on change de mode lineaire */
|
||||
goomdata->totalgoom++;
|
||||
goomdata->agoom = 20; /* mais pdt 20 cycles, il n'y en aura plus. */
|
||||
goomdata->lineMode = (goomdata->lineMode + 1) % 20; /* Tous les 10 gooms on change de mode lineaire */
|
||||
|
||||
/* changement eventuel de mode */
|
||||
switch (iRAND (10)) {
|
||||
switch (iRAND (goomdata, 10)) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
zfd.mode = WAVE_MODE;
|
||||
zfd.vitesse = STOP_SPEED - 1;
|
||||
zfd.reverse = 0;
|
||||
pzfd->mode = WAVE_MODE;
|
||||
pzfd->vitesse = STOP_SPEED - 1;
|
||||
pzfd->reverse = 0;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
zfd.mode = CRYSTAL_BALL_MODE;
|
||||
pzfd->mode = CRYSTAL_BALL_MODE;
|
||||
break;
|
||||
case 5:
|
||||
zfd.mode = AMULETTE_MODE;
|
||||
pzfd->mode = AMULETTE_MODE;
|
||||
break;
|
||||
case 6:
|
||||
zfd.mode = WATER_MODE;
|
||||
pzfd->mode = WATER_MODE;
|
||||
break;
|
||||
case 7:
|
||||
zfd.mode = SCRUNCH_MODE;
|
||||
pzfd->mode = SCRUNCH_MODE;
|
||||
break;
|
||||
default:
|
||||
zfd.mode = NORMAL_MODE;
|
||||
pzfd->mode = NORMAL_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
/* tout ceci ne sera fait qu'en cas de non-blocage */
|
||||
if (lockvar == 0) {
|
||||
if (goomdata->lockvar == 0) {
|
||||
/* reperage de goom (acceleration forte de l'acceleration du volume) */
|
||||
/* -> coup de boost de la vitesse si besoin.. */
|
||||
if ((accelvar > goomlimit) || (accelvar < -goomlimit)) {
|
||||
goomvar++;
|
||||
if ((accelvar > goomdata->goomlimit) || (accelvar < -goomdata->goomlimit)) {
|
||||
goomdata->goomvar++;
|
||||
/*if (goomvar % 1 == 0) */
|
||||
{
|
||||
guint32 vtmp;
|
||||
guint32 newvit;
|
||||
|
||||
newvit = STOP_SPEED - speedvar / 2;
|
||||
newvit = STOP_SPEED - goomdata->speedvar / 2;
|
||||
/* retablir le zoom avant.. */
|
||||
if ((zfd.reverse) && (!(cycle % 12)) && (rand () % 3 == 0)) {
|
||||
zfd.reverse = 0;
|
||||
zfd.vitesse = STOP_SPEED - 2;
|
||||
lockvar = 50;
|
||||
if ((pzfd->reverse) && (!(goomdata->cycle % 12)) && (rand () % 3 == 0)) {
|
||||
pzfd->reverse = 0;
|
||||
pzfd->vitesse = STOP_SPEED - 2;
|
||||
goomdata->lockvar = 50;
|
||||
}
|
||||
if (iRAND (10) == 0) {
|
||||
zfd.reverse = 1;
|
||||
lockvar = 100;
|
||||
if (iRAND (goomdata, 10) == 0) {
|
||||
pzfd->reverse = 1;
|
||||
goomdata->lockvar = 100;
|
||||
}
|
||||
|
||||
/* changement de milieu.. */
|
||||
switch (iRAND (20)) {
|
||||
switch (iRAND (goomdata, 20)) {
|
||||
case 0:
|
||||
zfd.middleY = resoly - 1;
|
||||
zfd.middleX = resolx / 2;
|
||||
pzfd->middleY = resoly - 1;
|
||||
pzfd->middleX = resolx / 2;
|
||||
break;
|
||||
case 1:
|
||||
zfd.middleX = resolx - 1;
|
||||
pzfd->middleX = resolx - 1;
|
||||
break;
|
||||
case 2:
|
||||
zfd.middleX = 1;
|
||||
pzfd->middleX = 1;
|
||||
break;
|
||||
default:
|
||||
zfd.middleY = resoly / 2;
|
||||
zfd.middleX = resolx / 2;
|
||||
pzfd->middleY = resoly / 2;
|
||||
pzfd->middleX = resolx / 2;
|
||||
}
|
||||
|
||||
if (zfd.mode == WATER_MODE) {
|
||||
zfd.middleX = resolx / 2;
|
||||
zfd.middleY = resoly / 2;
|
||||
if (pzfd->mode == WATER_MODE) {
|
||||
pzfd->middleX = resolx / 2;
|
||||
pzfd->middleY = resoly / 2;
|
||||
}
|
||||
|
||||
switch (vtmp = (iRAND (27))) {
|
||||
switch (vtmp = (iRAND (goomdata, 27))) {
|
||||
case 0:
|
||||
zfd.vPlaneEffect = iRAND (3);
|
||||
zfd.vPlaneEffect -= iRAND (3);
|
||||
zfd.hPlaneEffect = iRAND (3);
|
||||
zfd.hPlaneEffect -= iRAND (3);
|
||||
pzfd->vPlaneEffect = iRAND (goomdata, 3);
|
||||
pzfd->vPlaneEffect -= iRAND (goomdata, 3);
|
||||
pzfd->hPlaneEffect = iRAND (goomdata, 3);
|
||||
pzfd->hPlaneEffect -= iRAND (goomdata, 3);
|
||||
break;
|
||||
case 3:
|
||||
zfd.vPlaneEffect = 0;
|
||||
zfd.hPlaneEffect = iRAND (8);
|
||||
zfd.hPlaneEffect -= iRAND (8);
|
||||
pzfd->vPlaneEffect = 0;
|
||||
pzfd->hPlaneEffect = iRAND (goomdata, 8);
|
||||
pzfd->hPlaneEffect -= iRAND (goomdata, 8);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
zfd.vPlaneEffect = iRAND (5);
|
||||
zfd.vPlaneEffect -= iRAND (5);
|
||||
zfd.hPlaneEffect = -zfd.vPlaneEffect;
|
||||
pzfd->vPlaneEffect = iRAND (goomdata, 5);
|
||||
pzfd->vPlaneEffect -= iRAND (goomdata, 5);
|
||||
pzfd->hPlaneEffect = -pzfd->vPlaneEffect;
|
||||
break;
|
||||
case 8:
|
||||
zfd.hPlaneEffect = 5 + iRAND (8);
|
||||
zfd.vPlaneEffect = -zfd.hPlaneEffect;
|
||||
pzfd->hPlaneEffect = 5 + iRAND (goomdata, 8);
|
||||
pzfd->vPlaneEffect = -pzfd->hPlaneEffect;
|
||||
break;
|
||||
case 9:
|
||||
zfd.vPlaneEffect = 5 + iRAND (8);
|
||||
zfd.hPlaneEffect = -zfd.hPlaneEffect;
|
||||
pzfd->vPlaneEffect = 5 + iRAND (goomdata, 8);
|
||||
pzfd->hPlaneEffect = -pzfd->hPlaneEffect;
|
||||
break;
|
||||
case 13:
|
||||
zfd.hPlaneEffect = 0;
|
||||
zfd.vPlaneEffect = iRAND (10);
|
||||
zfd.vPlaneEffect -= iRAND (10);
|
||||
pzfd->hPlaneEffect = 0;
|
||||
pzfd->vPlaneEffect = iRAND (goomdata, 10);
|
||||
pzfd->vPlaneEffect -= iRAND (goomdata, 10);
|
||||
break;
|
||||
default:
|
||||
if (vtmp < 10) {
|
||||
zfd.vPlaneEffect = 0;
|
||||
zfd.hPlaneEffect = 0;
|
||||
pzfd->vPlaneEffect = 0;
|
||||
pzfd->hPlaneEffect = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (iRAND (3) != 0)
|
||||
zfd.noisify = 0;
|
||||
if (iRAND (goomdata, 3) != 0)
|
||||
pzfd->noisify = 0;
|
||||
else {
|
||||
zfd.noisify = iRAND (3) + 2;
|
||||
lockvar *= 3;
|
||||
pzfd->noisify = iRAND (goomdata, 3) + 2;
|
||||
goomdata->lockvar *= 3;
|
||||
}
|
||||
|
||||
if (zfd.mode == AMULETTE_MODE) {
|
||||
zfd.vPlaneEffect = 0;
|
||||
zfd.hPlaneEffect = 0;
|
||||
zfd.noisify = 0;
|
||||
if (pzfd->mode == AMULETTE_MODE) {
|
||||
pzfd->vPlaneEffect = 0;
|
||||
pzfd->hPlaneEffect = 0;
|
||||
pzfd->noisify = 0;
|
||||
}
|
||||
|
||||
if ((zfd.middleX == 1) || (zfd.middleX == resolx - 1)) {
|
||||
zfd.vPlaneEffect = 0;
|
||||
zfd.hPlaneEffect = iRAND (2) ? 0 : zfd.hPlaneEffect;
|
||||
if ((pzfd->middleX == 1) || (pzfd->middleX == resolx - 1)) {
|
||||
pzfd->vPlaneEffect = 0;
|
||||
pzfd->hPlaneEffect = iRAND (goomdata, 2) ? 0 : pzfd->hPlaneEffect;
|
||||
}
|
||||
|
||||
if (newvit < zfd.vitesse) { /* on accelere */
|
||||
pzfd = &zfd;
|
||||
if (newvit < pzfd->vitesse) { /* on accelere */
|
||||
zfd_update = 1;
|
||||
if (((newvit < STOP_SPEED - 7) &&
|
||||
(zfd.vitesse < STOP_SPEED - 6) &&
|
||||
(cycle % 3 == 0)) || (iRAND (40) == 0)) {
|
||||
zfd.vitesse = STOP_SPEED - 1;
|
||||
zfd.reverse = !zfd.reverse;
|
||||
(pzfd->vitesse < STOP_SPEED - 6) &&
|
||||
(goomdata->cycle % 3 == 0)) || (iRAND (goomdata, 40) == 0)) {
|
||||
pzfd->vitesse = STOP_SPEED - 1;
|
||||
pzfd->reverse = !pzfd->reverse;
|
||||
} else {
|
||||
zfd.vitesse = (newvit + zfd.vitesse * 4) / 5;
|
||||
pzfd->vitesse = (newvit + pzfd->vitesse * 4) / 5;
|
||||
}
|
||||
lockvar += 50;
|
||||
goomdata->lockvar += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* mode mega-lent */
|
||||
if (iRAND (1000) == 0) {
|
||||
if (iRAND (goomdata, 1000) == 0) {
|
||||
/*
|
||||
printf ("coup du sort...\n") ;
|
||||
*/
|
||||
pzfd = &zfd;
|
||||
zfd.vitesse = STOP_SPEED - 1;
|
||||
zfd.pertedec = 8;
|
||||
zfd.sqrtperte = 16;
|
||||
goomvar = 1;
|
||||
lockvar += 70;
|
||||
zfd_update = 1;
|
||||
pzfd->vitesse = STOP_SPEED - 1;
|
||||
pzfd->pertedec = 8;
|
||||
pzfd->sqrtperte = 16;
|
||||
goomdata->goomvar = 1;
|
||||
goomdata->lockvar += 70;
|
||||
}
|
||||
}
|
||||
|
||||
/* gros frein si la musique est calme */
|
||||
if ((speedvar < 1) && (zfd.vitesse < STOP_SPEED - 4) && (cycle % 16 == 0)) {
|
||||
if ((goomdata->speedvar < 1) && (pzfd->vitesse < STOP_SPEED - 4)
|
||||
&& (goomdata->cycle % 16 == 0)) {
|
||||
/*
|
||||
printf ("++slow part... %i\n", zfd.vitesse) ;
|
||||
*/
|
||||
pzfd = &zfd;
|
||||
zfd.vitesse += 3;
|
||||
zfd.pertedec = 8;
|
||||
zfd.sqrtperte = 16;
|
||||
goomvar = 0;
|
||||
zfd_update = 1;
|
||||
pzfd->vitesse += 3;
|
||||
pzfd->pertedec = 8;
|
||||
pzfd->sqrtperte = 16;
|
||||
goomdata->goomvar = 0;
|
||||
/*
|
||||
printf ("--slow part... %i\n", zfd.vitesse) ;
|
||||
*/
|
||||
}
|
||||
|
||||
/* baisser regulierement la vitesse... */
|
||||
if ((cycle % 73 == 0) && (zfd.vitesse < STOP_SPEED - 5)) {
|
||||
if ((goomdata->cycle % 73 == 0) && (pzfd->vitesse < STOP_SPEED - 5)) {
|
||||
/*
|
||||
printf ("slow down...\n") ;
|
||||
*/
|
||||
pzfd = &zfd;
|
||||
zfd.vitesse++;
|
||||
zfd_update = 1;
|
||||
pzfd->vitesse++;
|
||||
}
|
||||
|
||||
/* arreter de decrémenter au bout d'un certain temps */
|
||||
if ((cycle % 101 == 0) && (zfd.pertedec == 7)) {
|
||||
pzfd = &zfd;
|
||||
zfd.pertedec = 8;
|
||||
zfd.sqrtperte = 16;
|
||||
if ((goomdata->cycle % 101 == 0) && (pzfd->pertedec == 7)) {
|
||||
zfd_update = 1;
|
||||
pzfd->pertedec = 8;
|
||||
pzfd->sqrtperte = 16;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
if (pzfd) {
|
||||
printf ("GOOM: pzfd->mode = %d\n", pzfd->mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Zoom here ! */
|
||||
zoomFilterFastRGB (p1, p2, pzfd, resolx, resoly);
|
||||
zoomFilterFastRGB (goomdata, pzfd, zfd_update);
|
||||
|
||||
/* si on est dans un goom : afficher les lignes... */
|
||||
if (agoom > 15)
|
||||
if (goomdata->agoom > 15)
|
||||
goom_lines
|
||||
(data, ((zfd.middleX == resolx / 2) && (zfd.middleY == resoly / 2)
|
||||
&& (zfd.mode != WATER_MODE))
|
||||
? (lineMode / 10) : 0, p2, agoom - 15);
|
||||
(goomdata, data, ((pzfd->middleX == resolx / 2)
|
||||
&& (pzfd->middleY == resoly / 2)
|
||||
&& (pzfd->mode != WATER_MODE))
|
||||
? (goomdata->lineMode / 10) : 0, goomdata->p2, goomdata->agoom - 15);
|
||||
|
||||
return_val = p2;
|
||||
tmp = p1;
|
||||
p1 = p2;
|
||||
p2 = tmp;
|
||||
return_val = goomdata->p2;
|
||||
tmp = goomdata->p1;
|
||||
goomdata->p1 = goomdata->p2;
|
||||
goomdata->p2 = tmp;
|
||||
|
||||
/* affichage et swappage des buffers.. */
|
||||
cycle++;
|
||||
goomdata->cycle++;
|
||||
|
||||
/* tous les 100 cycles : vérifier si le taux de goom est correct */
|
||||
/* et le modifier sinon.. */
|
||||
if (!(cycle % 100)) {
|
||||
if (totalgoom > 15) {
|
||||
if (!(goomdata->cycle % 100)) {
|
||||
if (goomdata->totalgoom > 15) {
|
||||
/* printf ("less gooms\n") ; */
|
||||
goomlimit++;
|
||||
goomdata->goomlimit++;
|
||||
} else {
|
||||
if ((totalgoom == 0) && (goomlimit > 1))
|
||||
goomlimit--;
|
||||
if ((goomdata->totalgoom == 0) && (goomdata->goomlimit > 1))
|
||||
goomdata->goomlimit--;
|
||||
}
|
||||
totalgoom = 0;
|
||||
goomdata->totalgoom = 0;
|
||||
}
|
||||
return return_val;
|
||||
}
|
||||
|
||||
void
|
||||
goom_close ()
|
||||
goom_close (GoomData * goomdata)
|
||||
{
|
||||
if (pixel != NULL)
|
||||
free (pixel);
|
||||
if (back != NULL)
|
||||
free (back);
|
||||
pixel = back = NULL;
|
||||
RAND_CLOSE ();
|
||||
if (goomdata->pixel != NULL)
|
||||
free (goomdata->pixel);
|
||||
if (goomdata->back != NULL)
|
||||
free (goomdata->back);
|
||||
goomdata->pixel = goomdata->back = NULL;
|
||||
RAND_CLOSE (goomdata);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,41 @@
|
|||
|
||||
#include <glib.h>
|
||||
|
||||
void goom_init (guint32 resx, guint32 resy);
|
||||
void goom_set_resolution (guint32 resx, guint32 resy);
|
||||
typedef struct ZoomFilterData ZoomFilterData;
|
||||
|
||||
guint32 * goom_update (gint16 data [2][512]);
|
||||
typedef struct
|
||||
{
|
||||
/**-----------------------------------------------------**
|
||||
** SHARED DATA **
|
||||
**-----------------------------------------------------**/
|
||||
guint32 *pixel;
|
||||
guint32 *back;
|
||||
guint32 *p1, *p2;
|
||||
guint32 cycle;
|
||||
|
||||
void goom_close ();
|
||||
guint32 resolx, resoly, buffsize;
|
||||
|
||||
int lockvar; /* pour empecher de nouveaux changements */
|
||||
int goomvar; /* boucle des gooms */
|
||||
int totalgoom; /* nombre de gooms par seconds */
|
||||
int agoom; /* un goom a eu lieu.. */
|
||||
int loopvar; /* mouvement des points */
|
||||
int speedvar; /* vitesse des particules */
|
||||
int lineMode; /* l'effet lineaire a dessiner */
|
||||
char goomlimit; /* sensibilité du goom */
|
||||
|
||||
ZoomFilterData *zfd;
|
||||
|
||||
/* Random table */
|
||||
gint *rand_tab;
|
||||
guint rand_pos;
|
||||
} GoomData;
|
||||
|
||||
void goom_init (GoomData *goomdata, guint32 resx, guint32 resy);
|
||||
void goom_set_resolution (GoomData *goomdata, guint32 resx, guint32 resy);
|
||||
|
||||
guint32 *goom_update (GoomData *goomdata, gint16 data [2][512]);
|
||||
|
||||
void goom_close (GoomData *goomdata);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,27 +3,22 @@
|
|||
|
||||
#define NB_RAND 0x10000
|
||||
|
||||
/* in graphic.c */
|
||||
extern int * rand_tab ;
|
||||
extern unsigned short rand_pos ;
|
||||
#define RAND_INIT(gd,i) \
|
||||
srand (i); \
|
||||
if (gd->rand_tab == NULL) \
|
||||
gd->rand_tab = g_malloc (NB_RAND * sizeof(gint)) ;\
|
||||
gd->rand_pos = 0; \
|
||||
while (gd->rand_pos < NB_RAND) \
|
||||
gd->rand_tab [gd->rand_pos++] = rand ();
|
||||
|
||||
#define RAND_INIT(i) \
|
||||
srand (i) ;\
|
||||
if (!rand_tab)\
|
||||
rand_tab = (int *) malloc (NB_RAND * sizeof(int)) ;\
|
||||
rand_pos = 1 ;\
|
||||
while (rand_pos != 0)\
|
||||
rand_tab [rand_pos++] = rand () ;
|
||||
|
||||
#define RAND()\
|
||||
(rand_tab[rand_pos = rand_pos + 1])
|
||||
|
||||
#define RAND_CLOSE()\
|
||||
free (rand_tab);\
|
||||
rand_tab = 0;
|
||||
#define RAND(gd) \
|
||||
(gd->rand_tab[gd->rand_pos = ((gd->rand_pos + 1) % NB_RAND)])
|
||||
|
||||
#define RAND_CLOSE(gd) \
|
||||
g_free (gd->rand_tab); \
|
||||
gd->rand_tab = NULL;
|
||||
|
||||
/*#define iRAND(i) ((guint32)((float)i * RAND()/RAND_MAX)) */
|
||||
#define iRAND(i) (RAND()%i)
|
||||
#define iRAND(gd,i) (RAND(gd) % i)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,10 +12,3 @@ const Color BLUE = { 0, 0, 0xff };
|
|||
const Color YELLOW = { 0xff, 0xff, 0x33 };
|
||||
const Color ORANGE = { 0xff, 0xcc, 0x00 };
|
||||
const Color VIOLET = { 0x55, 0x00, 0xff };
|
||||
|
||||
unsigned int SIZE;
|
||||
unsigned int HEIGHT;
|
||||
unsigned int WIDTH;
|
||||
|
||||
int *rand_tab = 0;
|
||||
unsigned short int rand_pos = 0;
|
||||
|
|
|
@ -182,7 +182,7 @@ gst_goom_init (GstGoom * goom)
|
|||
goom->samples_consumed = 0;
|
||||
goom->disposed = FALSE;
|
||||
|
||||
goom_init (goom->width, goom->height);
|
||||
goom_init (&(goom->goomdata), goom->width, goom->height);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -191,7 +191,7 @@ gst_goom_dispose (GObject * object)
|
|||
GstGoom *goom = GST_GOOM (object);
|
||||
|
||||
if (!goom->disposed) {
|
||||
goom_close ();
|
||||
goom_close (&(goom->goomdata));
|
||||
goom->disposed = TRUE;
|
||||
|
||||
g_object_unref (goom->adapter);
|
||||
|
@ -233,7 +233,7 @@ gst_goom_src_setcaps (GstPad * pad, GstCaps * caps)
|
|||
&goom->fps_d))
|
||||
return FALSE;
|
||||
|
||||
goom_set_resolution (goom->width, goom->height);
|
||||
goom_set_resolution (&(goom->goomdata), goom->width, goom->height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ gst_goom_chain (GstPad * pad, GstBuffer * bufin)
|
|||
GST_BUFFER_DURATION (bufout) = frame_duration;
|
||||
GST_BUFFER_SIZE (bufout) = goom->width * goom->height * 4;
|
||||
|
||||
out_frame = (guchar *) goom_update (goom->datain);
|
||||
out_frame = (guchar *) goom_update (&(goom->goomdata), goom->datain);
|
||||
memcpy (GST_BUFFER_DATA (bufout), out_frame, GST_BUFFER_SIZE (bufout));
|
||||
|
||||
GST_DEBUG ("Pushing frame with time=%" G_GUINT64_FORMAT ", duration=%"
|
||||
|
|
|
@ -24,6 +24,7 @@ G_BEGIN_DECLS
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
#include "goom_core.h"
|
||||
|
||||
#define GOOM_SAMPLES 512
|
||||
|
||||
|
@ -60,6 +61,8 @@ struct _GstGoom
|
|||
gint channels;
|
||||
|
||||
gboolean disposed;
|
||||
|
||||
GoomData goomdata;
|
||||
};
|
||||
|
||||
struct _GstGoomClass
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "lines.h"
|
||||
#include <math.h>
|
||||
|
||||
extern unsigned int resolx, resoly;
|
||||
|
||||
static inline unsigned char
|
||||
lighten (unsigned char value, unsigned char power)
|
||||
{
|
||||
|
@ -27,11 +25,13 @@ lighten (unsigned char value, unsigned char power)
|
|||
}
|
||||
|
||||
void
|
||||
goom_lines (gint16 data[2][512], unsigned int ID, unsigned int *p,
|
||||
guint32 power)
|
||||
goom_lines (GoomData * goomdata, gint16 data[2][512], unsigned int ID,
|
||||
unsigned int *p, guint32 power)
|
||||
{
|
||||
guint32 color1;
|
||||
guint32 color2;
|
||||
guint32 resolx = goomdata->resolx;
|
||||
guint32 resoly = goomdata->resoly;
|
||||
unsigned char *color = 1 + (unsigned char *) &color1;
|
||||
|
||||
switch (ID) {
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include <glib.h>
|
||||
|
||||
#include "graphic.h"
|
||||
#include "goom_core.h"
|
||||
|
||||
void goom_lines(GoomData *goomdata, gint16 data [2][512], unsigned int ID,unsigned int* p, guint32 power);
|
||||
|
||||
void goom_lines(gint16 data [2][512], unsigned int ID,unsigned int* p, guint32 power);
|
||||
void goom_lines_conf(gint16 config [25]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue