MCPcopy Create free account
hub / github.com/LAStools/LAStools / pack

Method pack

LASzip/src/laszip.cpp:142–186  ·  view source on GitHub ↗

pack to VLR data

Source from the content-addressed store, hash-verified

140
141// pack to VLR data
142bool LASzip::pack(U8*& bytes, I32& num)
143{
144 // check if we support the contents
145 if (!check()) return false;
146
147 // prepare output
148 num = 34 + 6*num_items;
149 if (this->bytes) delete [] this->bytes;
150 this->bytes = bytes = new U8[num];
151
152 // pack
153 U16 i;
154 U8* b = bytes;
155 *((U16*)b) = compressor;
156 b += 2;
157 *((U16*)b) = coder;
158 b += 2;
159 *((U8*)b) = version_major;
160 b += 1;
161 *((U8*)b) = version_minor;
162 b += 1;
163 *((U16*)b) = version_revision;
164 b += 2;
165 *((U32*)b) = options;
166 b += 4;
167 *((U32*)b) = chunk_size;
168 b += 4;
169 *((I64*)b) = number_of_special_evlrs;
170 b += 8;
171 *((I64*)b) = offset_to_special_evlrs;
172 b += 8;
173 *((U16*)b) = num_items;
174 b += 2;
175 for (i = 0; i < num_items; i++)
176 {
177 *((U16*)b) = (U16)items[i].type;
178 b += 2;
179 *((U16*)b) = items[i].size;
180 b += 2;
181 *((U16*)b) = items[i].version;
182 b += 2;
183 }
184 assert((bytes + num) == b);
185 return true;
186}
187
188const char* LASzip::get_error() const
189{

Callers 4

run_testFunction · 0.45
readMethod · 0.45
readMethod · 0.45
readMethod · 0.45

Calls 1

checkFunction · 0.85

Tested by 1

run_testFunction · 0.36