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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Apr 17 11:18:09 CEST 2006


Revision: 21981
Author:   fingolfin
Date:     2006-04-17 11:17:02 -0700 (Mon, 17 Apr 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21981&view=rev

Log Message:
-----------
Renamed and merge some of the pixel interpolation functions (the names still could be better)

Modified Paths:
--------------
    scummvm/trunk/graphics/scaler/2xsai.cpp
    scummvm/trunk/graphics/scaler/aspect.cpp
    scummvm/trunk/graphics/scaler/intern.h
    scummvm/trunk/graphics/scaler/thumbnail.cpp
    scummvm/trunk/graphics/scaler.cpp
Modified: scummvm/trunk/graphics/scaler/2xsai.cpp
===================================================================
--- scummvm/trunk/graphics/scaler/2xsai.cpp	2006-04-17 17:39:08 UTC (rev 21980)
+++ scummvm/trunk/graphics/scaler/2xsai.cpp	2006-04-17 18:17:02 UTC (rev 21981)
@@ -44,8 +44,9 @@
 	return rmap[y][x];
 }
 
-#define INTERPOLATE		INTERPOLATE<bitFormat>
-#define Q_INTERPOLATE	Q_INTERPOLATE<bitFormat>
+#define interpolate32_1_1		interpolate32_1_1<bitFormat>
+#define interpolate32_3_1		interpolate32_3_1<bitFormat>
+#define interpolate32_1_1_1_1	interpolate32_1_1_1_1<bitFormat>
 
 template<int bitFormat>
 void Super2xSaITemplate(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) {
@@ -108,35 +109,35 @@
 				else if (r < 0)
 					product2b = product1b = color5;
 				else {
-					product2b = product1b = INTERPOLATE(color5, color6);
+					product2b = product1b = interpolate32_1_1(color5, color6);
 				}
 			} else {
 				if (color6 == color3 && color3 == colorA1 && color2 != colorA2 && color3 != colorA0)
-					product2b = Q_INTERPOLATE(color3, color3, color3, color2);
+					product2b = interpolate32_3_1(color3, color2);
 				else if (color5 == color2 && color2 == colorA2 && colorA1 != color3 && color2 != colorA3)
-					product2b = Q_INTERPOLATE(color2, color2, color2, color3);
+					product2b = interpolate32_3_1(color2, color3);
 				else
-					product2b = INTERPOLATE(color2, color3);
+					product2b = interpolate32_1_1(color2, color3);
 
 				if (color6 == color3 && color6 == colorB1 && color5 != colorB2 && color6 != colorB0)
-					product1b = Q_INTERPOLATE(color6, color6, color6, color5);
+					product1b = interpolate32_3_1(color6, color5);
 				else if (color5 == color2 && color5 == colorB2 && colorB1 != color6 && color5 != colorB3)
-					product1b = Q_INTERPOLATE(color6, color5, color5, color5);
+					product1b = interpolate32_3_1(color5, color6);
 				else
-					product1b = INTERPOLATE(color5, color6);
+					product1b = interpolate32_1_1(color5, color6);
 			}
 
 			if (color5 == color3 && color2 != color6 && color4 == color5 && color5 != colorA2)
-				product2a = INTERPOLATE(color2, color5);
+				product2a = interpolate32_1_1(color2, color5);
 			else if (color5 == color1 && color6 == color5 && color4 != color2 && color5 != colorA0)
-				product2a = INTERPOLATE(color2, color5);
+				product2a = interpolate32_1_1(color2, color5);
 			else
 				product2a = color2;
 
 			if (color2 == color6 && color5 != color3 && color1 == color2 && color2 != colorB2)
-				product1a = INTERPOLATE(color2, color5);
+				product1a = interpolate32_1_1(color2, color5);
 			else if (color4 == color2 && color3 == color2 && color1 != color5 && color2 != colorB0)
-				product1a = INTERPOLATE(color2, color5);
+				product1a = interpolate32_1_1(color2, color5);
 			else
 				product1a = color5;
 
@@ -192,43 +193,43 @@
 				if (color2 == color6) {
 					product1b = product2a = color2;
 					if ((color1 == color2) || (color6 == colorB2)) {
-						product1a = INTERPOLATE(color2, color5);
-						product1a = INTERPOLATE(color2, product1a);
+						product1a = interpolate32_1_1(color2, color5);
+						product1a = interpolate32_1_1(color2, product1a);
 					} else {
-						product1a = INTERPOLATE(color5, color6);
+						product1a = interpolate32_1_1(color5, color6);
 					}
 
 					if ((color6 == colorS2) || (color2 == colorA1)) {
-						product2b = INTERPOLATE(color2, color3);
-						product2b = INTERPOLATE(color2, product2b);
+						product2b = interpolate32_1_1(color2, color3);
+						product2b = interpolate32_1_1(color2, product2b);
 					} else {
-						product2b = INTERPOLATE(color2, color3);
+						product2b = interpolate32_1_1(color2, color3);
 					}
 				} else {
-					product2b = product1a = INTERPOLATE(color2, color6);
-					product2b = Q_INTERPOLATE(color3, color3, color3, product2b);
-					product1a = Q_INTERPOLATE(color5, color5, color5, product1a);
+					product2b = product1a = interpolate32_1_1(color2, color6);
+					product2b = interpolate32_3_1(color3, product2b);
+					product1a = interpolate32_3_1(color5, product1a);
 
-					product2a = product1b = INTERPOLATE(color5, color3);
-					product2a = Q_INTERPOLATE(color2, color2, color2, product2a);
-					product1b = Q_INTERPOLATE(color6, color6, color6, product1b);
+					product2a = product1b = interpolate32_1_1(color5, color3);
+					product2a = interpolate32_3_1(color2, product2a);
+					product1b = interpolate32_3_1(color6, product1b);
 				}
 			} else {
 				if (color2 != color6) {
 					product2b = product1a = color5;
 
 					if ((colorB1 == color5) || (color3 == colorS1)) {
-						product1b = INTERPOLATE(color5, color6);
-						product1b = INTERPOLATE(color5, product1b);
+						product1b = interpolate32_1_1(color5, color6);
+						product1b = interpolate32_1_1(color5, product1b);
 					} else {
-						product1b = INTERPOLATE(color5, color6);
+						product1b = interpolate32_1_1(color5, color6);
 					}
 
 					if ((color3 == colorA2) || (color4 == color5)) {
-						product2a = INTERPOLATE(color5, color2);
-						product2a = INTERPOLATE(color5, product2a);
+						product2a = interpolate32_1_1(color5, color2);
+						product2a = interpolate32_1_1(color5, product2a);
 					} else {
-						product2a = INTERPOLATE(color2, color3);
+						product2a = interpolate32_1_1(color2, color3);
 					}
 				} else {
 					register int r = 0;
@@ -240,10 +241,10 @@
 
 					if (r > 0) {
 						product1b = product2a = color2;
-						product1a = product2b = INTERPOLATE(color5, color6);
+						product1a = product2b = interpolate32_1_1(color5, color6);
 					} else if (r < 0) {
 						product2b = product1a = color5;
-						product1b = product2a = INTERPOLATE(color5, color6);
+						product1b = product2a = interpolate32_1_1(color5, color6);
 					} else {
 						product2b = product1a = color5;
 						product1b = product2a = color2;
@@ -314,14 +315,14 @@
 					((colorA == colorC) && (colorA == colorF) && (colorB != colorE) && (colorB == colorJ))) {
 					product = colorA;
 				} else {
-					product = INTERPOLATE(colorA, colorB);
+					product = interpolate32_1_1(colorA, colorB);
 				}
 
 				if (((colorA == colorG) && (colorC == colorO)) ||
 					((colorA == colorB) && (colorA == colorH) && (colorG != colorC)  && (colorC == colorM))) {
 					product1 = colorA;
 				} else {
-					product1 = INTERPOLATE(colorA, colorC);
+					product1 = interpolate32_1_1(colorA, colorC);
 				}
 				product2 = colorA;
 			} else if ((colorB == colorC) && (colorA != colorD)) {
@@ -329,14 +330,14 @@
 					((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI))) {
 					product = colorB;
 				} else {
-					product = INTERPOLATE(colorA, colorB);
+					product = interpolate32_1_1(colorA, colorB);
 				}
 
 				if (((colorC == colorH) && (colorA == colorF)) ||
 					((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI))) {
 					product1 = colorC;
 				} else {
-					product1 = INTERPOLATE(colorA, colorC);
+					product1 = interpolate32_1_1(colorA, colorC);
 				}
 				product2 = colorB;
 			} else if ((colorA == colorD) && (colorB == colorC)) {
@@ -347,8 +348,8 @@
 				} else {
 					register int r = 0;
 
-					product1 = INTERPOLATE(colorA, colorC);
-					product = INTERPOLATE(colorA, colorB);
+					product1 = interpolate32_1_1(colorA, colorC);
+					product = interpolate32_1_1(colorA, colorB);
 
 					r += GetResult(colorA, colorB, colorG, colorE);
 					r -= GetResult(colorB, colorA, colorK, colorF);
@@ -360,11 +361,11 @@
 					else if (r < 0)
 						product2 = colorB;
 					else {
-						product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD);
+						product2 = interpolate32_1_1_1_1(colorA, colorB, colorC, colorD);
 					}
 				}
 			} else {
-				product2 = Q_INTERPOLATE(colorA, colorB, colorC, colorD);
+				product2 = interpolate32_1_1_1_1(colorA, colorB, colorC, colorD);
 
 				if ((colorA == colorC) && (colorA == colorF)
 						&& (colorB != colorE) && (colorB == colorJ)) {
@@ -373,7 +374,7 @@
 									 && (colorA != colorF) && (colorA == colorI)) {
 					product = colorB;
 				} else {
-					product = INTERPOLATE(colorA, colorB);
+					product = interpolate32_1_1(colorA, colorB);
 				}
 
 				if ((colorA == colorB) && (colorA == colorH)
@@ -383,7 +384,7 @@
 									 && (colorA != colorH) && (colorA == colorI)) {
 					product1 = colorC;
 				} else {
-					product1 = INTERPOLATE(colorA, colorC);
+					product1 = interpolate32_1_1(colorA, colorC);
 				}
 			}
 

Modified: scummvm/trunk/graphics/scaler/aspect.cpp
===================================================================
--- scummvm/trunk/graphics/scaler/aspect.cpp	2006-04-17 17:39:08 UTC (rev 21980)
+++ scummvm/trunk/graphics/scaler/aspect.cpp	2006-04-17 18:17:02 UTC (rev 21981)
@@ -55,20 +55,6 @@
 
 #if ASPECT_MODE == kFastAndNiceAspectMode
 
-template<int bitFormat>
-static inline uint32 INTERPOLATE_1_1(uint32 A, uint32 B) {
-	return (((A & highBits) >> 1) + ((B & highBits) >> 1) + (A & B & lowBits));
-}
-
-template<int bitFormat>
-static inline uint32 INTERPOLATE_1_3(uint32 A, uint32 B) {
-	register uint32 x = ((A & qhighBits) >> 2) + ((B & qhighBits) >> 2) * 3;
-	register uint32 y = ((A & qlowBits) + (B & qlowBits) * 3) >> 2;
-
-	y &= qlowBits;
-	return x + y;
-}
-
 template<int bitFormat, int scale>
 static inline void interpolate5Line(uint16 *dst, const uint16 *srcA, const uint16 *srcB, int width) {
 	// For efficiency reasons we blit two pixels at a time, so it is important
@@ -90,11 +76,11 @@
 	uint32 *d = (uint32 *)dst;
 	if (scale == 1) {
 		while (width--) {
-			*d++ = INTERPOLATE_1_3<bitFormat>(*sA++, *sB++);
+			*d++ = interpolate32_3_1<bitFormat>(*sB++, *sA++);
 		}
 	} else {
 		while (width--) {
-			*d++ = INTERPOLATE_1_1<bitFormat>(*sA++, *sB++);
+			*d++ = interpolate32_1_1<bitFormat>(*sB++, *sA++);
 		}
 	}
 }

Modified: scummvm/trunk/graphics/scaler/intern.h
===================================================================
--- scummvm/trunk/graphics/scaler/intern.h	2006-04-17 17:39:08 UTC (rev 21980)
+++ scummvm/trunk/graphics/scaler/intern.h	2006-04-17 18:17:02 UTC (rev 21981)
@@ -38,23 +38,36 @@
 
 
 /**
- * Interpolate two 16 bit pixel pairs at once with equal weights 1.
+ * 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) {
-
+static inline uint32 interpolate32_1_1(uint32 A, uint32 B) {
 	return (((A & highBits) >> 1) + ((B & highBits) >> 1) + (A & B & lowBits));
 }
 
 /**
+ * Interpolate two 16 bit pixel *pairs* at once with weights 3 resp. 1.
+ * In particular, A and B can contain two pixels/each in the upper
+ * and lower halves.
+ */
+template<int bitFormat>
+static inline uint32 interpolate32_3_1(uint32 A, uint32 B) {
+	register uint32 x = ((A & qhighBits) >> 2) * 3 + ((B & qhighBits) >> 2);
+	register uint32 y = ((A & qlowBits) * 3 + (B & qlowBits)) >> 2;
+
+	y &= qlowBits;
+	return x + y;
+}
+
+/**
  * 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) {
+static inline uint32 interpolate32_1_1_1_1(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;
 
@@ -66,6 +79,7 @@
 /**
  * Interpolate two 16 bit pixels with the weights specified in the template
  * parameters. Used by the hq scaler family.
+ * @note w1 and w2 must sum up to 2, 4, 8 or 16.
  */
 template<int bitFormat, int w1, int w2>
 static inline uint16 interpolate16_2(uint16 p1, uint16 p2) {
@@ -76,6 +90,7 @@
 /**
  * Interpolate three 16 bit pixels with the weights specified in the template
  * parameters. Used by the hq scaler family.
+ * @note w1, w2 and w3 must sum up to 2, 4, 8 or 16.
  */
 template<int bitFormat, int w1, int w2, int w3>
 static inline uint16 interpolate16_3(uint16 p1, uint16 p2, uint16 p3) {

Modified: scummvm/trunk/graphics/scaler/thumbnail.cpp
===================================================================
--- scummvm/trunk/graphics/scaler/thumbnail.cpp	2006-04-17 17:39:08 UTC (rev 21980)
+++ scummvm/trunk/graphics/scaler/thumbnail.cpp	2006-04-17 18:17:02 UTC (rev 21981)
@@ -36,7 +36,7 @@
 	uint16 colorx1y2 = *(((const uint16*)(src + srcPitch)));
 	uint16 colorx2y2 = *(((const uint16*)(src + srcPitch)) + 1);
 
-	return Q_INTERPOLATE<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
+	return interpolate32_1_1_1_1<bitFormat>(colorx1y1, colorx2y1, colorx1y2, colorx2y2);
 }
 
 template<int bitFormat>
@@ -63,7 +63,7 @@
 			uint16 downleft = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * x, srcPitch);
 			uint16 downright = quadBlockInterpolate<bitFormat>(src + srcPitch * 2 + 2 * (x + 2), srcPitch);
 
-			*((uint16*)dstPtr) = Q_INTERPOLATE<bitFormat>(upleft, upright, downleft, downright);
+			*((uint16*)dstPtr) = interpolate32_1_1_1_1<bitFormat>(upleft, upright, downleft, downright);
 		}
 		dstPtr += (dstPitch - 2 * width / 4);
 		src += 4 * srcPitch;

Modified: scummvm/trunk/graphics/scaler.cpp
===================================================================
--- scummvm/trunk/graphics/scaler.cpp	2006-04-17 17:39:08 UTC (rev 21980)
+++ scummvm/trunk/graphics/scaler.cpp	2006-04-17 18:17:02 UTC (rev 21981)
@@ -178,8 +178,8 @@
 	}
 }
 
-#define INTERPOLATE		INTERPOLATE<bitFormat>
-#define Q_INTERPOLATE	Q_INTERPOLATE<bitFormat>
+#define interpolate32_1_1		interpolate32_1_1<bitFormat>
+#define interpolate32_1_1_1_1	interpolate32_1_1_1_1<bitFormat>
 
 /**
  * Trivial nearest-neighbour 1.5x scaler.
@@ -202,13 +202,13 @@
 			uint16 color3 = *(((const uint16 *)(srcPtr + srcPitch)) + i + 1);
 
 			*(uint16 *)(r + 0) = color0;
-			*(uint16 *)(r + 2) = INTERPOLATE(color0, color1);
+			*(uint16 *)(r + 2) = interpolate32_1_1(color0, color1);
 			*(uint16 *)(r + 4) = color1;
-			*(uint16 *)(r + 0 + dstPitch) = INTERPOLATE(color0, color2);
-			*(uint16 *)(r + 2 + dstPitch) = Q_INTERPOLATE(color0, color1, color2, color3);
-			*(uint16 *)(r + 4 + dstPitch) = INTERPOLATE(color1, color3);
+			*(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 + dstPitch2) = color2;
-			*(uint16 *)(r + 2 + dstPitch2) = INTERPOLATE(color2, color3);
+			*(uint16 *)(r + 2 + dstPitch2) = interpolate32_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