[Liblas-commits] laszip: 2 new changesets

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Dec 20 13:12:50 EST 2010


changeset 035b52b181dc in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=035b52b181dc
summary: minor changes to finalize interface

changeset b49409e2e144 in /Volumes/Data/www/liblas.org/laszip
details: http://hg.liblas.orglaszip?cmd=changeset;node=b49409e2e144
summary: more minor changes under the hood

diffstat:

 include/laszip/laszip.hpp         |  97 ++++++++++++++++++++++++++------------
 include/laszip/laszipper.hpp      |   3 +-
 src/lasreaditemcompressed_v1.cpp  |  18 +++++--
 src/lasreaditemcompressed_v1.hpp  |   1 +
 src/lasreadpoint.cpp              |   4 +
 src/laswriteitemcompressed_v1.cpp |  23 +++++++--
 src/laswriteitemcompressed_v1.hpp |   1 +
 src/laswritepoint.cpp             |   9 +++
 src/laszipper.cpp                 |   7 ++
 src/rangedecoder.cpp              |   2 +-
 src/rangeencoder.cpp              |   2 +-
 11 files changed, 121 insertions(+), 46 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r b095ef93a1f2 -r b49409e2e144 include/laszip/laszip.hpp
--- a/include/laszip/laszip.hpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/include/laszip/laszip.hpp	Mon Dec 20 10:12:32 2010 -0800
@@ -55,8 +55,8 @@
 #define LASZIP_VERSION_MINOR    0
 #define LASZIP_VERSION_REVISION 0
 
-#define LASZIP_COMPRESSION_NONE 0
-#define LASZIP_COMPRESSION_RANGE 1
+#define LASZIP_COMPRESSION_NONE       0
+#define LASZIP_COMPRESSION_RANGE      1
 #define LASZIP_COMPRESSION_ARITHMETIC 2
 
 class LASitem
@@ -67,36 +67,65 @@
   unsigned short size;
   unsigned short version;
 
-  // convenience function (not done as a ctor, since these items are usually allocated as an array)
-  void set(LASitem::Type type)
+  void set(LASitem::Type t, unsigned int number=1)
   {
-      LASitem& x = *this;
-      switch (type)
-      {
-      case LASitem::POINT10:
-          x.type = LASitem::POINT10;
-          x.size = 20;
-          x.version = 0;
-          break;
-      case LASitem::GPSTIME:
-          x.type = LASitem::GPSTIME;
-          x.size = 8;
-          x.version = 0;
-          break;
-      case LASitem::RGB:
-          x.type = LASitem::RGB;
-          x.size = 6;
-          x.version = 0;
-          break;
-      case LASitem::WAVEPACKET:
-          x.type = LASitem::WAVEPACKET;
-          x.size = 29;
-          x.version = 0;
-          break;
-      default:
-          throw 0; // BUG
-      }
-      return;
+    switch (t)
+    {
+    case LASitem::POINT10:
+        type = LASitem::POINT10;
+        size = 20;
+        version = 0;
+        break;
+    case LASitem::GPSTIME:
+        type = LASitem::GPSTIME;
+        size = 8;
+        version = 0;
+        break;
+    case LASitem::RGB:
+        type = LASitem::RGB;
+        size = 6;
+        version = 0;
+        break;
+    case LASitem::WAVEPACKET:
+        type = LASitem::WAVEPACKET;
+        size = 29;
+        version = 0;
+        break;
+    case LASitem::BYTE:
+        type = LASitem::BYTE;
+        size = number;
+        version = 0;
+        break;
+    default:
+        throw 0; // BUG
+    }
+    return;
+  }
+
+  bool is_type(LASitem::Type t) const
+  {
+    if (t != type) return false;
+    switch (t)
+    {
+    case POINT10:
+      if (size != 20) return false;
+      break;
+    case GPSTIME:
+      if (size != 8) return false;
+      break;
+    case RGB:
+      if (size != 6) return false;
+      break;
+    case WAVEPACKET:
+      if (size != 29) return false;
+      break;
+    case BYTE:
+      if (size < 1) return false;
+      break;
+    default:
+      return false;
+    }
+    return true;
   }
 
   bool supported_type() const
@@ -110,6 +139,8 @@
     case BYTE:
       return true;
       break;
+    default:
+      return false;
     }
     return false;
   }
@@ -195,10 +226,12 @@
   }
 };
 
+/*
 struct LASchunk
 {
   unsigned int count;
   unsigned int bytes;
-};
+}; 
+*/
 
 #endif
diff -r b095ef93a1f2 -r b49409e2e144 include/laszip/laszipper.hpp
--- a/include/laszip/laszipper.hpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/include/laszip/laszipper.hpp	Mon Dec 20 10:12:32 2010 -0800
@@ -68,8 +68,7 @@
   bool open(FILE* outfile, unsigned int num_items, LASitem* items, unsigned int compression=0);
   bool open(ostream* outstream, unsigned int num_items, LASitem* items, unsigned int compression=0);
   bool write(unsigned char** point);
-  bool chunk(LASchunk* chunk);
-  unsigned int close(LASchunk* chunk=0);
+  unsigned int close();
 
   LASzipper();
   ~LASzipper();
diff -r b095ef93a1f2 -r b49409e2e144 src/lasreaditemcompressed_v1.cpp
--- a/src/lasreaditemcompressed_v1.cpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/lasreaditemcompressed_v1.cpp	Mon Dec 20 10:12:32 2010 -0800
@@ -376,7 +376,8 @@
   this->dec = dec;
 
   /* create models and integer compressors */
-  ic_rgb = new IntegerCompressor(dec, 16, 3); // 16 bits, 3 contexts
+  m_byte_used = dec->createSymbolModel(64);
+  ic_rgb = new IntegerCompressor(dec, 8, 6);
 
   /* create last item */
   last_item = new U8[6];
@@ -384,6 +385,7 @@
 
 LASreadItemCompressed_RGB_v1::~LASreadItemCompressed_RGB_v1()
 {
+  dec->destroySymbolModel(m_byte_used);
   delete ic_rgb;
   delete [] last_item;
 }
@@ -393,6 +395,7 @@
   /* init state */
 
   /* init models and integer compressors */
+  dec->initSymbolModel(m_byte_used);
   ic_rgb->initDecompressor();
 
   /* init last item */
@@ -402,10 +405,15 @@
 
 BOOL LASreadItemCompressed_RGB_v1::read(U8* item)
 {
-	((U16*)item)[0] = (U16)(ic_rgb->decompress(((U16*)last_item)[0], 0));
-	((U16*)item)[1] = (U16)(ic_rgb->decompress(((U16*)last_item)[1], 1));
-	((U16*)item)[2] = (U16)(ic_rgb->decompress(((U16*)last_item)[2], 2));
-  memcpy(last_item, item, 6);
+  U32 i, sym = dec->decodeSymbol(m_byte_used);
+  for (i = 0; i < 6; i++)
+  {
+    if (sym & (1 << i))
+    {
+      item[i] = ic_rgb->decompress(last_item[i], i);
+      last_item[i] = item[i];
+    }
+  }
   return TRUE;
 }
 
diff -r b095ef93a1f2 -r b49409e2e144 src/lasreaditemcompressed_v1.hpp
--- a/src/lasreaditemcompressed_v1.hpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/lasreaditemcompressed_v1.hpp	Mon Dec 20 10:12:32 2010 -0800
@@ -118,6 +118,7 @@
   EntropyDecoder* dec;
   U8* last_item;
 
+  EntropyModel* m_byte_used;
   IntegerCompressor* ic_rgb;
 };
 
diff -r b095ef93a1f2 -r b49409e2e144 src/lasreadpoint.cpp
--- a/src/lasreadpoint.cpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/lasreadpoint.cpp	Mon Dec 20 10:12:32 2010 -0800
@@ -115,6 +115,8 @@
     case LASitem::BYTE:
       readers_raw[i] = new LASreadItemRaw_BYTE(items[i].size);
       break;
+    default:
+      return FALSE;
     }
   }
 
@@ -155,6 +157,8 @@
         else
           return FALSE;
         break;
+      default:
+        return FALSE;
       }
     }
   }
diff -r b095ef93a1f2 -r b49409e2e144 src/laswriteitemcompressed_v1.cpp
--- a/src/laswriteitemcompressed_v1.cpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/laswriteitemcompressed_v1.cpp	Mon Dec 20 10:12:32 2010 -0800
@@ -419,7 +419,8 @@
   this->enc = enc;
 
   /* create models and integer compressors */
-  ic_rgb = new IntegerCompressor(enc, 16, 3); // 16 bits, 3 contexts
+  m_byte_used = enc->createSymbolModel(64);
+  ic_rgb = new IntegerCompressor(enc, 8, 6);
 
   /* create last item */
   last_item = new U8[6];
@@ -427,6 +428,7 @@
 
 LASwriteItemCompressed_RGB_v1::~LASwriteItemCompressed_RGB_v1()
 {
+  enc->destroySymbolModel(m_byte_used);
   delete ic_rgb;
   delete [] last_item;
 }
@@ -436,6 +438,7 @@
   /* init state */
 
   /* init models and integer compressors */
+  enc->initSymbolModel(m_byte_used);
   ic_rgb->initCompressor();
 
   /* init last item */
@@ -445,10 +448,20 @@
 
 BOOL LASwriteItemCompressed_RGB_v1::write(U8* item)
 {
-	ic_rgb->compress(((U16*)last_item)[0], ((U16*)item)[0], 0);
-	ic_rgb->compress(((U16*)last_item)[1], ((U16*)item)[1], 1);
-	ic_rgb->compress(((U16*)last_item)[2], ((U16*)item)[2], 2);
-  memcpy(last_item, item, 6);
+  U32 i, sym = 0;
+  for (i = 0; i < 6; i++)
+  {
+    sym |= ((last_item[i] != item[i]) << i);
+  }
+  enc->encodeSymbol(m_byte_used, sym);
+  for (i = 0; i < 6; i++)
+  {
+    if (last_item[i] != item[i])
+    {
+      ic_rgb->compress(last_item[i], item[i], i);
+      last_item[i] = item[i];
+    }
+  }
   return TRUE;
 }
 
diff -r b095ef93a1f2 -r b49409e2e144 src/laswriteitemcompressed_v1.hpp
--- a/src/laswriteitemcompressed_v1.hpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/laswriteitemcompressed_v1.hpp	Mon Dec 20 10:12:32 2010 -0800
@@ -118,6 +118,7 @@
   EntropyEncoder* enc;
   U8* last_item;
 
+  EntropyModel* m_byte_used;
   IntegerCompressor* ic_rgb;
 };
 
diff -r b095ef93a1f2 -r b49409e2e144 src/laswritepoint.cpp
--- a/src/laswritepoint.cpp	Sat Dec 18 12:29:58 2010 -0800
+++ b/src/laswritepoint.cpp	Mon Dec 20 10:12:32 2010 -0800
@@ -101,19 +101,26 @@
     {
     case LASitem::POINT10:
       writers_raw[i] = new LASwriteItemRaw_POINT10();
+      items[i].version = 0;
       break;


More information about the Liblas-commits mailing list