aboutsummaryrefslogtreecommitdiff
path: root/graphics/scaler
diff options
context:
space:
mode:
authorMax Horn2010-03-08 10:32:45 +0000
committerMax Horn2010-03-08 10:32:45 +0000
commite90f074177e83630efdafe16fe59d4d1e42ab05a (patch)
treef5c2f4f82c7ca430ebd9327c5a6175cbfe58dc71 /graphics/scaler
parent706769a3dc616a7ab133bca84dae6bebfc182b7b (diff)
downloadscummvm-rg350-e90f074177e83630efdafe16fe59d4d1e42ab05a.tar.gz
scummvm-rg350-e90f074177e83630efdafe16fe59d4d1e42ab05a.tar.bz2
scummvm-rg350-e90f074177e83630efdafe16fe59d4d1e42ab05a.zip
Add new aspect ratio scaler variant, based on the Normal2xAspect ARM code
svn-id: r48195
Diffstat (limited to 'graphics/scaler')
-rw-r--r--graphics/scaler/aspect.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/graphics/scaler/aspect.cpp b/graphics/scaler/aspect.cpp
index 37aa147cca..45efb094f0 100644
--- a/graphics/scaler/aspect.cpp
+++ b/graphics/scaler/aspect.cpp
@@ -27,11 +27,12 @@
#include "graphics/scaler/aspect.h"
-#define kVeryFastAndUglyAspectMode 0 // No interpolation at all, but super-fast
-#define kFastAndNiceAspectMode 1 // Quite good quality with good speed
-#define kSlowAndPerfectAspectMode 2 // Accurate but slow code
+#define kSuperFastAndUglyAspectMode 0 // No interpolation at all, but super-fast
+#define kVeryFastAndGoodAspectMode 1 // Good quality with very good speed
+#define kFastAndVeryGoodAspectMode 2 // Very good quality with good speed
+#define kSlowAndPerfectAspectMode 3 // Accurate but slow code
-#define ASPECT_MODE kFastAndNiceAspectMode
+#define ASPECT_MODE kVeryFastAndGoodAspectMode
#if ASPECT_MODE == kSlowAndPerfectAspectMode
@@ -55,7 +56,7 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
}
#endif
-#if ASPECT_MODE == kFastAndNiceAspectMode
+#if ASPECT_MODE == kVeryFastAndGoodAspectMode
template<typename ColorMask, int scale>
static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
@@ -72,6 +73,26 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
//assert(((int)srcB & 3) == 0);
//assert((width & 1) == 0);
+ if (scale == 1) {
+ while (width--) {
+ *dst++ = interpolate16_7_1<ColorMask>(*srcB++, *srcA++);
+ }
+ } 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);
+ }
+ }
+}
+#endif
+
+#if ASPECT_MODE == kFastAndVeryGoodAspectMode
+
+template<typename ColorMask, int scale>
+static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
+
width /= 2;
const uint32 *sA = (const uint32 *)srcA;
const uint32 *sB = (const uint32 *)srcB;
@@ -89,7 +110,7 @@ static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint1
#endif
void makeRectStretchable(int &x, int &y, int &w, int &h) {
-#if ASPECT_MODE != kVeryFastAndUglyAspectMode
+#if ASPECT_MODE != kSuperFastAndUglyAspectMode
int m = real2Aspect(y) % 6;
// Ensure that the rect will start on a line that won't have its
@@ -99,7 +120,7 @@ void makeRectStretchable(int &x, int &y, int &w, int &h) {
h += m;
}
- #if ASPECT_MODE == kFastAndNiceAspectMode
+ #if ASPECT_MODE == kVeryFastAndGoodAspectMode
// Force x to be even, to ensure aligned memory access (this assumes
// that each line starts at an even memory location, but that should
// be the case on every target anyway).
@@ -143,7 +164,7 @@ int stretch200To240(uint8 *buf, uint32 pitch, int width, int height, int srcX, i
for (y = maxDstY; y >= srcY; y--) {
const uint8 *srcPtr = startSrcPtr + aspect2Real(y) * pitch;
-#if ASPECT_MODE == kVeryFastAndUglyAspectMode
+#if ASPECT_MODE == kSuperFastAndUglyAspectMode
if (srcPtr == dstPtr)
break;
memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);
@@ -189,7 +210,7 @@ void Normal1xAspectTemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr,
for (int y = 0; y < height; ++y) {
-#if ASPECT_MODE == kVeryFastAndUglyAspectMode
+#if ASPECT_MODE == kSuperFastAndUglyAspectMode
if ((y % 6) == 5)
srcPtr -= srcPitch;
memcpy(dstPtr, srcPtr, sizeof(OverlayColor) * width);