From a7bc7485b1a4d7e1b1a12ff593ca4ccb1d59e466 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 23 Feb 2008 01:51:37 +0000 Subject: configure.ac: Add checks for Flex/Yacc/Bison and other furry animals, for the new goom 2k4 based plugin Original commit message from CVS: 2008-02-23 Bastien Nocera * configure.ac: Add checks for Flex/Yacc/Bison and other furry animals, for the new goom 2k4 based plugin * gst/goom/*: Update to use goom 2k4, uses liboil to detect CPU optimisations (not working yet), move the old plugin to... * gst/goom2k1/*: ... here, in case somebody is sick enough Fixes #515073 --- gst/goom/lines.c | 288 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 211 insertions(+), 77 deletions(-) (limited to 'gst/goom/lines.c') diff --git a/gst/goom/lines.c b/gst/goom/lines.c index 3214e1db..a2a94d43 100644 --- a/gst/goom/lines.c +++ b/gst/goom/lines.c @@ -1,107 +1,241 @@ /* * lines.c - * iTunesXPlugIn - * - * Created by guillaum on Tue Aug 14 2001. - * Copyright (c) 2001 __CompanyName__. All rights reserved. - * */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include "lines.h" #include +#include +#include +#include "goom_tools.h" +#include "drawmethods.h" +#include "goom_plugin_info.h" static inline unsigned char -lighten (unsigned char value, unsigned char power) +lighten (unsigned char value, float power) { - unsigned char i; + int val = value; + float t = (float) val * log10 (power) / 2.0; - for (i = 0; i < power; i++) - value += (255 - value) / 5; - return value; + if (t > 0) { + val = (int) t; /* (32.0f * log (t)); */ + if (val > 255) + val = 255; + if (val < 0) + val = 0; + return val; + } else { + return 0; + } } -void -goom_lines (GoomData * goomdata, gint16 data[2][512], unsigned int ID, - unsigned int *p, guint32 power) +static void +lightencolor (guint32 * col, float power) { - guint32 color1; - guint32 color2; - guint32 resolx = goomdata->resolx; - guint32 resoly = goomdata->resoly; - unsigned char *color = 1 + (unsigned char *) &color1; - - switch (ID) { - case 0: /* Horizontal stereo lines */ - { - color1 = 0x0000AA00; - color2 = 0x00AA0000; - break; - } + unsigned char *color; - case 1: /* Stereo circles */ - { - color1 = 0x00AA33DD; - color2 = 0x00AA33DD; - break; - } - } + color = (unsigned char *) col; *color = lighten (*color, power); color++; *color = lighten (*color, power); color++; *color = lighten (*color, power); - color = 1 + (unsigned char *) &color2; - *color = lighten (*color, power); - color++; - *color = lighten (*color, power); color++; *color = lighten (*color, power); +} - switch (ID) { - case 0: /* Horizontal stereo lines */ - { - unsigned int i; + +static void +genline (int id, float param, GMUnitPointer * l, int rx, int ry) +{ + int i; + + switch (id) { + case GML_HLINE: for (i = 0; i < 512; i++) { - guint32 plot; - - plot = i * resolx / 512 + (resoly / 4 + data[0][i] / 1600) * resolx; - p[plot] = color1; - p[plot + 1] = color1; - plot = i * resolx / 512 + (resoly * 3 / 4 - data[1][i] / 1600) * resolx; - p[plot] = color2; - p[plot + 1] = color2; + l[i].x = ((float) i * rx) / 512.0f; + l[i].y = param; + l[i].angle = M_PI / 2.0f; } - break; - } + return; + case GML_VLINE: + for (i = 0; i < 512; i++) { + l[i].y = ((float) i * ry) / 512.0f; + l[i].x = param; + l[i].angle = 0.0f; + } + return; + case GML_CIRCLE: + for (i = 0; i < 512; i++) { + float cosa, sina; - case 1: /* Stereo circles */ - { - float z; - unsigned int monX = resolx / 2; - float monY = resoly / 4; - float monY2 = resoly / 2; - - for (z = 0; z < 6.2832f; z += 1.0f / monY) { - /* float offset1 = 128+data[1][(unsigned int)(z*81.33f)])/200000; */ - p[monX + (unsigned int) ((monY + ((float) resoly) * (128 + - data[1][(unsigned int) (z * 81.33f)]) / 200000) * - cos (z) + resolx * (unsigned int) (monY2 + (monY + - ((float) resoly) * (128 + - data[1][(unsigned int) (z * 81.33f)]) / 400000) * - sin (z)))] = color1; - p[monX + (unsigned int) ((monY - ((float) resoly) * (128 + - data[0][(unsigned int) (z * 81.33f)]) / 200000) * - cos (z) + resolx * (unsigned int) (monY2 + (monY - - ((float) resoly) * (128 + - data[0][(unsigned int) (z * 81.33f)]) / 400000) * - sin (z)))] = color2; + l[i].angle = 2.0f * M_PI * (float) i / 512.0f; + cosa = param * cos (l[i].angle); + sina = param * sin (l[i].angle); + l[i].x = ((float) rx / 2.0f) + cosa; + l[i].y = (float) ry / 2.0f + sina; } - break; + return; + } +} + +static guint32 +getcouleur (int mode) +{ + switch (mode) { + case GML_RED: + return (230 << (ROUGE * 8)) | (120 << (VERT * 8)) | (18 << (BLEU * 8)); + case GML_ORANGE_J: + return (120 << (VERT * 8)) | (252 << (ROUGE * 8)) | (18 << (BLEU * 8)); + case GML_ORANGE_V: + return (160 << (VERT * 8)) | (236 << (ROUGE * 8)) | (40 << (BLEU * 8)); + case GML_BLEUBLANC: + return (40 << (BLEU * 8)) | (220 << (ROUGE * 8)) | (140 << (VERT * 8)); + case GML_VERT: + return (200 << (VERT * 8)) | (80 << (ROUGE * 8)) | (18 << (BLEU * 8)); + case GML_BLEU: + return (250 << (BLEU * 8)) | (30 << (VERT * 8)) | (80 << (ROUGE * 8)); + case GML_BLACK: + return (16 << (BLEU * 8)) | (16 << (VERT * 8)) | (16 << (ROUGE * 8)); + } + return 0; +} + +void +goom_lines_set_res (GMLine * gml, int rx, int ry) +{ + if (gml != NULL) { + gml->screenX = rx; + gml->screenY = ry; + + genline (gml->IDdest, gml->param, gml->points2, rx, ry); + } +} + + +static void +goom_lines_move (GMLine * l) +{ + int i; + unsigned char *c1, *c2; + + for (i = 0; i < 512; i++) { + l->points[i].x = (l->points2[i].x + 39.0f * l->points[i].x) / 40.0f; + l->points[i].y = (l->points2[i].y + 39.0f * l->points[i].y) / 40.0f; + l->points[i].angle = + (l->points2[i].angle + 39.0f * l->points[i].angle) / 40.0f; + } + + c1 = (unsigned char *) &l->color; + c2 = (unsigned char *) &l->color2; + for (i = 0; i < 4; i++) { + int cc1, cc2; + + cc1 = *c1; + cc2 = *c2; + *c1 = (unsigned char) ((cc1 * 63 + cc2) >> 6); + ++c1; + ++c2; + } + + l->power += l->powinc; + if (l->power < 1.1f) { + l->power = 1.1f; + l->powinc = (float) (goom_irand (l->goomInfo->gRandom, 20) + 10) / 300.0f; + } + if (l->power > 17.5f) { + l->power = 17.5f; + l->powinc = -(float) (goom_irand (l->goomInfo->gRandom, 20) + 10) / 300.0f; + } + + l->amplitude = (99.0f * l->amplitude + l->amplitudeF) / 100.0f; +} + +void +goom_lines_switch_to (GMLine * gml, int IDdest, + float param, float amplitude, int col) +{ + genline (IDdest, param, gml->points2, gml->screenX, gml->screenY); + gml->IDdest = IDdest; + gml->param = param; + gml->amplitudeF = amplitude; + gml->color2 = getcouleur (col); +} + +GMLine * +goom_lines_init (PluginInfo * goomInfo, int rx, int ry, + int IDsrc, float paramS, int coulS, int IDdest, float paramD, int coulD) +{ + GMLine *l = (GMLine *) malloc (sizeof (GMLine)); + + l->goomInfo = goomInfo; + + l->points = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer)); + l->points2 = (GMUnitPointer *) malloc (512 * sizeof (GMUnitPointer)); + l->nbPoints = 512; + + l->IDdest = IDdest; + l->param = paramD; + + l->amplitude = l->amplitudeF = 1.0f; + + genline (IDsrc, paramS, l->points, rx, ry); + genline (IDdest, paramD, l->points2, rx, ry); + + l->color = getcouleur (coulS); + l->color2 = getcouleur (coulD); + + l->screenX = rx; + l->screenY = ry; + + l->power = 0.0f; + l->powinc = 0.01f; + + goom_lines_switch_to (l, IDdest, paramD, 1.0f, coulD); + + return l; +} + +void +goom_lines_free (GMLine ** l) +{ + free ((*l)->points); + free (*l); + l = NULL; +} + +void +goom_lines_draw (PluginInfo * plug, GMLine * line, gint16 data[512], Pixel * p) +{ + if (line != NULL) { + int i, x1, y1; + guint32 color = line->color; + GMUnitPointer *pt = &(line->points[0]); + + float cosa = cos (pt->angle) / 1000.0f; + float sina = sin (pt->angle) / 1000.0f; + + lightencolor (&color, line->power); + + x1 = (int) (pt->x + cosa * line->amplitude * data[0]); + y1 = (int) (pt->y + sina * line->amplitude * data[0]); + + for (i = 1; i < 512; i++) { + int x2, y2; + GMUnitPointer *pt = &(line->points[i]); + + float cosa = cos (pt->angle) / 1000.0f; + float sina = sin (pt->angle) / 1000.0f; + + x2 = (int) (pt->x + cosa * line->amplitude * data[i]); + y2 = (int) (pt->y + sina * line->amplitude * data[i]); + + plug->methods.draw_line (p, x1, y1, x2, y2, color, line->screenX, + line->screenY); + + x1 = x2; + y1 = y2; } + goom_lines_move (line); } } -- cgit