libsquashfs 1.3.0
A new set of tools and libraries for working with SquashFS images
Loading...
Searching...
No Matches
compressor.h File Reference

Contains declarations to everything related to data compression. More...

#include "sqfs/predef.h"
#include "sqfs/super.h"

Go to the source code of this file.

Data Structures

interface  sqfs_compressor_t
 Encapsultes a compressor with a simple interface to compress or extract chunks of data. More...
 
struct  sqfs_compressor_config_t
 Configuration parameters for instantiating a compressor backend. More...
 

Macros

#define SQFS_GZIP_DEFAULT_LEVEL   (9)
 
#define SQFS_GZIP_DEFAULT_WINDOW   (15)
 
#define SQFS_LZO_DEFAULT_ALG   SQFS_LZO1X_999
 
#define SQFS_LZO_DEFAULT_LEVEL   (8)
 
#define SQFS_ZSTD_DEFAULT_LEVEL   (15)
 
#define SQFS_GZIP_MIN_LEVEL   (1)
 
#define SQFS_GZIP_MAX_LEVEL   (9)
 
#define SQFS_LZO_MIN_LEVEL   (0)
 
#define SQFS_LZO_MAX_LEVEL   (9)
 
#define SQFS_ZSTD_MIN_LEVEL   (1)
 
#define SQFS_ZSTD_MAX_LEVEL   (22)
 
#define SQFS_GZIP_MIN_WINDOW   (8)
 
#define SQFS_GZIP_MAX_WINDOW   (15)
 
#define SQFS_XZ_MIN_LEVEL   (0)
 
#define SQFS_XZ_MAX_LEVEL   (9)
 
#define SQFS_XZ_DEFAULT_LEVEL   (6)
 
#define SQFS_XZ_MIN_LC   0
 
#define SQFS_XZ_MAX_LC   4
 
#define SQFS_XZ_DEFAULT_LC   3
 
#define SQFS_XZ_MIN_LP   0
 
#define SQFS_XZ_MAX_LP   4
 
#define SQFS_XZ_DEFAULT_LP   0
 
#define SQFS_XZ_MIN_PB   0
 
#define SQFS_XZ_MAX_PB   4
 
#define SQFS_XZ_DEFAULT_PB   2
 
#define SQFS_LZMA_MIN_LEVEL   (0)
 
#define SQFS_LZMA_MAX_LEVEL   (9)
 
#define SQFS_LZMA_DEFAULT_LEVEL   (5)
 
#define SQFS_LZMA_MIN_LC   0
 
#define SQFS_LZMA_MAX_LC   4
 
#define SQFS_LZMA_DEFAULT_LC   3
 
#define SQFS_LZMA_MIN_LP   0
 
#define SQFS_LZMA_MAX_LP   4
 
#define SQFS_LZMA_DEFAULT_LP   0
 
#define SQFS_LZMA_MIN_PB   0
 
#define SQFS_LZMA_MAX_PB   4
 
#define SQFS_LZMA_DEFAULT_PB   2
 
#define SQFS_LZMA_MIN_DICT_SIZE   SQFS_META_BLOCK_SIZE
 
#define SQFS_LZMA_MAX_DICT_SIZE   SQFS_MAX_BLOCK_SIZE
 
#define SQFS_XZ_MIN_DICT_SIZE   SQFS_META_BLOCK_SIZE
 
#define SQFS_XZ_MAX_DICT_SIZE   SQFS_MAX_BLOCK_SIZE
 

Enumerations

enum  SQFS_COMP_FLAG {
  SQFS_COMP_FLAG_LZ4_HC = 0x0001 , SQFS_COMP_FLAG_LZ4_ALL = 0x0001 , SQFS_COMP_FLAG_LZMA_EXTREME = 0x0001 , SQFS_COMP_FLAG_LZMA_ALL = 0x0001 ,
  SQFS_COMP_FLAG_XZ_X86 = 0x0001 , SQFS_COMP_FLAG_XZ_POWERPC = 0x0002 , SQFS_COMP_FLAG_XZ_IA64 = 0x0004 , SQFS_COMP_FLAG_XZ_ARM = 0x0008 ,
  SQFS_COMP_FLAG_XZ_ARMTHUMB = 0x0010 , SQFS_COMP_FLAG_XZ_SPARC = 0x0020 , SQFS_COMP_FLAG_XZ_EXTREME = 0x0100 , SQFS_COMP_FLAG_XZ_ALL = 0x013F ,
  SQFS_COMP_FLAG_GZIP_DEFAULT = 0x0001 , SQFS_COMP_FLAG_GZIP_FILTERED = 0x0002 , SQFS_COMP_FLAG_GZIP_HUFFMAN = 0x0004 , SQFS_COMP_FLAG_GZIP_RLE = 0x0008 ,
  SQFS_COMP_FLAG_GZIP_FIXED = 0x0010 , SQFS_COMP_FLAG_GZIP_ALL = 0x001F , SQFS_COMP_FLAG_UNCOMPRESS = 0x8000 , SQFS_COMP_FLAG_GENERIC_ALL = 0x8000
}
 Flags for configuring the compressor. More...
 
enum  SQFS_LZO_ALGORITHM {
  SQFS_LZO1X_1 = 0 , SQFS_LZO1X_1_11 = 1 , SQFS_LZO1X_1_12 = 2 , SQFS_LZO1X_1_15 = 3 ,
  SQFS_LZO1X_999 = 4
}
 The available LZO algorithms. More...
 

Functions

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_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.
 
SQFS_API int sqfs_compressor_id_from_name (const char *name)
 Get the compressor ID using just the name of the backend.
 

Detailed Description

Contains declarations to everything related to data compression.

Definition in file compressor.h.

Macro Definition Documentation

◆ SQFS_GZIP_DEFAULT_LEVEL

#define SQFS_GZIP_DEFAULT_LEVEL   (9)

Definition at line 329 of file compressor.h.

◆ SQFS_GZIP_DEFAULT_WINDOW

#define SQFS_GZIP_DEFAULT_WINDOW   (15)

Definition at line 330 of file compressor.h.

◆ SQFS_GZIP_MAX_LEVEL

#define SQFS_GZIP_MAX_LEVEL   (9)

Definition at line 338 of file compressor.h.

◆ SQFS_GZIP_MAX_WINDOW

#define SQFS_GZIP_MAX_WINDOW   (15)

Definition at line 347 of file compressor.h.

◆ SQFS_GZIP_MIN_LEVEL

#define SQFS_GZIP_MIN_LEVEL   (1)

Definition at line 337 of file compressor.h.

◆ SQFS_GZIP_MIN_WINDOW

#define SQFS_GZIP_MIN_WINDOW   (8)

Definition at line 346 of file compressor.h.

◆ SQFS_LZMA_DEFAULT_LC

#define SQFS_LZMA_DEFAULT_LC   3

Definition at line 371 of file compressor.h.

◆ SQFS_LZMA_DEFAULT_LEVEL

#define SQFS_LZMA_DEFAULT_LEVEL   (5)

Definition at line 367 of file compressor.h.

◆ SQFS_LZMA_DEFAULT_LP

#define SQFS_LZMA_DEFAULT_LP   0

Definition at line 375 of file compressor.h.

◆ SQFS_LZMA_DEFAULT_PB

#define SQFS_LZMA_DEFAULT_PB   2

Definition at line 379 of file compressor.h.

◆ SQFS_LZMA_MAX_DICT_SIZE

#define SQFS_LZMA_MAX_DICT_SIZE   SQFS_MAX_BLOCK_SIZE

Definition at line 382 of file compressor.h.

◆ SQFS_LZMA_MAX_LC

#define SQFS_LZMA_MAX_LC   4

Definition at line 370 of file compressor.h.

◆ SQFS_LZMA_MAX_LEVEL

#define SQFS_LZMA_MAX_LEVEL   (9)

Definition at line 366 of file compressor.h.

◆ SQFS_LZMA_MAX_LP

#define SQFS_LZMA_MAX_LP   4

Definition at line 374 of file compressor.h.

◆ SQFS_LZMA_MAX_PB

#define SQFS_LZMA_MAX_PB   4

Definition at line 378 of file compressor.h.

◆ SQFS_LZMA_MIN_DICT_SIZE

#define SQFS_LZMA_MIN_DICT_SIZE   SQFS_META_BLOCK_SIZE

Definition at line 381 of file compressor.h.

◆ SQFS_LZMA_MIN_LC

#define SQFS_LZMA_MIN_LC   0

Definition at line 369 of file compressor.h.

◆ SQFS_LZMA_MIN_LEVEL

#define SQFS_LZMA_MIN_LEVEL   (0)

Definition at line 365 of file compressor.h.

◆ SQFS_LZMA_MIN_LP

#define SQFS_LZMA_MIN_LP   0

Definition at line 373 of file compressor.h.

◆ SQFS_LZMA_MIN_PB

#define SQFS_LZMA_MIN_PB   0

Definition at line 377 of file compressor.h.

◆ SQFS_LZO_DEFAULT_ALG

#define SQFS_LZO_DEFAULT_ALG   SQFS_LZO1X_999

Definition at line 332 of file compressor.h.

◆ SQFS_LZO_DEFAULT_LEVEL

#define SQFS_LZO_DEFAULT_LEVEL   (8)

Definition at line 333 of file compressor.h.

◆ SQFS_LZO_MAX_LEVEL

#define SQFS_LZO_MAX_LEVEL   (9)

Definition at line 341 of file compressor.h.

◆ SQFS_LZO_MIN_LEVEL

#define SQFS_LZO_MIN_LEVEL   (0)

Definition at line 340 of file compressor.h.

◆ SQFS_XZ_DEFAULT_LC

#define SQFS_XZ_DEFAULT_LC   3

Definition at line 355 of file compressor.h.

◆ SQFS_XZ_DEFAULT_LEVEL

#define SQFS_XZ_DEFAULT_LEVEL   (6)

Definition at line 351 of file compressor.h.

◆ SQFS_XZ_DEFAULT_LP

#define SQFS_XZ_DEFAULT_LP   0

Definition at line 359 of file compressor.h.

◆ SQFS_XZ_DEFAULT_PB

#define SQFS_XZ_DEFAULT_PB   2

Definition at line 363 of file compressor.h.

◆ SQFS_XZ_MAX_DICT_SIZE

#define SQFS_XZ_MAX_DICT_SIZE   SQFS_MAX_BLOCK_SIZE

Definition at line 385 of file compressor.h.

◆ SQFS_XZ_MAX_LC

#define SQFS_XZ_MAX_LC   4

Definition at line 354 of file compressor.h.

◆ SQFS_XZ_MAX_LEVEL

#define SQFS_XZ_MAX_LEVEL   (9)

Definition at line 350 of file compressor.h.

◆ SQFS_XZ_MAX_LP

#define SQFS_XZ_MAX_LP   4

Definition at line 358 of file compressor.h.

◆ SQFS_XZ_MAX_PB

#define SQFS_XZ_MAX_PB   4

Definition at line 362 of file compressor.h.

◆ SQFS_XZ_MIN_DICT_SIZE

#define SQFS_XZ_MIN_DICT_SIZE   SQFS_META_BLOCK_SIZE

Definition at line 384 of file compressor.h.

◆ SQFS_XZ_MIN_LC

#define SQFS_XZ_MIN_LC   0

Definition at line 353 of file compressor.h.

◆ SQFS_XZ_MIN_LEVEL

#define SQFS_XZ_MIN_LEVEL   (0)

Definition at line 349 of file compressor.h.

◆ SQFS_XZ_MIN_LP

#define SQFS_XZ_MIN_LP   0

Definition at line 357 of file compressor.h.

◆ SQFS_XZ_MIN_PB

#define SQFS_XZ_MIN_PB   0

Definition at line 361 of file compressor.h.

◆ SQFS_ZSTD_DEFAULT_LEVEL

#define SQFS_ZSTD_DEFAULT_LEVEL   (15)

Definition at line 335 of file compressor.h.

◆ SQFS_ZSTD_MAX_LEVEL

#define SQFS_ZSTD_MAX_LEVEL   (22)

Definition at line 344 of file compressor.h.

◆ SQFS_ZSTD_MIN_LEVEL

#define SQFS_ZSTD_MIN_LEVEL   (1)

Definition at line 343 of file compressor.h.

Enumeration Type Documentation

◆ SQFS_COMP_FLAG

Flags for configuring the compressor.

Enumerator
SQFS_COMP_FLAG_LZ4_HC 

For LZ4, set this to use high compression mode.

SQFS_COMP_FLAG_LZMA_EXTREME 

Tell the LZMAv1 compressor to try the "extreme" option.

The "extreme" option means that the compressor should try some strategies that it normally wouldn't, that may drastically increase compression time, but will not increase the decompressors memory consumption.

SQFS_COMP_FLAG_XZ_X86 

For XZ, set this to select the x86 BCJ filter.

SQFS_COMP_FLAG_XZ_POWERPC 

For XZ, set this to select the PowerPC BCJ filter.

SQFS_COMP_FLAG_XZ_IA64 

For XZ, set this to select the Itanium BCJ filter.

SQFS_COMP_FLAG_XZ_ARM 

For XZ, set this to select the ARM BCJ filter.

SQFS_COMP_FLAG_XZ_ARMTHUMB 

For XZ, set this to select the ARM Thumb BCJ filter.

SQFS_COMP_FLAG_XZ_SPARC 

For XZ, set this to select the Sparc BCJ filter.

SQFS_COMP_FLAG_XZ_EXTREME 

Tell the XZ compressor to try the "extreme" option.

SQFS_COMP_FLAG_GZIP_DEFAULT 

For zlib deflate, set this to try the default strategy.

SQFS_COMP_FLAG_GZIP_FILTERED 

For zlib deflate, set this to try the "filtered" strategy.

SQFS_COMP_FLAG_GZIP_HUFFMAN 

For zlib deflate, set this to try the huffman only strategy.

SQFS_COMP_FLAG_GZIP_RLE 

For zlib deflate, set this to try the RLE strategy.

SQFS_COMP_FLAG_GZIP_FIXED 

For zlib deflate, set this to try the fixed strategy.

SQFS_COMP_FLAG_UNCOMPRESS 

Set this if the compressor should actually extract instead of compress data.

Definition at line 227 of file compressor.h.

◆ SQFS_LZO_ALGORITHM

The available LZO algorithms.

Definition at line 321 of file compressor.h.

Function Documentation

◆ sqfs_compressor_config_init()

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.

The detail configuration options are all initialized to the defaults for the compressor in question.

Parameters
cfgA pointer to a compressor configuration to initialize
idThe compressor id to set.
block_sizeThe block size to set.
flagsThe compressor flags to set.
Returns
Zero on success, an SQFS_ERROR value if some of the options don't make sense (e.g. unknown flags are used).
Examples
list_files.c.

◆ sqfs_compressor_create()

SQFS_API int sqfs_compressor_create ( const sqfs_compressor_config_t cfg,
sqfs_compressor_t **  out 
)

Create an instance of a compressor implementation.

If this function returns SQFS_ERROR_UNSUPPORTED, it can mean that either the compressor is not supported at all by the version of libsquashfs you are using, or that the specific configuration that has been requested is not supported (e.g. unknown flags, or the local version can only uncompress, but not compress).

Parameters
cfgA pointer to a compressor configuration.
outReturns a pointer to the compressor on success.
Returns
Zero on success, an SQFS_ERROR code on failure.
Examples
list_files.c.

◆ sqfs_compressor_id_from_name()

SQFS_API int sqfs_compressor_id_from_name ( const char *  name)

Get the compressor ID using just the name of the backend.

Parameters
nameThe name of the compressor backend.
Returns
A positive, SQFS_COMPRESSOR identifier on success or SQFS_ERROR_UNSUPPORTED if the backend is unknown.

◆ sqfs_compressor_name_from_id()

SQFS_API const char * sqfs_compressor_name_from_id ( SQFS_COMPRESSOR  id)

Get the name of a compressor backend from its ID.

Parameters
idAn SQFS_COMPRESSOR identifier.
Returns
A string holding the name of the compressor, NULL if the compressor ID is not known.