aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler/intern.h
diff options
context:
space:
mode:
authorMax Horn2009-01-27 01:46:29 +0000
committerMax Horn2009-01-27 01:46:29 +0000
commite338205066c7d794973e8f31e943ac7d1339bdec (patch)
tree07ab02e9e63fec6232bbcb46094d659729442aef /graphics/scaler/intern.h
parent379fe274dfe713c508cff6908444ae87c722d124 (diff)
downloadscummvm-rg350-e338205066c7d794973e8f31e943ac7d1339bdec.tar.gz
scummvm-rg350-e338205066c7d794973e8f31e943ac7d1339bdec.tar.bz2
scummvm-rg350-e338205066c7d794973e8f31e943ac7d1339bdec.zip
Added new interpolate16_1_1_1_1 func, got rid of interpolate32_1_1_1_1
svn-id: r36090
Diffstat (limited to 'graphics/scaler/intern.h')
-rw-r--r--graphics/scaler/intern.h26
1 files changed, 12 insertions, 14 deletions
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.
*/