Began completely ripping out 16bit filters.

It's not worth the complexity.
If 16 bit is ever needed, can just down convert the input and output.
Though, I'd rather just make everything 32bit, and upconvert at the start if needed.
This commit is contained in:
Arthur Moore 2015-03-12 04:12:19 -04:00
parent 7c5cc4dfef
commit decdb9c82e
2 changed files with 27 additions and 82 deletions

View File

@ -1,49 +1,42 @@
#include "filters.hpp"
//Helper function for creating filterMap
namedfilter InsertFilter(std::string filterName, FilterFunc thirtyTwoBitFilter, FilterFunc sixteenBitFilter)
{
filterpair filters = std::make_pair<FilterFunc,FilterFunc>(thirtyTwoBitFilter,sixteenBitFilter);
return std::make_pair<std::string,filterpair>(filterName,filters) ;
}
//Actually make the fitlermap (since C++11 doesn't work right now)
const std::map<std::string,filterpair> makeFilterMap()
const std::map<std::string,FilterFunc> makeFilterMap()
{
std::map<std::string,filterpair> tempMap;
std::map<std::string,FilterFunc> tempMap;
tempMap.insert(InsertFilter("Pixelate",Pixelate32,Pixelate));
tempMap.insert(InsertFilter("Scanlines",Scanlines32,Scanlines));
tempMap.insert(InsertFilter("TV Mode",ScanlinesTV32,ScanlinesTV));
tempMap.insert(namedfilter("Pixelate",Pixelate32));
tempMap.insert(namedfilter("Scanlines",Scanlines32));
tempMap.insert(namedfilter("TV Mode",ScanlinesTV32));
//These require Init_2xSaI(u32 BitFormat);
tempMap.insert(InsertFilter("Simple 2x",Simple2x32,Simple2x16));
tempMap.insert(InsertFilter("Simple 3x",Simple3x32,Simple3x16));
tempMap.insert(InsertFilter("Simple 4x",Simple4x32,Simple4x16));
tempMap.insert(namedfilter("Simple 2x",Simple2x32));
tempMap.insert(namedfilter("Simple 3x",Simple3x32));
tempMap.insert(namedfilter("Simple 4x",Simple4x32));
tempMap.insert(InsertFilter("Bilinear",Bilinear32,Bilinear));
tempMap.insert(InsertFilter("Bilinear Plus",BilinearPlus32,BilinearPlus));
tempMap.insert(InsertFilter("Advance MAME Scale2x",AdMame2x32,AdMame2x));
tempMap.insert(namedfilter("Bilinear",Bilinear32));
tempMap.insert(namedfilter("Bilinear Plus",BilinearPlus32));
tempMap.insert(namedfilter("Advance MAME Scale2x",AdMame2x32));
//These require Init_2xSaI(u32 BitFormat);
tempMap.insert(InsertFilter("2xSaI",_2xSaI32,_2xSaI));
tempMap.insert(InsertFilter("Super 2xSaI",Super2xSaI32,Super2xSaI));
tempMap.insert(InsertFilter("Super Eagle",SuperEagle32,SuperEagle));
tempMap.insert(namedfilter("2xSaI",_2xSaI32));
tempMap.insert(namedfilter("Super 2xSaI",Super2xSaI32));
tempMap.insert(namedfilter("Super Eagle",SuperEagle32));
//These require calling hq2x_init first and whenever bpp changes
tempMap.insert(InsertFilter("hq2x",hq2x32,hq2x));
tempMap.insert(InsertFilter("lq2x",lq2x32,lq2x));
tempMap.insert(namedfilter("hq2x",hq2x32));
tempMap.insert(namedfilter("lq2x",lq2x32));
tempMap.insert(InsertFilter("HQ 3x",hq3x32,hq3x16));
tempMap.insert(InsertFilter("HQ 4x",hq4x32,hq4x16));
tempMap.insert(namedfilter("HQ 3x",hq3x32));
tempMap.insert(namedfilter("HQ 4x",hq4x32));
//These require sdlStretchInit
tempMap.insert(InsertFilter("sdlStretch1x",sdlStretch1x,sdlStretch1x));
tempMap.insert(InsertFilter("sdlStretch2x",sdlStretch2x,sdlStretch2x));
tempMap.insert(InsertFilter("sdlStretch3x",sdlStretch3x,sdlStretch3x));
tempMap.insert(InsertFilter("sdlStretch4x",sdlStretch4x,sdlStretch4x));
tempMap.insert(namedfilter("sdlStretch1x",sdlStretch1x));
tempMap.insert(namedfilter("sdlStretch2x",sdlStretch2x));
tempMap.insert(namedfilter("sdlStretch3x",sdlStretch3x));
tempMap.insert(namedfilter("sdlStretch4x",sdlStretch4x));
return tempMap;
}
const std::map<std::string,filterpair> filters::filterMap = makeFilterMap();
const std::map<std::string,FilterFunc> filters::filterMap = makeFilterMap();

View File

@ -13,35 +13,24 @@
// Function pointer type for a filter function
typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
typedef std::pair<FilterFunc,FilterFunc> filterpair;
typedef std::pair<std::string,filterpair> namedfilter;
typedef std::pair<std::string,FilterFunc> namedfilter;
///A class allowing for easy access to all the filters
class filters {
private:
//A named map of all the filters
static const std::map<std::string,filterpair> filterMap;
static const std::map<std::string,FilterFunc> filterMap;
public:
///Returns a function pointer to a 32 bit filter
static FilterFunc GetFilter(std::string filterName)
{
std::map<std::string,filterpair>::const_iterator found = filterMap.find(filterName);
std::map<std::string,FilterFunc>::const_iterator found = filterMap.find(filterName);
if(found == filterMap.end()){
//Not doing the error checking here
// throw std::runtime_error("ERROR: Filter not found!");
return NULL;
}
return found->second.first;
};
///Returns a function pointer to a 16 bit filter
static FilterFunc GetFilter16(std::string filterName)
{
std::map<std::string,filterpair>::const_iterator found = filterMap.find(filterName);
if(found == filterMap.end()){
// throw std::runtime_error("ERROR: Filter not found!");
return NULL;
}
return found->second.second;
return found->second;
};
///Returns the filter's scaling factor
///TODO: De hardcode this
@ -173,15 +162,12 @@ public:
// initial value appears to be all-0xff
//pixel.cpp
void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height);
void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height);
//scanline.cpp
void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *, u8 *dstPtr, u32 dstPitch, int width, int height);
void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height);
// "TV" here means each pixel is faded horizontally & vertically rather than
// inserting black scanlines
void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height);
void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height);
//simpleFilter.cpp
@ -189,16 +175,10 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u3
// in any case, they are worthless, since all renderers do "simple" or
// better by default
int Init_2xSaI(u32 BitFormat);
void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
@ -206,18 +186,12 @@ void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
//These convert to rgb24 in internal buffers first, and then back again
/*static void fill_rgb_row_16(u16 *from, int src_width, u8 *row, int width);
static void fill_rgb_row_32(u32 *from, int src_width, u8 *row, int width);*/
void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
//admame.cpp
void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
@ -226,22 +200,12 @@ void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
int Init_2xSaI(u32 BitFormat);
// endianness or bit shift variables in init.
// next 4*2 may be MMX-accelerated
void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height);
void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
//This one was commented out in other source files
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch,
u32 dstWidth, u32 dstHeight, int width, int height);
void Super2xSaI (u8 *srcPtr, u32 srcPitch,
u8 *deltaPtr, u8 *dstPtr, u32 dstPitch,
int width, int height);
void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch,
int width, int height);
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height);
void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height);
//hq2x.cpp
@ -251,12 +215,8 @@ static void hq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
static void lq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count);
static void lq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count);*/
void hq2x_init(unsigned bits_per_pixel);
void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height);
@ -271,14 +231,6 @@ void hq4x32(unsigned char * pIn, unsigned int srcPitch,
unsigned char *,
unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres);
void hq3x16(unsigned char * pIn, unsigned int srcPitch,
unsigned char *,
unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres);
void hq4x16(unsigned char * pIn, unsigned int srcPitch,
unsigned char *,
unsigned char * pOut, unsigned int dstPitch,
int Xres, int Yres);
// this takes 32-bit input
// (by converting to 16-bit first in asm version
void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres);