[Bug 52008] synaescope and tippercanoe don't work with Sparc Solaris - endian problem
aaronw at net.com
aaronw at net.com
Wed Jun 25 08:47:01 BST 2003
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=52008
------- Additional Comments From aaronw at net.com 2003-06-25 09:47 -------
Here are some patches for the tyler plugin:
--- display.c 2001-07-31 10:47:49.000000000 -0700
+++ new/display.c 2003-01-14 02:14:46.000000000 -0800
@@ -25,12 +25,11 @@
#define wrap(a) ( a < 0 ? 0 : ( a > 255 ? 255 : a ))
#define assign_max(p,a) ( *p = ( *p > a ? *p : a ))
-#define PI 3.14159
-
+#define PI 3.1415926535
#define VIDEO_FLAGS (SDL_SWSURFACE)
SDL_Color color_table[NB_PALETTES][256];
-short current_colors[256];
+Uint32 current_colors[256];
byte* surface1;
byte* surface2;
@@ -38,17 +37,17 @@
void generate_colors()
{
int i,k;
- float colors[NB_PALETTES][2][3]={{{1,1,1},{1,1,1}},
- {{2,1.5,0},{0,0.5,2}},
- {{0,1,2},{0,1,0}},
- {{0,2,1},{0,0,1}},
- {{2,0,0},{0,1,1}}};
+ static const float colors[NB_PALETTES][2][3]={{{1.,1.,1.},{1.,1.,1.}},
+ {{2.,1.5,0.},{0.,0.5,2.}},
+ {{0.,1.,2.},{0.,1.,0.}},
+ {{0.,2.,1.},{0.,0.,1.}},
+ {{2.,0.,0.},{0.,1.,1.}}};
for (k=0;k<NB_PALETTES;k++) {
for ( i=0; i<128; i++ )
{
- color_table[k][i].r = colors[k][0][0]*i;
- color_table[k][i].g = colors[k][0][1]*i;
- color_table[k][i].b = colors[k][0][2]*i;
+ color_table[k][i].r = (int)(colors[k][0][0]*i);
+ color_table[k][i].g = (int)(colors[k][0][1]*i);
+ color_table[k][i].b = (int)(colors[k][0][2]*i);
}
for ( i=0; i<128; i++ )
{
@@ -62,14 +61,32 @@
void change_color(int t2,int t1,int w)
{
int i;
+ SDL_Color sdlPalette[256];
for (i=0;i<255;i++) {
int r,g,b;
+
+#if 0
r=color_table[t1][i].r*w+color_table[t2][i].r*(256-w)>>11;
g=color_table[t1][i].g*w+color_table[t2][i].g*(256-w)>>10;
b=color_table[t1][i].b*w+color_table[t2][i].b*(256-w)>>11;
current_colors[i]=(r<<11)+(g<<5)+b;
+#else
+ r = color_table[t1][i].r*w + color_table[t2][i].r*(256-w) >> 8;
+ if (r > 255)
+ r = 255;
+ g = color_table[t1][i].g*w + color_table[t2][i].g*(256-w) >> 8;
+ if (g > 255)
+ g = 255;
+ b = color_table[t1][i].b*w + color_table[t2][i].b*(256-w) >> 8;
+ if (b > 255)
+ b = 255;
+ sdlPalette[i].r = r;
+ sdlPalette[i].g = g;
+ sdlPalette[i].b = b;
+#endif
}
+ SDL_SetColors(screen, sdlPalette, 0, 256);
}
void compute_surface(t_interpol* vector_field)
@@ -93,7 +110,7 @@
if (color>255)
surface2[add_dest]=255;
- else
+ else
surface2[add_dest]=color;
add_dest++;
}
@@ -109,16 +126,24 @@
void display_surface()
{
int i,j;
-
+ static unsigned char count = 0;
+
+ if (SDL_MUSTLOCK(screen)) {
+ if (SDL_LockSurface(screen) < 0) {
+ fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError());
+ return;
+ }
+ }
if (scr_par.scale>1)
for (i=0;i<scr_par.height;i++) {
- short* pdest=(short*)(screen->pixels+i*screen->pitch*scr_par.scale);
+ Uint8* pdest=(Uint8*)(screen->pixels+i*screen->pitch*scr_par.scale);
byte* psrc=surface1+i*scr_par.width;
if (scr_par.scale==2)
{
for (j=1;j<scr_par.width;j++) {
- *(pdest++)=current_colors[*psrc++];
- *(pdest++)=*(pdest-1);
+ /* *(pdest++)=current_colors[*psrc++]; */
+ *(pdest++) = *psrc;
+ *(pdest++) = *psrc++;
}
memcpy(screen->pixels+i*screen->pitch*2+screen->pitch,
@@ -142,12 +167,17 @@
else {
byte* psrc=surface1;
for (i=0;i<scr_par.height;i++) {
- short* pdest=(short*)(screen->pixels+i*screen->pitch);
+ Uint8* pdest=(Uint8*)(screen->pixels+i*screen->pitch);
for (j=0;j<scr_par.width;j++)
- *pdest++=current_colors[*psrc++];
+ /* *pdest++=current_colors[*psrc++] | 0x00001080U | count << 16;*/
+ *pdest++ = *psrc++;
}
}
+ if (SDL_MUSTLOCK(screen)) {
+ SDL_UnlockSurface(screen);
+ }
SDL_UpdateRect(screen, 0, 0, 0, 0);
+ count++;
}
void blur(t_interpol* vector_field)
@@ -425,15 +455,21 @@
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
+
+ SDL_WM_SetCaption("Tyler","tyler");
- screen = SDL_SetVideoMode(scr_par.width*scr_par.scale,
scr_par.height*scr_par.scale,
- 16,VIDEO_FLAGS);
+ screen = SDL_SetVideoMode(scr_par.width*scr_par.scale,
+ scr_par.height*scr_par.scale,
+ 8, VIDEO_FLAGS);
if ( screen == NULL )
{
fprintf(stderr, "Couldn't init video mode: %s\n", SDL_GetError());
exit(1);
}
- SDL_ShowCursor(0);
+ /* SDL_ShowCursor(0);*/
+ if (screen->format->BytesPerPixel != 1) {
+ exit(1);
+ }
SDL_EnableKeyRepeat(0,0);
}
--- file.cpp 2002-05-18 04:51:46.000000000 -0700
+++ new/file.cpp 2003-01-14 02:11:33.000000000 -0800
@@ -39,19 +39,44 @@
return dirs.saveLocation("data", "noatun/") + "tylerstates";
}
+static Uint32 readWord(QFile &file)
+{
+ Uint32 word;
+ word = file.getch() |
+ (file.getch() << 8) |
+ (file.getch() << 16) |
+ (file.getch() << 24);
+ return word;
+}
+
+static void writeWord(QFile &file, Uint32 word)
+{
+ file.putch(word & 255);
+ file.putch((word>>8) & 255);
+ file.putch((word >> 16) & 255);
+ file.putch(word >> 24);
+}
+
extern "C" void save_effect(t_effect *effect)
{
QFile file(getSavePath());
if(!file.open(IO_WriteOnly))
return;
- for(unsigned i = 0; i < sizeof(t_effect); i++)
- file.putch( *((byte *)effect + i) );
+ writeWord(file, effect->num_effect);
+ writeWord(file, effect->x_curve);
+ writeWord(file, effect->curve_color);
+ writeWord(file, effect->curve_amplitude);
+ writeWord(file, effect->spectral_amplitude);
+ writeWord(file, effect->spectral_color);
+ writeWord(file, effect->mode_spectre);
+ writeWord(file, effect->spectral_shift);
}
t_effect effects[100];
int nb_effects=0;
+
extern "C" void load_effects()
{
QFile file(getDataPath());
@@ -59,11 +84,17 @@
exit(1);
nb_effects = 0;
- while(!file.atEnd())
+ while(!file.atEnd() && nb_effects < 100)
{
- byte* ptr_effect = (byte *)&effects[nb_effects++];
- for(int i = 0; i < sizeof(t_effect); i++)
- ptr_effect[i] = file.getch();
+ t_effect* ptr_effect = &effects[nb_effects++];
+ ptr_effect->num_effect = readWord(file);
+ ptr_effect->x_curve = readWord(file);
+ ptr_effect->curve_color = readWord(file);
+ ptr_effect->curve_amplitude = readWord(file);
+ ptr_effect->spectral_amplitude = readWord(file);
+ ptr_effect->spectral_color = readWord(file);
+ ptr_effect->mode_spectre = readWord(file);
+ ptr_effect->spectral_shift = readWord(file);
}
}
--- main.cpp 2002-01-02 05:19:49.000000000 -0800
+++ new/main.cpp 2003-01-14 01:04:22.000000000 -0800
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
+#include <sys/resource.h>
#include "renderer.h"
#include "display.h"
@@ -65,10 +66,11 @@
{
fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL) &
~O_NONBLOCK);
- atexit(SDL_Quit);
-
KInstance in("noatuntyler");
+ setpriority(PRIO_PROCESS, getpid(), 18);
+ atexit(SDL_Quit);
+
finished = false;
access_mutex = SDL_CreateMutex();
@@ -90,6 +92,15 @@
{
SDL_mutexP(access_mutex);
read(STDIN_FILENO, (void *)pcm_data, sizeof(short) * 2 * 512);
+ for (int i=0; i<512; i++) {
+ register short temp;
+ temp = pcm_data[0][i];
+ temp = (temp >> 8) | (temp << 8);
+ pcm_data[0][i] = temp;
+ temp = pcm_data[1][i];
+ temp = (temp >> 8) | (temp << 8);
+ pcm_data[1][i] = temp;
+ }
SDL_mutexV(access_mutex);
}
}
More information about the kde-multimedia
mailing list