aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2003-10-01 16:47:49 +0000
committerMax Horn2003-10-01 16:47:49 +0000
commit628f65b639ee9357935d8f141d43d46825506082 (patch)
tree5456ce7c06498953bc0dad6eb0b0320bfb42c3c0 /common
parentb6f85de558e57bcae7932329523ed8478dd83760 (diff)
downloadscummvm-rg350-628f65b639ee9357935d8f141d43d46825506082.tar.gz
scummvm-rg350-628f65b639ee9357935d8f141d43d46825506082.tar.bz2
scummvm-rg350-628f65b639ee9357935d8f141d43d46825506082.zip
move INTERPOLATE / Q_INTERPOLATE to intern.h; remove some jumps (pipelin trashers I call 'em :-) from diffYUV
svn-id: r10523
Diffstat (limited to 'common')
-rw-r--r--common/scaler/2xsai.cpp15
-rw-r--r--common/scaler/hq2x.cpp16
-rw-r--r--common/scaler/intern.h41
3 files changed, 38 insertions, 34 deletions
diff --git a/common/scaler/2xsai.cpp b/common/scaler/2xsai.cpp
index 7cf02bba47..1c99168e63 100644
--- a/common/scaler/2xsai.cpp
+++ b/common/scaler/2xsai.cpp
@@ -43,21 +43,6 @@ static inline int GetResult(uint32 A, uint32 B, uint32 C, uint32 D) {
return rmap[y][x];
}
-template<int bitFormat>
-static inline uint32 INTERPOLATE(uint32 A, uint32 B) {
-
- return (((A & highBits) >> 1) + ((B & highBits) >> 1) + (A & B & lowBits));
-}
-
-template<int bitFormat>
-static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D) {
- register uint32 x = ((A & qhighBits) >> 2) + ((B & qhighBits) >> 2) + ((C & qhighBits) >> 2) + ((D & qhighBits) >> 2);
- register uint32 y = ((A & qlowBits) + (B & qlowBits) + (C & qlowBits) + (D & qlowBits)) >> 2;
-
- y &= qlowBits;
- return x + y;
-}
-
#define INTERPOLATE INTERPOLATE<bitFormat>
#define Q_INTERPOLATE Q_INTERPOLATE<bitFormat>
diff --git a/common/scaler/hq2x.cpp b/common/scaler/hq2x.cpp
index 92a80f5e6c..cd461f7be9 100644
--- a/common/scaler/hq2x.cpp
+++ b/common/scaler/hq2x.cpp
@@ -83,7 +83,6 @@
*/
template<int bitFormat>
void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
-// int w[10];
register int w1, w2, w3, w4, w5, w6, w7, w8, w9;
const uint32 nextlineSrc = srcPitch / sizeof(uint16);
@@ -130,23 +129,8 @@ void HQ2x(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
vector signed char vecYUV5555;
vector signed char vecYUV1234;
vector signed char vecYUV6789;
-/*
- // The pixel vectors.
- // TODO: Keep the pixels up-to-date in this, just like for the YUV data.
- // But instead of just keeping the 16 bit pixel values in them, keep
- // them convert to 32 bit RGB in there! This way, we avoid converting
- // the same pixels to 32 bit repeatedly (which may be expensive, esp.
- // when reading 16 bit pixels in 565 format).
- // The Altivec enhanced interpolation functions (to be written :-)
- // then can directly make use of these vectors.
- vector signed char vecRGB5555;
- vector signed char vecRGB1234;
- vector signed char vecRGB6789;
-*/
#endif
-
-
while (height--) {
w1 = *(p - 1 - nextlineSrc);
w4 = *(p - 1);
diff --git a/common/scaler/intern.h b/common/scaler/intern.h
index 02773bca93..69af4a2230 100644
--- a/common/scaler/intern.h
+++ b/common/scaler/intern.h
@@ -29,6 +29,11 @@
#include "common/scaler.h"
#include "common/util.h"
+// HACK HACK HACK
+// Enable *experimental* AltiVec support.
+// This will produce code crashing on any machine *without* Altivec
+//
+#define USE_ALTIVEC 0
template<int bitFormat>
struct ColorMasks {
@@ -64,6 +69,32 @@ extern int gBitFormat;
/**
+ * Interpolate two 16 bit pixel pairs at once with equal weights 1.
+ * In particular, A and B can contain two pixels/each in the upper
+ * and lower halves.
+ */
+template<int bitFormat>
+static inline uint32 INTERPOLATE(uint32 A, uint32 B) {
+
+ return (((A & highBits) >> 1) + ((B & highBits) >> 1) + (A & B & lowBits));
+}
+
+/**
+ * Interpolate four 16 bit pixel pairs at once with equal weights 1.
+ * In particular, A and B can contain two pixels/each in the upper
+ * and lower halves.
+ */
+template<int bitFormat>
+static inline uint32 Q_INTERPOLATE(uint32 A, uint32 B, uint32 C, uint32 D) {
+ register uint32 x = ((A & qhighBits) >> 2) + ((B & qhighBits) >> 2) + ((C & qhighBits) >> 2) + ((D & qhighBits) >> 2);
+ register uint32 y = ((A & qlowBits) + (B & qlowBits) + (C & qlowBits) + (D & qlowBits)) >> 2;
+
+ y &= qlowBits;
+ return x + y;
+}
+
+
+/**
* Interpolate two 16 bit pixels with the weights specified in the template
* parameters. Used by the hq scaler family.
*/
@@ -97,17 +128,21 @@ static inline bool diffYUV(int yuv1, int yuv2) {
static const int trV = 0x00000006;
int diff;
+ int mask;
diff = ((yuv1 & Ymask) - (yuv2 & Ymask));
- if (diff < 0) diff = - diff;
+ mask = diff >> 31; // -1 if value < 0, 0 otherwise
+ diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value
if (diff > trY) return true;
diff = ((yuv1 & Umask) - (yuv2 & Umask));
- if (diff < 0) diff = - diff;
+ mask = diff >> 31; // -1 if value < 0, 0 otherwise
+ diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value
if (diff > trU) return true;
diff = ((yuv1 & Vmask) - (yuv2 & Vmask));
- if (diff < 0) diff = - diff;
+ mask = diff >> 31; // -1 if value < 0, 0 otherwise
+ diff = (diff ^ mask) - mask; //-1: ~value + 1; 0: value
if (diff > trV) return true;
return false;