libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
Loading...
Searching...
No Matches
compressor.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/*
3 * compressor.h - This file is part of libsquashfs
4 *
5 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef SQFS_COMPRESSOR_H
21#define SQFS_COMPRESSOR_H
22
23#include "sqfs/predef.h"
24#include "sqfs/super.h"
25
41 sqfs_object_t base;
42
51
67
77
92 sqfs_s32 (*do_block)(sqfs_compressor_t *cmp, const sqfs_u8 *in,
93 sqfs_u32 size, sqfs_u8 *out, sqfs_u32 outsize);
94};
95
110 sqfs_u16 id;
111
115 sqfs_u16 flags;
116
120 sqfs_u32 block_size;
121
127 sqfs_u32 level;
128
132 union {
136 struct {
142 sqfs_u16 window_size;
143
144 sqfs_u8 padd0[14];
146
150 struct {
157 sqfs_u16 algorithm;
158
159 sqfs_u8 padd0[14];
161
165 struct {
175 sqfs_u32 dict_size;
176
187 sqfs_u8 lc;
188
199 sqfs_u8 lp;
200
213 sqfs_u8 pb;
214
215 sqfs_u8 padd0[9];
216 } xz, lzma;
217
218 sqfs_u64 padd0[2];
220};
221
227typedef enum {
232 SQFS_COMP_FLAG_LZ4_ALL = 0x0001,
233
243 SQFS_COMP_FLAG_LZMA_ALL = 0x0001,
244
249
254
259
264
269
274
279
280 SQFS_COMP_FLAG_XZ_ALL = 0x013F,
281
286
291
296
301
306 SQFS_COMP_FLAG_GZIP_ALL = 0x001F,
307
313 SQFS_COMP_FLAG_GENERIC_ALL = 0x8000,
315
321typedef enum {
322 SQFS_LZO1X_1 = 0,
323 SQFS_LZO1X_1_11 = 1,
324 SQFS_LZO1X_1_12 = 2,
325 SQFS_LZO1X_1_15 = 3,
326 SQFS_LZO1X_999 = 4,
328
329#define SQFS_GZIP_DEFAULT_LEVEL (9)
330#define SQFS_GZIP_DEFAULT_WINDOW (15)
331
332#define SQFS_LZO_DEFAULT_ALG SQFS_LZO1X_999
333#define SQFS_LZO_DEFAULT_LEVEL (8)
334
335#define SQFS_ZSTD_DEFAULT_LEVEL (15)
336
337#define SQFS_GZIP_MIN_LEVEL (1)
338#define SQFS_GZIP_MAX_LEVEL (9)
339
340#define SQFS_LZO_MIN_LEVEL (0)
341#define SQFS_LZO_MAX_LEVEL (9)
342
343#define SQFS_ZSTD_MIN_LEVEL (1)
344#define SQFS_ZSTD_MAX_LEVEL (22)
345
346#define SQFS_GZIP_MIN_WINDOW (8)
347#define SQFS_GZIP_MAX_WINDOW (15)
348
349#define SQFS_XZ_MIN_LEVEL (0)
350#define SQFS_XZ_MAX_LEVEL (9)
351#define SQFS_XZ_DEFAULT_LEVEL (6)
352
353#define SQFS_XZ_MIN_LC 0
354#define SQFS_XZ_MAX_LC 4
355#define SQFS_XZ_DEFAULT_LC 3
356
357#define SQFS_XZ_MIN_LP 0
358#define SQFS_XZ_MAX_LP 4
359#define SQFS_XZ_DEFAULT_LP 0
360
361#define SQFS_XZ_MIN_PB 0
362#define SQFS_XZ_MAX_PB 4
363#define SQFS_XZ_DEFAULT_PB 2
364
365#define SQFS_LZMA_MIN_LEVEL (0)
366#define SQFS_LZMA_MAX_LEVEL (9)
367#define SQFS_LZMA_DEFAULT_LEVEL (5)
368
369#define SQFS_LZMA_MIN_LC 0
370#define SQFS_LZMA_MAX_LC 4
371#define SQFS_LZMA_DEFAULT_LC 3
372
373#define SQFS_LZMA_MIN_LP 0
374#define SQFS_LZMA_MAX_LP 4
375#define SQFS_LZMA_DEFAULT_LP 0
376
377#define SQFS_LZMA_MIN_PB 0
378#define SQFS_LZMA_MAX_PB 4
379#define SQFS_LZMA_DEFAULT_PB 2
380
381#define SQFS_LZMA_MIN_DICT_SIZE SQFS_META_BLOCK_SIZE
382#define SQFS_LZMA_MAX_DICT_SIZE SQFS_MAX_BLOCK_SIZE
383
384#define SQFS_XZ_MIN_DICT_SIZE SQFS_META_BLOCK_SIZE
385#define SQFS_XZ_MAX_DICT_SIZE SQFS_MAX_BLOCK_SIZE
386
387#ifdef __cplusplus
388extern "C" {
389#endif
390
407 size_t block_size, sqfs_u16 flags);
408
424 sqfs_compressor_t **out);
425
435
444SQFS_API int sqfs_compressor_id_from_name(const char *name);
445
446#ifdef __cplusplus
447}
448#endif
449
450#endif /* SQFS_COMPRESSOR_H */
SQFS_COMP_FLAG
Flags for configuring the compressor.
Definition: compressor.h:227
@ SQFS_COMP_FLAG_XZ_SPARC
For XZ, set this to select the Sparc BCJ filter.
Definition: compressor.h:273
@ SQFS_COMP_FLAG_UNCOMPRESS
Set this if the compressor should actually extract instead of compress data.
Definition: compressor.h:312
@ SQFS_COMP_FLAG_LZMA_EXTREME
Tell the LZMAv1 compressor to try the "extreme" option.
Definition: compressor.h:242
@ SQFS_COMP_FLAG_GZIP_HUFFMAN
For zlib deflate, set this to try the huffman only strategy.
Definition: compressor.h:295
@ SQFS_COMP_FLAG_GZIP_DEFAULT
For zlib deflate, set this to try the default strategy.
Definition: compressor.h:285
@ SQFS_COMP_FLAG_GZIP_FILTERED
For zlib deflate, set this to try the "filtered" strategy.
Definition: compressor.h:290
@ SQFS_COMP_FLAG_XZ_POWERPC
For XZ, set this to select the PowerPC BCJ filter.
Definition: compressor.h:253
@ SQFS_COMP_FLAG_XZ_ARM
For XZ, set this to select the ARM BCJ filter.
Definition: compressor.h:263
@ SQFS_COMP_FLAG_GZIP_RLE
For zlib deflate, set this to try the RLE strategy.
Definition: compressor.h:300
@ SQFS_COMP_FLAG_XZ_IA64
For XZ, set this to select the Itanium BCJ filter.
Definition: compressor.h:258
@ SQFS_COMP_FLAG_XZ_X86
For XZ, set this to select the x86 BCJ filter.
Definition: compressor.h:248
@ SQFS_COMP_FLAG_GZIP_FIXED
For zlib deflate, set this to try the fixed strategy.
Definition: compressor.h:305
@ SQFS_COMP_FLAG_LZ4_HC
For LZ4, set this to use high compression mode.
Definition: compressor.h:231
@ SQFS_COMP_FLAG_XZ_EXTREME
Tell the XZ compressor to try the "extreme" option.
Definition: compressor.h:278
@ SQFS_COMP_FLAG_XZ_ARMTHUMB
For XZ, set this to select the ARM Thumb BCJ filter.
Definition: compressor.h:268
SQFS_API int sqfs_compressor_config_init(sqfs_compressor_config_t *cfg, SQFS_COMPRESSOR id, size_t block_size, sqfs_u16 flags)
Initialize a compressor configuration.
SQFS_API int sqfs_compressor_id_from_name(const char *name)
Get the compressor ID using just the name of the backend.
SQFS_LZO_ALGORITHM
The available LZO algorithms.
Definition: compressor.h:321
SQFS_API int sqfs_compressor_create(const sqfs_compressor_config_t *cfg, sqfs_compressor_t **out)
Create an instance of a compressor implementation.
SQFS_API const char * sqfs_compressor_name_from_id(SQFS_COMPRESSOR id)
Get the name of a compressor backend from its ID.
Includes forward declarations of data structures, macros and integer types.
Configuration parameters for instantiating a compressor backend.
Definition: compressor.h:106
sqfs_u16 algorithm
Which variant of lzo should be used.
Definition: compressor.h:157
struct sqfs_compressor_config_t::@0::@1 gzip
Options for the zlib compressor.
sqfs_u32 dict_size
LZMA dictionary size.
Definition: compressor.h:175
sqfs_u16 window_size
Deflate window size. Value between 8 and 15.
Definition: compressor.h:142
struct sqfs_compressor_config_t::@0::@3 xz
Options for the LZMA and XZ (LZMA v2) compressors.
struct sqfs_compressor_config_t::@0::@2 lzo
Options for the lzo compressor.
sqfs_u8 pb
Number of position bits.
Definition: compressor.h:213
sqfs_u16 flags
A combination of SQFS_COMP_FLAG flags.
Definition: compressor.h:115
sqfs_u8 lp
Number of literal position bits.
Definition: compressor.h:199
sqfs_u32 level
Compression level.
Definition: compressor.h:127
sqfs_u8 lc
Number of literal context bits.
Definition: compressor.h:187
sqfs_u16 id
An SQFS_COMPRESSOR identifier.
Definition: compressor.h:110
sqfs_u32 block_size
The intended data block size.
Definition: compressor.h:120
union sqfs_compressor_config_t::@0 opt
Backend specific options for fine tuing.
Encapsultes a compressor with a simple interface to compress or extract chunks of data.
Definition: compressor.h:40
sqfs_s32(* do_block)(sqfs_compressor_t *cmp, const sqfs_u8 *in, sqfs_u32 size, sqfs_u8 *out, sqfs_u32 outsize)
Compress or uncompress a chunk of data.
Definition: compressor.h:92
int(* read_options)(sqfs_compressor_t *cmp, sqfs_file_t *file)
Read compressor options from disk.
Definition: compressor.h:76
void(* get_configuration)(const sqfs_compressor_t *cmp, sqfs_compressor_config_t *cfg)
Get the current compressor configuration.
Definition: compressor.h:49
int(* write_options)(sqfs_compressor_t *cmp, sqfs_file_t *file)
Write compressor options to disk if non-default settings have been used.
Definition: compressor.h:66
Abstracts file I/O to make it easy to embedd SquashFS.
Definition: io.h:94
Base interface for all libsquashfs in-memory data structures.
Definition: predef.h:126
Contains on-disk data structures, identifiers and functions for the SquashFS super block.
SQFS_COMPRESSOR
Set in sqfs_super_t to identify the compresser used by the filesystem.
Definition: super.h:194