[Scummvm-cvs-logs] SF.net SVN: scummvm:[36090] scummvm/trunk/graphics

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Jan 27 02:46:29 CET 2009


Revision: 36090
          http://scummvm.svn.sourceforge.net/scummvm/?rev=36090&view=rev
Author:   fingolfin
Date:     2009-01-27 01:46:29 +0000 (Tue, 27 Jan 2009)

Log Message:
-----------
Added new interpolate16_1_1_1_1 func, got rid of interpolate32_1_1_1_1

Modified Paths:
--------------
    scummvm/trunk/graphics/scaler/2xsai.cpp
    scummvm/trunk/graphics/scaler/intern.h
    scummvm/trunk/graphics/scaler/thumbnail_intern.cpp
    scummvm/trunk/graphics/scaler.cpp

Modified: scummvm/trunk/graphics/scaler/2xsai.cpp
===================================================================
--- scummvm/trunk/graphics/scaler/2xsai.cpp	2009-01-27 01:35:21 UTC (rev 36089)
+++ scummvm/trunk/graphics/scaler/2xsai.cpp	2009-01-27 01:46:29 UTC (rev 36090)
@@ -44,7 +44,7 @@
 #define interpolate_1_1		interpolate16_1_1<Graphics::ColorMasks<bitFormat> >
 #define interpolate_3_1		interpolate16_3_1<Graphics::ColorMasks<bitFormat> >
 #define interpolate_6_1_1	interpolate16_6_1_1<Graphics::ColorMasks<bitFormat> >
-#define interpolate_1_1_1_1	interpolate32_1_1_1_1<bitFormat>
+#define interpolate_1_1_1_1	interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >
 
 template<int bitFormat>
 void Super2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
@@ -57,12 +57,12 @@
 		dP = (uint16 *)dstPtr;
 
 		for (int i = 0; i < width; ++i) {
-			uint32 color4, color5, color6;
-			uint32 color1, color2, color3;
-			uint32 colorA0, colorA1, colorA2, colorA3;
-			uint32 colorB0, colorB1, colorB2, colorB3;
-			uint32 colorS1, colorS2;
-			uint32 product1a, product1b, product2a, product2b;
+			unsigned color4, color5, color6;
+			unsigned color1, color2, color3;
+			unsigned colorA0, colorA1, colorA2, colorA3;
+			unsigned colorB0, colorB1, colorB2, colorB3;
+			unsigned colorS1, colorS2;
+			unsigned product1a, product1b, product2a, product2b;
 
 //---------------------------------------    B1 B2
 //                                         4  5  6 S2
@@ -165,10 +165,10 @@
 		bP = (const uint16 *)srcPtr;
 		dP = (uint16 *)dstPtr;
 		for (int i = 0; i < width; ++i) {
-			uint32 color4, color5, color6;
-			uint32 color1, color2, color3;
-			uint32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
-			uint32 product1a, product1b, product2a, product2b;
+			unsigned color4, color5, color6;
+			unsigned color1, color2, color3;
+			unsigned colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
+			unsigned product1a, product1b, product2a, product2b;
 
 			colorB1 = *(bP - nextlineSrc);
 			colorB2 = *(bP - nextlineSrc + 1);
@@ -272,10 +272,10 @@
 
 		for (int i = 0; i < width; ++i) {
 
-			register uint32 colorA, colorB;
-			uint32 colorC, colorD,
+			register unsigned colorA, colorB;
+			unsigned colorC, colorD,
 				colorE, colorF, colorG, colorH, colorI, colorJ, colorK, colorL, colorM, colorN, colorO, colorP;
-			uint32 product, product1, product2;
+			unsigned product, product1, product2;
 
 //---------------------------------------
 // Map of the pixels:                    I|E F|J

Modified: scummvm/trunk/graphics/scaler/intern.h
===================================================================
--- scummvm/trunk/graphics/scaler/intern.h	2009-01-27 01:35:21 UTC (rev 36089)
+++ scummvm/trunk/graphics/scaler/intern.h	2009-01-27 01:46:29 UTC (rev 36090)
@@ -63,20 +63,6 @@
 }
 
 /**
- * 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 @@
 }
 
 /**
+ * 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.
  */

Modified: scummvm/trunk/graphics/scaler/thumbnail_intern.cpp
===================================================================
--- scummvm/trunk/graphics/scaler/thumbnail_intern.cpp	2009-01-27 01:35:21 UTC (rev 36089)
+++ scummvm/trunk/graphics/scaler/thumbnail_intern.cpp	2009-01-27 01:46:29 UTC (rev 36090)
@@ -38,7 +38,7 @@
 	uint16 colorx1y2 = *(((const uint16*)(src + srcPitch)));
 	uint16 colorx2y2 = *(((const uint16*)(src + srcPitch)) + 1);
 
-	return interpolate32_1_1_1_1<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
+	return interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
 }
 
 template<int bitFormat>
@@ -65,7 +65,7 @@
 			uint16 downleft = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * x, srcPitch);
 			uint16 downright = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * (x + 2), srcPitch);
 
-			*((uint16*)dstPtr) = interpolate32_1_1_1_1<bitFormat>(upleft, upright, downleft, downright);
+			*((uint16*)dstPtr) = interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >(upleft, upright, downleft, downright);
 		}
 		dstPtr += (dstPitch - 2 * width / 4);
 		src += 4 * srcPitch;

Modified: scummvm/trunk/graphics/scaler.cpp
===================================================================
--- scummvm/trunk/graphics/scaler.cpp	2009-01-27 01:35:21 UTC (rev 36089)
+++ scummvm/trunk/graphics/scaler.cpp	2009-01-27 01:46:29 UTC (rev 36090)
@@ -222,8 +222,8 @@
 	}
 }
 
-#define interpolate32_1_1		interpolate32_1_1<bitFormat>
-#define interpolate32_1_1_1_1	interpolate32_1_1_1_1<bitFormat>
+#define interpolate_1_1		interpolate16_1_1<Graphics::ColorMasks<bitFormat> >
+#define interpolate_1_1_1_1	interpolate16_1_1_1_1<Graphics::ColorMasks<bitFormat> >
 
 /**
  * Trivial nearest-neighbour 1.5x scaler.
@@ -246,13 +246,13 @@
 			uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch)) + i + 1);
 
 			*(uint16 *)(r + 0) = color0;
-			*(uint16 *)(r + 2) = interpolate32_1_1(color0, color1);
+			*(uint16 *)(r + 2) = interpolate_1_1(color0, color1);
 			*(uint16 *)(r + 4) = color1;
-			*(uint16 *)(r + 0 + dstPitch) = interpolate32_1_1(color0, color2);
-			*(uint16 *)(r + 2 + dstPitch) = interpolate32_1_1_1_1(color0, color1, color2, color3);
-			*(uint16 *)(r + 4 + dstPitch) = interpolate32_1_1(color1, color3);
+			*(uint16 *)(r + 0 + dstPitch) = interpolate_1_1(color0, color2);
+			*(uint16 *)(r + 2 + dstPitch) = interpolate_1_1_1_1(color0, color1, color2, color3);
+			*(uint16 *)(r + 4 + dstPitch) = interpolate_1_1(color1, color3);
 			*(uint16 *)(r + 0 + dstPitch2) = color2;
-			*(uint16 *)(r + 2 + dstPitch2) = interpolate32_1_1(color2, color3);
+			*(uint16 *)(r + 2 + dstPitch2) = interpolate_1_1(color2, color3);
 			*(uint16 *)(r + 4 + dstPitch2) = color3;
 		}
 		srcPtr += srcPitch2;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list