try optimizing deemph vs scale2x (should fix #375)
This commit is contained in:
parent
359b5c3786
commit
907af7f87e
|
@ -466,7 +466,7 @@ void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, in
|
||||||
/* Todo: Make sure 24bpp code works right with big-endian cpus */
|
/* Todo: Make sure 24bpp code works right with big-endian cpus */
|
||||||
|
|
||||||
//takes a pointer to XBuf and applies fully modern deemph palettizing
|
//takes a pointer to XBuf and applies fully modern deemph palettizing
|
||||||
u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale)
|
template<int SCALE> static u32 _ModernDeemphColorMap(u8* src, u8* srcbuf)
|
||||||
{
|
{
|
||||||
u8 pixel = *src;
|
u8 pixel = *src;
|
||||||
|
|
||||||
|
@ -476,8 +476,8 @@ u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale)
|
||||||
int ofs = src-srcbuf;
|
int ofs = src-srcbuf;
|
||||||
int xofs = ofs&255;
|
int xofs = ofs&255;
|
||||||
int yofs = ofs>>8;
|
int yofs = ofs>>8;
|
||||||
if(xscale!=1) xofs /= xscale; //untested optimization
|
xofs /= SCALE;
|
||||||
if(yscale!=1) yofs /= yscale; //untested optimization
|
yofs /= SCALE;
|
||||||
ofs = xofs+yofs*256;
|
ofs = xofs+yofs*256;
|
||||||
|
|
||||||
//find out which deemph bitplane value we're on
|
//find out which deemph bitplane value we're on
|
||||||
|
@ -490,6 +490,15 @@ u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale)
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale)
|
||||||
|
{
|
||||||
|
if(scale == 1)_ModernDeemphColorMap<1>(src,srcbuf);
|
||||||
|
else if(scale == 2) _ModernDeemphColorMap<2>(src,srcbuf);
|
||||||
|
else if(scale == 3) _ModernDeemphColorMap<3>(src,srcbuf);
|
||||||
|
else if(scale == 4) _ModernDeemphColorMap<4>(src,srcbuf);
|
||||||
|
else abort();
|
||||||
|
}
|
||||||
|
|
||||||
void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale)
|
void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
|
@ -514,6 +523,9 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
int mdcmxs = xscale*mult;
|
int mdcmxs = xscale*mult;
|
||||||
int mdcmys = yscale*mult;
|
int mdcmys = yscale*mult;
|
||||||
|
|
||||||
|
if(mdcmxs != mdcmys)
|
||||||
|
abort();
|
||||||
|
|
||||||
xr *= mult;
|
xr *= mult;
|
||||||
yr *= mult;
|
yr *= mult;
|
||||||
xscale=yscale=1;
|
xscale=yscale=1;
|
||||||
|
@ -528,7 +540,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
{
|
{
|
||||||
for(x=xr;x;x--)
|
for(x=xr;x;x--)
|
||||||
{
|
{
|
||||||
*(uint32 *)dest=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs, mdcmys);
|
*(uint32 *)dest=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs);
|
||||||
dest+=4;
|
dest+=4;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
@ -541,7 +553,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
{
|
{
|
||||||
for(x=xr;x;x--)
|
for(x=xr;x;x--)
|
||||||
{
|
{
|
||||||
uint32 tmp=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs, mdcmys);
|
uint32 tmp=ModernDeemphColorMap(src,specbuf8bpp,mdcmxs);
|
||||||
*(uint8 *)dest=tmp;
|
*(uint8 *)dest=tmp;
|
||||||
*((uint8 *)dest+1)=tmp>>8;
|
*((uint8 *)dest+1)=tmp>>8;
|
||||||
*((uint8 *)dest+2)=tmp>>16;
|
*((uint8 *)dest+2)=tmp>>16;
|
||||||
|
@ -581,7 +593,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
{
|
{
|
||||||
for(x=xr; x; x--)
|
for(x=xr; x; x--)
|
||||||
{
|
{
|
||||||
*(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1,1);
|
*(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1);
|
||||||
dest += 4;
|
dest += 4;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
@ -920,7 +932,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
for(x=xr;x;x--)
|
for(x=xr;x;x--)
|
||||||
{
|
{
|
||||||
//THE MAIN BLITTING CODEPATH (there may be others that are important)
|
//THE MAIN BLITTING CODEPATH (there may be others that are important)
|
||||||
*(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1,1);
|
*(uint32 *)dest = ModernDeemphColorMap(src,XBuf,1);
|
||||||
dest+=4;
|
dest+=4;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
@ -933,7 +945,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
{
|
{
|
||||||
for(x=xr;x;x--)
|
for(x=xr;x;x--)
|
||||||
{
|
{
|
||||||
uint32 tmp = ModernDeemphColorMap(src,XBuf,1,1);
|
uint32 tmp = ModernDeemphColorMap(src,XBuf,1);
|
||||||
*(uint8 *)dest=tmp;
|
*(uint8 *)dest=tmp;
|
||||||
*((uint8 *)dest+1)=tmp>>8;
|
*((uint8 *)dest+1)=tmp>>8;
|
||||||
*((uint8 *)dest+2)=tmp>>16;
|
*((uint8 *)dest+2)=tmp>>16;
|
||||||
|
@ -949,7 +961,7 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
|
||||||
{
|
{
|
||||||
for(x=xr;x;x--)
|
for(x=xr;x;x--)
|
||||||
{
|
{
|
||||||
*(uint16 *)dest = ModernDeemphColorMap(src,XBuf,1,1);
|
*(uint16 *)dest = ModernDeemphColorMap(src,XBuf,1);
|
||||||
dest+=2;
|
dest+=2;
|
||||||
src++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,4 +29,4 @@ void Blit32to16(uint32 *src, uint16 *dest, int xr, int yr, int dpitch,
|
||||||
int shiftr[3], int shiftl[3]);
|
int shiftr[3], int shiftl[3]);
|
||||||
|
|
||||||
|
|
||||||
u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int xscale, int yscale);
|
u32 ModernDeemphColorMap(u8* src, u8* srcbuf, int scale);
|
|
@ -582,7 +582,7 @@ int SaveSnapshot(void)
|
||||||
dest++;
|
dest++;
|
||||||
for(x=256;x;x--)
|
for(x=256;x;x--)
|
||||||
{
|
{
|
||||||
u32 color = ModernDeemphColorMap(tmp,XBuf,1,1);
|
u32 color = ModernDeemphColorMap(tmp,XBuf,1);
|
||||||
*dest++=(color>>0x10)&0xFF;
|
*dest++=(color>>0x10)&0xFF;
|
||||||
*dest++=(color>>0x08)&0xFF;
|
*dest++=(color>>0x08)&0xFF;
|
||||||
*dest++=(color>>0x00)&0xFF;
|
*dest++=(color>>0x00)&0xFF;
|
||||||
|
|
Loading…
Reference in New Issue