1 /* 2 =============================================================================== 3 4 FILE: lasreaditemcompressed_v4.hpp 5 6 CONTENTS: 7 8 Native extension for decompressing the *new* point types 6 to 10 of LAS 1.4 9 10 PROGRAMMERS: 11 12 martin.isenburg@rapidlasso.com - http://rapidlasso.com 13 14 COPYRIGHT: 15 16 (c) 2007-2017, martin isenburg, rapidlasso - fast tools to catch reality 17 18 This is free software; you can redistribute and/or modify it under the 19 terms of the GNU Lesser General Licence as published by the Free Software 20 Foundation. See the COPYING file for more information. 21 22 This software is distributed WITHOUT ANY WARRANTY and without even the 23 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 24 25 CHANGE HISTORY: 26 27 28 December 2017 -- fix incorrect 'context switch' reported by Wanwannodao 28 28 August 2017 -- moving 'context' from global development hack to interface 29 19 April 2017 -- support for selective decompression for new LAS 1.4 points 30 22 June 2016 -- created after Island beat Austria 2:1 in the EM2016 31 32 =============================================================================== 33 */ 34 #ifndef LAS_READ_ITEM_COMPRESSED_V4_HPP 35 #define LAS_READ_ITEM_COMPRESSED_V4_HPP 36 37 #include "lasreaditem.hpp" 38 #include "arithmeticdecoder.hpp" 39 #include "integercompressor.hpp" 40 #include "bytestreamin_array.hpp" 41 42 #include "laszip_common_v3.hpp" 43 #include "laszip_decompress_selective_v3.hpp" 44 45 class LASreadItemCompressed_POINT14_v4 : public LASreadItemCompressed 46 { 47 public: 48 49 LASreadItemCompressed_POINT14_v4(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 50 51 BOOL chunk_sizes(); 52 BOOL init(const U8* item, U32& context); // context is set 53 void read(U8* item, U32& context); // context is set 54 55 ~LASreadItemCompressed_POINT14_v4(); 56 57 private: 58 59 /* not used as a decoder. just gives access to instream */ 60 61 ArithmeticDecoder* dec; 62 63 ByteStreamInArray* instream_channel_returns_XY; 64 ByteStreamInArray* instream_Z; 65 ByteStreamInArray* instream_classification; 66 ByteStreamInArray* instream_flags; 67 ByteStreamInArray* instream_intensity; 68 ByteStreamInArray* instream_scan_angle; 69 ByteStreamInArray* instream_user_data; 70 ByteStreamInArray* instream_point_source; 71 ByteStreamInArray* instream_gps_time; 72 73 ArithmeticDecoder* dec_channel_returns_XY; 74 ArithmeticDecoder* dec_Z; 75 ArithmeticDecoder* dec_classification; 76 ArithmeticDecoder* dec_flags; 77 ArithmeticDecoder* dec_intensity; 78 ArithmeticDecoder* dec_scan_angle; 79 ArithmeticDecoder* dec_user_data; 80 ArithmeticDecoder* dec_point_source; 81 ArithmeticDecoder* dec_gps_time; 82 83 BOOL changed_Z; 84 BOOL changed_classification; 85 BOOL changed_flags; 86 BOOL changed_intensity; 87 BOOL changed_scan_angle; 88 BOOL changed_user_data; 89 BOOL changed_point_source; 90 BOOL changed_gps_time; 91 92 U32 num_bytes_channel_returns_XY; 93 U32 num_bytes_Z; 94 U32 num_bytes_classification; 95 U32 num_bytes_flags; 96 U32 num_bytes_intensity; 97 U32 num_bytes_scan_angle; 98 U32 num_bytes_user_data; 99 U32 num_bytes_point_source; 100 U32 num_bytes_gps_time; 101 102 BOOL requested_Z; 103 BOOL requested_classification; 104 BOOL requested_flags; 105 BOOL requested_intensity; 106 BOOL requested_scan_angle; 107 BOOL requested_user_data; 108 BOOL requested_point_source; 109 BOOL requested_gps_time; 110 111 U8* bytes; 112 U32 num_bytes_allocated; 113 114 U32 current_context; 115 LAScontextPOINT14 contexts[4]; 116 117 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 118 void read_gps_time(); 119 }; 120 121 class LASreadItemCompressed_RGB14_v4 : public LASreadItemCompressed 122 { 123 public: 124 125 LASreadItemCompressed_RGB14_v4(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 126 127 BOOL chunk_sizes(); 128 BOOL init(const U8* item, U32& context); // context is only read 129 void read(U8* item, U32& context); // context is only read 130 131 ~LASreadItemCompressed_RGB14_v4(); 132 133 private: 134 135 /* not used as a decoder. just gives access to instream */ 136 137 ArithmeticDecoder* dec; 138 139 ByteStreamInArray* instream_RGB; 140 141 ArithmeticDecoder* dec_RGB; 142 143 BOOL changed_RGB; 144 145 U32 num_bytes_RGB; 146 147 BOOL requested_RGB; 148 149 U8* bytes; 150 U32 num_bytes_allocated; 151 152 U32 current_context; 153 LAScontextRGB14 contexts[4]; 154 155 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 156 }; 157 158 class LASreadItemCompressed_RGBNIR14_v4 : public LASreadItemCompressed 159 { 160 public: 161 162 LASreadItemCompressed_RGBNIR14_v4(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 163 164 BOOL chunk_sizes(); 165 BOOL init(const U8* item, U32& context); // context is only read 166 void read(U8* item, U32& context); // context is only read 167 168 ~LASreadItemCompressed_RGBNIR14_v4(); 169 170 private: 171 172 /* not used as a decoder. just gives access to instream */ 173 174 ArithmeticDecoder* dec; 175 176 ByteStreamInArray* instream_RGB; 177 ByteStreamInArray* instream_NIR; 178 179 ArithmeticDecoder* dec_RGB; 180 ArithmeticDecoder* dec_NIR; 181 182 BOOL changed_RGB; 183 BOOL changed_NIR; 184 185 U32 num_bytes_RGB; 186 U32 num_bytes_NIR; 187 188 BOOL requested_RGB; 189 BOOL requested_NIR; 190 191 U8* bytes; 192 U32 num_bytes_allocated; 193 194 U32 current_context; 195 LAScontextRGBNIR14 contexts[4]; 196 197 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 198 }; 199 200 class LASreadItemCompressed_WAVEPACKET14_v4 : public LASreadItemCompressed 201 { 202 public: 203 204 LASreadItemCompressed_WAVEPACKET14_v4(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 205 206 BOOL chunk_sizes(); 207 BOOL init(const U8* item, U32& context); // context is only read 208 void read(U8* item, U32& context); // context is only read 209 210 ~LASreadItemCompressed_WAVEPACKET14_v4(); 211 212 private: 213 214 /* not used as a decoder. just gives access to instream */ 215 216 ArithmeticDecoder* dec; 217 218 ByteStreamInArray* instream_wavepacket; 219 220 ArithmeticDecoder* dec_wavepacket; 221 222 BOOL changed_wavepacket; 223 224 U32 num_bytes_wavepacket; 225 226 BOOL requested_wavepacket; 227 228 U8* bytes; 229 U32 num_bytes_allocated; 230 231 U32 current_context; 232 LAScontextWAVEPACKET14 contexts[4]; 233 234 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 235 }; 236 237 class LASreadItemCompressed_BYTE14_v4 : public LASreadItemCompressed 238 { 239 public: 240 241 LASreadItemCompressed_BYTE14_v4(ArithmeticDecoder* dec, U32 number, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 242 243 BOOL chunk_sizes(); 244 BOOL init(const U8* item, U32& context); // context is only read 245 void read(U8* item, U32& context); // context is only read 246 247 ~LASreadItemCompressed_BYTE14_v4(); 248 249 private: 250 251 /* not used as a decoder. just gives access to instream */ 252 253 ArithmeticDecoder* dec; 254 255 ByteStreamInArray** instream_Bytes; 256 257 ArithmeticDecoder** dec_Bytes; 258 259 U32* num_bytes_Bytes; 260 261 BOOL* changed_Bytes; 262 263 BOOL* requested_Bytes; 264 265 U8* bytes; 266 U32 num_bytes_allocated; 267 268 U32 current_context; 269 LAScontextBYTE14 contexts[4]; 270 271 U32 number; 272 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 273 }; 274 275 #endif 276