1 /*
2 ===============================================================================
3 
4   FILE:  lasreaditemcompressed_v2.hpp
5 
6   CONTENTS:
7 
8     Implementation of LASitemReadCompressed for *all* items (version 2).
9 
10   PROGRAMMERS:
11 
12     martin.isenburg@rapidlasso.com  -  http://rapidlasso.com
13 
14   COPYRIGHT:
15 
16     (c) 2007-2014, 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     6 September 2014 -- removed inheritance of EntropyEncoder and EntropyDecoder
29     5 March 2011 -- created first night in ibiza to improve the RGB compressor
30 
31 ===============================================================================
32 */
33 #ifndef LAS_READ_ITEM_COMPRESSED_V2_HPP
34 #define LAS_READ_ITEM_COMPRESSED_V2_HPP
35 
36 #include "lasreaditem.hpp"
37 #include "arithmeticdecoder.hpp"
38 #include "integercompressor.hpp"
39 
40 #include "laszip_common_v2.hpp"
41 
42 class LASreadItemCompressed_POINT10_v2 : public LASreadItemCompressed
43 {
44 public:
45 
46   LASreadItemCompressed_POINT10_v2(ArithmeticDecoder* dec);
47 
48   BOOL init(const U8* item, U32& context); // context is unused
49   void read(U8* item, U32& context);       // context is unused
50 
51   ~LASreadItemCompressed_POINT10_v2();
52 
53 private:
54   ArithmeticDecoder* dec;
55   U8 last_item[20];
56   U16 last_intensity[16];
57   StreamingMedian5 last_x_diff_median5[16];
58   StreamingMedian5 last_y_diff_median5[16];
59   I32 last_height[8];
60 
61   ArithmeticModel* m_changed_values;
62   IntegerCompressor* ic_intensity;
63   ArithmeticModel* m_scan_angle_rank[2];
64   IntegerCompressor* ic_point_source_ID;
65   ArithmeticModel* m_bit_byte[256];
66   ArithmeticModel* m_classification[256];
67   ArithmeticModel* m_user_data[256];
68   IntegerCompressor* ic_dx;
69   IntegerCompressor* ic_dy;
70   IntegerCompressor* ic_z;
71 };
72 
73 class LASreadItemCompressed_GPSTIME11_v2 : public LASreadItemCompressed
74 {
75 public:
76 
77   LASreadItemCompressed_GPSTIME11_v2(ArithmeticDecoder* dec);
78 
79   BOOL init(const U8* item, U32& context); // context is unused
80   void read(U8* item, U32& context);       // context is unused
81 
82   ~LASreadItemCompressed_GPSTIME11_v2();
83 
84 private:
85   ArithmeticDecoder* dec;
86   U32 last, next;
87   U64I64F64 last_gpstime[4];
88   I32 last_gpstime_diff[4];
89   I32 multi_extreme_counter[4];
90 
91   ArithmeticModel* m_gpstime_multi;
92   ArithmeticModel* m_gpstime_0diff;
93   IntegerCompressor* ic_gpstime;
94 };
95 
96 class LASreadItemCompressed_RGB12_v2 : public LASreadItemCompressed
97 {
98 public:
99 
100   LASreadItemCompressed_RGB12_v2(ArithmeticDecoder* dec);
101 
102   BOOL init(const U8* item, U32& context); // context is unused
103   void read(U8* item, U32& context);       // context is unused
104 
105   ~LASreadItemCompressed_RGB12_v2();
106 
107 private:
108   ArithmeticDecoder* dec;
109   U16 last_item[3];
110 
111   ArithmeticModel* m_byte_used;
112   ArithmeticModel* m_rgb_diff_0;
113   ArithmeticModel* m_rgb_diff_1;
114   ArithmeticModel* m_rgb_diff_2;
115   ArithmeticModel* m_rgb_diff_3;
116   ArithmeticModel* m_rgb_diff_4;
117   ArithmeticModel* m_rgb_diff_5;
118 };
119 
120 class LASreadItemCompressed_BYTE_v2 : public LASreadItemCompressed
121 {
122 public:
123 
124   LASreadItemCompressed_BYTE_v2(ArithmeticDecoder* dec, U32 number);
125 
126   BOOL init(const U8* item, U32& context); // context is unused
127   void read(U8* item, U32& context);       // context is unused
128 
129   ~LASreadItemCompressed_BYTE_v2();
130 
131 private:
132   ArithmeticDecoder* dec;
133   U32 number;
134   U8* last_item;
135 
136   ArithmeticModel** m_byte;
137 };
138 
139 #endif
140