1 /* 2 =============================================================================== 3 4 FILE: laswriteitemcompressed_v4.hpp 5 6 CONTENTS: 7 8 Native extension for compressing 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 22 August 2016 -- finalizing at Basecamp in Bonn during FOSS4g hackfest 30 23 February 2016 -- created at OSGeo Code Sprint in Paris to prototype 31 32 =============================================================================== 33 */ 34 #ifndef LAS_WRITE_ITEM_COMPRESSED_V4_HPP 35 #define LAS_WRITE_ITEM_COMPRESSED_V4_HPP 36 37 #include "laswriteitem.hpp" 38 #include "arithmeticencoder.hpp" 39 #include "integercompressor.hpp" 40 #include "bytestreamout_array.hpp" 41 42 #include "laszip_common_v3.hpp" 43 44 class LASwriteItemCompressed_POINT14_v4 : public LASwriteItemCompressed 45 { 46 public: 47 48 LASwriteItemCompressed_POINT14_v4(ArithmeticEncoder* enc); 49 50 BOOL init(const U8* item, U32& context); 51 BOOL write(const U8* item, U32& context); 52 BOOL chunk_sizes(); 53 BOOL chunk_bytes(); 54 55 ~LASwriteItemCompressed_POINT14_v4(); 56 57 private: 58 59 /* not used as a encoder. just gives access to outstream */ 60 61 ArithmeticEncoder* enc; 62 63 ByteStreamOutArray* outstream_channel_returns_XY; 64 ByteStreamOutArray* outstream_Z; 65 ByteStreamOutArray* outstream_classification; 66 ByteStreamOutArray* outstream_flags; 67 ByteStreamOutArray* outstream_intensity; 68 ByteStreamOutArray* outstream_scan_angle; 69 ByteStreamOutArray* outstream_user_data; 70 ByteStreamOutArray* outstream_point_source; 71 ByteStreamOutArray* outstream_gps_time; 72 73 ArithmeticEncoder* enc_channel_returns_XY; 74 ArithmeticEncoder* enc_Z; 75 ArithmeticEncoder* enc_classification; 76 ArithmeticEncoder* enc_flags; 77 ArithmeticEncoder* enc_intensity; 78 ArithmeticEncoder* enc_scan_angle; 79 ArithmeticEncoder* enc_user_data; 80 ArithmeticEncoder* enc_point_source; 81 ArithmeticEncoder* enc_gps_time; 82 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 U32 current_context; 102 LAScontextPOINT14 contexts[4]; 103 104 BOOL createAndInitModelsAndCompressors(U32 context, const U8* item); 105 void write_gps_time(const U64I64F64 gps_time); 106 }; 107 108 class LASwriteItemCompressed_RGB14_v4 : public LASwriteItemCompressed 109 { 110 public: 111 112 LASwriteItemCompressed_RGB14_v4(ArithmeticEncoder* enc); 113 114 BOOL init(const U8* item, U32& context); 115 BOOL write(const U8* item, U32& context); 116 BOOL chunk_sizes(); 117 BOOL chunk_bytes(); 118 119 ~LASwriteItemCompressed_RGB14_v4(); 120 121 private: 122 123 /* not used as a encoder. just gives access to outstream */ 124 125 ArithmeticEncoder* enc; 126 127 ByteStreamOutArray* outstream_RGB; 128 129 ArithmeticEncoder* enc_RGB; 130 131 BOOL changed_RGB; 132 133 U32 num_bytes_RGB; 134 135 U32 current_context; 136 LAScontextRGB14 contexts[4]; 137 138 BOOL createAndInitModelsAndCompressors(U32 context, const U8* item); 139 }; 140 141 class LASwriteItemCompressed_RGBNIR14_v4 : public LASwriteItemCompressed 142 { 143 public: 144 145 LASwriteItemCompressed_RGBNIR14_v4(ArithmeticEncoder* enc); 146 147 BOOL init(const U8* item, U32& context); 148 BOOL write(const U8* item, U32& context); 149 BOOL chunk_sizes(); 150 BOOL chunk_bytes(); 151 152 ~LASwriteItemCompressed_RGBNIR14_v4(); 153 154 private: 155 156 /* not used as a encoder. just gives access to outstream */ 157 158 ArithmeticEncoder* enc; 159 160 ByteStreamOutArray* outstream_RGB; 161 ByteStreamOutArray* outstream_NIR; 162 163 ArithmeticEncoder* enc_RGB; 164 ArithmeticEncoder* enc_NIR; 165 166 BOOL changed_RGB; 167 BOOL changed_NIR; 168 169 U32 num_bytes_RGB; 170 U32 num_bytes_NIR; 171 172 U32 current_context; 173 LAScontextRGBNIR14 contexts[4]; 174 175 BOOL createAndInitModelsAndCompressors(U32 context, const U8* item); 176 }; 177 178 class LASwriteItemCompressed_WAVEPACKET14_v4 : public LASwriteItemCompressed 179 { 180 public: 181 182 LASwriteItemCompressed_WAVEPACKET14_v4(ArithmeticEncoder* enc); 183 184 BOOL init(const U8* item, U32& context); 185 BOOL write(const U8* item, U32& context); 186 BOOL chunk_sizes(); 187 BOOL chunk_bytes(); 188 189 ~LASwriteItemCompressed_WAVEPACKET14_v4(); 190 191 private: 192 193 /* not used as a encoder. just gives access to outstream */ 194 195 ArithmeticEncoder* enc; 196 197 ByteStreamOutArray* outstream_wavepacket; 198 199 ArithmeticEncoder* enc_wavepacket; 200 201 BOOL changed_wavepacket; 202 203 U32 num_bytes_wavepacket; 204 205 U32 current_context; 206 LAScontextWAVEPACKET14 contexts[4]; 207 208 BOOL createAndInitModelsAndCompressors(U32 context, const U8* item); 209 }; 210 211 class LASwriteItemCompressed_BYTE14_v4 : public LASwriteItemCompressed 212 { 213 public: 214 215 LASwriteItemCompressed_BYTE14_v4(ArithmeticEncoder* enc, U32 number); 216 217 BOOL init(const U8* item, U32& context); 218 BOOL write(const U8* item, U32& context); 219 BOOL chunk_sizes(); 220 BOOL chunk_bytes(); 221 222 ~LASwriteItemCompressed_BYTE14_v4(); 223 224 private: 225 226 /* not used as a encoder. just gives access to outstream */ 227 228 ArithmeticEncoder* enc; 229 230 ByteStreamOutArray** outstream_Bytes; 231 232 ArithmeticEncoder** enc_Bytes; 233 234 U32* num_bytes_Bytes; 235 236 BOOL* changed_Bytes; 237 238 U32 current_context; 239 LAScontextBYTE14 contexts[4]; 240 241 U32 number; 242 BOOL createAndInitModelsAndCompressors(U32 context, const U8* item); 243 }; 244 245 #endif 246