aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler
diff options
context:
space:
mode:
authorMax Horn2009-01-27 01:23:04 +0000
committerMax Horn2009-01-27 01:23:04 +0000
commit980970946854eee26b4576483c2dedc29e0177c8 (patch)
tree4086a57f0f43edb4e6f2948ce0ca50754d9abf6f /graphics/scaler
parent153b32391faff822a657851e82b986dd6a340e12 (diff)
downloadscummvm-rg350-980970946854eee26b4576483c2dedc29e0177c8.tar.gz
scummvm-rg350-980970946854eee26b4576483c2dedc29e0177c8.tar.bz2
scummvm-rg350-980970946854eee26b4576483c2dedc29e0177c8.zip
Speed up HQ2x/HQ3x C++ version a bit (about 20% faster with -O3 on my system)
svn-id: r36087
Diffstat (limited to 'graphics/scaler')
-rw-r--r--graphics/scaler/hq2x.cpp102
-rw-r--r--graphics/scaler/hq3x.cpp86
-rw-r--r--graphics/scaler/intern.h110
3 files changed, 199 insertions, 99 deletions
diff --git a/graphics/scaler/hq2x.cpp b/graphics/scaler/hq2x.cpp
index bef97e7251..df1c34626f 100644
--- a/graphics/scaler/hq2x.cpp
+++ b/graphics/scaler/hq2x.cpp
@@ -38,78 +38,78 @@ void hq2x_16(const byte *, byte *, uint32, uint32, uint32, uint32);
}
-void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
+void HQ2x_ASM(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
hq2x_16(srcPtr, dstPtr, width, height, srcPitch, dstPitch);
}
-#else
+#endif
#define PIXEL00_0 *(q) = w5;
-#define PIXEL00_10 *(q) = interpolate16_2<bitFormat,3,1>(w5, w1);
-#define PIXEL00_11 *(q) = interpolate16_2<bitFormat,3,1>(w5, w4);
-#define PIXEL00_12 *(q) = interpolate16_2<bitFormat,3,1>(w5, w2);
-#define PIXEL00_20 *(q) = interpolate16_3<bitFormat,2,1,1>(w5, w4, w2);
-#define PIXEL00_21 *(q) = interpolate16_3<bitFormat,2,1,1>(w5, w1, w2);
-#define PIXEL00_22 *(q) = interpolate16_3<bitFormat,2,1,1>(w5, w1, w4);
-#define PIXEL00_60 *(q) = interpolate16_3<bitFormat,5,2,1>(w5, w2, w4);
-#define PIXEL00_61 *(q) = interpolate16_3<bitFormat,5,2,1>(w5, w4, w2);
-#define PIXEL00_70 *(q) = interpolate16_3<bitFormat,6,1,1>(w5, w4, w2);
-#define PIXEL00_90 *(q) = interpolate16_3<bitFormat,2,3,3>(w5, w4, w2);
-#define PIXEL00_100 *(q) = interpolate16_3<bitFormat,14,1,1>(w5, w4, w2);
+#define PIXEL00_10 *(q) = interpolate16_3_1<ColorMask>(w5, w1);
+#define PIXEL00_11 *(q) = interpolate16_3_1<ColorMask>(w5, w4);
+#define PIXEL00_12 *(q) = interpolate16_3_1<ColorMask>(w5, w2);
+#define PIXEL00_20 *(q) = interpolate16_2_1_1<ColorMask>(w5, w4, w2);
+#define PIXEL00_21 *(q) = interpolate16_2_1_1<ColorMask>(w5, w1, w2);
+#define PIXEL00_22 *(q) = interpolate16_2_1_1<ColorMask>(w5, w1, w4);
+#define PIXEL00_60 *(q) = interpolate16_5_2_1<ColorMask>(w5, w2, w4);
+#define PIXEL00_61 *(q) = interpolate16_5_2_1<ColorMask>(w5, w4, w2);
+#define PIXEL00_70 *(q) = interpolate16_6_1_1<ColorMask>(w5, w4, w2);
+#define PIXEL00_90 *(q) = interpolate16_2_3_3<ColorMask>(w5, w4, w2);
+#define PIXEL00_100 *(q) = interpolate16_14_1_1<ColorMask>(w5, w4, w2);
#define PIXEL01_0 *(q+1) = w5;
-#define PIXEL01_10 *(q+1) = interpolate16_2<bitFormat,3,1>(w5, w3);
-#define PIXEL01_11 *(q+1) = interpolate16_2<bitFormat,3,1>(w5, w2);
-#define PIXEL01_12 *(q+1) = interpolate16_2<bitFormat,3,1>(w5, w6);
-#define PIXEL01_20 *(q+1) = interpolate16_3<bitFormat,2,1,1>(w5, w2, w6);
-#define PIXEL01_21 *(q+1) = interpolate16_3<bitFormat,2,1,1>(w5, w3, w6);
-#define PIXEL01_22 *(q+1) = interpolate16_3<bitFormat,2,1,1>(w5, w3, w2);
-#define PIXEL01_60 *(q+1) = interpolate16_3<bitFormat,5,2,1>(w5, w6, w2);
-#define PIXEL01_61 *(q+1) = interpolate16_3<bitFormat,5,2,1>(w5, w2, w6);
-#define PIXEL01_70 *(q+1) = interpolate16_3<bitFormat,6,1,1>(w5, w2, w6);
-#define PIXEL01_90 *(q+1) = interpolate16_3<bitFormat,2,3,3>(w5, w2, w6);
-#define PIXEL01_100 *(q+1) = interpolate16_3<bitFormat,14,1,1>(w5, w2, w6);
+#define PIXEL01_10 *(q+1) = interpolate16_3_1<ColorMask>(w5, w3);
+#define PIXEL01_11 *(q+1) = interpolate16_3_1<ColorMask>(w5, w2);
+#define PIXEL01_12 *(q+1) = interpolate16_3_1<ColorMask>(w5, w6);
+#define PIXEL01_20 *(q+1) = interpolate16_2_1_1<ColorMask>(w5, w2, w6);
+#define PIXEL01_21 *(q+1) = interpolate16_2_1_1<ColorMask>(w5, w3, w6);
+#define PIXEL01_22 *(q+1) = interpolate16_2_1_1<ColorMask>(w5, w3, w2);
+#define PIXEL01_60 *(q+1) = interpolate16_5_2_1<ColorMask>(w5, w6, w2);
+#define PIXEL01_61 *(q+1) = interpolate16_5_2_1<ColorMask>(w5, w2, w6);
+#define PIXEL01_70 *(q+1) = interpolate16_6_1_1<ColorMask>(w5, w2, w6);
+#define PIXEL01_90 *(q+1) = interpolate16_2_3_3<ColorMask>(w5, w2, w6);
+#define PIXEL01_100 *(q+1) = interpolate16_14_1_1<ColorMask>(w5, w2, w6);
#define PIXEL10_0 *(q+nextlineDst) = w5;
-#define PIXEL10_10 *(q+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w7);
-#define PIXEL10_11 *(q+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w8);
-#define PIXEL10_12 *(q+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w4);
-#define PIXEL10_20 *(q+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w8, w4);
-#define PIXEL10_21 *(q+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w7, w4);
-#define PIXEL10_22 *(q+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w7, w8);
-#define PIXEL10_60 *(q+nextlineDst) = interpolate16_3<bitFormat,5,2,1>(w5, w4, w8);
-#define PIXEL10_61 *(q+nextlineDst) = interpolate16_3<bitFormat,5,2,1>(w5, w8, w4);
-#define PIXEL10_70 *(q+nextlineDst) = interpolate16_3<bitFormat,6,1,1>(w5, w8, w4);
-#define PIXEL10_90 *(q+nextlineDst) = interpolate16_3<bitFormat,2,3,3>(w5, w8, w4);
-#define PIXEL10_100 *(q+nextlineDst) = interpolate16_3<bitFormat,14,1,1>(w5, w8, w4);
+#define PIXEL10_10 *(q+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w7);
+#define PIXEL10_11 *(q+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w8);
+#define PIXEL10_12 *(q+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w4);
+#define PIXEL10_20 *(q+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w8, w4);
+#define PIXEL10_21 *(q+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w7, w4);
+#define PIXEL10_22 *(q+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w7, w8);
+#define PIXEL10_60 *(q+nextlineDst) = interpolate16_5_2_1<ColorMask>(w5, w4, w8);
+#define PIXEL10_61 *(q+nextlineDst) = interpolate16_5_2_1<ColorMask>(w5, w8, w4);
+#define PIXEL10_70 *(q+nextlineDst) = interpolate16_6_1_1<ColorMask>(w5, w8, w4);
+#define PIXEL10_90 *(q+nextlineDst) = interpolate16_2_3_3<ColorMask>(w5, w8, w4);
+#define PIXEL10_100 *(q+nextlineDst) = interpolate16_14_1_1<ColorMask>(w5, w8, w4);
#define PIXEL11_0 *(q+1+nextlineDst) = w5;
-#define PIXEL11_10 *(q+1+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w9);
-#define PIXEL11_11 *(q+1+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w6);
-#define PIXEL11_12 *(q+1+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w8);
-#define PIXEL11_20 *(q+1+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w6, w8);
-#define PIXEL11_21 *(q+1+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w9, w8);
-#define PIXEL11_22 *(q+1+nextlineDst) = interpolate16_3<bitFormat,2,1,1>(w5, w9, w6);
-#define PIXEL11_60 *(q+1+nextlineDst) = interpolate16_3<bitFormat,5,2,1>(w5, w8, w6);
-#define PIXEL11_61 *(q+1+nextlineDst) = interpolate16_3<bitFormat,5,2,1>(w5, w6, w8);
-#define PIXEL11_70 *(q+1+nextlineDst) = interpolate16_3<bitFormat,6,1,1>(w5, w6, w8);
-#define PIXEL11_90 *(q+1+nextlineDst) = interpolate16_3<bitFormat,2,3,3>(w5, w6, w8);
-#define PIXEL11_100 *(q+1+nextlineDst) = interpolate16_3<bitFormat,14,1,1>(w5, w6, w8);
+#define PIXEL11_10 *(q+1+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w9);
+#define PIXEL11_11 *(q+1+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w6);
+#define PIXEL11_12 *(q+1+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w8);
+#define PIXEL11_20 *(q+1+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w6, w8);
+#define PIXEL11_21 *(q+1+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w9, w8);
+#define PIXEL11_22 *(q+1+nextlineDst) = interpolate16_2_1_1<ColorMask>(w5, w9, w6);
+#define PIXEL11_60 *(q+1+nextlineDst) = interpolate16_5_2_1<ColorMask>(w5, w8, w6);
+#define PIXEL11_61 *(q+1+nextlineDst) = interpolate16_5_2_1<ColorMask>(w5, w6, w8);
+#define PIXEL11_70 *(q+1+nextlineDst) = interpolate16_6_1_1<ColorMask>(w5, w6, w8);
+#define PIXEL11_90 *(q+1+nextlineDst) = interpolate16_2_3_3<ColorMask>(w5, w6, w8);
+#define PIXEL11_100 *(q+1+nextlineDst) = interpolate16_14_1_1<ColorMask>(w5, w6, w8);
#define YUV(x) RGBtoYUV[w ## x]
-#define bitFormat 565
+#define ColorMask Graphics::ColorMasks<565>
void HQ2x_565(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
#include "graphics/scaler/hq2x.h"
}
-#undef bitFormat
+#undef ColorMask
-#define bitFormat 555
+#define ColorMask Graphics::ColorMasks<555>
void HQ2x_555(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
#include "graphics/scaler/hq2x.h"
}
-#undef bitFormat
+#undef ColorMask
void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
@@ -118,5 +118,3 @@ void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
else
HQ2x_555(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
}
-
-#endif //Assembly version
diff --git a/graphics/scaler/hq3x.cpp b/graphics/scaler/hq3x.cpp
index b225fcae87..b40c85d56a 100644
--- a/graphics/scaler/hq3x.cpp
+++ b/graphics/scaler/hq3x.cpp
@@ -39,80 +39,80 @@ void hq3x_16(const byte *, byte *, uint32, uint32, uint32, uint32);
}
-void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
+void HQ3x_ASM(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
hq3x_16(srcPtr, dstPtr, width, height, srcPitch, dstPitch);
}
-#else
+#endif
-#define PIXEL00_1M *(q) = interpolate16_2<bitFormat,3,1>(w5, w1);
-#define PIXEL00_1U *(q) = interpolate16_2<bitFormat,3,1>(w5, w2);
-#define PIXEL00_1L *(q) = interpolate16_2<bitFormat,3,1>(w5, w4);
-#define PIXEL00_2 *(q) = interpolate16_3<bitFormat,2,1,1>(w5, w4, w2);
-#define PIXEL00_4 *(q) = interpolate16_3<bitFormat,2,7,7>(w5, w4, w2);
-#define PIXEL00_5 *(q) = interpolate16_2<bitFormat,1,1>(w4, w2);
+#define PIXEL00_1M *(q) = interpolate16_3_1<ColorMask>(w5, w1);
+#define PIXEL00_1U *(q) = interpolate16_3_1<ColorMask>(w5, w2);
+#define PIXEL00_1L *(q) = interpolate16_3_1<ColorMask>(w5, w4);
+#define PIXEL00_2 *(q) = interpolate16_2_1_1<ColorMask>(w5, w4, w2);
+#define PIXEL00_4 *(q) = interpolate16_2_7_7<ColorMask>(w5, w4, w2);
+#define PIXEL00_5 *(q) = interpolate16_1_1<ColorMask>(w4, w2);
#define PIXEL00_C *(q) = w5;
-#define PIXEL01_1 *(q+1) = interpolate16_2<bitFormat,3,1>(w5, w2);
-#define PIXEL01_3 *(q+1) = interpolate16_2<bitFormat,7,1>(w5, w2);
-#define PIXEL01_6 *(q+1) = interpolate16_2<bitFormat,3,1>(w2, w5);
+#define PIXEL01_1 *(q+1) = interpolate16_3_1<ColorMask>(w5, w2);
+#define PIXEL01_3 *(q+1) = interpolate16_7_1<ColorMask>(w5, w2);
+#define PIXEL01_6 *(q+1) = interpolate16_3_1<ColorMask>(w2, w5);
#define PIXEL01_C *(q+1) = w5;
-#define PIXEL02_1M *(q+2) = interpolate16_2<bitFormat,3,1>(w5, w3);
-#define PIXEL02_1U *(q+2) = interpolate16_2<bitFormat,3,1>(w5, w2);
-#define PIXEL02_1R *(q+2) = interpolate16_2<bitFormat,3,1>(w5, w6);
-#define PIXEL02_2 *(q+2) = interpolate16_3<bitFormat,2,1,1>(w5, w2, w6);
-#define PIXEL02_4 *(q+2) = interpolate16_3<bitFormat,2,7,7>(w5, w2, w6);
-#define PIXEL02_5 *(q+2) = interpolate16_2<bitFormat,1,1>(w2, w6);
+#define PIXEL02_1M *(q+2) = interpolate16_3_1<ColorMask>(w5, w3);
+#define PIXEL02_1U *(q+2) = interpolate16_3_1<ColorMask>(w5, w2);
+#define PIXEL02_1R *(q+2) = interpolate16_3_1<ColorMask>(w5, w6);
+#define PIXEL02_2 *(q+2) = interpolate16_2_1_1<ColorMask>(w5, w2, w6);
+#define PIXEL02_4 *(q+2) = interpolate16_2_7_7<ColorMask>(w5, w2, w6);
+#define PIXEL02_5 *(q+2) = interpolate16_1_1<ColorMask>(w2, w6);
#define PIXEL02_C *(q+2) = w5;
-#define PIXEL10_1 *(q+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w4);
-#define PIXEL10_3 *(q+nextlineDst) = interpolate16_2<bitFormat,7,1>(w5, w4);
-#define PIXEL10_6 *(q+nextlineDst) = interpolate16_2<bitFormat,3,1>(w4, w5);
+#define PIXEL10_1 *(q+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w4);
+#define PIXEL10_3 *(q+nextlineDst) = interpolate16_7_1<ColorMask>(w5, w4);
+#define PIXEL10_6 *(q+nextlineDst) = interpolate16_3_1<ColorMask>(w4, w5);
#define PIXEL10_C *(q+nextlineDst) = w5;
#define PIXEL11 *(q+1+nextlineDst) = w5;
-#define PIXEL12_1 *(q+2+nextlineDst) = interpolate16_2<bitFormat,3,1>(w5, w6);
-#define PIXEL12_3 *(q+2+nextlineDst) = interpolate16_2<bitFormat,7,1>(w5, w6);
-#define PIXEL12_6 *(q+2+nextlineDst) = interpolate16_2<bitFormat,3,1>(w6, w5);
+#define PIXEL12_1 *(q+2+nextlineDst) = interpolate16_3_1<ColorMask>(w5, w6);
+#define PIXEL12_3 *(q+2+nextlineDst) = interpolate16_7_1<ColorMask>(w5, w6);
+#define PIXEL12_6 *(q+2+nextlineDst) = interpolate16_3_1<ColorMask>(w6, w5);
#define PIXEL12_C *(q+2+nextlineDst) = w5;
-#define PIXEL20_1M *(q+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w7);
-#define PIXEL20_1D *(q+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w8);
-#define PIXEL20_1L *(q+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w4);
-#define PIXEL20_2 *(q+nextlineDst2) = interpolate16_3<bitFormat,2,1,1>(w5, w8, w4);
-#define PIXEL20_4 *(q+nextlineDst2) = interpolate16_3<bitFormat,2,7,7>(w5, w8, w4);
-#define PIXEL20_5 *(q+nextlineDst2) = interpolate16_2<bitFormat,1,1>(w8, w4);
+#define PIXEL20_1M *(q+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w7);
+#define PIXEL20_1D *(q+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w8);
+#define PIXEL20_1L *(q+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w4);
+#define PIXEL20_2 *(q+nextlineDst2) = interpolate16_2_1_1<ColorMask>(w5, w8, w4);
+#define PIXEL20_4 *(q+nextlineDst2) = interpolate16_2_7_7<ColorMask>(w5, w8, w4);
+#define PIXEL20_5 *(q+nextlineDst2) = interpolate16_1_1<ColorMask>(w8, w4);
#define PIXEL20_C *(q+nextlineDst2) = w5;
-#define PIXEL21_1 *(q+1+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w8);
-#define PIXEL21_3 *(q+1+nextlineDst2) = interpolate16_2<bitFormat,7,1>(w5, w8);
-#define PIXEL21_6 *(q+1+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w8, w5);
+#define PIXEL21_1 *(q+1+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w8);
+#define PIXEL21_3 *(q+1+nextlineDst2) = interpolate16_7_1<ColorMask>(w5, w8);
+#define PIXEL21_6 *(q+1+nextlineDst2) = interpolate16_3_1<ColorMask>(w8, w5);
#define PIXEL21_C *(q+1+nextlineDst2) = w5;
-#define PIXEL22_1M *(q+2+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w9);
-#define PIXEL22_1D *(q+2+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w8);
-#define PIXEL22_1R *(q+2+nextlineDst2) = interpolate16_2<bitFormat,3,1>(w5, w6);
-#define PIXEL22_2 *(q+2+nextlineDst2) = interpolate16_3<bitFormat,2,1,1>(w5, w6, w8);
-#define PIXEL22_4 *(q+2+nextlineDst2) = interpolate16_3<bitFormat,2,7,7>(w5, w6, w8);
-#define PIXEL22_5 *(q+2+nextlineDst2) = interpolate16_2<bitFormat,1,1>(w6, w8);
+#define PIXEL22_1M *(q+2+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w9);
+#define PIXEL22_1D *(q+2+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w8);
+#define PIXEL22_1R *(q+2+nextlineDst2) = interpolate16_3_1<ColorMask>(w5, w6);
+#define PIXEL22_2 *(q+2+nextlineDst2) = interpolate16_2_1_1<ColorMask>(w5, w6, w8);
+#define PIXEL22_4 *(q+2+nextlineDst2) = interpolate16_2_7_7<ColorMask>(w5, w6, w8);
+#define PIXEL22_5 *(q+2+nextlineDst2) = interpolate16_1_1<ColorMask>(w6, w8);
#define PIXEL22_C *(q+2+nextlineDst2) = w5;
#define YUV(x) RGBtoYUV[w ## x]
-#define bitFormat 565
+#define ColorMask Graphics::ColorMasks<565>
void HQ3x_565(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
#include "graphics/scaler/hq3x.h"
}
-#undef bitFormat
+#undef ColorMask
-#define bitFormat 555
+#define ColorMask Graphics::ColorMasks<555>
void HQ3x_555(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
#include "graphics/scaler/hq3x.h"
}
-#undef bitFormat
+#undef ColorMask
void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
@@ -121,5 +121,3 @@ void HQ3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
else
HQ3x_555(srcPtr, srcPitch, dstPtr, dstPitch, width, height);
}
-
-#endif
diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h
index c9fd550d35..7546d39021 100644
--- a/graphics/scaler/intern.h
+++ b/graphics/scaler/intern.h
@@ -31,7 +31,7 @@
#define kHighBitsMask Graphics::ColorMasks<bitFormat>::kHighBitsMask
-#define kLowBitsMask Graphics::ColorMasks<bitFormat>::kLowBitsMask
+#define kLowBitsMask Graphics::ColorMasks<bitFormat>::kLowBitsMask
#define qhighBits Graphics::ColorMasks<bitFormat>::qhighBits
#define qlowBits Graphics::ColorMasks<bitFormat>::qlowBits
#define redblueMask Graphics::ColorMasks<bitFormat>::kRedBlueMask
@@ -78,7 +78,7 @@ static inline uint32 interpolate32_1_1_1_1(uint32 p1, uint32 p2, uint32 p3, uint
/**
* Interpolate two 16 bit pixels with the weights specified in the template
- * parameters. Used by the hq scaler family.
+ * parameters.
* @note w1 and w2 must sum up to 2, 4, 8 or 16.
*/
template<int bitFormat, int w1, int w2>
@@ -89,7 +89,7 @@ static inline uint16 interpolate16_2(uint16 p1, uint16 p2) {
/**
* Interpolate three 16 bit pixels with the weights specified in the template
- * parameters. Used by the hq scaler family.
+ * parameters.
* @note w1, w2 and w3 must sum up to 2, 4, 8 or 16.
*/
template<int bitFormat, int w1, int w2, int w3>
@@ -100,6 +100,110 @@ static inline uint16 interpolate16_3(uint16 p1, uint16 p2, uint16 p3) {
/**
+ * Interpolate two 16 bit pixels with weights 1 and 1, i.e., (p1+p2)/2.
+ * See <http://www.slack.net/~ant/info/rgb_mixing.html> for details on how this works.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_1_1(unsigned p1, unsigned p2) {
+ const unsigned lowbits = (p1 ^ p2) & ColorMask::kLowBits;
+ return ((p1 + p2) - lowbits) >> 1;
+}
+
+/**
+ * Interpolate two 16 bit pixels with weights 3 and 1, i.e., (3*p1+p2)/4.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_3_1(unsigned p1, unsigned p2) {
+ const unsigned lowbits = (((p1 & ColorMask::kLowBits) << 1) + (p1 & ColorMask::kLow2Bits)
+ + (p2 & ColorMask::kLow2Bits)) & ColorMask::kLow2Bits;
+ return ((p1*3 + p2) - lowbits) >> 2;
+}
+
+/**
+ * Interpolate two 16 bit pixels with weights 7 and 1, i.e., (7*p1+p2)/8.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_7_1(unsigned p1, unsigned p2) {
+ const unsigned lowbits = (((p1 & ColorMask::kLowBits) << 2) + ((p1 & ColorMask::kLow2Bits) << 1) + (p1 & ColorMask::kLow3Bits)
+ + (p2 & ColorMask::kLow3Bits)) & ColorMask::kLow3Bits;
+ return ((p1*7+p2) - lowbits) >> 3;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 2, 1, and 1, i.e., (2*p1+p2+p3)/4.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_2_1_1(unsigned p1, unsigned p2, unsigned p3) {
+ p1<<=1;
+ const unsigned lowbits = ((p1 & (ColorMask::kLowBits << 1))
+ + (p2 & ColorMask::kLow2Bits)
+ + (p3 & ColorMask::kLow2Bits)) & ColorMask::kLow2Bits;
+ return ((p1+p2+p3) - lowbits) >> 2;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 5, 2, and 1, i.e., (5*p1+2*p2+p3)/8.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_5_2_1(unsigned p1, unsigned p2, unsigned p3) {
+ p2<<=1;
+ const unsigned lowbits = (((p1 & ColorMask::kLowBits) << 2) + (p1 & ColorMask::kLow3Bits)
+ + (p2 & (ColorMask::kLow2Bits << 1))
+ + (p3 & ColorMask::kLow3Bits)) & ColorMask::kLow3Bits;
+ return ((p1*5 + p2 + p3) - lowbits) >> 3;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 6, 1, and 1, i.e., (6*p1+p2+p3)/8.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_6_1_1(unsigned p1, unsigned p2, unsigned p3) {
+ const unsigned lowbits = (((((p1 & ColorMask::kLowBits) << 1) + (p1 & ColorMask::kLow2Bits)) << 1)
+ + (p2 & ColorMask::kLow3Bits)
+ + (p3 & ColorMask::kLow3Bits)) & ColorMask::kLow3Bits;
+ return ((p1*6 + p2 + p3) - lowbits) >> 3;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 2, 3, and 3, i.e., (2*p1+3*(p2+p3))/8.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_2_3_3(unsigned p1, unsigned p2, unsigned p3) {
+ p1 <<= 1;
+ const unsigned rb = (p1 & (ColorMask::kRedBlueMask<<1))
+ + ((p2 & ColorMask::kRedBlueMask) + (p3 & ColorMask::kRedBlueMask))*3;
+ const unsigned g = (p1 & (ColorMask::kGreenMask<<1))
+ + ((p2 & ColorMask::kGreenMask) + (p3 & ColorMask::kGreenMask))*3;
+ return ((rb & (ColorMask::kRedBlueMask<<3)) | (g & (ColorMask::kGreenMask<<3))) >> 3;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 2, 7, and 7, i.e., (2*p1+7*(p2+p3))/16.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_2_7_7(unsigned p1, unsigned p2, unsigned p3) {
+ p1 <<= 1;
+ const unsigned rb = (p1 & (ColorMask::kRedBlueMask<<1))
+ + ((p2 & ColorMask::kRedBlueMask) + (p3 & ColorMask::kRedBlueMask))*7;
+ const unsigned g = (p1 & (ColorMask::kGreenMask<<1))
+ + ((p2 & ColorMask::kGreenMask) + (p3 & ColorMask::kGreenMask))*7;
+ return ((rb & (ColorMask::kRedBlueMask<<4)) | (g & (ColorMask::kGreenMask<<4))) >> 4;
+}
+
+/**
+ * Interpolate three 16 bit pixels with weights 14, 1, and 1, i.e., (14*p1+p2+p3)/16.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_14_1_1(unsigned p1, unsigned p2, unsigned p3) {
+ const unsigned rb = (p1&ColorMask::kRedBlueMask)*14
+ + (p2&ColorMask::kRedBlueMask)
+ + (p3&ColorMask::kRedBlueMask);
+ const unsigned g = (p1&ColorMask::kGreenMask)*14
+ + (p2&ColorMask::kGreenMask) + (p3&ColorMask::kGreenMask);
+ return ((rb&(ColorMask::kRedBlueMask<<4)) | (g&(ColorMask::kGreenMask<<4))) >> 4;
+}
+
+/**
* Compare two YUV values (encoded 8-8-8) and check if they differ by more than
* a certain hard coded threshold. Used by the hq scaler family.
*/