1 /* 2 =============================================================================== 3 4 FILE: lasreaditemcompressed_v3.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 August 2017 -- moving 'context' from global development hack to interface 28 19 April 2017 -- support for selective decompression for new LAS 1.4 points 29 22 June 2016 -- created after Island beat Austria 2:1 in the EM2016 30 31 =============================================================================== 32 */ 33 #ifndef LAS_READ_ITEM_COMPRESSED_V3_HPP 34 #define LAS_READ_ITEM_COMPRESSED_V3_HPP 35 36 #include "lasreaditem.hpp" 37 #include "arithmeticdecoder.hpp" 38 #include "integercompressor.hpp" 39 #include "bytestreamin_array.hpp" 40 41 #include "laszip_common_v3.hpp" 42 #include "laszip_decompress_selective_v3.hpp" 43 44 class LASreadItemCompressed_POINT14_v3 : public LASreadItemCompressed 45 { 46 public: 47 48 LASreadItemCompressed_POINT14_v3(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 49 50 BOOL chunk_sizes(); 51 BOOL init(const U8* item, U32& context); // context is set 52 void read(U8* item, U32& context); // context is set 53 54 ~LASreadItemCompressed_POINT14_v3(); 55 56 private: 57 58 /* not used as a decoder. just gives access to instream */ 59 60 ArithmeticDecoder* dec; 61 62 ByteStreamInArray* instream_channel_returns_XY; 63 ByteStreamInArray* instream_Z; 64 ByteStreamInArray* instream_classification; 65 ByteStreamInArray* instream_flags; 66 ByteStreamInArray* instream_intensity; 67 ByteStreamInArray* instream_scan_angle; 68 ByteStreamInArray* instream_user_data; 69 ByteStreamInArray* instream_point_source; 70 ByteStreamInArray* instream_gps_time; 71 72 ArithmeticDecoder* dec_channel_returns_XY; 73 ArithmeticDecoder* dec_Z; 74 ArithmeticDecoder* dec_classification; 75 ArithmeticDecoder* dec_flags; 76 ArithmeticDecoder* dec_intensity; 77 ArithmeticDecoder* dec_scan_angle; 78 ArithmeticDecoder* dec_user_data; 79 ArithmeticDecoder* dec_point_source; 80 ArithmeticDecoder* dec_gps_time; 81 82 BOOL changed_Z; 83 BOOL changed_classification; 84 BOOL changed_flags; 85 BOOL changed_intensity; 86 BOOL changed_scan_angle; 87 BOOL changed_user_data; 88 BOOL changed_point_source; 89 BOOL changed_gps_time; 90 91 U32 num_bytes_channel_returns_XY; 92 U32 num_bytes_Z; 93 U32 num_bytes_classification; 94 U32 num_bytes_flags; 95 U32 num_bytes_intensity; 96 U32 num_bytes_scan_angle; 97 U32 num_bytes_user_data; 98 U32 num_bytes_point_source; 99 U32 num_bytes_gps_time; 100 101 BOOL requested_Z; 102 BOOL requested_classification; 103 BOOL requested_flags; 104 BOOL requested_intensity; 105 BOOL requested_scan_angle; 106 BOOL requested_user_data; 107 BOOL requested_point_source; 108 BOOL requested_gps_time; 109 110 U8* bytes; 111 U32 num_bytes_allocated; 112 113 U32 current_context; 114 LAScontextPOINT14 contexts[4]; 115 116 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 117 void read_gps_time(); 118 }; 119 120 class LASreadItemCompressed_RGB14_v3 : public LASreadItemCompressed 121 { 122 public: 123 124 LASreadItemCompressed_RGB14_v3(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 125 126 BOOL chunk_sizes(); 127 BOOL init(const U8* item, U32& context); // context is only read 128 void read(U8* item, U32& context); // context is only read 129 130 ~LASreadItemCompressed_RGB14_v3(); 131 132 private: 133 134 /* not used as a decoder. just gives access to instream */ 135 136 ArithmeticDecoder* dec; 137 138 ByteStreamInArray* instream_RGB; 139 140 ArithmeticDecoder* dec_RGB; 141 142 BOOL changed_RGB; 143 144 U32 num_bytes_RGB; 145 146 BOOL requested_RGB; 147 148 U8* bytes; 149 U32 num_bytes_allocated; 150 151 U32 current_context; 152 LAScontextRGB14 contexts[4]; 153 154 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 155 }; 156 157 class LASreadItemCompressed_RGBNIR14_v3 : public LASreadItemCompressed 158 { 159 public: 160 161 LASreadItemCompressed_RGBNIR14_v3(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 162 163 BOOL chunk_sizes(); 164 BOOL init(const U8* item, U32& context); // context is only read 165 void read(U8* item, U32& context); // context is only read 166 167 ~LASreadItemCompressed_RGBNIR14_v3(); 168 169 private: 170 171 /* not used as a decoder. just gives access to instream */ 172 173 ArithmeticDecoder* dec; 174 175 ByteStreamInArray* instream_RGB; 176 ByteStreamInArray* instream_NIR; 177 178 ArithmeticDecoder* dec_RGB; 179 ArithmeticDecoder* dec_NIR; 180 181 BOOL changed_RGB; 182 BOOL changed_NIR; 183 184 U32 num_bytes_RGB; 185 U32 num_bytes_NIR; 186 187 BOOL requested_RGB; 188 BOOL requested_NIR; 189 190 U8* bytes; 191 U32 num_bytes_allocated; 192 193 U32 current_context; 194 LAScontextRGBNIR14 contexts[4]; 195 196 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 197 }; 198 199 class LASreadItemCompressed_WAVEPACKET14_v3 : public LASreadItemCompressed 200 { 201 public: 202 203 LASreadItemCompressed_WAVEPACKET14_v3(ArithmeticDecoder* dec, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 204 205 BOOL chunk_sizes(); 206 BOOL init(const U8* item, U32& context); // context is only read 207 void read(U8* item, U32& context); // context is only read 208 209 ~LASreadItemCompressed_WAVEPACKET14_v3(); 210 211 private: 212 213 /* not used as a decoder. just gives access to instream */ 214 215 ArithmeticDecoder* dec; 216 217 ByteStreamInArray* instream_wavepacket; 218 219 ArithmeticDecoder* dec_wavepacket; 220 221 BOOL changed_wavepacket; 222 223 U32 num_bytes_wavepacket; 224 225 BOOL requested_wavepacket; 226 227 U8* bytes; 228 U32 num_bytes_allocated; 229 230 U32 current_context; 231 LAScontextWAVEPACKET14 contexts[4]; 232 233 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 234 }; 235 236 class LASreadItemCompressed_BYTE14_v3 : public LASreadItemCompressed 237 { 238 public: 239 240 LASreadItemCompressed_BYTE14_v3(ArithmeticDecoder* dec, U32 number, const U32 decompress_selective=LASZIP_DECOMPRESS_SELECTIVE_ALL); 241 242 BOOL chunk_sizes(); 243 BOOL init(const U8* item, U32& context); // context is only read 244 void read(U8* item, U32& context); // context is only read 245 246 ~LASreadItemCompressed_BYTE14_v3(); 247 248 private: 249 250 /* not used as a decoder. just gives access to instream */ 251 252 ArithmeticDecoder* dec; 253 254 ByteStreamInArray** instream_Bytes; 255 256 ArithmeticDecoder** dec_Bytes; 257 258 U32* num_bytes_Bytes; 259 260 BOOL* changed_Bytes; 261 262 BOOL* requested_Bytes; 263 264 U8* bytes; 265 U32 num_bytes_allocated; 266 267 U32 current_context; 268 LAScontextBYTE14 contexts[4]; 269 270 U32 number; 271 BOOL createAndInitModelsAndDecompressors(U32 context, const U8* item); 272 }; 273 274 #endif 275