jonathan: thuban/libraries/thuban gdalwarp.cpp,1.8,1.9

cvs@intevation.de cvs at intevation.de
Fri Feb 18 22:22:55 CET 2005


Author: jonathan

Update of /thubanrepository/thuban/libraries/thuban
In directory doto:/tmp/cvs-serv21882/libraries/thuban

Modified Files:
	gdalwarp.cpp 
Log Message:
Optimize the loop in gdalwarp which builds a mask. Handle the majority of an 
image in a loop, creating 8 bits at a time. Later, handle the edge case where 
less than 8 bits are packed.


Index: gdalwarp.cpp
===================================================================
RCS file: /thubanrepository/thuban/libraries/thuban/gdalwarp.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- gdalwarp.cpp	18 Feb 2005 14:54:17 -0000	1.8
+++ gdalwarp.cpp	18 Feb 2005 21:22:53 -0000	1.9
@@ -29,6 +29,11 @@
  ******************************************************************************
  *
  * $Log$
+ * Revision 1.9  2005/02/18 21:22:53  jonathan
+ * Optimize the loop in gdalwarp which builds a mask. Handle the majority of an
+ * image in a loop, creating 8 bits at a time. Later, handle the edge case where
+ * less than 8 bits are packed.
+ *
  * Revision 1.8  2005/02/18 14:54:17  jonathan
  * Refactored baserenderer.py and renderer.py to remove baserenderer.py's
  * dependencies on wxPython. Added a new method projected_raster_layer()
@@ -496,31 +501,47 @@
 
                         for (i=0; i < nRasterYSize; i++)
                         {
-                            for (j=0; j < nRasterXSize;)
+                            for (j=nRasterXSize; j >= 8; j -= 8)
                             {
-                                if (bInvertMask)
-                                {
-                                    if (*tptr++ < 128) c |= b;
-                                }
+                                c=0; b=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                
+                                if (bInvertMask) 
+                                    *(ptr++) = ~c;
                                 else
-                                {
-                                    if (*tptr++ >= 128) c |= b;
-                                }
-
-                                b <<= 1;
-                                if (!(++j & 7))
-                                {
-                                    //if (c==0) empty_count++;
                                     *(ptr++) = c;
-                                    c = 0; b = 1;
-                                }
                             }
 
-                            if (j & 7)
+                            c=0; b=1;
+                            switch (nRasterXSize & 7)
                             {
-                                //if (c==0) empty_count++;
-                                *(ptr++) = c;
-                                c = 0; b = 1;
+                                case 7: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 6: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 5: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 4: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 3: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 2: if (*tptr++ >= 128) {c|=b;} b<<=1;
+                                case 1: 
+                                    if (*tptr++ >= 128) {c|=b;} 
+                                    b<<=1;
+
+                                    //
+                                    // byte should be padded with 0's so
+                                    // it's not a simple inversion
+                                    //
+                                    if (bInvertMask) 
+                                        *(ptr++) = ~c & (b-1);
+                                    else
+                                        *(ptr++) = c;
+
+                                default: break;
                             }
                         }
 





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)