add hq4x filter. i can't tell if i did it right, because all hqx filters look broken to me even when theyre working.

This commit is contained in:
zeromus 2011-03-05 20:04:05 +00:00
parent 009029b15d
commit 9897125f9a
15 changed files with 5358 additions and 885 deletions

View File

@ -940,6 +940,10 @@
RelativePath=".\filter\epx.cpp"
>
</File>
<File
RelativePath=".\filter\filter.h"
>
</File>
<File
RelativePath=".\filter\hq2x.cpp"
>
@ -948,6 +952,14 @@
RelativePath=".\filter\hq2x.h"
>
</File>
<File
RelativePath=".\filter\hq4x.cpp"
>
</File>
<File
RelativePath=".\filter\hq4x.dat"
>
</File>
<File
RelativePath=".\filter\interp.h"
>
@ -1631,30 +1643,6 @@
<Filter
Name="addons"
>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_gbagame.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_guitarGrip.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_none.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_piano.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_rumblepak.cpp"
>
</File>
<File
RelativePath="..\addons\slot1_none.cpp"
>
@ -1667,14 +1655,38 @@
RelativePath="..\addons\slot1_retail.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_gbagame.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_guitarGrip.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_mpcf.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_none.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_paddle.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_piano.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_rumblepak.cpp"
>
</File>
</Filter>
<Filter
Name="metaspu"
@ -2004,10 +2016,6 @@
RelativePath="..\FIFO.h"
>
</File>
<File
RelativePath=".\filter\filter.h"
>
</File>
<File
RelativePath="..\firmware.cpp"
>

View File

@ -993,30 +993,6 @@
<Filter
Name="addons"
>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_gbagame.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_guitarGrip.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_none.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_piano.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_rumblepak.cpp"
>
</File>
<File
RelativePath="..\addons\slot1_none.cpp"
>
@ -1029,14 +1005,38 @@
RelativePath="..\addons\slot1_retail.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_gbagame.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_guitarGrip.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_mpcf.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_none.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_paddle.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_piano.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_rumblepak.cpp"
>
</File>
</Filter>
<Filter
Name="gdbstub"
@ -1605,6 +1605,18 @@
RelativePath=".\filter\hq2x.cpp"
>
</File>
<File
RelativePath=".\filter\hq4x.cpp"
>
</File>
<File
RelativePath=".\filter\hq4x.dat"
>
</File>
<File
RelativePath=".\filter\hq4x.h"
>
</File>
<File
RelativePath=".\filter\lq2x.cpp"
>

View File

@ -528,6 +528,7 @@
<ClCompile Include="colorctrl.cpp" />
<ClCompile Include="console.cpp" />
<ClCompile Include="CWindow.cpp" />
<ClCompile Include="filter\hq4x.cpp" />
<ClCompile Include="FirmConfig.cpp" />
<ClCompile Include="gbaslot_config.cpp" />
<ClCompile Include="hotkey.cpp" />
@ -665,6 +666,7 @@
<ClInclude Include="console.h" />
<ClInclude Include="CWindow.h" />
<ClInclude Include="filter\hq2x.h" />
<ClInclude Include="filter\hq4x.h" />
<ClInclude Include="filter\interp.h" />
<ClInclude Include="filter\lq2x.h" />
<ClInclude Include="FirmConfig.h" />
@ -814,6 +816,7 @@
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">7z.exe;un7z_and_touch.bat;%(AdditionalInputs)</AdditionalInputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.libs\wx.tag;%(Outputs)</Outputs>
</CustomBuild>
<None Include="filter\hq4x.dat" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources.rc" />

View File

@ -444,6 +444,9 @@
<ClCompile Include="..\addons\slot2_paddle.cpp">
<Filter>Core\addons</Filter>
</ClCompile>
<ClCompile Include="filter\hq4x.cpp">
<Filter>Windows\filters</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\addons.h">
@ -834,6 +837,9 @@
<ClInclude Include="..\utils\emufat_types.h">
<Filter>Core\utils</Filter>
</ClInclude>
<ClInclude Include="filter\hq4x.h">
<Filter>Windows\filters</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\instruction_tabdef.inc">
@ -848,6 +854,9 @@
<None Include="DeSmuME.ico">
<Filter>Windows\resources</Filter>
</None>
<None Include="filter\hq4x.dat">
<Filter>Windows\filters</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resources.rc">

View File

@ -1,21 +1,20 @@
/* Copyright (C) 2009 DeSmuME team
/*
Copyright (C) 2009-2011 DeSmuME team
This file is part of DeSmuME
This file 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.
DeSmuME 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 file 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.
DeSmuME 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 the this software. If not, see <http://www.gnu.org/licenses/>.
*/
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
struct SSurface {
unsigned char *Surface;
@ -28,6 +27,7 @@ void RenderNearest2X (SSurface Src, SSurface Dst);
void RenderLQ2X (SSurface Src, SSurface Dst);
void RenderLQ2XS (SSurface Src, SSurface Dst);
void RenderHQ2X (SSurface Src, SSurface Dst);
void RenderHQ4X (SSurface Src, SSurface Dst);
void RenderHQ2XS (SSurface Src, SSurface Dst);
void Render2xSaI (SSurface Src, SSurface Dst);
void RenderSuper2xSaI (SSurface Src, SSurface Dst);

View File

@ -31,125 +31,123 @@
#include "filter.h"
#include "interp.h"
unsigned interp_mask[2];
unsigned interp_bits_per_pixel;
/***************************************************************************/
/* HQ2x C implementation */
/*
* This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin
*/
static void hq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 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]) // top-right
#define MDR interp_16_diff(c[5], c[7]) // bottom-right
#define MDL interp_16_diff(c[7], c[3]) // bottom-left
#define MUL interp_16_diff(c[3], c[1]) // top-left
#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;
}
}
//
///***************************************************************************/
///* HQ2x C implementation */
//
///*
// * This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin
// */
//
//static void hq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
//{
// unsigned i;
//
// for(i=0;i<count;++i) {
// unsigned char mask;
//
// u16 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]) // top-right
//#define MDR interp_16_diff(c[5], c[7]) // bottom-right
//#define MDL interp_16_diff(c[7], c[3]) // bottom-left
//#define MUL interp_16_diff(c[3], c[1]) // top-left
//#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(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count)
{
@ -268,143 +266,143 @@ static void hq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
* This effect is derived from the hq2x effect made by Maxim Stepin
*/
static void hq2xS_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 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;
// hq2xS dynamic edge detection:
// simply comparing the center color against its surroundings will give bad results in many cases,
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++)
{
int r,g,b;
if (interp_bits_per_pixel == 16) {
b = (int)((c[j] & 0x1F)) << 3;
g = (int)((c[j] & 0x7E0)) >> 3;
r = (int)((c[j] & 0xF800)) >> 8;
} else {
b = (int)((c[j] & 0x1F)) << 3;
g = (int)((c[j] & 0x3E0)) >> 2;
r = (int)((c[j] & 0x7C00)) >> 7;
}
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7)
{
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR false//(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right
#define MDR false//(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right
#define MDL false//(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left
#define MUL false//(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left
#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 hq2xS_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
//{
// unsigned i;
//
// for(i=0;i<count;++i) {
// unsigned char mask;
//
// u16 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;
//
// // hq2xS dynamic edge detection:
// // simply comparing the center color against its surroundings will give bad results in many cases,
// // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
// int brightArray[9];
// int maxBright = 0, minBright = 999999;
// for(int j = 0 ; j < 9 ; j++)
// {
// int r,g,b;
// if (interp_bits_per_pixel == 16) {
// b = (int)((c[j] & 0x1F)) << 3;
// g = (int)((c[j] & 0x7E0)) >> 3;
// r = (int)((c[j] & 0xF800)) >> 8;
// } else {
// b = (int)((c[j] & 0x1F)) << 3;
// g = (int)((c[j] & 0x3E0)) >> 2;
// r = (int)((c[j] & 0x7C00)) >> 7;
// }
// const int bright = r+r+r + g+g+g + b+b;
// if(bright > maxBright) maxBright = bright;
// if(bright < minBright) minBright = bright;
//
// brightArray[j] = bright;
// }
// int diffBright = ((maxBright - minBright) * 7) >> 4;
// if(diffBright > 7)
// {
// const int centerBright = brightArray[4];
// if(ABS(brightArray[0] - centerBright) > diffBright)
// mask |= 1 << 0;
// if(ABS(brightArray[1] - centerBright) > diffBright)
// mask |= 1 << 1;
// if(ABS(brightArray[2] - centerBright) > diffBright)
// mask |= 1 << 2;
// if(ABS(brightArray[3] - centerBright) > diffBright)
// mask |= 1 << 3;
// if(ABS(brightArray[5] - centerBright) > diffBright)
// mask |= 1 << 4;
// if(ABS(brightArray[6] - centerBright) > diffBright)
// mask |= 1 << 5;
// if(ABS(brightArray[7] - centerBright) > diffBright)
// mask |= 1 << 6;
// if(ABS(brightArray[8] - centerBright) > diffBright)
// mask |= 1 << 7;
// }
//
//#define P0 dst0[0]
//#define P1 dst0[1]
//#define P2 dst1[0]
//#define P3 dst1[1]
//#define MUR false//(ABS(brightArray[1] - brightArray[5]) > diffBright) // top-right
//#define MDR false//(ABS(brightArray[5] - brightArray[7]) > diffBright) // bottom-right
//#define MDL false//(ABS(brightArray[7] - brightArray[3]) > diffBright) // bottom-left
//#define MUL false//(ABS(brightArray[3] - brightArray[1]) > diffBright) // top-left
//#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 hq2xS_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count)
{
@ -534,35 +532,35 @@ static void hq2xS_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
dst1 += 2;
}
}
void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
int count = height;
count -= 2;
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 hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// u8 *dstPtr, u32 dstPitch, int width, int height)
//{
// u16 *dst0 = (u16 *)dstPtr;
// u16 *dst1 = dst0 + (dstPitch >> 1);
//
// u16 *src0 = (u16 *)srcPtr;
// u16 *src1 = src0 + (srcPitch >> 1);
// u16 *src2 = src1 + (srcPitch >> 1);
//
// hq2x_16_def(dst0, dst1, src0, src0, src1, width);
//
// int count = height;
//
// count -= 2;
// 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(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
@ -591,35 +589,35 @@ void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dst1 += dstPitch >> 1;
hq2x_32_def(dst0, dst1, src0, src1, src1, width);
}
void hq2xS(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
hq2xS_16_def(dst0, dst1, src0, src0, src1, width);
int count = height;
count -= 2;
while(count) {
dst0 += dstPitch;
dst1 += dstPitch;
hq2xS_16_def(dst0, dst1, src0, src1, src2, width);
src0 = src1;
src1 = src2;
src2 += srcPitch >> 1;
--count;
}
dst0 += dstPitch;
dst1 += dstPitch;
hq2xS_16_def(dst0, dst1, src0, src1, src1, width);
}
//
//void hq2xS(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// u8 *dstPtr, u32 dstPitch, int width, int height)
//{
// u16 *dst0 = (u16 *)dstPtr;
// u16 *dst1 = dst0 + (dstPitch >> 1);
//
// u16 *src0 = (u16 *)srcPtr;
// u16 *src1 = src0 + (srcPitch >> 1);
// u16 *src2 = src1 + (srcPitch >> 1);
//
// hq2xS_16_def(dst0, dst1, src0, src0, src1, width);
//
// int count = height;
//
// count -= 2;
// while(count) {
// dst0 += dstPitch;
// dst1 += dstPitch;
// hq2xS_16_def(dst0, dst1, src0, src1, src2, width);
// src0 = src1;
// src1 = src2;
// src2 += srcPitch >> 1;
// --count;
// }
// dst0 += dstPitch;
// dst1 += dstPitch;
// hq2xS_16_def(dst0, dst1, src0, src1, src1, width);
//}
void hq2xS32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
@ -649,10 +647,10 @@ void hq2xS32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
hq2xS_32_def(dst0, dst1, src0, src1, src1, width);
}
void hq2x_init(unsigned bits_per_pixel)
{
interp_set(bits_per_pixel);
}
//void hq2x_init(unsigned bits_per_pixel)
//{
// interp_set(bits_per_pixel);
//}
void RenderHQ2X (SSurface Src, SSurface Dst)
{

View File

@ -0,0 +1,135 @@
/*
* This file is part of the Advance project.
*
* Copyright (C) 2003, 2008 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.
*/
#include "filter.h"
#include "interp.h"
/***************************************************************************/
/* HQ4x C implementation */
/*
* This effect is a rewritten implementation of the hq4x effect made by Maxim Stepin
*/
void hq4x_32_def(u32* dst0, u32* dst1, u32* dst2, u32* dst3, const u32* src0, const u32* src1, const u32* src2, unsigned count, unsigned flag)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u32 c[9];
c[1] = src0[0];
c[4] = src1[0];
c[7] = src2[0];
c[0] = src0[-1];
c[3] = src1[-1];
c[6] = src2[-1];
c[2] = src0[1];
c[5] = src1[1];
c[8] = src2[1];
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 P(a, b) dst##b[a]
#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 I1(p0) c[p0]
#define I2(i0, i1, p0, p1) interp_32_##i0##i1(c[p0], c[p1])
#define I3(i0, i1, i2, p0, p1, p2) interp_32_##i0##i1##i2(c[p0], c[p1], c[p2])
switch (mask) {
#include "hq4x.dat"
}
#undef P
#undef MUR
#undef MDR
#undef MDL
#undef MUL
#undef I1
#undef I2
#undef I3
src0 += 1;
src1 += 1;
src2 += 1;
dst0 += 4;
dst1 += 4;
dst2 += 4;
dst3 += 4;
}
}
void RenderHQ4X (SSurface Src, SSurface Dst)
{
u32 *lpSrc, *lpDst;
lpSrc = (u32*)Src.Surface;
lpDst = (u32*)Dst.Surface;
int dp = Dst.Pitch/2;
int sp = Src.Pitch/2;
for(int i=0;i<Src.Height;i++)
{
hq4x_32_def(lpDst,lpDst+dp,lpDst+dp*2,lpDst+dp*3,lpSrc,lpSrc+sp,lpSrc+sp*2,Src.Width,0);
lpDst += Dst.Pitch*2;
lpSrc += Src.Pitch/2;
}
//hq4x_32_def (lpSrc, Src.Pitch*2,
// lpSrc,
// lpDst, Dst.Pitch*2 , Src.Width, Src.Height);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
/*
* This file is part of the Advance project.
*
* Copyright (C) 2003, 2004, 2008 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 __HQ4X_H
#define __HQ4X_H
#include "segment.h"
void hq4x_16_def(interp_uint16* dst0, interp_uint16* dst1, interp_uint16* dst2, interp_uint16* dst3, const interp_uint16* src0, const interp_uint16* src1, const interp_uint16* src2, unsigned count, unsigned flag);
void hq4x_32_def(interp_uint32* dst0, interp_uint32* dst1, interp_uint32* dst2, interp_uint32* dst3, const interp_uint32* src0, const interp_uint32* src1, const interp_uint32* src2, unsigned count, unsigned flag);
#endif

View File

@ -41,89 +41,89 @@ typedef unsigned int u32;
/***************************************************************************/
/* interpolation */
extern unsigned interp_mask[2];
extern unsigned interp_bits_per_pixel;
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
#define INTERP_16_MASK_2(v) (v & interp_mask[1])
static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_71(u16 p1, u16 p2)
{
return 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);
}
static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_11(u16 p1, u16 p2)
{
return 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);
}
static inline u16 interp_16_31(u16 p1, u16 p2)
{
return 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);
}
static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
{
return 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);
}
static inline u16 interp_16_53(u16 p1, u16 p2)
{
return 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);
}
static inline u16 interp_16_151(u16 p1, u16 p2)
{
return 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);
}
static inline u16 interp_16_97(u16 p1, u16 p2)
{
return 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);
}
//extern unsigned interp_mask[2];
//extern unsigned interp_bits_per_pixel;
//
//#define INTERP_16_MASK_1(v) (v & interp_mask[0])
//#define INTERP_16_MASK_2(v) (v & interp_mask[1])
//
//static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_71(u16 p1, u16 p2)
//{
// return 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);
//}
//
//static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_11(u16 p1, u16 p2)
//{
// return 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);
//}
//
//static inline u16 interp_16_31(u16 p1, u16 p2)
//{
// return 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);
//}
//
//static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
//{
// return 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);
//}
//
//static inline u16 interp_16_53(u16 p1, u16 p2)
//{
// return 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);
//}
//
//static inline u16 interp_16_151(u16 p1, u16 p2)
//{
// return 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);
//}
//
//static inline u16 interp_16_97(u16 p1, u16 p2)
//{
// return 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)
@ -212,40 +212,40 @@ static inline u32 interp_32_97(u32 p1, u32 p2)
#define INTERP_Y_LIMIT (0x30*4)
#define INTERP_U_LIMIT (0x07*4)
#define INTERP_V_LIMIT (0x06*8)
static int interp_16_diff(u16 p1, u16 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_16_diff(u16 p1, u16 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(u32 p1, u32 p2)
{
@ -281,34 +281,34 @@ static int interp_32_diff(u32 p1, u32 p2)
static __forceinline unsigned int ABS(int x) { return (x+(x>>31))^(x>>31); } // faster
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
static int interp_16_diff2(u16 p1, u16 p2)
{
int r, g, b;
int y, u, v;
if ((p1 & 0xF79E) == (p2 & 0xF79E))
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;
}
// yb = 30*r + 58*g + 12*b;
y = 33*r + 36*g + 31*b;
u = -14*r - 29*g + 44*b;
v = 62*r - 51*g - 10*b;
if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2)
return 1;
return 0;
}
//
//static int interp_16_diff2(u16 p1, u16 p2)
//{
// int r, g, b;
// int y, u, v;
//
// if ((p1 & 0xF79E) == (p2 & 0xF79E))
// 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;
// }
//
//// yb = 30*r + 58*g + 12*b;
// y = 33*r + 36*g + 31*b;
// u = -14*r - 29*g + 44*b;
// v = 62*r - 51*g - 10*b;
//
// if (11*ABS(y) + 8*ABS(u) + 6*ABS(v) > INTERP_LIMIT2)
// return 1;
// return 0;
//}
static int interp_32_diff2(u32 p1, u32 p2)
{
@ -332,25 +332,25 @@ static int interp_32_diff2(u32 p1, u32 p2)
return 0;
}
static void interp_set(unsigned 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;
}
}
//
//static void interp_set(unsigned 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

@ -31,244 +31,244 @@
#include "filter.h"
#include "interp.h"
static void lq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 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 lq2xS_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 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];
}
// lq2xS dynamic edge detection:
// simply comparing the center color against its surroundings will give bad results in many cases,
// so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
int brightArray[9];
int maxBright = 0, minBright = 999999;
for(int j = 0 ; j < 9 ; j++)
{
const int b = (int)((c[j] & 0xF8));
const int g = (int)((c[j] & 0xF800)) >> 8;
const int r = (int)((c[j] & 0xF80000)) >> 16;
const int bright = r+r+r + g+g+g + b+b;
if(bright > maxBright) maxBright = bright;
if(bright < minBright) minBright = bright;
brightArray[j] = bright;
}
int diffBright = ((maxBright - minBright) * 7) >> 4;
if(diffBright > 7)
{
const int centerBright = brightArray[4];
if(ABS(brightArray[0] - centerBright) > diffBright)
mask |= 1 << 0;
if(ABS(brightArray[1] - centerBright) > diffBright)
mask |= 1 << 1;
if(ABS(brightArray[2] - centerBright) > diffBright)
mask |= 1 << 2;
if(ABS(brightArray[3] - centerBright) > diffBright)
mask |= 1 << 3;
if(ABS(brightArray[5] - centerBright) > diffBright)
mask |= 1 << 4;
if(ABS(brightArray[6] - centerBright) > diffBright)
mask |= 1 << 5;
if(ABS(brightArray[7] - centerBright) > diffBright)
mask |= 1 << 6;
if(ABS(brightArray[8] - centerBright) > diffBright)
mask |= 1 << 7;
}
#define P0 dst0[0]
#define P1 dst0[1]
#define P2 dst1[0]
#define P3 dst1[1]
#define MUR false
#define MDR false
#define MDL false
#define MUL false
#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_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
//{
// unsigned i;
//
// for(i=0;i<count;++i) {
// unsigned char mask;
//
// u16 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 lq2xS_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
//{
// unsigned i;
//
// for(i=0;i<count;++i) {
// unsigned char mask;
//
// u16 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];
// }
//
// // lq2xS dynamic edge detection:
// // simply comparing the center color against its surroundings will give bad results in many cases,
// // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block
// int brightArray[9];
// int maxBright = 0, minBright = 999999;
// for(int j = 0 ; j < 9 ; j++)
// {
// const int b = (int)((c[j] & 0xF8));
// const int g = (int)((c[j] & 0xF800)) >> 8;
// const int r = (int)((c[j] & 0xF80000)) >> 16;
// const int bright = r+r+r + g+g+g + b+b;
// if(bright > maxBright) maxBright = bright;
// if(bright < minBright) minBright = bright;
//
// brightArray[j] = bright;
// }
// int diffBright = ((maxBright - minBright) * 7) >> 4;
// if(diffBright > 7)
// {
// const int centerBright = brightArray[4];
// if(ABS(brightArray[0] - centerBright) > diffBright)
// mask |= 1 << 0;
// if(ABS(brightArray[1] - centerBright) > diffBright)
// mask |= 1 << 1;
// if(ABS(brightArray[2] - centerBright) > diffBright)
// mask |= 1 << 2;
// if(ABS(brightArray[3] - centerBright) > diffBright)
// mask |= 1 << 3;
// if(ABS(brightArray[5] - centerBright) > diffBright)
// mask |= 1 << 4;
// if(ABS(brightArray[6] - centerBright) > diffBright)
// mask |= 1 << 5;
// if(ABS(brightArray[7] - centerBright) > diffBright)
// mask |= 1 << 6;
// if(ABS(brightArray[8] - centerBright) > diffBright)
// mask |= 1 << 7;
// }
//
//#define P0 dst0[0]
//#define P1 dst0[1]
//#define P2 dst1[0]
//#define P3 dst1[1]
//#define MUR false
//#define MDR false
//#define MDL false
//#define MUL false
//#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(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count)
{
@ -508,67 +508,67 @@ static void lq2xS_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
dst1 += 2;
}
}
void lq2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
int count = height;
count -= 2;
while(count>0) {
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 lq2xS16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
int count;
lq2xS_16_def(dst0, dst1, src0, src0, src1, width);
if( height == 1 ) return;
count = height;
count -= 2;
while(count>0) {
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;
lq2xS_16_def(dst0, dst1, src0, src1, src1, width);
}
//void lq2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// u8 *dstPtr, u32 dstPitch, int width, int height)
//{
// u16 *dst0 = (u16 *)dstPtr;
// u16 *dst1 = dst0 + (dstPitch >> 1);
//
// u16 *src0 = (u16 *)srcPtr;
// u16 *src1 = src0 + (srcPitch >> 1);
// u16 *src2 = src1 + (srcPitch >> 1);
//
// lq2x_16_def(dst0, dst1, src0, src0, src1, width);
// if( height == 1 ) return;
//
// int count = height;
//
// count -= 2;
// while(count>0) {
// 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 lq2xS16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// u8 *dstPtr, u32 dstPitch, int width, int height)
//{
// u16 *dst0 = (u16 *)dstPtr;
// u16 *dst1 = dst0 + (dstPitch >> 1);
//
// u16 *src0 = (u16 *)srcPtr;
// u16 *src1 = src0 + (srcPitch >> 1);
// u16 *src2 = src1 + (srcPitch >> 1);
//
// int count;
//
// lq2xS_16_def(dst0, dst1, src0, src0, src1, width);
// if( height == 1 ) return;
//
// count = height;
//
// count -= 2;
// while(count>0) {
// 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;
// lq2xS_16_def(dst0, dst1, src0, src1, src1, width);
//}
void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
@ -631,10 +631,10 @@ void lq2xS32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
lq2xS_32_def(dst0, dst1, src0, src1, src1, width);
}
void lq2x_init(unsigned bits_per_pixel)
{
interp_set(bits_per_pixel);
}
//void lq2x_init(unsigned bits_per_pixel)
//{
// interp_set(bits_per_pixel);
//}
void RenderLQ2X (SSurface Src, SSurface Dst)
{

View File

@ -1,19 +1,19 @@
/* main.cpp
Copyright 2006 Theo Berkau
Copyright (C) 2006-2010 DeSmuME team
/*
Copyright 2006 Theo Berkau
Copyright (C) 2006-2011 DeSmuME team
This file 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 file 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 file 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.
This file 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 the this software. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
// icon gradient: #f6f6fb to #8080c0
@ -2593,8 +2593,10 @@ int _main()
WndY = GetPrivateProfileInt("Video","WindowPosY", CW_USEDEFAULT, IniName);
if(WndX < -10000) WndX = CW_USEDEFAULT; // fix for missing window problem
if(WndY < -10000) WndY = CW_USEDEFAULT; // (happens if you close desmume while it's minimized)
video.width = GetPrivateProfileInt("Video", "Width", 256, IniName);
video.height = GetPrivateProfileInt("Video", "Height", 384, IniName);
video.width = 256;
video.height = 384;
//video.width = GetPrivateProfileInt("Video", "Width", 256, IniName);
//video.height = GetPrivateProfileInt("Video", "Height", 384, IniName);
video.layout_old = video.layout = GetPrivateProfileInt("Video", "LCDsLayout", 0, IniName);
if (video.layout > 2)
{
@ -2677,8 +2679,18 @@ int _main()
}
//disable wacky stylus stuff
GlobalAddAtom("MicrosoftTabletPenServiceProperty");
SetProp(MainWindow->getHWnd(),"MicrosoftTabletPenServiceProperty",(HANDLE)1);
GlobalAddAtom(MICROSOFT_TABLETPENSERVICE_PROPERTY);
SetProp(MainWindow->getHWnd(),MICROSOFT_TABLETPENSERVICE_PROPERTY,(HANDLE)(
TABLET_DISABLE_PRESSANDHOLD |
TABLET_DISABLE_PENTAPFEEDBACK |
TABLET_DISABLE_PENBARRELFEEDBACK |
TABLET_DISABLE_TOUCHUIFORCEON |
TABLET_DISABLE_TOUCHUIFORCEOFF |
TABLET_DISABLE_TOUCHSWITCH |
TABLET_DISABLE_FLICKS |
TABLET_DISABLE_SMOOTHSCROLLING |
TABLET_DISABLE_FLICKFALLBACKKEYS
));
gpu_SetRotateScreen(video.rotation);
@ -2914,7 +2926,7 @@ int _main()
GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName);
CommonSettings.BootFromFirmware = GetPrivateProfileBool("Firmware", "BootFromFirmware", false, IniName);
video.currentfilter = GetPrivateProfileInt("Video", "Filter", video.NONE, IniName);
video.setfilter(GetPrivateProfileInt("Video", "Filter", video.NONE, IniName));
FilterUpdate(MainWindow->getHWnd(),false);
/* Read the firmware settings from the init file */
@ -4013,6 +4025,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
MainWindow->checkMenu(IDM_RENDER_LQ2X, video.currentfilter == video.LQ2X );
MainWindow->checkMenu(IDM_RENDER_LQ2XS, video.currentfilter == video.LQ2XS );
MainWindow->checkMenu(IDM_RENDER_HQ2X, video.currentfilter == video.HQ2X );
MainWindow->checkMenu(IDM_RENDER_HQ4X, video.currentfilter == video.HQ4X );
MainWindow->checkMenu(IDM_RENDER_HQ2XS, video.currentfilter == video.HQ2XS );
MainWindow->checkMenu(IDM_RENDER_2XSAI, video.currentfilter == video._2XSAI );
MainWindow->checkMenu(IDM_RENDER_SUPER2XSAI, video.currentfilter == video.SUPER2XSAI );
@ -4516,16 +4529,6 @@ DOKEYDOWN:
NDS_UnPause();
}
return 0;
case WM_TABLET_QUERYSYSTEMGESTURESTATUS:
return TABLET_DISABLE_PRESSANDHOLD |
TABLET_DISABLE_PENTAPFEEDBACK |
TABLET_DISABLE_PENBARRELFEEDBACK |
TABLET_DISABLE_TOUCHUIFORCEON |
TABLET_DISABLE_TOUCHUIFORCEOFF |
TABLET_DISABLE_TOUCHSWITCH |
TABLET_DISABLE_FLICKS |
TABLET_DISABLE_SMOOTHSCROLLING |
TABLET_DISABLE_FLICKFALLBACKKEYS;
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
@ -4708,6 +4711,13 @@ DOKEYDOWN:
FilterUpdate(hwnd);
}
break;
case IDM_RENDER_HQ4X:
{
Lock lock (win_backbuffer_sync);
video.setfilter(video.HQ4X);
FilterUpdate(hwnd);
}
break;
case IDM_RENDER_HQ2XS:
{
Lock lock (win_backbuffer_sync);
@ -6507,8 +6517,8 @@ bool DDRAW::createSurfaces(HWND hwnd)
else
surfDescBack.ddsCaps.dwCaps |= DDSCAPS_VIDEOMEMORY;
surfDescBack.dwWidth = 384 * 2;
surfDescBack.dwHeight = 384 * 2;
surfDescBack.dwWidth = 384 * 4;
surfDescBack.dwHeight = 384 * 4;
if (FAILED(handle->CreateSurface(&surfDescBack, &surface.back, NULL))) return false;
if (FAILED(handle->CreateClipper(0, &clip, NULL))) return false;

View File

@ -862,6 +862,12 @@
#define ID_TOOLS_SETFONT 40085
#define ID_CONFIG_SETFONT 40086
#define IDD_FONTCONFIG 40087
#define ID_MAGNIFICATIONFILTER_HQ4X 40088
#define IDM_RENDER_HQ4X 40089
#define ID_40090 40090
#define ID_MAGNIFICATIONFILTER_HQ4X40091 40091
#define ID_FILTRI_HQ4X 40092
#define ID_40093 40093
#define IDC_LABEL_UP 50000
#define IDC_LABEL_RIGHT 50001
#define IDC_LABEL_LEFT 50002
@ -962,7 +968,7 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 125
#define _APS_NEXT_COMMAND_VALUE 40088
#define _APS_NEXT_COMMAND_VALUE 40094
#define _APS_NEXT_CONTROL_VALUE 1041
#define _APS_NEXT_SYMED_VALUE 101
#endif

Binary file not shown.

View File

@ -17,8 +17,8 @@ public:
int currentfilter;
u8* srcBuffer;
CACHE_ALIGN u32 buffer[4*256*192*2];
CACHE_ALIGN u32 filteredbuffer[4*256*192*2];
CACHE_ALIGN u32 buffer[16*256*192*2];
CACHE_ALIGN u32 filteredbuffer[16*256*192*2];
enum {
NONE,
@ -38,6 +38,7 @@ public:
EPXPLUS,
EPX1POINT5,
EPXPLUS1POINT5,
HQ4X,
NUM_FILTERS,
};
@ -68,6 +69,10 @@ public:
width = 256*3/2;
height = 384*3/2;
break;
case HQ4X:
width = 256*4;
height = 384*4;
break;
default:
width = 256*2;
height = 384*2;
@ -110,6 +115,9 @@ public:
case HQ2X:
RenderHQ2X(src, dst);
break;
case HQ4X:
RenderHQ4X(src, dst);
break;
case HQ2XS:
RenderHQ2XS(src, dst);
break;