MCPcopy Create free account
hub / github.com/LASzip/LASzip / unpack

Method unpack

src/laszip.cpp:86–139  ·  view source on GitHub ↗

unpack from VLR data

Source from the content-addressed store, hash-verified

84
85// unpack from VLR data
86bool LASzip::unpack(const U8* bytes, const I32 num)
87{
88 // check input
89 if (num < 34) return return_error("too few bytes to unpack");
90 if (((num - 34) % 6) != 0) return return_error("wrong number bytes to unpack");
91 if (((num - 34) / 6) == 0) return return_error("zero items to unpack");
92 num_items = (num - 34) / 6;
93
94 // create item list
95 if (items) delete [] items;
96 items = new LASitem[num_items];
97
98 // do the unpacking
99 U16 i;
100 const U8* b = bytes;
101 compressor = *((const U16*)b);
102 b += 2;
103 coder = *((const U16*)b);
104 b += 2;
105 version_major = *((const U8*)b);
106 b += 1;
107 version_minor = *((const U8*)b);
108 b += 1;
109 version_revision = *((const U16*)b);
110 b += 2;
111 options = *((const U32*)b);
112 b += 4;
113 chunk_size = *((const U32*)b);
114 b += 4;
115 number_of_special_evlrs = *((const I64*)b);
116 b += 8;
117 offset_to_special_evlrs = *((const I64*)b);
118 b += 8;
119 num_items = *((const U16*)b);
120 b += 2;
121 for (i = 0; i < num_items; i++)
122 {
123 items[i].type = (LASitem::Type)*((const U16*)b);
124 b += 2;
125 items[i].size = *((const U16*)b);
126 b += 2;
127 items[i].version = *((const U16*)b);
128 b += 2;
129 }
130 assert((bytes + num) == b);
131
132 // check if we support the contents
133
134 for (i = 0; i < num_items; i++)
135 {
136 if (!check_item(&items[i])) return false;
137 }
138 return true;
139}
140
141// pack to VLR data
142bool LASzip::pack(U8*& bytes, I32& num)

Callers 1

run_testFunction · 0.45

Calls

no outgoing calls

Tested by 1

run_testFunction · 0.36