remove hi-res filters

This commit is contained in:
Ronald Kinard 2014-03-19 18:21:53 -05:00
parent c282fe9dec
commit 648a91adec
9 changed files with 0 additions and 8365 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,212 +0,0 @@
#ifndef __FILTERS_H__
#define __FILTERS_H__
#ifdef _MSC_VER
#pragma warning(disable : 4514 4214 4244)
#endif
#include "SDL.h"
#ifdef _MSC_VER
#pragma warning(default : 4214 4244)
#endif
typedef enum {
FILTER_2XSAI = 0,
FILTER_SUPER2XSAI,
FILTER_SUPEREAGLE,
FILTER_ADVMAME2X ,
FILTER_TV2X ,
FILTER_NORMAL2X ,
FILTER_BILINEAR ,
FILTER_DOTMATRIX ,
FILTER_NUM ,
} t_filter;
typedef void (*filter_2)(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
SDL_Surface *filter_2x(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter);
SDL_Surface *filter_2xe(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter,Uint8 R, Uint8 G, Uint8 B);
//Alam_GBC: Header file based on sms_sdl's filter.h
//Note: need 3 lines at the bottom and top?
//int filter_init_2xsai(SDL_PixelFormat *BitFormat);
#define FILTER(src,dst) (Uint8 *)(src->pixels)+src->pitch*3, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h-6
#define SDLFILTER(src,dst) (Uint8 *)src->pixels, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h
int filter_init_2xsai(SDL_PixelFormat *BitFormat); //unless?
void filter_scan50(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_scan100(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_super2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_supereagle(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_advmame2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_tv2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_normal2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_bilinear(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_dotmatrix(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_bicubic(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void hq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void filter_hq2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height);
#ifdef FILTERS
typedef struct filter_s { filter_2 filter; int bpp; } filter_t;
#define NUMFILTERS 13
static filter_t filtermode[NUMFILTERS+1] = {
{NULL , 0}, //None
{filter_normal2x , 16}, //2xNormal
{filter_advmame2x , 16}, //AdvMAME2x
{filter_tv2x , 16}, //TV2x
{filter_bilinear , 16}, //Bilinear
{filter_dotmatrix , 16}, //DotMatrix
{lq2x16 , 16}, //16LQ2x
{hq2x16 , 16}, //16HQ2x
{lq2x32 , 32}, //32LQ2x
{hq2x32 , 32}, //32HQ2x
// {filter_bicubic , 16}, //Slow Bicubic
// BAD
{filter_2xsai , 16}, //2xSAI
{filter_super2xsai, 16}, //Super2xSAI
{filter_supereagle, 16}, //SuperEagle
};
CV_PossibleValue_t CV_Filters[] = {{ 0, "None"}, { 1, "2xNormal"},
{ 2, "AdvMAME2x"}, { 3, "TV2x"}, { 4, "Bilinear"} , { 5, "DotMatrix"},
{ 6, "16LQ2x"}, { 7, "16HQ2x"}, { 8, "32LQ2x"} , { 9, "32HQ2x"},
{10, "2xSAI"}, {11, "Super2xSAI"}, {12, "SuperEagle"}, {0, NULL},};
static void Filterchange(void);
consvar_t cv_filter = {"filter", "None", CV_CALL|CV_NOINIT, CV_Filters,Filterchange,0,NULL,NULL,0,0,NULL};
static filter_2 blitfilter = NULL;
static SDL_Surface *preSurface = NULL;
static SDL_Surface *f2xSurface = NULL;
static void Filterchange(void)
{
if(blitfilter) // only filtering?
{
int i=0;
for(;i < NUMFILTERS; i++)//find old filter
{
if(filtermode[i].filter == blitfilter) //Found it
break; //Stop
}
if(i < NUMFILTERS && filtermode[i].bpp == filtermode[cv_filter.value].bpp) //Easy to swap?
blitfilter = filtermode[cv_filter.value].filter; // Swap with new filter
}
}
FUNCINLINE static ATTRINLINE void FilterBlit(SDL_Surface *froSurface)
{
if(froSurface && blitfilter && preSurface && f2xSurface)
{
SDL_Rect dstclp = {0,3,0,0};
int lockedpre = 0, lockedf2x = 0, blitpre = 0;
blitpre = SDL_BlitSurface(froSurface,NULL,preSurface,&dstclp);
if(SDL_MUSTLOCK(preSurface)) lockedpre = SDL_LockSurface(preSurface);
if(SDL_MUSTLOCK(f2xSurface)) lockedf2x = SDL_LockSurface(f2xSurface);
if(lockedpre == 0 && preSurface->pixels && lockedf2x == 0 && f2xSurface->pixels && blitpre == 0)
{
blitfilter(FILTER(preSurface,f2xSurface));
if(SDL_MUSTLOCK(preSurface)) SDL_UnlockSurface(preSurface);
if(SDL_MUSTLOCK(f2xSurface)) SDL_UnlockSurface(f2xSurface);
}
}
else
{
blitfilter = NULL;
if(preSurface) SDL_FreeSurface(preSurface);
preSurface = NULL;
if(f2xSurface) SDL_FreeSurface(f2xSurface);
f2xSurface = NULL;
}
}
FUNCINLINE static ATTRINLINE int Setupf2x(int width, int height, int bpp)
{
blitfilter = NULL;
if(preSurface) SDL_FreeSurface(preSurface);
preSurface = NULL;
if(f2xSurface) SDL_FreeSurface(f2xSurface);
f2xSurface = NULL;
if( !(width%2) && !(height%2) && width >= BASEVIDWIDTH*2 && height >= BASEVIDHEIGHT*2 && cv_filter.value
&& cv_filter.value <= NUMFILTERS && filtermode[cv_filter.value].filter && filtermode[cv_filter.value].bpp)
{
int hwidth = width/2 + 6;
int heighth = height/2 + 6;
int hbpp = filtermode[cv_filter.value].bpp;
switch(hbpp)
{
case 8:
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth, 8,0x00000000,0x00000000,0x00000000,0x00);
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height , 8,0x00000000,0x00000000,0x00000000,0x00);
case 15:
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,15,0x00007C00,0x000003E0,0x0000001F,0x00);
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,15,0x00007C00,0x000003E0,0x0000001F,0x00);
break;
case 16:
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,16,0x0000F800,0x000007E0,0x0000001F,0x00);
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,16,0x0000F800,0x000007E0,0x0000001F,0x00);
break;
case 24:
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,24,0x00FF0000,0x0000FF00,0x000000FF,0x00);
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,24,0x00FF0000,0x0000FF00,0x000000FF,0x00);
break;
case 32:
preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,32,0x00FF0000,0x0000FF00,0x000000FF,0x00);
f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,32,0x00FF0000,0x0000FF00,0x000000FF,0x00);
break;
default:
//I_Error("Filter help");
break;
}
if(preSurface && f2xSurface)
{
blitfilter = filtermode[cv_filter.value].filter;
if(bpp < hbpp) bpp = hbpp;
}
else
{
if(preSurface) SDL_FreeSurface(preSurface);
preSurface = NULL;
if(f2xSurface) SDL_FreeSurface(f2xSurface);
f2xSurface = NULL;
}
}
return bpp;
}
#else
#ifdef __GNUC__ // __attribute__ ((X))
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
#define FUNCINLINE __attribute__((always_inline))
#endif
#define FUNCNOINLINE __attribute__((noinline))
#elif defined(_MSC_VER)
#define inline __inline
#define ATTRNORETURN __declspec(noreturn)
#define ATTRINLINE __forceinline
#if _MSC_VER > 1200
#define ATTRNOINLINE __declspec(noinline)
#endif
#endif
#ifndef FUNCINLINE
#define FUNCINLINE
#endif
#ifndef FUNCNOINLINE
#define FUNCNOINLINE
#endif
#ifndef ATTRINLINE
#define ATTRINLINE inline
#endif
#ifndef ATTRNOINLINE
#define ATTRNOINLINE
#endif
#endif
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,306 +0,0 @@
/*
* This file is part of the Advance project.
*
* Copyright (C) 2003 Andrea Mazzoleni
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* In addition, as a special exception, Andrea Mazzoleni
* gives permission to link the code of this program with
* the MAME library (or with modified versions of MAME that use the
* same license as MAME), and distribute linked combinations including
* the two. You must obey the GNU General Public License in all
* respects for all of the code used other than MAME. If you modify
* this file, you may extend this exception to your version of the
* file, but you are not obligated to do so. If you do not wish to
* do so, delete this exception statement from your version.
*/
#ifndef __INTERP_H
#define __INTERP_H
/***************************************************************************/
/* Basic types */
/***************************************************************************/
/* interpolation */
static Uint32 interp_mask[2] = {0xF81F,0x07E0};
static Uint32 interp_bits_per_pixel = 16;
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
#define INTERP_16_MASK_2(v) (v & interp_mask[1])
FUNCINLINE static ATTRINLINE Uint16 interp_16_521(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_332(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_611(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8));
}
/*
FUNCINLINE static ATTRINLINE Uint16 interp_16_71(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8));
}
*/
FUNCINLINE static ATTRINLINE Uint16 interp_16_211(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4));
}
/*
FUNCINLINE static ATTRINLINE Uint16 interp_16_772(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16)
| INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_11(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2));
}
*/
FUNCINLINE static ATTRINLINE Uint16 interp_16_31(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_1411(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16));
}
/*
FUNCINLINE static ATTRINLINE Uint16 interp_16_431(Uint16 p1, Uint16 p2, Uint16 p3)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_53(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_151(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16));
}
FUNCINLINE static ATTRINLINE Uint16 interp_16_97(Uint16 p1, Uint16 p2)
{
return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16)
| INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16));
}
*/
#define INTERP_32_MASK_1(v) (v & 0xFF00FF)
#define INTERP_32_MASK_2(v) (v & 0x00FF00)
FUNCINLINE static ATTRINLINE Uint32 interp_32_521(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_332(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_211(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_611(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8);
}
/*
FUNCINLINE static ATTRINLINE Uint32 interp_32_71(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_772(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16)
| INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_11(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2);
}
*/
FUNCINLINE static ATTRINLINE Uint32 interp_32_31(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_1411(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16);
}
/*
FUNCINLINE static ATTRINLINE Uint32 interp_32_431(Uint32 p1, Uint32 p2, Uint32 p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_53(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_151(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16);
}
FUNCINLINE static ATTRINLINE Uint32 interp_32_97(Uint32 p1, Uint32 p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16)
| INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16);
}
*/
/***************************************************************************/
/* diff */
#define INTERP_Y_LIMIT (0x30*4)
#define INTERP_U_LIMIT (0x07*4)
#define INTERP_V_LIMIT (0x06*8)
static int interp_16_diff(Uint16 p1, Uint16 p2)
{
int r, g, b;
int y, u, v;
if (p1 == p2)
return 0;
if (interp_bits_per_pixel == 16) {
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3;
r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8;
} else {
b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3;
g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2;
r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7;
}
y = r + g + b;
u = r - b;
v = -r + 2*g - b;
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
return 1;
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
return 1;
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
return 1;
return 0;
}
static int interp_32_diff(Uint32 p1, Uint32 p2)
{
int r, g, b;
int y, u, v;
if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8))
return 0;
b = (int)((p1 & 0xFF) - (p2 & 0xFF));
g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8;
r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16;
y = r + g + b;
u = r - b;
v = -r + 2*g - b;
if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT)
return 1;
if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT)
return 1;
if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT)
return 1;
return 0;
}
/*
static void interp_set(Uint32 bits_per_pixel)
{
interp_bits_per_pixel = bits_per_pixel;
switch (bits_per_pixel) {
case 15 :
interp_mask[0] = 0x7C1F;
interp_mask[1] = 0x03E0;
break;
case 16 :
interp_mask[0] = 0xF81F;
interp_mask[1] = 0x07E0;
break;
case 32 :
interp_mask[0] = 0xFF00FF;
interp_mask[1] = 0x00FF00;
break;
}
}
*/
#endif

View file

@ -1,564 +0,0 @@
#include "filters.h"
#include "interp.h"
static void hq2x_16_def(Uint16* dst0, Uint16* dst1, const Uint16* src0, const Uint16* src1, const Uint16* src2, Uint32 count)
{
Uint32 i;
for(i=0;i<count;++i) {
Uint8 mask;
Uint16 c[9];
c[1] = src0[0];
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
}
mask = 0;
if (interp_16_diff(c[0], c[4]))
mask |= 1 << 0;
if (interp_16_diff(c[1], c[4]))
mask |= 1 << 1;
if (interp_16_diff(c[2], c[4]))
mask |= 1 << 2;
if (interp_16_diff(c[3], c[4]))
mask |= 1 << 3;
if (interp_16_diff(c[5], c[4]))
mask |= 1 << 4;
if (interp_16_diff(c[6], c[4]))
mask |= 1 << 5;
if (interp_16_diff(c[7], c[4]))
mask |= 1 << 6;
if (interp_16_diff(c[8], c[4]))
mask |= 1 << 7;
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR interp_16_diff(c[1], c[5])
#define MDR interp_16_diff(c[5], c[7])
#define MDL interp_16_diff(c[7], c[3])
#define MUL interp_16_diff(c[3], c[1])
#define IC(p0) c[p0]
#define I11(p0,p1) interp_16_11(c[p0], c[p1])
#define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
#define I31(p0,p1) interp_16_31(c[p0], c[p1])
#define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
#define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
#define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
#define I53(p0,p1) interp_16_53(c[p0], c[p1])
#define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
#define I71(p0,p1) interp_16_71(c[p0], c[p1])
#define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
#define I97(p0,p1) interp_16_97(c[p0], c[p1])
#define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
#define I151(p0,p1) interp_16_151(c[p0], c[p1])
switch (mask) {
#include "hq2x.h"
}
#undef P0
#undef P1
#undef P2
#undef P3
#undef MUR
#undef MDR
#undef MDL
#undef MUL
#undef IC
#undef I11
#undef I211
#undef I31
#undef I332
#undef I431
#undef I521
#undef I53
#undef I611
#undef I71
#undef I772
#undef I97
#undef I1411
#undef I151
src0 += 1;
src1 += 1;
src2 += 1;
dst0 += 2;
dst1 += 2;
}
}
static void hq2x_32_def(Uint32* dst0, Uint32* dst1, const Uint32* src0, const Uint32* src1, const Uint32* src2, Uint32 count)
{
Uint32 i;
for(i=0;i<count;++i) {
Uint8 mask;
Uint32 c[9];
c[1] = src0[0];
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
}
mask = 0;
if (interp_32_diff(c[0], c[4]))
mask |= 1 << 0;
if (interp_32_diff(c[1], c[4]))
mask |= 1 << 1;
if (interp_32_diff(c[2], c[4]))
mask |= 1 << 2;
if (interp_32_diff(c[3], c[4]))
mask |= 1 << 3;
if (interp_32_diff(c[5], c[4]))
mask |= 1 << 4;
if (interp_32_diff(c[6], c[4]))
mask |= 1 << 5;
if (interp_32_diff(c[7], c[4]))
mask |= 1 << 6;
if (interp_32_diff(c[8], c[4]))
mask |= 1 << 7;
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR interp_32_diff(c[1], c[5])
#define MDR interp_32_diff(c[5], c[7])
#define MDL interp_32_diff(c[7], c[3])
#define MUL interp_32_diff(c[3], c[1])
#define IC(p0) c[p0]
#define I11(p0,p1) interp_32_11(c[p0], c[p1])
#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
#define I31(p0,p1) interp_32_31(c[p0], c[p1])
#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
#define I53(p0,p1) interp_32_53(c[p0], c[p1])
#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
#define I71(p0,p1) interp_32_71(c[p0], c[p1])
#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
#define I97(p0,p1) interp_32_97(c[p0], c[p1])
#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
#define I151(p0,p1) interp_32_151(c[p0], c[p1])
switch (mask) {
#include "hq2x.h"
}
#undef P0
#undef P1
#undef P2
#undef P3
#undef MUR
#undef MDR
#undef MDL
#undef MUL
#undef IC
#undef I11
#undef I211
#undef I31
#undef I332
#undef I431
#undef I521
#undef I53
#undef I611
#undef I71
#undef I772
#undef I97
#undef I1411
#undef I151
src0 += 1;
src1 += 1;
src2 += 1;
dst0 += 2;
dst1 += 2;
}
}
/***************************************************************************/
/* LQ2x C implementation */
/*
* This effect is derived from the hq2x effect made by Maxim Stepin
*/
static void lq2x_16_def(Uint16* dst0, Uint16* dst1, const Uint16* src0, const Uint16* src1, const Uint16* src2, Uint32 count)
{
Uint32 i;
for(i=0;i<count;++i) {
Uint8 mask;
Uint16 c[9];
c[1] = src0[0];
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
}
mask = 0;
if (c[0] != c[4])
mask |= 1 << 0;
if (c[1] != c[4])
mask |= 1 << 1;
if (c[2] != c[4])
mask |= 1 << 2;
if (c[3] != c[4])
mask |= 1 << 3;
if (c[5] != c[4])
mask |= 1 << 4;
if (c[6] != c[4])
mask |= 1 << 5;
if (c[7] != c[4])
mask |= 1 << 6;
if (c[8] != c[4])
mask |= 1 << 7;
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR (c[1] != c[5])
#define MDR (c[5] != c[7])
#define MDL (c[7] != c[3])
#define MUL (c[3] != c[1])
#define IC(p0) c[p0]
#define I11(p0,p1) interp_16_11(c[p0], c[p1])
#define I211(p0,p1,p2) interp_16_211(c[p0], c[p1], c[p2])
#define I31(p0,p1) interp_16_31(c[p0], c[p1])
#define I332(p0,p1,p2) interp_16_332(c[p0], c[p1], c[p2])
#define I431(p0,p1,p2) interp_16_431(c[p0], c[p1], c[p2])
#define I521(p0,p1,p2) interp_16_521(c[p0], c[p1], c[p2])
#define I53(p0,p1) interp_16_53(c[p0], c[p1])
#define I611(p0,p1,p2) interp_16_611(c[p0], c[p1], c[p2])
#define I71(p0,p1) interp_16_71(c[p0], c[p1])
#define I772(p0,p1,p2) interp_16_772(c[p0], c[p1], c[p2])
#define I97(p0,p1) interp_16_97(c[p0], c[p1])
#define I1411(p0,p1,p2) interp_16_1411(c[p0], c[p1], c[p2])
#define I151(p0,p1) interp_16_151(c[p0], c[p1])
switch (mask) {
#include "lq2x.h"
}
#undef P0
#undef P1
#undef P2
#undef P3
#undef MUR
#undef MDR
#undef MDL
#undef MUL
#undef IC
#undef I11
#undef I211
#undef I31
#undef I332
#undef I431
#undef I521
#undef I53
#undef I611
#undef I71
#undef I772
#undef I97
#undef I1411
#undef I151
src0 += 1;
src1 += 1;
src2 += 1;
dst0 += 2;
dst1 += 2;
}
}
static void lq2x_32_def(Uint32* dst0, Uint32* dst1, const Uint32* src0, const Uint32* src1, const Uint32* src2, Uint32 count)
{
Uint32 i;
for(i=0;i<count;++i) {
Uint8 mask;
Uint32 c[9];
c[1] = src0[0];
c[4] = src1[0];
c[7] = src2[0];
if (i>0) {
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
} else {
c[0] = c[1];
c[3] = c[4];
c[6] = c[7];
}
if (i<count-1) {
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
} else {
c[2] = c[1];
c[5] = c[4];
c[8] = c[7];
}
mask = 0;
if (c[0] != c[4])
mask |= 1 << 0;
if (c[1] != c[4])
mask |= 1 << 1;
if (c[2] != c[4])
mask |= 1 << 2;
if (c[3] != c[4])
mask |= 1 << 3;
if (c[5] != c[4])
mask |= 1 << 4;
if (c[6] != c[4])
mask |= 1 << 5;
if (c[7] != c[4])
mask |= 1 << 6;
if (c[8] != c[4])
mask |= 1 << 7;
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR (c[1] != c[5])
#define MDR (c[5] != c[7])
#define MDL (c[7] != c[3])
#define MUL (c[3] != c[1])
#define IC(p0) c[p0]
#define I11(p0,p1) interp_32_11(c[p0], c[p1])
#define I211(p0,p1,p2) interp_32_211(c[p0], c[p1], c[p2])
#define I31(p0,p1) interp_32_31(c[p0], c[p1])
#define I332(p0,p1,p2) interp_32_332(c[p0], c[p1], c[p2])
#define I431(p0,p1,p2) interp_32_431(c[p0], c[p1], c[p2])
#define I521(p0,p1,p2) interp_32_521(c[p0], c[p1], c[p2])
#define I53(p0,p1) interp_32_53(c[p0], c[p1])
#define I611(p0,p1,p2) interp_32_611(c[p0], c[p1], c[p2])
#define I71(p0,p1) interp_32_71(c[p0], c[p1])
#define I772(p0,p1,p2) interp_32_772(c[p0], c[p1], c[p2])
#define I97(p0,p1) interp_32_97(c[p0], c[p1])
#define I1411(p0,p1,p2) interp_32_1411(c[p0], c[p1], c[p2])
#define I151(p0,p1) interp_32_151(c[p0], c[p1])
switch (mask) {
#include "lq2x.h"
}
#undef P0
#undef P1
#undef P2
#undef P3
#undef MUR
#undef MDR
#undef MDL
#undef MUL
#undef IC
#undef I11
#undef I211
#undef I31
#undef I332
#undef I431
#undef I521
#undef I53
#undef I611
#undef I71
#undef I772
#undef I97
#undef I1411
#undef I151
src0 += 1;
src1 += 1;
src2 += 1;
dst0 += 2;
dst1 += 2;
}
}
void hq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
Uint32 dstPitch, int width, int height)
{
Uint16 *dst0 = (Uint16 *)dstPtr;
Uint16 *dst1 = dst0 + (dstPitch >> 1);
Uint16 *src0 = (Uint16 *)srcPtr;
Uint16 *src1 = src0 + (srcPitch >> 1);
Uint16 *src2 = src1 + (srcPitch >> 1);
int count = height-2;
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
while(count) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2x_16_def(dst0, dst1, src0, src1, src2, width);
src0 = src1;
src1 = src2;
src2 += srcPitch >> 1;
--count;
}
dst0 += dstPitch;
dst1 += dstPitch;
hq2x_16_def(dst0, dst1, src0, src1, src1, width);
}
void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
Uint32 dstPitch, int width, int height)
{
Uint32 *dst0 = (Uint32 *)dstPtr;
Uint32 *dst1 = dst0 + (dstPitch >> 2);
Uint32 *src0 = (Uint32 *)srcPtr;
Uint32 *src1 = src0 + (srcPitch >> 2);
Uint32 *src2 = src1 + (srcPitch >> 2);
int count = height-2;
hq2x_32_def(dst0, dst1, src0, src0, src1, width);
while(count) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src2, width);
src0 = src1;
src1 = src2;
src2 += srcPitch >> 2;
--count;
}
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src1, width);
}
void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
Uint32 dstPitch, int width, int height)
{
Uint16 *dst0 = (Uint16 *)dstPtr;
Uint16 *dst1 = dst0 + (dstPitch >> 1);
Uint16 *src0 = (Uint16 *)srcPtr;
Uint16 *src1 = src0 + (srcPitch >> 1);
Uint16 *src2 = src1 + (srcPitch >> 1);
int count = height-2;
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
while(count) {
dst0 += dstPitch;
dst1 += dstPitch;
lq2x_16_def(dst0, dst1, src0, src1, src2, width);
src0 = src1;
src1 = src2;
src2 += srcPitch >> 1;
--count;
}
dst0 += dstPitch;
dst1 += dstPitch;
lq2x_16_def(dst0, dst1, src0, src1, src1, width);
}
void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr,
Uint32 dstPitch, int width, int height)
{
Uint32 *dst0 = (Uint32 *)dstPtr;
Uint32 *dst1 = dst0 + (dstPitch >> 2);
Uint32 *src0 = (Uint32 *)srcPtr;
Uint32 *src1 = src0 + (srcPitch >> 2);
Uint32 *src2 = src1 + (srcPitch >> 2);
int count = height-2;
lq2x_32_def(dst0, dst1, src0, src0, src1, width);
while(count) {
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
lq2x_32_def(dst0, dst1, src0, src1, src2, width);
src0 = src1;
src1 = src2;
src2 += srcPitch >> 2;
--count;
}
dst0 += dstPitch >> 1;
dst1 += dstPitch >> 1;
lq2x_32_def(dst0, dst1, src0, src1, src1, width);
}
/*
static inline void hq2x_init(Uint32 bits_per_pixel)
{
interp_set(bits_per_pixel);
}
*/

File diff suppressed because it is too large Load diff

View file

@ -1,15 +0,0 @@
#include "filters.h"
int main(int argc, char *argv[])
{
SDL_Surface *src = NULL;
SDL_Surface *dst = NULL;
src = SDL_LoadBMP("src.bmp"); //load
if(!src) return -1; //check
dst = filter_2x(src, NULL, hq2x32); //prcoess
SDL_FreeSurface(src); //free
if(!dst) return 0; //error
SDL_SaveBMP(dst, "dst.bmp"); //save
SDL_FreeSurface(dst); //free
return 1; //good
}

View file

@ -85,11 +85,6 @@
#include "ogl_sdl.h"
#endif
#ifdef HAVE_FILTER
#define FILTERS
#include "filter/filters.h"
#endif
// maximum number of windowed modes (see windowedModes[][])
#define MAXWINMODES (27)
@ -182,9 +177,6 @@ static void SDLSetMode(INT32 width, INT32 height, INT32 bpp, Uint32 flags)
{
#if 0
const char *SDLVD = I_GetEnv("SDL_VIDEODRIVER");
#ifdef FILTERS
bpp = Setupf2x(width, height, bpp);
#endif
if (SDLVD && strncasecmp(SDLVD,"glSDL",6) == 0) //for glSDL videodriver
vidSurface = SDL_SetVideoMode(width, height,0,SDL_DOUBLEBUF);
else if (cv_vidwait.value && videoblitok && SDL_VideoModeOK(width, height, bpp, flags|SDL_HWSURFACE|SDL_DOUBLEBUF) >= bpp)
@ -196,13 +188,6 @@ static void SDLSetMode(INT32 width, INT32 height, INT32 bpp, Uint32 flags)
else return;
realwidth = (Uint16)width;
realheight = (Uint16)height;
#ifdef FILTERS
if (vidSurface && preSurface && f2xSurface)
{
vid.width = width/2;
vid.height = height/2;
}
#endif
#endif
if (window == NULL)
{
@ -582,10 +567,6 @@ static void VID_Command_Info_f (void)
//*vfmt
}
SurfaceInfo(bufSurface, M_GetText("Current Engine Mode"));
#ifdef FILTERS
SurfaceInfo(preSurface, M_GetText("Prebuffer Mode"));
SurfaceInfo(f2xSurface, M_GetText("Postbuffer Mode"));
#endif
SurfaceInfo(vidSurface, M_GetText("Current Video Mode"));
#endif
}
@ -920,15 +901,8 @@ void I_GetEvent(void)
setmodeneeded = VID_GetModeForSize(inputEvent.resize.w,inputEvent.resize.h)+1;
if (render_soft == rendermode)
{
#ifdef FILTERS
INT32 filtervalue = cv_filter.value;
if (blitfilter) CV_SetValue(&cv_filter,1);
#endif
SDLSetMode(realwidth, realheight, vid.bpp*8, surfaceFlagsW);
if (vidSurface) SDL_SetColors(vidSurface, localPalette, 0, 256);
#ifdef FILTERS
CV_SetValue(&cv_filter,filtervalue);
#endif
}
else
SDLSetMode(realwidth, realheight, vid.bpp*8, surfaceFlagsW);
@ -1541,9 +1515,6 @@ void I_StartupGraphics(void)
COM_AddCommand ("vid_mode", VID_Command_Mode_f);
CV_RegisterVar (&cv_vidwait);
CV_RegisterVar (&cv_stretch);
#ifdef FILTERS
CV_RegisterVar (&cv_filter);
#endif
disable_mouse = M_CheckParm("-nomouse");
if (disable_mouse)
I_PutEnv(SDLNOMOUSE);
@ -1713,12 +1684,6 @@ void I_ShutdownGraphics(void)
vid.buffer = NULL;
if (bufSurface) SDL_FreeSurface(bufSurface);
bufSurface = NULL;
#ifdef FILTERS
if (preSurface) SDL_FreeSurface(preSurface);
preSurface = NULL;
if (f2xSurface) SDL_FreeSurface(f2xSurface);
f2xSurface = NULL;
#endif
}
// was graphics initialized anyway?