[Scummvm-cvs-logs] CVS: scummvm/common/scaler intern.h,1.3,1.4 2xsai.cpp,1.2,1.3 hq2x.cpp,1.5,1.6

Max Horn fingolfin at users.sourceforge.net
Wed Oct 1 09:48:13 CEST 2003


Update of /cvsroot/scummvm/scummvm/common/scaler
In directory sc8-pr-cvs1:/tmp/cvs-serv22042

Modified Files:
	intern.h 2xsai.cpp hq2x.cpp 
Log Message:
move INTERPOLATE / Q_INTERPOLATE to intern.h; remove some jumps (pipelin trashers I call 'em :-) from diffYUV

Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler/intern.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- intern.h	29 Sep 2003 23:34:43 -0000	1.3
+++ intern.h	1 Oct 2003 16:47:49 -0000	1.4
@@ -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 @@
 
 
 /**
+ * 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 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;

Index: 2xsai.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler/2xsai.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- 2xsai.cpp	29 Sep 2003 18:38:51 -0000	1.2
+++ 2xsai.cpp	1 Oct 2003 16:47:49 -0000	1.3
@@ -43,21 +43,6 @@
 	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>
 

Index: hq2x.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/scaler/hq2x.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- hq2x.cpp	1 Oct 2003 16:39:31 -0000	1.5
+++ hq2x.cpp	1 Oct 2003 16:47:49 -0000	1.6
@@ -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,22 +129,7 @@
 	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);





More information about the Scummvm-git-logs mailing list