Flipper Zero Firmware
Loading...
Searching...
No Matches
compress.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <stdbool.h>
8#include <stdint.h>
9#include <stddef.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
17
26CompressIcon* compress_icon_alloc(size_t decode_buf_size);
27
32void compress_icon_free(CompressIcon* instance);
33
45void compress_icon_decode(CompressIcon* instance, const uint8_t* icon_data, uint8_t** output);
46
48
50typedef struct Compress Compress;
51
53typedef enum {
54 CompressTypeHeatshrink = 0,
56
58typedef struct {
59 uint16_t window_sz2;
60 uint16_t lookahead_sz2;
61 uint16_t input_buffer_sz;
63
66
74Compress* compress_alloc(CompressType type, const void* config);
75
80void compress_free(Compress* compress);
81
96 Compress* compress,
97 uint8_t* data_in,
98 size_t data_in_size,
99 uint8_t* data_out,
100 size_t data_out_size,
101 size_t* data_res_size);
102
115bool compress_decode(
116 Compress* compress,
117 uint8_t* data_in,
118 size_t data_in_size,
119 uint8_t* data_out,
120 size_t data_out_size,
121 size_t* data_res_size);
122
131typedef int32_t (*CompressIoCallback)(void* context, uint8_t* buffer, size_t size);
132
145 Compress* compress,
146 CompressIoCallback read_cb,
147 void* read_context,
148 CompressIoCallback write_cb,
149 void* write_context);
150
152
155
166 CompressType type,
167 const void* config,
168 CompressIoCallback read_cb,
169 void* read_context);
170
176
186 CompressStreamDecoder* instance,
187 uint8_t* data_out,
188 size_t data_out_size);
189
198bool compress_stream_decoder_seek(CompressStreamDecoder* instance, size_t position);
199
207
216
217#ifdef __cplusplus
218}
219#endif
bool compress_decode_streamed(Compress *compress, CompressIoCallback read_cb, void *read_context, CompressIoCallback write_cb, void *write_context)
Decompress streamed data.
Definition compress.c:385
CompressIcon * compress_icon_alloc(size_t decode_buf_size)
Initialize icon compressor.
Definition compress.c:47
void compress_icon_free(CompressIcon *instance)
Free icon compressor.
Definition compress.c:61
void compress_icon_decode(CompressIcon *instance, const uint8_t *icon_data, uint8_t **output)
Decompress icon.
Definition compress.c:68
Compress * compress_alloc(CompressType type, const void *config)
Allocate encoder and decoder.
Definition compress.c:97
const CompressConfigHeatshrink compress_config_heatshrink_default
Default configuration for heatshrink compression.
Definition compress.c:18
CompressType
Supported compression types.
Definition compress.h:53
CompressStreamDecoder * compress_stream_decoder_alloc(CompressType type, const void *config, CompressIoCallback read_cb, void *read_context)
Allocate stream decoder.
Definition compress.c:419
bool compress_decode(Compress *compress, uint8_t *data_in, size_t data_in_size, uint8_t *data_out, size_t data_out_size, size_t *data_res_size)
Decode data.
Definition compress.c:369
bool compress_encode(Compress *compress, uint8_t *data_in, size_t data_in_size, uint8_t *data_out, size_t data_out_size, size_t *data_res_size)
Encode data.
Definition compress.c:353
void compress_stream_decoder_free(CompressStreamDecoder *instance)
Free stream decoder.
Definition compress.c:441
void compress_free(Compress *compress)
Free encoder and decoder.
Definition compress.c:109
size_t compress_stream_decoder_tell(CompressStreamDecoder *instance)
Get current position in uncompressed data stream.
Definition compress.c:559
bool compress_stream_decoder_seek(CompressStreamDecoder *instance, size_t position)
Seek to position in uncompressed data stream.
Definition compress.c:533
bool compress_stream_decoder_rewind(CompressStreamDecoder *instance)
Reset stream decoder to the beginning.
Definition compress.c:564
int32_t(* CompressIoCallback)(void *context, uint8_t *buffer, size_t size)
I/O callback for streamed compression/decompression.
Definition compress.h:131
bool compress_stream_decoder_read(CompressStreamDecoder *instance, uint8_t *data_out, size_t data_out_size)
Read uncompressed data chunk from stream decoder.
Definition compress.c:518
Configuration for heatshrink compression.
Definition compress.h:58
Definition compress.c:91
Definition compress.c:41
Definition compress.c:409