lz4s.c
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, Ben Charrow
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of Willow Garage, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 ********************************************************************/
34 
35 #include "roslz4/lz4s.h"
36 
37 #include "xxhash.h"
38 
39 #include <stdint.h>
40 #include <string.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 
44 #if 0
45 #define DEBUG(...) fprintf(stderr, __VA_ARGS__)
46 #else
47 #define DEBUG(...)
48 #endif
49 
50 // magic numbers
51 const uint32_t kMagicNumber = 0x184D2204;
52 const uint32_t kEndOfStream = 0x00000000;
53 
54 // Bitmasks
55 const uint8_t k1Bits = 0x01;
56 const uint8_t k2Bits = 0x03;
57 const uint8_t k3Bits = 0x07;
58 const uint8_t k4Bits = 0x0F;
59 const uint8_t k8Bits = 0xFF;
60 
61 uint32_t readUInt32(unsigned char *buffer) {
62  return ((buffer[0] << 0) | (buffer[1] << 8) |
63  (buffer[2] << 16) | (buffer[3] << 24));
64 }
65 
66 void writeUInt32(unsigned char *buffer, uint32_t val) {
67  buffer[0] = val & 0xFF;
68  buffer[1] = (val >> 8) & 0xFF;
69  buffer[2] = (val >> 16) & 0xFF;
70  buffer[3] = (val >> 24) & 0xFF;
71 }
72 #undef min
73 int min(int a, int b) {
74  return a < b ? a : b;
75 }
76 
77 /*========================== Low level compression ==========================*/
78 
79 typedef struct {
83 
84  char *buffer;
87 
88  int finished; // 1 if done compressing/decompressing; 0 otherwise
89 
90  void* xxh32_state;
91 
92  // Compression state
94 
95  // Decompression state
96  char header[10];
97  uint32_t block_size; // Size of current block
98  int block_size_read; // # of bytes read for current block_size
99  int block_uncompressed; // 1 if block is uncompressed, 0 otherwise
100  uint32_t stream_checksum; // Storage for checksum
101  int stream_checksum_read; // # of bytes read for stream_checksum
102 } stream_state;
103 
104 void advanceInput(roslz4_stream *str, int nbytes) {
105  str->input_next += nbytes;
106  str->input_left -= nbytes;
107  str->total_in += nbytes;
108 }
109 
110 void advanceOutput(roslz4_stream *str, int nbytes) {
111  str->output_next += nbytes;
112  str->output_left -= nbytes;
113  str->total_out += nbytes;
114 }
115 
116 void fillUInt32(roslz4_stream *str, uint32_t *dest_val, int *offset) {
117  char *dest = (char*) dest_val;
118  int to_copy = min(4 - *offset, str->input_left);
119  memcpy(dest + *offset, str->input_next, to_copy);
120  advanceInput(str, to_copy);
121  *offset += to_copy;
122 }
123 
125  if (str->output_left < 7) {
126  return ROSLZ4_OUTPUT_SMALL; // Output must have 7 bytes
127  }
128 
129  stream_state *state = str->state;
130  writeUInt32((unsigned char*) str->output_next, kMagicNumber);
131  int version = 1;
132  char *out = str->output_next;
133  *(out+4) = ((unsigned)version & k2Bits) << 6;
134  *(out+4) |= ((unsigned)state->block_independence_flag & k1Bits) << 5;
135  *(out+4) |= ((unsigned)state->block_checksum_flag & k1Bits) << 4;
136  *(out+4) |= ((unsigned)state->stream_checksum_flag & k1Bits) << 2;
137  *(out+5) = ((unsigned)str->block_size_id & k3Bits) << 4;
138 
139  // Checksum: 2nd byte of hash of header flags
140  unsigned char checksum = (XXH32(str->output_next + 4, 2, 0) >> 8) & k8Bits;
141  *(str->output_next+6) = checksum;
142 
143  advanceOutput(str, 7);
144  DEBUG("writeHeader() Put 7 bytes in output\n");
145 
146  return ROSLZ4_OK;
147 }
148 
150  if (str->output_left < 8) {
151  return ROSLZ4_OUTPUT_SMALL;
152  }
153 
154  stream_state *state = str->state;
155  state->finished = 1;
156  writeUInt32((unsigned char*) str->output_next, kEndOfStream);
157  advanceOutput(str, 4);
158 
159  uint32_t stream_checksum = XXH32_digest(state->xxh32_state);
160  writeUInt32((unsigned char*) str->output_next, stream_checksum);
161  advanceOutput(str, 4);
162  state->xxh32_state = NULL;
163 
164  DEBUG("writeEOS() Wrote 8 bytes to output %i\n", str->output_left);
165  return ROSLZ4_STREAM_END;
166 }
167 
168 // If successfull, number of bytes written to output
169 // If error, LZ4 return code
171  stream_state *state = str->state;
172  int uncomp_size = state->buffer_offset;
173  if (state->buffer_offset == 0) {
174  return 0; // No data to flush
175  } else if (str->output_left - 4 < uncomp_size) {
176  DEBUG("bufferToOutput() Not enough space left in output\n");
177  return ROSLZ4_OUTPUT_SMALL;
178  }
179 
180  DEBUG("bufferToOutput() Flushing %i bytes, %i left in output\n",
181  state->buffer_offset, str->output_left);
182 
183  // Shrink output by 1 to detect if data is not compressible
184  uint32_t comp_size = LZ4_compress_default(state->buffer,
185  str->output_next + 4,
186  state->buffer_offset,
187  uncomp_size - 1);
188  uint32_t wrote;
189  if (comp_size > 0) {
190  DEBUG("bufferToOutput() Compressed to %i bytes\n", comp_size);
191  // Write compressed data size
192  wrote = 4 + comp_size;
193  writeUInt32((unsigned char*)str->output_next, comp_size);
194  } else {
195  // Write uncompressed data
196  DEBUG("bufferToOutput() Can't compress, copying input\n");
197  memcpy(str->output_next + 4, state->buffer, uncomp_size);
198  // Write uncompressed data size. Signal data is uncompressed with high
199  // order bit; won't confuse decompression because max block size is < 2GB
200  wrote = 4 + uncomp_size;
201  writeUInt32((unsigned char*) str->output_next, uncomp_size | 0x80000000);
202  }
203 
204  advanceOutput(str, wrote);
205  state->buffer_offset -= uncomp_size;
206 
207  DEBUG("bufferToOutput() Ate %i from buffer, wrote %i to output (%i)\n",
208  uncomp_size, wrote, str->output_left);
209  return wrote;
210 }
211 
212 // Copy as much data as possible from input to internal buffer
213 // Return number of bytes written if successful, LZ4 error code on error
215  stream_state *state = str->state;
216  if (str->input_left == 0 ||
217  state->buffer_size == state->buffer_offset) {
218  return 0;
219  }
220  int buffer_left = state->buffer_size - state->buffer_offset;
221  int to_copy = min(str->input_left, buffer_left);
222 
223  int ret = XXH32_update(state->xxh32_state, str->input_next, to_copy);
224  if (ret == XXH_ERROR) { return ROSLZ4_ERROR; }
225 
226  memcpy(state->buffer + state->buffer_offset, str->input_next, to_copy);
227  advanceInput(str, to_copy);
228  state->buffer_offset += to_copy;
229 
230  DEBUG("inputToBuffer() Wrote % 5i bytes to buffer (size=% 5i)\n",
231  to_copy, state->buffer_offset);
232  return to_copy;
233 }
234 
236  stream_state *state = (stream_state*) malloc(sizeof(stream_state));
237  if (state == NULL) {
238  return ROSLZ4_MEMORY_ERROR; // Allocation of state failed
239  }
240  str->state = state;
241 
242  str->block_size_id = -1;
243  state->block_independence_flag = 1;
244  state->block_checksum_flag = 0;
245  state->stream_checksum_flag = 1;
246 
247  state->finished = 0;
248 
249  state->xxh32_state = XXH32_init(0);
250  state->stream_checksum = 0;
251  state->stream_checksum_read = 0;
252 
253  state->wrote_header = 0;
254 
255  state->buffer_offset = 0;
256  state->buffer_size = 0;
257  state->buffer = NULL;
258 
259  state->block_size = 0;
260  state->block_size_read = 0;
261  state->block_uncompressed = 0;
262 
263  str->total_in = 0;
264  str->total_out = 0;
265 
266  return ROSLZ4_OK;
267 }
268 
269 int streamResizeBuffer(roslz4_stream *str, int block_size_id) {
270  stream_state *state = str->state;
271  if (!(4 <= block_size_id && block_size_id <= 7)) {
272  return ROSLZ4_PARAM_ERROR; // Invalid block size
273  }
274 
275  str->block_size_id = block_size_id;
276  state->buffer_offset = 0;
278  state->buffer = (char*) malloc(sizeof(char) * state->buffer_size);
279  if (state->buffer == NULL) {
280  return ROSLZ4_MEMORY_ERROR; // Allocation of buffer failed
281  }
282  return ROSLZ4_OK;
283 }
284 
286  stream_state *state = str->state;
287  if (state != NULL) {
288  if (state->buffer != NULL) {
289  free(state->buffer);
290  }
291  if (state->xxh32_state != NULL) {
292  XXH32_digest(state->xxh32_state);
293  }
294  free(state);
295  str->state = NULL;
296  }
297 }
298 
299 int roslz4_blockSizeFromIndex(int block_id) {
300  return (1 << (8 + (2 * block_id)));
301 }
302 
303 int roslz4_compressStart(roslz4_stream *str, int block_size_id) {
304  int ret = streamStateAlloc(str);
305  if (ret < 0) { return ret; }
306  return streamResizeBuffer(str, block_size_id);
307 }
308 
310  int ret;
311  stream_state *state = str->state;
312  if (action != ROSLZ4_RUN && action != ROSLZ4_FINISH) {
313  return ROSLZ4_PARAM_ERROR; // Unrecognized compression action
314  } else if (state->finished) {
315  return ROSLZ4_ERROR; // Cannot call action on finished stream
316  }
317 
318  if (!state->wrote_header) {
319  ret = writeHeader(str);
320  if (ret < 0) { return ret; }
321  state->wrote_header = 1;
322  }
323 
324  // Copy input to internal buffer, compressing when full or finishing stream
325  int read = 0, wrote = 0;
326  do {
327  read = inputToBuffer(str);
328  if (read < 0) { return read; }
329 
330  wrote = 0;
331  if (action == ROSLZ4_FINISH || state->buffer_offset == state->buffer_size) {
332  wrote = bufferToOutput(str);
333  if (wrote < 0) { return wrote; }
334  }
335  } while (read > 0 || wrote > 0);
336 
337  // Signal end of stream if finishing up, otherwise done
338  if (action == ROSLZ4_FINISH) {
339  return writeEOS(str);
340  } else {
341  return ROSLZ4_OK;
342  }
343 }
344 
346  streamStateFree(str);
347 }
348 
349 /*========================= Low level decompression =========================*/
350 
352  return streamStateAlloc(str);
353  // Can't allocate internal buffer, block size is unknown until header is read
354 }
355 
356 // Return 1 if header is present, 0 if more data is needed,
357 // LZ4 error code (< 0) if error
359  stream_state *state = str->state;
360  if (str->total_in >= 7) {
361  return 1;
362  }
363  // Populate header buffer
364  int to_copy = min(7 - str->total_in, str->input_left);
365  memcpy(state->header + str->total_in, str->input_next, to_copy);
366  advanceInput(str, to_copy);
367  if (str->total_in < 7) {
368  return 0;
369  }
370 
371  // Parse header buffer
372  unsigned char *header = (unsigned char*) state->header;
373  uint32_t magic_number = readUInt32(header);
374  if (magic_number != kMagicNumber) {
375  return ROSLZ4_DATA_ERROR; // Stream does not start with magic number
376  }
377  // Check descriptor flags
378  int version = (header[4] >> 6) & k2Bits;
379  int block_independence_flag = (header[4] >> 5) & k1Bits;
380  int block_checksum_flag = (header[4] >> 4) & k1Bits;
381  int stream_size_flag = (header[4] >> 3) & k1Bits;
382  int stream_checksum_flag = (header[4] >> 2) & k1Bits;
383  int reserved1 = (header[4] >> 1) & k1Bits;
384  int preset_dictionary_flag = (header[4] >> 0) & k1Bits;
385 
386  int reserved2 = (header[5] >> 7) & k1Bits;
387  int block_max_id = (header[5] >> 4) & k3Bits;
388  int reserved3 = (header[5] >> 0) & k4Bits;
389 
390  // LZ4 standard requirements
391  if (version != 1) {
392  return ROSLZ4_DATA_ERROR; // Wrong version number
393  }
394  if (reserved1 != 0 || reserved2 != 0 || reserved3 != 0) {
395  return ROSLZ4_DATA_ERROR; // Reserved bits must be 0
396  }
397  if (!(4 <= block_max_id && block_max_id <= 7)) {
398  return ROSLZ4_DATA_ERROR; // Invalid block size
399  }
400 
401  // Implementation requirements
402  if (stream_size_flag != 0) {
403  return ROSLZ4_DATA_ERROR; // Stream size not supported
404  }
405  if (preset_dictionary_flag != 0) {
406  return ROSLZ4_DATA_ERROR; // Dictionary not supported
407  }
408  if (block_independence_flag != 1) {
409  return ROSLZ4_DATA_ERROR; // Block dependence not supported
410  }
411  if (block_checksum_flag != 0) {
412  return ROSLZ4_DATA_ERROR; // Block checksums not supported
413  }
414  if (stream_checksum_flag != 1) {
415  return ROSLZ4_DATA_ERROR; // Must have stream checksum
416  }
417 
418  int header_checksum = (XXH32(header + 4, 2, 0) >> 8) & k8Bits;
419  int stored_header_checksum = (header[6] >> 0) & k8Bits;
420  if (header_checksum != stored_header_checksum) {
421  return ROSLZ4_DATA_ERROR; // Header checksum doesn't match
422  }
423 
424  int ret = streamResizeBuffer(str, block_max_id);
425  if (ret == ROSLZ4_OK) {
426  return 1;
427  } else {
428  return ret;
429  }
430 }
431 
432 // Read block size, return 1 if value is stored in state->block_size 0 otherwise
434  stream_state *state = str->state;
435  if (state->block_size_read < 4) {
436  fillUInt32(str, &state->block_size, &state->block_size_read);
437  if (state->block_size_read == 4) {
438  state->block_size = readUInt32((unsigned char*)&state->block_size);
439  state->block_uncompressed = ((unsigned)state->block_size >> 31) & k1Bits;
440  state->block_size &= 0x7FFFFFFF;
441  DEBUG("readBlockSize() Block size = %i uncompressed = %i\n",
442  state->block_size, state->block_uncompressed);
443  return 1;
444  } else {
445  return 0;
446  }
447  }
448  return 1;
449 }
450 
451 // Copy at most one blocks worth of data from input to internal buffer.
452 // Return 1 if whole block has been read, 0 if not, LZ4 error otherwise
454  stream_state *state = str->state;
455  if (state->block_size_read != 4 || state->block_size == kEndOfStream) {
456  return ROSLZ4_ERROR;
457  }
458 
459  int block_left = state->block_size - state->buffer_offset;
460  int to_copy = min(str->input_left, block_left);
461  memcpy(state->buffer + state->buffer_offset, str->input_next, to_copy);
462  advanceInput(str, to_copy);
463  state->buffer_offset += to_copy;
464  DEBUG("readBlock() Read %i bytes from input (block = %i/%i)\n",
465  to_copy, state->buffer_offset, state->block_size);
466  return state->buffer_offset == state->block_size;
467 }
468 
470  stream_state *state = str->state;
471  if (state->block_size_read != 4 || state->block_size != state->buffer_offset) {
472  // Internal error: Can't decompress block, it's not in buffer
473  return ROSLZ4_ERROR;
474  }
475 
476  if (state->block_uncompressed) {
477  if (str->output_left > 0 && (unsigned int)str->output_left >= state->block_size) {
478  memcpy(str->output_next, state->buffer, state->block_size);
479  int ret = XXH32_update(state->xxh32_state, str->output_next,
480  state->block_size);
481  if (ret == XXH_ERROR) { return ROSLZ4_ERROR; }
482  advanceOutput(str, state->block_size);
483  state->block_size_read = 0;
484  state->buffer_offset = 0;
485  return ROSLZ4_OK;
486  } else {
487  return ROSLZ4_OUTPUT_SMALL;
488  }
489  } else {
490  int decomp_size;
491  decomp_size = LZ4_decompress_safe(state->buffer, str->output_next,
492  state->block_size, str->output_left);
493  if (decomp_size < 0) {
494  if (str->output_left >= state->buffer_size) {
495  return ROSLZ4_DATA_ERROR; // Must be a problem with the data stream
496  } else {
497  // Data error or output is small; increase output to disambiguate
498  return ROSLZ4_OUTPUT_SMALL;
499  }
500  } else {
501  int ret = XXH32_update(state->xxh32_state, str->output_next, decomp_size);
502  if (ret == XXH_ERROR) { return ROSLZ4_ERROR; }
503  advanceOutput(str, decomp_size);
504  state->block_size_read = 0;
505  state->buffer_offset = 0;
506  return ROSLZ4_OK;
507  }
508  }
509 }
510 
512  stream_state *state = str->state;
513  fillUInt32(str, &state->stream_checksum, &state->stream_checksum_read);
514  if (state->stream_checksum_read == 4) {
515  state->finished = 1;
516  state->stream_checksum = readUInt32((unsigned char*)&state->stream_checksum);
517  uint32_t checksum = XXH32_digest(state->xxh32_state);
518  state->xxh32_state = NULL;
519  if (checksum == state->stream_checksum) {
520  return ROSLZ4_STREAM_END;
521  } else {
522  return ROSLZ4_DATA_ERROR;
523  }
524  }
525  return ROSLZ4_OK;
526 }
527 
529  stream_state *state = str->state;
530  if (state->finished) {
531  return ROSLZ4_ERROR; // Already reached end of stream
532  }
533 
534  // Return if header isn't present or error was encountered
535  int ret = processHeader(str);
536  if (ret <= 0) {
537  return ret;
538  }
539 
540  // Read in blocks and decompress them as long as there's data to be processed
541  while (str->input_left > 0) {
542  ret = readBlockSize(str);
543  if (ret == 0) { return ROSLZ4_OK; }
544 
545  if (state->block_size == kEndOfStream) {
546  return readChecksum(str);
547  }
548 
549  ret = readBlock(str);
550  if (ret == 0) { return ROSLZ4_OK; }
551  else if (ret < 0) { return ret; }
552 
553  ret = decompressBlock(str);
554  if (ret < 0) { return ret; }
555  }
556  return ROSLZ4_OK;
557 }
558 
560  streamStateFree(str);
561 }
562 
563 /*=================== Oneshot compression / decompression ===================*/
564 
566  char *output, unsigned int *output_size,
567  int block_size_id) {
569  stream.input_next = input;
570  stream.input_left = input_size;
571  stream.output_next = output;
572  stream.output_left = *output_size;
573 
574  int ret;
575  ret = roslz4_compressStart(&stream, block_size_id);
576  if (ret != ROSLZ4_OK) { return ret; }
577 
578  while (stream.input_left > 0 && ret != ROSLZ4_STREAM_END) {
579  ret = roslz4_compress(&stream, ROSLZ4_FINISH);
580  if (ret == ROSLZ4_ERROR || ret == ROSLZ4_OUTPUT_SMALL) {
581  roslz4_compressEnd(&stream);
582  return ret;
583  }
584  }
585 
586  *output_size = *output_size - stream.output_left;
587  roslz4_compressEnd(&stream);
588 
589  if (stream.input_left == 0 && ret == ROSLZ4_STREAM_END) {
590  return ROSLZ4_OK; // Success
591  } else {
592  return ROSLZ4_ERROR; // User did not provide exact buffer
593  }
594 }
595 
597  char *output, unsigned int *output_size) {
599  stream.input_next = input;
600  stream.input_left = input_size;
601  stream.output_next = output;
602  stream.output_left = *output_size;
603 
604  int ret;
605  ret = roslz4_decompressStart(&stream);
606  if (ret != ROSLZ4_OK) { return ret; }
607 
608  while (stream.input_left > 0 && ret != ROSLZ4_STREAM_END) {
609  ret = roslz4_decompress(&stream);
610  if (ret < 0) {
611  roslz4_decompressEnd(&stream);
612  return ret;
613  }
614  }
615 
616  *output_size = *output_size - stream.output_left;
617  roslz4_decompressEnd(&stream);
618 
619  if (stream.input_left == 0 && ret == ROSLZ4_STREAM_END) {
620  return ROSLZ4_OK; // Success
621  } else {
622  return ROSLZ4_ERROR; // User did not provide exact buffer
623  }
624 }
const int ROSLZ4_MEMORY_ERROR
Definition: lz4s.h:45
GLboolean GLboolean GLboolean b
void * xxh32_state
Definition: lz4s.c:90
int buffer_offset
Definition: lz4s.c:86
const uint8_t k1Bits
Definition: lz4s.c:55
int writeEOS(roslz4_stream *str)
Definition: lz4s.c:149
void advanceOutput(roslz4_stream *str, int nbytes)
Definition: lz4s.c:110
void advanceInput(roslz4_stream *str, int nbytes)
Definition: lz4s.c:104
int writeHeader(roslz4_stream *str)
Definition: lz4s.c:124
int stream_checksum_read
Definition: lz4s.c:101
int total_out
Definition: lz4s.h:65
int block_size_id
Definition: lz4s.h:67
int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
Definition: lz4.c:1262
uint32_t readUInt32(unsigned char *buffer)
Definition: lz4s.c:61
const int ROSLZ4_OUTPUT_SMALL
Definition: lz4s.h:48
std_msgs::Header * header(M &m)
returns Header<M>::pointer(m);
int LZ4_compress_default(const char *source, char *dest, int inputSize, int maxOutputSize)
Definition: lz4.c:708
void roslz4_decompressEnd(roslz4_stream *str)
Definition: lz4s.c:559
GLuint GLuint stream
Definition: glext.h:1790
int block_independence_flag
Definition: lz4s.c:80
void streamStateFree(roslz4_stream *str)
Definition: lz4s.c:285
XXH_PUBLIC_API unsigned int XXH32_digest(const XXH32_state_t *state_in)
Definition: lz4/xxhash.c:485
unsigned char uint8_t
Definition: stdint.h:78
GLenum GLfloat * buffer
GLboolean GLboolean GLboolean GLboolean a
int finished
Definition: lz4s.c:88
GLuint GLfloat * val
int total_in
Definition: lz4s.h:64
const uint8_t k2Bits
Definition: lz4s.c:56
int roslz4_compress(roslz4_stream *str, int action)
Definition: lz4s.c:309
void roslz4_compressEnd(roslz4_stream *str)
Definition: lz4s.c:345
int processHeader(roslz4_stream *str)
Definition: lz4s.c:358
char * buffer
Definition: lz4s.c:84
const int ROSLZ4_STREAM_END
Definition: lz4s.h:51
int roslz4_buffToBuffCompress(char *input, unsigned int input_size, char *output, unsigned int *output_size, int block_size_id)
Definition: lz4s.c:565
int input_left
Definition: lz4s.h:59
int readBlockSize(roslz4_stream *str)
Definition: lz4s.c:433
int block_size_read
Definition: lz4s.c:98
const uint8_t k8Bits
Definition: lz4s.c:59
int streamStateAlloc(roslz4_stream *str)
Definition: lz4s.c:235
void fillUInt32(roslz4_stream *str, uint32_t *dest_val, int *offset)
Definition: lz4s.c:116
unsigned int uint32_t
Definition: stdint.h:80
void * XXH32_init(U32 seed)
const uint8_t k3Bits
Definition: lz4s.c:57
const int ROSLZ4_PARAM_ERROR
Definition: lz4s.h:46
char * output_next
Definition: lz4s.h:61
void * state
Definition: lz4s.h:70
int readBlock(roslz4_stream *str)
Definition: lz4s.c:453
int roslz4_decompressStart(roslz4_stream *str)
Definition: lz4s.c:351
char * input_next
Definition: lz4s.h:58
int bufferToOutput(roslz4_stream *str)
Definition: lz4s.c:170
int buffer_size
Definition: lz4s.c:85
void writeUInt32(unsigned char *buffer, uint32_t val)
Definition: lz4s.c:66
const int ROSLZ4_DATA_ERROR
Definition: lz4s.h:47
const int ROSLZ4_OK
Definition: lz4s.h:50
action
Definition: enums.py:62
int block_checksum_flag
Definition: lz4s.c:81
uint32_t block_size
Definition: lz4s.c:97
const uint32_t kEndOfStream
Definition: lz4s.c:52
int decompressBlock(roslz4_stream *str)
Definition: lz4s.c:469
const int ROSLZ4_FINISH
Definition: lz4s.h:55
int block_uncompressed
Definition: lz4s.c:99
GLenum GLenum GLenum input
Definition: glext.h:10805
const uint32_t kMagicNumber
Definition: lz4s.c:51
const int ROSLZ4_ERROR
Definition: lz4s.h:49
int min(int a, int b)
Definition: lz4s.c:73
int readChecksum(roslz4_stream *str)
Definition: lz4s.c:511
int streamResizeBuffer(roslz4_stream *str, int block_size_id)
Definition: lz4s.c:269
LZ4LIB_API char * dest
Definition: lz4.h:438
XXH_PUBLIC_API XXH_errorcode XXH32_update(XXH32_state_t *state_in, const void *input, size_t len)
Definition: lz4/xxhash.c:437
int inputToBuffer(roslz4_stream *str)
Definition: lz4s.c:214
XXH_PUBLIC_API unsigned int XXH32(const void *input, size_t len, unsigned int seed)
Definition: lz4/xxhash.c:321
#define NULL
Definition: tinycthread.c:47
int wrote_header
Definition: lz4s.c:93
int roslz4_decompress(roslz4_stream *str)
Definition: lz4s.c:528
#define DEBUG(...)
Definition: lz4s.c:47
const int ROSLZ4_RUN
Definition: lz4s.h:54
int stream_checksum_flag
Definition: lz4s.c:82
int output_left
Definition: lz4s.h:62
int roslz4_compressStart(roslz4_stream *str, int block_size_id)
Definition: lz4s.c:303
char header[10]
Definition: lz4s.c:96
int roslz4_blockSizeFromIndex(int block_id)
Definition: lz4s.c:299
const uint8_t k4Bits
Definition: lz4s.c:58
GLintptr offset
int roslz4_buffToBuffDecompress(char *input, unsigned int input_size, char *output, unsigned int *output_size)
Definition: lz4s.c:596
uint32_t stream_checksum
Definition: lz4s.c:100


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21