aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/scaler.cpp14
-rw-r--r--graphics/scaler/2xsai.cpp28
-rw-r--r--graphics/scaler/intern.h26
-rw-r--r--graphics/scaler/thumbnail_intern.cpp4
4 files changed, 35 insertions, 37 deletions
diff --git a/graphics/scaler.cpp b/graphics/scaler.cpp
index afee8be92d..adfcda128d 100644
--- a/graphics/scaler.cpp
+++ b/graphics/scaler.cpp
@@ -222,8 +222,8 @@ void Normal3x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPit
}
}
-#define interpolate32_1_1 interpolate32_1_1<bitFormat>
-#define interpolate32_1_1_1_1 interpolate32_1_1_1_1<bitFormat>
+#define interpolate_1_1 interpolate16_1_1<Graphics::ColorMasks<bitFormat> >
+#define interpolate_1_1_1_1 interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >
/**
* Trivial nearest-neighbour 1.5x scaler.
@@ -246,13 +246,13 @@ void Normal1o5xTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uin
uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch)) + i + 1);
*(uint16 *)(r + 0) = color0;
- *(uint16 *)(r + 2) = interpolate32_1_1(color0, color1);
+ *(uint16 *)(r + 2) = interpolate_1_1(color0, color1);
*(uint16 *)(r + 4) = color1;
- *(uint16 *)(r + 0 + dstPitch) = interpolate32_1_1(color0, color2);
- *(uint16 *)(r + 2 + dstPitch) = interpolate32_1_1_1_1(color0, color1, color2, color3);
- *(uint16 *)(r + 4 + dstPitch) = interpolate32_1_1(color1, color3);
+ *(uint16 *)(r + 0 + dstPitch) = interpolate_1_1(color0, color2);
+ *(uint16 *)(r + 2 + dstPitch) = interpolate_1_1_1_1(color0, color1, color2, color3);
+ *(uint16 *)(r + 4 + dstPitch) = interpolate_1_1(color1, color3);
*(uint16 *)(r + 0 + dstPitch2) = color2;
- *(uint16 *)(r + 2 + dstPitch2) = interpolate32_1_1(color2, color3);
+ *(uint16 *)(r + 2 + dstPitch2) = interpolate_1_1(color2, color3);
*(uint16 *)(r + 4 + dstPitch2) = color3;
}
srcPtr += srcPitch2;
diff --git a/graphics/scaler/2xsai.cpp b/graphics/scaler/2xsai.cpp
index adea68ba78..64c989c629 100644
--- a/graphics/scaler/2xsai.cpp
+++ b/graphics/scaler/2xsai.cpp
@@ -44,7 +44,7 @@ static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D) {
#define interpolate_1_1 interpolate16_1_1<Graphics::ColorMasks<bitFormat> >
#define interpolate_3_1 interpolate16_3_1<Graphics::ColorMasks<bitFormat> >
#define interpolate_6_1_1 interpolate16_6_1_1<Graphics::ColorMasks<bitFormat> >
-#define interpolate_1_1_1_1 interpolate32_1_1_1_1<bitFormat>
+#define interpolate_1_1_1_1 interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >
template<int bitFormat>
void Super2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
@@ -57,12 +57,12 @@ void Super2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uin
dP = (uint16 *)dstPtr;
for (int i = 0; i < width; ++i) {
- uint32 color4, color5, color6;
- uint32 color1, color2, color3;
- uint32 colorA0, colorA1, colorA2, colorA3;
- uint32 colorB0, colorB1, colorB2, colorB3;
- uint32 colorS1, colorS2;
- uint32 product1a, product1b, product2a, product2b;
+ unsigned color4, color5, color6;
+ unsigned color1, color2, color3;
+ unsigned colorA0, colorA1, colorA2, colorA3;
+ unsigned colorB0, colorB1, colorB2, colorB3;
+ unsigned colorS1, colorS2;
+ unsigned product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2
// 4 5 6 S2
@@ -165,10 +165,10 @@ void SuperEagleTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uin
bP = (const uint16 *)srcPtr;
dP = (uint16 *)dstPtr;
for (int i = 0; i < width; ++i) {
- uint32 color4, color5, color6;
- uint32 color1, color2, color3;
- uint32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
- uint32 product1a, product1b, product2a, product2b;
+ unsigned color4, color5, color6;
+ unsigned color1, color2, color3;
+ unsigned colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
+ unsigned product1a, product1b, product2a, product2b;
colorB1 = *(bP - nextlineSrc);
colorB2 = *(bP - nextlineSrc + 1);
@@ -272,10 +272,10 @@ void _2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32
for (int i = 0; i < width; ++i) {
- register uint32 colorA, colorB;
- uint32 colorC, colorD,
+ register unsigned colorA, colorB;
+ unsigned colorC, colorD,
colorE, colorF, colorG, colorH, colorI, colorJ, colorK, colorL, colorM, colorN, colorO, colorP;
- uint32 product, product1, product2;
+ unsigned product, product1, product2;
//---------------------------------------
// Map of the pixels: I|E F|J
diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h
index aec3ad13b5..8da7b42e39 100644
--- a/graphics/scaler/intern.h
+++ b/graphics/scaler/intern.h
@@ -63,20 +63,6 @@ static inline uint32 interpolate32_3_1(uint32 p1, uint32 p2) {
}
/**
- * Interpolate four 16 bit pixel pairs at once with equal weights 1.
- * In particular, p1, p2, p3 and p3 can each contain two pixels in the upper
- * and lower halves.
- */
-template<int bitFormat>
-static inline uint32 interpolate32_1_1_1_1(uint32 p1, uint32 p2, uint32 p3, uint32 p4) {
- register uint32 x = ((p1 & qhighBits) >> 2) + ((p2 & qhighBits) >> 2) + ((p3 & qhighBits) >> 2) + ((p4 & qhighBits) >> 2);
- register uint32 y = ((p1 & qlowBits) + (p2 & qlowBits) + (p3 & qlowBits) + (p4 & qlowBits)) >> 2;
-
- y &= qlowBits;
- return x + y;
-}
-
-/**
* 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.
*/
@@ -181,6 +167,18 @@ static inline unsigned interpolate16_14_1_1(unsigned p1, unsigned p2, unsigned p
}
/**
+ * Interpolate four 16 bit pixels with weights 1, 1, 1, and 1, i.e., (p1+p2+p3+p4)/4.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_1_1_1_1(unsigned p1, unsigned p2, unsigned p3, unsigned p4) {
+ const unsigned lowbits = ((p1 & ColorMask::kLow2Bits)
+ + (p2 & ColorMask::kLow2Bits)
+ + (p3 & ColorMask::kLow2Bits)
+ + (p4 & ColorMask::kLow2Bits)) & ColorMask::kLow2Bits;
+ return ((p1+p2+p3+p4) - lowbits) >> 2;
+}
+
+/**
* 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.
*/
diff --git a/graphics/scaler/thumbnail_intern.cpp b/graphics/scaler/thumbnail_intern.cpp
index a7389e3d8d..fabe07b031 100644
--- a/graphics/scaler/thumbnail_intern.cpp
+++ b/graphics/scaler/thumbnail_intern.cpp
@@ -38,7 +38,7 @@ uint16 quadBlockInterpolate(const uint8* src, uint32 srcPitch) {
uint16 colorx1y2 = *(((const uint16*)(src + srcPitch)));
uint16 colorx2y2 = *(((const uint16*)(src + srcPitch)) + 1);
- return interpolate32_1_1_1_1<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
+ return interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
}
template<int bitFormat>
@@ -65,7 +65,7 @@ void createThumbnail_4(const uint8* src, uint32 srcPitch, uint8* dstPtr, uint32
uint16 downleft = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * x, srcPitch);
uint16 downright = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * (x + 2), srcPitch);
- *((uint16*)dstPtr) = interpolate32_1_1_1_1<bitFormat>(upleft, upright, downleft, downright);
+ *((uint16*)dstPtr) = interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >(upleft, upright, downleft, downright);
}
dstPtr += (dstPitch - 2 * width / 4);
src += 4 * srcPitch;