SDL'ified hq4x filter. (Doesn't work right yet)

This commit is contained in:
William Kendrick 2003-12-20 19:45:38 +00:00
parent a6427c94ee
commit 7f9fb79d9f
6 changed files with 3705 additions and 3434 deletions

View file

@ -586,20 +586,20 @@ obj/BeOS_Print.o: src/BeOS_Print.cpp obj src/BeOS_print.h
obj/hq3x.o: src/hq3x.c src/hq3x.h src/hqxx.h
@echo
@echo "...Compiling high quality 3x scale filter..."
@$(CC) $(CFLAGS) \
@$(CC) $(CFLAGS) $(SDL_CFLAGS) \
-c src/hq3x.c -o obj/hq3x.o
obj/hq4x.o: src/hq4x.c src/hq4x.h src/hqxx.h
@echo
@echo "...Compiling high quality 4x scale filter..."
@$(CC) $(CFLAGS) \
@$(CC) $(CFLAGS) $(SDL_CFLAGS) \
-c src/hq4x.c -o obj/hq4x.o
obj/hqxx.o: src/hqxx.c src/hqxx.h
@echo
@echo "...Compiling high quality scale filter helpers..."
@$(CC) $(CFLAGS) \
@$(CC) $(CFLAGS) $(SDL_CFLAGS) \
-c src/hqxx.c -o obj/hqxx.o

6910
src/hq4x.c

File diff suppressed because it is too large Load diff

View file

@ -1 +1,9 @@
void hq4x_32( unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int BpL, int LUT16to32[65536], int RGBtoYUV[65536] );
#ifndef HQ4X_H
#define HQ4X_H
#include "SDL.h"
void hq4x_32(SDL_Surface * src, SDL_Surface * dest,
int LUT16to32[65536], int RGBtoYUV[65536]);
#endif

View file

@ -1,5 +1,5 @@
/*
hqNx filter look-up table init
hqNx filter look-up table init and helper functions
Copyright (C) 2003 MaxSt ( maxst@hiend3d.com )
Library-ified by Bill Kendrick <bill@newbreedsoftware.com>
@ -24,6 +24,7 @@
*/
#include "SDL.h"
#include "hqxx.h"
@ -56,17 +57,17 @@ void InitLUTs(int * LUT16to32, int * RGBtoYUV)
}
}
inline void Interp1(unsigned char * pc, int c1, int c2)
inline void Interp1(Uint8 * pc, int c1, int c2)
{
*((int*)pc) = (c1*3+c2) >> 2;
}
inline void Interp2(unsigned char * pc, int c1, int c2, int c3)
inline void Interp2(Uint8 * pc, int c1, int c2, int c3)
{
*((int*)pc) = (c1*2+c2+c3) >> 2;
}
inline void Interp3(unsigned char * pc, int c1, int c2)
inline void Interp3(Uint8 * pc, int c1, int c2)
{
//*((int*)pc) = (c1*7+c2)/8;
@ -74,7 +75,7 @@ inline void Interp3(unsigned char * pc, int c1, int c2)
(((c1 & 0xFF00FF)*7 + (c2 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
}
inline void Interp4(unsigned char * pc, int c1, int c2, int c3)
inline void Interp4(Uint8 * pc, int c1, int c2, int c3)
{
//*((int*)pc) = (c1*2+(c2+c3)*7)/16;
@ -82,12 +83,12 @@ inline void Interp4(unsigned char * pc, int c1, int c2, int c3)
(((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*7 ) & 0x0FF00FF0)) >> 4;
}
inline void Interp5(unsigned char * pc, int c1, int c2)
inline void Interp5(Uint8 * pc, int c1, int c2)
{
*((int*)pc) = (c1+c2) >> 1;
}
inline void Interp6(unsigned char * pc, int c1, int c2, int c3)
inline void Interp6(Uint8 * pc, int c1, int c2, int c3)
{
//*((int*)pc) = (c1*5+c2*2+c3)/8;
@ -95,7 +96,7 @@ inline void Interp6(unsigned char * pc, int c1, int c2, int c3)
(((c1 & 0xFF00FF)*5 + (c2 & 0xFF00FF)*2 + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
}
inline void Interp7(unsigned char * pc, int c1, int c2, int c3)
inline void Interp7(Uint8 * pc, int c1, int c2, int c3)
{
//*((int*)pc) = (c1*6+c2+c3)/8;
@ -103,7 +104,7 @@ inline void Interp7(unsigned char * pc, int c1, int c2, int c3)
(((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3;
}
inline void Interp8(unsigned char * pc, int c1, int c2)
inline void Interp8(Uint8 * pc, int c1, int c2)
{
//*((int*)pc) = (c1*5+c2*3)/8;

View file

@ -1,5 +1,5 @@
/*
hqNx filter look-up table init
hqNx filter look-up table init and helper functions
Copyright (C) 2003 MaxSt ( maxst@hiend3d.com )
Library-ified by Bill Kendrick <bill@newbreedsoftware.com>
@ -25,6 +25,8 @@
#ifndef HQINIT_H
#define HQINIT_H
#include "SDL.h"
static int YUV1, YUV2;
extern const int Ymask;
extern const int Umask;
@ -34,14 +36,14 @@ extern const int trU;
extern const int trV;
void InitLUTs(int * LUT16to32, int * RGBtoYUV);
inline void Interp1(unsigned char * pc, int c1, int c2);
inline void Interp2(unsigned char * pc, int c1, int c2, int c3);
inline void Interp3(unsigned char * pc, int c1, int c2);
inline void Interp4(unsigned char * pc, int c1, int c2, int c3);
inline void Interp5(unsigned char * pc, int c1, int c2);
inline void Interp6(unsigned char * pc, int c1, int c2, int c3);
inline void Interp7(unsigned char * pc, int c1, int c2, int c3);
inline void Interp8(unsigned char * pc, int c1, int c2);
inline void Interp1(Uint8 * pc, int c1, int c2);
inline void Interp2(Uint8 * pc, int c1, int c2, int c3);
inline void Interp3(Uint8 * pc, int c1, int c2);
inline void Interp4(Uint8 * pc, int c1, int c2, int c3);
inline void Interp5(Uint8 * pc, int c1, int c2);
inline void Interp6(Uint8 * pc, int c1, int c2, int c3);
inline void Interp7(Uint8 * pc, int c1, int c2, int c3);
inline void Interp8(Uint8 * pc, int c1, int c2);
inline int Diff(unsigned int w1, unsigned int w2);
#endif

View file

@ -510,6 +510,8 @@ SDL_Event scrolltimer_event;
char * langstr;
char * savedir;
int LUT16to32[65536], RGBtoYUV[65536];
/* Local function prototypes: */
@ -2988,10 +2990,49 @@ void stamp_draw(int x, int y)
/* Shrink or grow it! */
if (state_stamps[cur_stamp]->size == 400)
{
/* Use high quality 4x filter! */
/* Make the new surface for the scaled image: */
amask = ~(img_stamps[cur_stamp]->format->Rmask |
img_stamps[cur_stamp]->format->Gmask |
img_stamps[cur_stamp]->format->Bmask);
final_surf = SDL_CreateRGBSurface(SDL_SWSURFACE,
img_stamps[cur_stamp]->w * 4,
img_stamps[cur_stamp]->h * 4,
16,
img_stamps[cur_stamp]->format->Rmask,
img_stamps[cur_stamp]->format->Gmask,
img_stamps[cur_stamp]->format->Bmask,
amask);
if (final_surf == NULL)
{
fprintf(stderr, "\nError: Can't build stamp thumbnails\n"
"The Simple DirectMedia Layer error that occurred was:\n"
"%s\n\n", SDL_GetError());
cleanup();
exit(1);
}
hq4x_32(img_stamps[cur_stamp], final_surf,
LUT16to32, RGBtoYUV);
}
else
{
final_surf = thumbnail(tmp_surf,
(tmp_surf->w * state_stamps[cur_stamp]->size) / 100,
(tmp_surf->h * state_stamps[cur_stamp]->size) / 100,
(tmp_surf->w *
state_stamps[cur_stamp]->size) / 100,
(tmp_surf->h *
state_stamps[cur_stamp]->size) / 100,
0);
}
/* Where it will go? */
@ -4816,6 +4857,11 @@ void setup(int argc, char * argv[])
SDL_Flip(screen);
/* Init high quality scaling stuff: */
InitLUTs(LUT16to32, RGBtoYUV);
/* Load other images: */
for (i = 0; i < NUM_TOOLS; i++)