Commit b1877117 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

gst/goom/: Remove a bunch of font/text related code that we don't need.

Original commit message from CVS:
* gst/goom/Makefile.am:
* gst/goom/gfontlib.c:
* gst/goom/gfontlib.h:
* gst/goom/gfontrle.c:
* gst/goom/gfontrle.h:
* gst/goom/goom.h:
* gst/goom/goom_core.c: (goom_update):
* gst/goom/goom_plugin_info.h:
* gst/goom/gstgoom.c: (gst_goom_chain):
* gst/goom/plugin_info.c:
Remove a bunch of font/text related code that we don't need.
parent 758639f9
2008-04-09 Tim-Philipp Müller <tim at centricular dot net>
* gst/goom/Makefile.am:
* gst/goom/gfontlib.c:
* gst/goom/gfontlib.h:
* gst/goom/gfontrle.c:
* gst/goom/gfontrle.h:
* gst/goom/goom.h:
* gst/goom/goom_core.c: (goom_update):
* gst/goom/goom_plugin_info.h:
* gst/goom/gstgoom.c: (gst_goom_chain):
* gst/goom/plugin_info.c:
Remove a bunch of font/text related code that we don't need.
2008-04-09 Tim-Philipp Müller <tim at centricular dot net>
* gst/goom/ppc_drawings.s:
......
......@@ -28,7 +28,6 @@ libgstgoom_la_SOURCES = \
goomsl.c goomsl_private.h \
lines.c lines.h ifs.c ifs.h surf3d.c surf3d.h \
tentacle3d.c tentacle3d.h v3d.c v3d.h \
gfontrle.c gfontrle.h gfontlib.c gfontlib.h \
convolve_fx.c flying_stars_fx.c \
goom_fx.h goom_visual_fx.h \
motif_goom1.h motif_goom2.h \
......
#include "goom_config.h"
#include "gfontrle.h"
#include "gfontlib.h"
#include <string.h>
#include <stdlib.h>
static Pixel ***font_chars;
static int *font_width;
static int *font_height;
static Pixel ***small_font_chars;
static int *small_font_width;
static int *small_font_height;
void
gfont_load (void)
{
unsigned char *gfont;
unsigned int i = 0, j = 0;
unsigned int nba = 0;
unsigned int current = 32;
int *font_pos;
/* decompress le rle */
gfont = malloc (the_font.width * the_font.height * the_font.bytes_per_pixel);
while (i < the_font.rle_size) {
unsigned char c = the_font.rle_pixel[i++];
if (c == 0) {
unsigned int nb = the_font.rle_pixel[i++];
while (nb--)
gfont[j++] = 0;
} else
gfont[j++] = c;
}
/* determiner les positions de chaque lettre. */
font_height = calloc (256, sizeof (int));
small_font_height = calloc (256, sizeof (int));
font_width = calloc (256, sizeof (int));
small_font_width = calloc (256, sizeof (int));
font_chars = calloc (256, sizeof (int **));
small_font_chars = calloc (256, sizeof (int **));
font_pos = calloc (256, sizeof (int));
for (i = 0; i < the_font.width; i++) {
unsigned char a = gfont[i * 4 + 3];
if (a)
nba++;
else
nba = 0;
if (nba == 2) {
font_width[current] = i - font_pos[current];
small_font_width[current] = font_width[current] / 2;
font_pos[++current] = i;
font_height[current] = the_font.height - 2;
small_font_height[current] = font_height[current] / 2;
}
}
font_pos[current] = 0;
font_height[current] = 0;
small_font_height[current] = 0;
/* charger les lettres et convertir au format de la machine */
for (i = 33; i < current; i++) {
int x;
int y;
font_chars[i] = malloc (font_height[i] * sizeof (int *));
small_font_chars[i] = malloc (font_height[i] * sizeof (int *) / 2);
for (y = 0; y < font_height[i]; y++) {
font_chars[i][y] = malloc (font_width[i] * sizeof (int));
for (x = 0; x < font_width[i]; x++) {
unsigned int r, g, b, a;
r = gfont[(y + 2) * (the_font.width * 4) + (x * 4 + font_pos[i] * 4)];
g = gfont[(y + 2) * (the_font.width * 4) + (x * 4 + font_pos[i] * 4 +
1)];
b = gfont[(y + 2) * (the_font.width * 4) + (x * 4 + font_pos[i] * 4 +
2)];
a = gfont[(y + 2) * (the_font.width * 4) + (x * 4 + font_pos[i] * 4 +
3)];
font_chars[i][y][x].val =
(r << (ROUGE * 8)) | (g << (VERT * 8)) | (b << (BLEU *
8)) | (a << (ALPHA * 8));
}
}
for (y = 0; y < font_height[i] / 2; y++) {
small_font_chars[i][y] = malloc (font_width[i] * sizeof (int) / 2);
for (x = 0; x < font_width[i] / 2; x++) {
unsigned int r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3, r4, g4, b4,
a4;
r1 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4)];
g1 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 1)];
b1 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 2)];
a1 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 3)];
r2 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 4)];
g2 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 5)];
b2 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 6)];
a2 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 7)];
r3 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4)];
g3 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 1)];
b3 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 2)];
a3 = gfont[(2 * y + 3) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 3)];
r4 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 4)];
g4 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 5)];
b4 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 6)];
a4 = gfont[2 * (y + 1) * (the_font.width * 4) + (x * 8 +
font_pos[i] * 4 + 7)];
small_font_chars[i][y][x].val =
(((r1 + r2 + r3 + r4) >> 2) << (ROUGE * 8)) | (((g1 + g2 + g3 +
g4) >> 2) << (VERT * 8)) | (((b1 + b2 + b3 +
b4) >> 2) << (BLEU * 8)) | (((a1 + a2 + a3 +
a4) >> 2) << (ALPHA * 8));
}
}
}
/* definir les lettres restantes */
for (i = 0; i < 256; i++) {
if (font_chars[i] == 0) {
font_chars[i] = font_chars[42];
small_font_chars[i] = small_font_chars[42];
font_width[i] = font_width[42];
font_pos[i] = font_pos[42];
font_height[i] = font_height[42];
small_font_width[i] = small_font_width[42];
small_font_height[i] = small_font_height[42];
}
}
font_width[32] = (the_font.height / 2) - 1;
small_font_width[32] = font_width[32] / 2;
font_chars[32] = 0;
small_font_chars[32] = 0;
}
void
goom_draw_text (Pixel * buf, int resolx, int resoly,
int x, int y, const char *str, float charspace, int center)
{
float fx = (float) x;
int fin = 0;
Pixel ***cur_font_chars;
int *cur_font_width;
int *cur_font_height;
if (resolx > 320) {
/* printf("use big\n"); */
cur_font_chars = font_chars;
cur_font_width = font_width;
cur_font_height = font_height;
} else {
/* printf ("use small\n"); */
cur_font_chars = small_font_chars;
cur_font_width = small_font_width;
cur_font_height = small_font_height;
}
if (cur_font_chars == NULL)
return;
if (center) {
unsigned char *tmp = (unsigned char *) str;
float lg = -charspace;
while (*tmp != '\0')
lg += cur_font_width[*(tmp++)] + charspace;
fx -= lg / 2;
}
while (!fin) {
unsigned char c = *str;
x = (int) fx;
if (c == '\0')
fin = 1;
else if (cur_font_chars[c] == 0) {
fx += cur_font_width[c] + charspace;
} else {
int xx, yy;
int xmin = x;
int xmax = x + cur_font_width[c];
int ymin = y - cur_font_height[c];
int ymax = y;
yy = ymin;
if (xmin < 0)
xmin = 0;
if (xmin >= resolx - 1)
return;
if (xmax >= (int) resolx)
xmax = resolx - 1;
if (yy < 0)
yy = 0;
if (yy <= (int) resoly - 1) {
if (ymax >= (int) resoly - 1)
ymax = resoly - 1;
for (; yy < ymax; yy++)
for (xx = xmin; xx < xmax; xx++) {
Pixel color = cur_font_chars[c][yy - ymin][xx - x];
Pixel transparency;
transparency.val = color.val & A_CHANNEL;
if (transparency.val) {
if (transparency.val == A_CHANNEL)
buf[yy * resolx + xx] = color;
else {
Pixel back = buf[yy * resolx + xx];
unsigned int a1 = color.channels.a;
unsigned int a2 = 255 - a1;
buf[yy * resolx + xx].channels.r =
(unsigned char) ((((unsigned int) color.channels.r * a1) +
((unsigned int) back.channels.r * a2)) >> 8);
buf[yy * resolx + xx].channels.g =
(unsigned char) ((((unsigned int) color.channels.g * a1) +
((unsigned int) back.channels.g * a2)) >> 8);
buf[yy * resolx + xx].channels.b =
(unsigned char) ((((unsigned int) color.channels.b * a1) +
((unsigned int) back.channels.b * a2)) >> 8);
}
}
}
}
fx += cur_font_width[c] + charspace;
}
str++;
}
}
#ifndef _GFONTLIB_H
#define _GFONTLIB_H
#include "goom_graphic.h"
void gfont_load (void);
void goom_draw_text (Pixel * buf,int resolx,int resoly, int x, int y,
const char *str, float chspace, int center);
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
extern const struct {
unsigned int width;
unsigned int height;
unsigned int bytes_per_pixel;
unsigned int rle_size;
unsigned char rle_pixel [49725];
} the_font ;
......@@ -14,13 +14,8 @@ void goom_set_resolution (PluginInfo *goomInfo, guint32 resx, guint32 resy);
* forceMode == 0 : do nothing
* forceMode == -1 : lock the FX
* forceMode == 1..NB_FX : force a switch to FX n# forceMode
*
* songTitle = pointer to the title of the song...
* - NULL if it is not the start of the song
* - only have a value at the start of the song
*/
guint32 *goom_update (PluginInfo *goomInfo, gint16 data[2][512], int forceMode, float fps,
char *songTitle, char *message);
guint32 *goom_update (PluginInfo *goomInfo, gint16 data[2][512], int forceMode, float fps);
/* returns 0 if the buffer wasn't accepted */
int goom_set_screenbuffer(PluginInfo *goomInfo, void *buffer);
......
......@@ -20,7 +20,6 @@
#include "lines.h"
#include "ifs.h"
#include "tentacle3d.h"
#include "gfontlib.h"
#include "sound_tester.h"
#include "goom_plugin_info.h"
......@@ -36,8 +35,6 @@
static void choose_a_goom_line (PluginInfo * goomInfo, float *param1,
float *param2, int *couleur, int *mode, float *amplitude, int far);
static void update_message (PluginInfo * goomInfo, char *message);
static void
init_buffers (PluginInfo * goomInfo, int buffsize)
{
......@@ -104,8 +101,6 @@ goom_init (guint32 resx, guint32 resy)
GML_HLINE, 0, GML_BLACK,
GML_CIRCLE, 0.2f * (float) goomInfo->screen.height, GML_RED);
gfont_load ();
/* goom_set_main_script(goomInfo, goomInfo->main_script_str); */
return goomInfo;
......@@ -148,8 +143,8 @@ goom_set_screenbuffer (PluginInfo * goomInfo, void *buffer)
* WARNING: this is a 600 lines function ! (21-11-2003)
*/
guint32 *
goom_update (PluginInfo * goomInfo, gint16 data[2][512],
int forceMode, float fps, char *songTitle, char *message)
goom_update (PluginInfo * goomInfo, gint16 data[2][512], int forceMode,
float fps)
{
Pixel *return_val;
guint32 pointWidth;
......@@ -652,47 +647,6 @@ goom_update (PluginInfo * goomInfo, gint16 data[2][512],
goomInfo->star_fx.apply (&goomInfo->star_fx, goomInfo->p2, goomInfo->p1,
goomInfo);
/*
* Affichage de texte
*/
{
/*char title[1024]; */
char text[64];
/*
* Le message
*/
update_message (goomInfo, message);
if (fps > 0) {
sprintf (text, "%2.0f fps", fps);
goom_draw_text (goomInfo->p1, goomInfo->screen.width,
goomInfo->screen.height, 10, 24, text, 1, 0);
}
/*
* Le titre
*/
if (songTitle != NULL) {
strncpy (goomInfo->update.titleText, songTitle, 1023);
goomInfo->update.titleText[1023] = 0;
goomInfo->update.timeOfTitleDisplay = 200;
}
if (goomInfo->update.timeOfTitleDisplay) {
goom_draw_text (goomInfo->p1, goomInfo->screen.width,
goomInfo->screen.height, goomInfo->screen.width / 2,
goomInfo->screen.height / 2 + 7, goomInfo->update.titleText,
((float) (190 - goomInfo->update.timeOfTitleDisplay) / 10.0f), 1);
goomInfo->update.timeOfTitleDisplay--;
if (goomInfo->update.timeOfTitleDisplay < 4)
goom_draw_text (goomInfo->p2, goomInfo->screen.width,
goomInfo->screen.height, goomInfo->screen.width / 2,
goomInfo->screen.height / 2 + 7, goomInfo->update.titleText,
((float) (190 - goomInfo->update.timeOfTitleDisplay) / 10.0f), 1);
}
}
/*
* Gestion du Scope
*/
......@@ -879,73 +833,3 @@ choose_a_goom_line (PluginInfo * goomInfo, float *param1, float *param2,
*couleur = goom_irand (goomInfo->gRandom, 6);
}
#define ECART_VARIATION 1.5
#define POS_VARIATION 3.0
#define SCROLLING_SPEED 80
/*
* Met a jour l'affichage du message defilant
*/
void
update_message (PluginInfo * goomInfo, char *message)
{
int fin = 0;
if (message) {
int i = 1, j = 0;
sprintf (goomInfo->update_message.message, message);
for (j = 0; goomInfo->update_message.message[j]; j++)
if (goomInfo->update_message.message[j] == '\n')
i++;
goomInfo->update_message.numberOfLinesInMessage = i;
goomInfo->update_message.affiche =
goomInfo->screen.height +
goomInfo->update_message.numberOfLinesInMessage * 25 + 105;
goomInfo->update_message.longueur =
strlen (goomInfo->update_message.message);
}
if (goomInfo->update_message.affiche) {
int i = 0;
char *msg = malloc (goomInfo->update_message.longueur + 1);
char *ptr = msg;
int pos;
float ecart;
message = msg;
sprintf (msg, goomInfo->update_message.message);
while (!fin) {
while (1) {
if (*ptr == 0) {
fin = 1;
break;
}
if (*ptr == '\n') {
*ptr = 0;
break;
}
++ptr;
}
pos =
goomInfo->update_message.affiche -
(goomInfo->update_message.numberOfLinesInMessage - i) * 25;
pos += POS_VARIATION * (cos ((double) pos / 20.0));
pos -= SCROLLING_SPEED;
ecart = (ECART_VARIATION * sin ((double) pos / 20.0));
if ((fin) && (2 * pos < (int) goomInfo->screen.height))
pos = (int) goomInfo->screen.height / 2;
pos += 7;
goom_draw_text (goomInfo->p1, goomInfo->screen.width,
goomInfo->screen.height, goomInfo->screen.width / 2, pos, message,
ecart, 1);
message = ++ptr;
i++;
}
goomInfo->update_message.affiche--;
free (msg);
}
}
......@@ -144,18 +144,9 @@ struct _PLUGIN_INFO {
int stateSelectionRnd;
int stateSelectionBlocker;
int previousZoomSpeed;
int timeOfTitleDisplay;
char titleText[1024];
ZoomFilterData zoomFilterData;
} update;
struct {
int numberOfLinesInMessage;
char message[0x800];
int affiche;
int longueur;
} update_message;
struct {
void (*draw_line) (Pixel *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny);
void (*zoom_filter) (int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]);
......
......@@ -523,8 +523,7 @@ gst_goom_chain (GstPad * pad, GstBuffer * buffer)
GST_BUFFER_DURATION (outbuf) = goom->duration;
GST_BUFFER_SIZE (outbuf) = goom->outsize;
out_frame = (guchar *) goom_update (goom->plugin, goom->datain, 0, 0,
NULL, NULL);
out_frame = (guchar *) goom_update (goom->plugin, goom->datain, 0, 0);
memcpy (GST_BUFFER_DATA (outbuf), out_frame, goom->outsize);
GST_DEBUG ("Pushing frame with time=%" GST_TIME_FORMAT ", duration=%"
......
......@@ -183,9 +183,6 @@ plugin_info_init (PluginInfo * pp, int nbVisuals)
pp->update.stateSelectionRnd = 0;
pp->update.stateSelectionBlocker = 0;
pp->update.previousZoomSpeed = 128;
pp->update.timeOfTitleDisplay = 0;
pp->update_message.affiche = 0;
{
ZoomFilterData zfd = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment