[Liblas-commits] laszip: mean bug fix due to floating-point 'Inf'
compiler differ...
liblas-commits at liblas.org
liblas-commits at liblas.org
Mon Jan 31 16:22:42 EST 2011
details: http://hg.liblas.orglaszip/rev/a372803f1069
changeset: 172:a372803f1069
user: isenburg
date: Mon Jan 31 13:22:30 2011 -0800
description:
mean bug fix due to floating-point 'Inf' compiler differences
diffstat:
src/arithmeticdecoder.cpp | 14 +++++++-------
src/arithmeticencoder.cpp | 12 ++++++------
src/lasreaditemcompressed_v1.cpp | 14 +++++++-------
src/lasreaditemcompressed_v1.hpp | 2 +-
src/laswriteitemcompressed_v1.cpp | 20 ++++++++++----------
src/laswriteitemcompressed_v1.hpp | 2 +-
src/mydefs.hpp | 8 ++++----
7 files changed, 36 insertions(+), 36 deletions(-)
diffs (209 lines):
diff -r 8f4361c46238 -r a372803f1069 src/arithmeticdecoder.cpp
--- a/src/arithmeticdecoder.cpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/arithmeticdecoder.cpp Mon Jan 31 13:22:30 2011 -0800
@@ -247,7 +247,7 @@
return (U8)sym;
}
-unsigned short ArithmeticDecoder::readShort()
+U16 ArithmeticDecoder::readShort()
{
U32 sym = value / (length >>= 16); // decode symbol, change length
value -= length * sym; // update interval
@@ -268,9 +268,9 @@
inline F32 ArithmeticDecoder::readFloat()
{
- U32F32 u32f32;
- u32f32.u32 = readInt();
- return u32f32.f32;
+ U32I32F32 u32i32f32;
+ u32i32f32.u32 = readInt();
+ return u32i32f32.f32;
}
inline U64 ArithmeticDecoder::readInt64()
@@ -282,9 +282,9 @@
inline F64 ArithmeticDecoder::readDouble()
{
- U64F64 u64f64;
- u64f64.u64 = readInt64();
- return u64f64.f64;
+ U64I64F64 u64i64f64;
+ u64i64f64.u64 = readInt64();
+ return u64i64f64.f64;
}
ArithmeticDecoder::~ArithmeticDecoder()
diff -r 8f4361c46238 -r a372803f1069 src/arithmeticencoder.cpp
--- a/src/arithmeticencoder.cpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/arithmeticencoder.cpp Mon Jan 31 13:22:30 2011 -0800
@@ -268,9 +268,9 @@
inline void ArithmeticEncoder::writeFloat(F32 sym)
{
- U32F32 u32f32;
- u32f32.f32 = sym;
- writeInt(u32f32.u32);
+ U32I32F32 u32i32f32;
+ u32i32f32.f32 = sym;
+ writeInt(u32i32f32.u32);
}
inline void ArithmeticEncoder::writeInt64(U64 sym)
@@ -281,9 +281,9 @@
inline void ArithmeticEncoder::writeDouble(F64 sym)
{
- U64F64 u64f64;
- u64f64.f64 = sym;
- writeInt64(u64f64.u64);
+ U64I64F64 u64i64f64;
+ u64i64f64.f64 = sym;
+ writeInt64(u64i64f64.u64);
}
inline void ArithmeticEncoder::propagate_carry()
diff -r 8f4361c46238 -r a372803f1069 src/lasreaditemcompressed_v1.cpp
--- a/src/lasreaditemcompressed_v1.cpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/lasreaditemcompressed_v1.cpp Mon Jan 31 13:22:30 2011 -0800
@@ -309,7 +309,7 @@
}
else if (multi == 2) // the difference is huge
{
- last_gpstime.i64 = dec->readInt64();
+ last_gpstime.u64 = dec->readInt64();
}
}
else
@@ -360,10 +360,10 @@
}
else if (multi < LASZIP_GPSTIME_MULTIMAX-1)
{
- last_gpstime.i64 = dec->readInt64();
+ last_gpstime.u64 = dec->readInt64();
}
}
- *((F64*)item) = last_gpstime.f64;
+ *((I64*)item) = last_gpstime.i64;
return TRUE;
}
@@ -436,10 +436,10 @@
{
U64 offset;
U32 packet_size;
- I32F32 return_point;
- I32F32 x;
- I32F32 y;
- I32F32 z;
+ U32I32F32 return_point;
+ U32I32F32 x;
+ U32I32F32 y;
+ U32I32F32 z;
};
LASreadItemCompressed_WAVEPACKET13_v1::LASreadItemCompressed_WAVEPACKET13_v1(EntropyDecoder* dec)
diff -r 8f4361c46238 -r a372803f1069 src/lasreaditemcompressed_v1.hpp
--- a/src/lasreaditemcompressed_v1.hpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/lasreaditemcompressed_v1.hpp Mon Jan 31 13:22:30 2011 -0800
@@ -79,7 +79,7 @@
private:
EntropyDecoder* dec;
- I64F64 last_gpstime;
+ U64I64F64 last_gpstime;
EntropyModel* m_gpstime_multi;
EntropyModel* m_gpstime_0diff;
diff -r 8f4361c46238 -r a372803f1069 src/laswriteitemcompressed_v1.cpp
--- a/src/laswriteitemcompressed_v1.cpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/laswriteitemcompressed_v1.cpp Mon Jan 31 13:22:30 2011 -0800
@@ -299,8 +299,8 @@
inline BOOL LASwriteItemCompressed_GPSTIME11_v1::write(const U8* item)
{
- I64F64 this_gpstime;
- this_gpstime.f64 = *((F64*)item);
+ U64I64F64 this_gpstime;
+ this_gpstime.i64 = *((I64*)item);
if (last_gpstime_diff == 0) // if the last integer difference was zero
{
@@ -322,9 +322,9 @@
else
{
enc->encodeSymbol(m_gpstime_0diff, 2); // the difference is huge
- enc->writeInt64(this_gpstime.i64);
+ enc->writeInt64(this_gpstime.u64);
}
- last_gpstime.f64 = this_gpstime.f64;
+ last_gpstime.i64 = this_gpstime.i64;
}
}
else // the last integer difference was *not* zero
@@ -402,9 +402,9 @@
{
// if difference is so huge ... we simply write the double
enc->encodeSymbol(m_gpstime_multi, LASZIP_GPSTIME_MULTIMAX-2);
- enc->writeInt64(this_gpstime.i64);
+ enc->writeInt64(this_gpstime.u64);
}
- last_gpstime.f64 = this_gpstime.f64;
+ last_gpstime.i64 = this_gpstime.i64;
}
}
return TRUE;
@@ -479,10 +479,10 @@
{
U64 offset;
U32 packet_size;
- I32F32 return_point;
- I32F32 x;
- I32F32 y;
- I32F32 z;
+ U32I32F32 return_point;
+ U32I32F32 x;
+ U32I32F32 y;
+ U32I32F32 z;
};
LASwriteItemCompressed_WAVEPACKET13_v1::LASwriteItemCompressed_WAVEPACKET13_v1(EntropyEncoder* enc)
diff -r 8f4361c46238 -r a372803f1069 src/laswriteitemcompressed_v1.hpp
--- a/src/laswriteitemcompressed_v1.hpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/laswriteitemcompressed_v1.hpp Mon Jan 31 13:22:30 2011 -0800
@@ -79,7 +79,7 @@
private:
EntropyEncoder* enc;
- I64F64 last_gpstime;
+ U64I64F64 last_gpstime;
EntropyModel* m_gpstime_multi;
EntropyModel* m_gpstime_0diff;
diff -r 8f4361c46238 -r a372803f1069 src/mydefs.hpp
--- a/src/mydefs.hpp Mon Jan 31 11:28:38 2011 -0800
+++ b/src/mydefs.hpp Mon Jan 31 13:22:30 2011 -0800
@@ -4,6 +4,8 @@
FILE: mydefs.hpp
CONTENTS:
+
+ Basic data type definitions to be robust across platforms.
PROGRAMMERS:
@@ -55,10 +57,8 @@
typedef bool BOOL;
#endif
-typedef union U32F32 { U32 u32; F32 f32; } U32F32;
-typedef union U64F64 { U64 u64; F64 f64; } U64F64;
-typedef union I32F32 { I32 i32; F32 f32; } I32F32;
-typedef union I64F64 { I64 i64; F64 f64; } I64F64;
+typedef union U32I32F32 { U32 u32; I32 i32; F32 f32; } U32I32F32;
+typedef union U64I64F64 { U64 u64; I64 i64; F64 f64; } U64I64F64;
#define F32_MAX +1.0e+30f
#define F32_MIN -1.0e+30f
More information about the Liblas-commits
mailing list