75 for (i = 0; i < 256; i++)
78 m_classification[i] = 0;
90 delete ic_scan_angle_rank;
91 delete ic_point_source_ID;
92 enc->destroySymbolModel(m_changed_values);
93 for (i = 0; i < 256; i++)
95 if (m_bit_byte[i]) enc->destroySymbolModel(m_bit_byte[i]);
96 if (m_classification[i]) enc->destroySymbolModel(m_classification[i]);
97 if (m_user_data[i]) enc->destroySymbolModel(m_user_data[i]);
106 last_x_diff[0] = last_x_diff[1] = last_x_diff[2] = 0;
107 last_y_diff[0] = last_y_diff[1] = last_y_diff[2] = 0;
111 ic_dx->initCompressor();
112 ic_dy->initCompressor();
113 ic_z->initCompressor();
114 ic_intensity->initCompressor();
115 ic_scan_angle_rank->initCompressor();
116 ic_point_source_ID->initCompressor();
117 enc->initSymbolModel(m_changed_values);
118 for (i = 0; i < 256; i++)
120 if (m_bit_byte[i]) enc->initSymbolModel(m_bit_byte[i]);
121 if (m_classification[i]) enc->initSymbolModel(m_classification[i]);
122 if (m_user_data[i]) enc->initSymbolModel(m_user_data[i]);
126 memcpy(last_item, item, 20);
135 if (last_x_diff[0] < last_x_diff[1])
137 if (last_x_diff[1] < last_x_diff[2])
138 median_x = last_x_diff[1];
139 else if (last_x_diff[0] < last_x_diff[2])
140 median_x = last_x_diff[2];
142 median_x = last_x_diff[0];
146 if (last_x_diff[0] < last_x_diff[2])
147 median_x = last_x_diff[0];
148 else if (last_x_diff[1] < last_x_diff[2])
149 median_x = last_x_diff[2];
151 median_x = last_x_diff[1];
155 if (last_y_diff[0] < last_y_diff[1])
157 if (last_y_diff[1] < last_y_diff[2])
158 median_y = last_y_diff[1];
159 else if (last_y_diff[0] < last_y_diff[2])
160 median_y = last_y_diff[2];
162 median_y = last_y_diff[0];
166 if (last_y_diff[0] < last_y_diff[2])
167 median_y = last_y_diff[0];
168 else if (last_y_diff[1] < last_y_diff[2])
169 median_y = last_y_diff[2];
171 median_y = last_y_diff[1];
178 ic_dx->compress(median_x, x_diff);
180 U32 k_bits = ic_dx->getK();
181 ic_dy->compress(median_y, y_diff, (k_bits < 19 ? k_bits : 19));
182 k_bits = (k_bits + ic_dy->getK()) / 2;
187 ((last_item[14] != item[14]) << 4) |
188 ((last_item[15] != item[15]) << 3) |
189 ((last_item[16] != item[16]) << 2) |
190 ((last_item[17] != item[17]) << 1) |
193 enc->encodeSymbol(m_changed_values, changed_values);
196 if (changed_values & 32)
202 if (changed_values & 16)
204 if (m_bit_byte[last_item[14]] == 0)
206 m_bit_byte[last_item[14]] = enc->createSymbolModel(256);
207 enc->initSymbolModel(m_bit_byte[last_item[14]]);
209 enc->encodeSymbol(m_bit_byte[last_item[14]], item[14]);
213 if (changed_values & 8)
215 if (m_classification[last_item[15]] == 0)
217 m_classification[last_item[15]] = enc->createSymbolModel(256);
218 enc->initSymbolModel(m_classification[last_item[15]]);
220 enc->encodeSymbol(m_classification[last_item[15]], item[15]);
224 if (changed_values & 4)
226 ic_scan_angle_rank->compress(last_item[16], item[16], k_bits < 3);
230 if (changed_values & 2)
232 if (m_user_data[last_item[17]] == 0)
234 m_user_data[last_item[17]] = enc->createSymbolModel(256);
235 enc->initSymbolModel(m_user_data[last_item[17]]);
237 enc->encodeSymbol(m_user_data[last_item[17]], item[17]);
241 if (changed_values & 1)
247 last_x_diff[last_incr] = x_diff;
248 last_y_diff[last_incr] = y_diff;
250 if (last_incr > 2) last_incr = 0;
253 memcpy(last_item, item, 20);
263 #define LASZIP_GPSTIME_MULTIMAX 512 278 enc->destroySymbolModel(m_gpstime_multi);
279 enc->destroySymbolModel(m_gpstime_0diff);
286 last_gpstime_diff = 0;
287 multi_extreme_counter = 0;
290 enc->initSymbolModel(m_gpstime_multi);
291 enc->initSymbolModel(m_gpstime_0diff);
292 ic_gpstime->initCompressor();
295 last_gpstime.u64 = *((
U64*)item);
302 this_gpstime.
i64 = *((
I64*)item);
304 if (last_gpstime_diff == 0)
306 if (this_gpstime.
i64 == last_gpstime.i64)
308 enc->encodeSymbol(m_gpstime_0diff, 0);
313 I64 curr_gpstime_diff_64 = this_gpstime.
i64 - last_gpstime.i64;
314 I32 curr_gpstime_diff = (
I32)curr_gpstime_diff_64;
315 if (curr_gpstime_diff_64 == (
I64)(curr_gpstime_diff))
317 enc->encodeSymbol(m_gpstime_0diff, 1);
318 ic_gpstime->compress(0, curr_gpstime_diff, 0);
319 last_gpstime_diff = curr_gpstime_diff;
323 enc->encodeSymbol(m_gpstime_0diff, 2);
324 enc->writeInt64(this_gpstime.
u64);
326 last_gpstime.i64 = this_gpstime.
i64;
331 if (this_gpstime.
i64 == last_gpstime.i64)
339 I64 curr_gpstime_diff_64 = this_gpstime.
i64 - last_gpstime.i64;
340 I32 curr_gpstime_diff = (
I32)curr_gpstime_diff_64;
342 if (curr_gpstime_diff_64 == (
I64)(curr_gpstime_diff))
345 I32 multi = (
I32)(((
F32)curr_gpstime_diff / (
F32)last_gpstime_diff) + 0.5f);
357 enc->encodeSymbol(m_gpstime_multi, multi);
362 ic_gpstime->compress(last_gpstime_diff, curr_gpstime_diff, 1);
363 last_gpstime_diff = curr_gpstime_diff;
364 multi_extreme_counter = 0;
370 ic_gpstime->compress(last_gpstime_diff/4, curr_gpstime_diff, 2);
371 multi_extreme_counter++;
372 if (multi_extreme_counter > 3)
374 last_gpstime_diff = curr_gpstime_diff;
375 multi_extreme_counter = 0;
380 ic_gpstime->compress(multi*last_gpstime_diff, curr_gpstime_diff, 3);
384 ic_gpstime->compress(multi*last_gpstime_diff, curr_gpstime_diff, 4);
388 ic_gpstime->compress(multi*last_gpstime_diff, curr_gpstime_diff, 5);
391 multi_extreme_counter++;
392 if (multi_extreme_counter > 3)
394 last_gpstime_diff = curr_gpstime_diff;
395 multi_extreme_counter = 0;
405 enc->writeInt64(this_gpstime.
u64);
407 last_gpstime.i64 = this_gpstime.
i64;
430 last_item =
new U8[6];
435 enc->destroySymbolModel(m_byte_used);
445 enc->initSymbolModel(m_byte_used);
446 ic_rgb->initCompressor();
449 memcpy(last_item, item, 6);
455 U32 sym = ((((
U16*)last_item)[0]&0x00FF) != (((
U16*)item)[0]&0x00FF)) << 0;
456 sym |= ((((
U16*)last_item)[0]&0xFF00) != (((
U16*)item)[0]&0xFF00)) << 1;
457 sym |= ((((
U16*)last_item)[1]&0x00FF) != (((
U16*)item)[1]&0x00FF)) << 2;
458 sym |= ((((
U16*)last_item)[1]&0xFF00) != (((
U16*)item)[1]&0xFF00)) << 3;
459 sym |= ((((
U16*)last_item)[2]&0x00FF) != (((
U16*)item)[2]&0x00FF)) << 4;
460 sym |= ((((
U16*)last_item)[2]&0xFF00) != (((
U16*)item)[2]&0xFF00)) << 5;
461 enc->encodeSymbol(m_byte_used, sym);
462 if (sym & (1 << 0)) ic_rgb->compress(((
U16*)last_item)[0]&255,((
U16*)item)[0]&255, 0);
463 if (sym & (1 << 1)) ic_rgb->compress(((
U16*)last_item)[0]>>8,((
U16*)item)[0]>>8, 1);
464 if (sym & (1 << 2)) ic_rgb->compress(((
U16*)last_item)[1]&255,((
U16*)item)[1]&255, 2);
465 if (sym & (1 << 3)) ic_rgb->compress(((
U16*)last_item)[1]>>8,((
U16*)item)[1]>>8, 3);
466 if (sym & (1 << 4)) ic_rgb->compress(((
U16*)last_item)[2]&255,((
U16*)item)[2]&255, 4);
467 if (sym & (1 << 5)) ic_rgb->compress(((
U16*)last_item)[2]>>8,((
U16*)item)[2]>>8, 5);
468 memcpy(last_item, item, 6);
506 last_item =
new U8[28];
511 enc->destroySymbolModel(m_packet_index);
512 enc->destroySymbolModel(m_offset_diff[0]);
513 enc->destroySymbolModel(m_offset_diff[1]);
514 enc->destroySymbolModel(m_offset_diff[2]);
515 enc->destroySymbolModel(m_offset_diff[3]);
516 delete ic_offset_diff;
517 delete ic_packet_size;
518 delete ic_return_point;
527 sym_last_offset_diff = 0;
530 enc->initSymbolModel(m_packet_index);
531 enc->initSymbolModel(m_offset_diff[0]);
532 enc->initSymbolModel(m_offset_diff[1]);
533 enc->initSymbolModel(m_offset_diff[2]);
534 enc->initSymbolModel(m_offset_diff[3]);
535 ic_offset_diff->initCompressor();
536 ic_packet_size->initCompressor();
537 ic_return_point->initCompressor();
538 ic_xyz->initCompressor();
542 memcpy(last_item, item, 28);
548 enc->encodeSymbol(m_packet_index, (
U32)(item[0]));
553 I32 curr_diff_32 = (
I32)curr_diff_64;
555 if (curr_diff_64 == (
I64)(curr_diff_32))
557 if (curr_diff_32 == 0)
559 enc->encodeSymbol(m_offset_diff[sym_last_offset_diff], 0);
560 sym_last_offset_diff = 0;
564 enc->encodeSymbol(m_offset_diff[sym_last_offset_diff], 1);
565 sym_last_offset_diff = 1;
569 enc->encodeSymbol(m_offset_diff[sym_last_offset_diff], 2);
570 sym_last_offset_diff = 2;
571 ic_offset_diff->compress(last_diff_32, curr_diff_32);
572 last_diff_32 = curr_diff_32;
577 enc->encodeSymbol(m_offset_diff[sym_last_offset_diff], 3);
578 sym_last_offset_diff = 3;
586 memcpy(last_item, item, 28);
602 this->number = number;
608 last_item =
new U8[number];
622 ic_byte->initCompressor();
625 memcpy(last_item, item, number);
632 for (i = 0; i < number; i++)
634 ic_byte->compress(last_item[i], item[i], i);
636 memcpy(last_item, item, number);
BOOL init(const U8 *item)
#define LASZIP_GPSTIME_MULTIMAX
~LASwriteItemCompressed_RGB12_v1()
BOOL init(const U8 *item)
~LASwriteItemCompressed_BYTE_v1()
U8 number_of_returns_of_given_pulse
BOOL write(const U8 *item)
BOOL init(const U8 *item)
~LASwriteItemCompressed_POINT10_v1()
LASwriteItemCompressed_POINT10_v1(EntropyEncoder *enc)
LASwriteItemCompressed_BYTE_v1(EntropyEncoder *enc, U32 number)
~LASwriteItemCompressed_GPSTIME11_v1()
LASwriteItemCompressed_RGB12_v1(EntropyEncoder *enc)
BOOL write(const U8 *item)
BOOL write(const U8 *item)
LASwriteItemCompressed_GPSTIME11_v1(EntropyEncoder *enc)
virtual EntropyModel * createSymbolModel(U32 n)=0
~LASwriteItemCompressed_WAVEPACKET13_v1()
BOOL init(const U8 *item)
BOOL init(const U8 *item)
BOOL write(const U8 *item)
BOOL write(const U8 *item)
LASwriteItemCompressed_WAVEPACKET13_v1(EntropyEncoder *enc)