aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorperes2011-05-08 08:25:24 -0700
committerperes2011-05-08 08:25:24 -0700
commit4ffab87da4c7a6cfb9423e0d08c82f4bba7fceb3 (patch)
treecb49a9ef96570d7d570373fddc5f70925bd080a2
parent3e8a7afeae15f0a6d804d8092ccec2bea7a1a2f3 (diff)
parent6ddf6693ce106cc3ddc830eaffebc4e3918d02ab (diff)
downloadscummvm-rg350-4ffab87da4c7a6cfb9423e0d08c82f4bba7fceb3.tar.gz
scummvm-rg350-4ffab87da4c7a6cfb9423e0d08c82f4bba7fceb3.tar.bz2
scummvm-rg350-4ffab87da4c7a6cfb9423e0d08c82f4bba7fceb3.zip
Merge pull request #34 from peres/interpolate16_5_3
Add a new function to interpolate a pair of 16 bits values with weights 5 and 3, respectively.
-rw-r--r--graphics/scaler/aspect.cpp5
-rw-r--r--graphics/scaler/intern.h10
2 files changed, 11 insertions, 4 deletions
diff --git a/graphics/scaler/aspect.cpp b/graphics/scaler/aspect.cpp
index 85768fbced..85b79ab6cd 100644
--- a/graphics/scaler/aspect.cpp
+++ b/graphics/scaler/aspect.cpp
@@ -79,10 +79,7 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
}
} else {
while (width--) {
- // TODO: We really would like to use interpolate16_5_3, but that
- // does not exist (yet), so we use this trick instead.
- uint16 tmp = *srcA++;
- *dst++ = interpolate16_5_2_1<ColorMask>(*srcB++, tmp, tmp);
+ *dst++ = interpolate16_5_3<ColorMask>(*srcB++, *srcA++);
}
}
}
diff --git a/graphics/scaler/intern.h b/graphics/scaler/intern.h
index 4addd6d3bd..7317745e62 100644
--- a/graphics/scaler/intern.h
+++ b/graphics/scaler/intern.h
@@ -77,6 +77,16 @@ static inline unsigned interpolate16_3_1(unsigned p1, unsigned p2) {
}
/**
+ * Interpolate two 16 bit pixels with weights 5 and 3 and 1, i.e., (5*p1+3*p2)/8.
+ */
+template<typename ColorMask>
+static inline unsigned interpolate16_5_3(unsigned p1, unsigned p2) {
+ const unsigned lowbits = (((p1 & ColorMask::kLowBits) << 2) + (p1 & ColorMask::kLow3Bits)
+ + ((p2 & ColorMask::kLow2Bits) << 1) + (p2 & ColorMask::kLow3Bits)) & ColorMask::kLow3Bits;
+ return ((p1*5 + p2*3) - lowbits) >> 3;
+}
+
+/**
* Interpolate two 16 bit pixels with weights 7 and 1, i.e., (7*p1+p2)/8.
*/
template<typename ColorMask>