|
iPXE
|
DEFLATE decompression algorithm. More...
Go to the source code of this file.
Data Structures | |
| struct | deflate_huf_symbols |
| A Huffman-coded set of symbols of a given length. More... | |
| struct | deflate_alphabet |
| A Huffman-coded alphabet. More... | |
| struct | deflate_static_length_pattern |
| A static Huffman alphabet length pattern. More... | |
| struct | deflate |
| Decompressor. More... | |
| struct | deflate_chunk |
| A chunk of data. More... | |
Macros | |
| #define | DEFLATE_HEADER_BITS 3 |
| Block header length (in bits) | |
| #define | DEFLATE_HEADER_BFINAL_BIT 0 |
| Block header final block flags bit. | |
| #define | DEFLATE_HEADER_BTYPE_LSB 1 |
| Block header type LSB. | |
| #define | DEFLATE_HEADER_BTYPE_MASK 0x03 |
| Block header type mask. | |
| #define | DEFLATE_HEADER_BTYPE_LITERAL 0 |
| Block header type: literal data. | |
| #define | DEFLATE_HEADER_BTYPE_STATIC 1 |
| Block header type: static Huffman alphabet. | |
| #define | DEFLATE_HEADER_BTYPE_DYNAMIC 2 |
| Block header type: dynamic Huffman alphabet. | |
| #define | DEFLATE_LITERAL_LEN_BITS 16 |
| Literal header LEN/NLEN field length (in bits) | |
| #define | DEFLATE_DYNAMIC_BITS 14 |
| Dynamic header length (in bits) | |
| #define | DEFLATE_DYNAMIC_HLIT_LSB 0 |
| Dynamic header HLIT field LSB. | |
| #define | DEFLATE_DYNAMIC_HLIT_MASK 0x1f |
| Dynamic header HLIT field mask. | |
| #define | DEFLATE_DYNAMIC_HDIST_LSB 5 |
| Dynamic header HDIST field LSB. | |
| #define | DEFLATE_DYNAMIC_HDIST_MASK 0x1f |
| Dynamic header HDIST field mask. | |
| #define | DEFLATE_DYNAMIC_HCLEN_LSB 10 |
| Dynamic header HCLEN field LSB. | |
| #define | DEFLATE_DYNAMIC_HCLEN_MASK 0x0f |
| Dynamic header HCLEN field mask. | |
| #define | DEFLATE_CODELEN_BITS 3 |
| Dynamic header code length length (in bits) | |
| #define | DEFLATE_HUFFMAN_BITS 15 |
| Maximum length of a Huffman symbol (in bits) | |
| #define | DEFLATE_HUFFMAN_QL_BITS 7 |
| Quick lookup length for a Huffman symbol (in bits) | |
| #define | DEFLATE_HUFFMAN_QL_SHIFT ( 16 - DEFLATE_HUFFMAN_QL_BITS ) |
| Quick lookup shift. | |
| #define | DEFLATE_LITLEN_END 256 |
| Literal/length end of block code. | |
| #define | DEFLATE_LITLEN_MAX_CODE 287 |
| Maximum value of a literal/length code. | |
| #define | DEFLATE_DISTANCE_MAX_CODE 31 |
| Maximum value of a distance code. | |
| #define | DEFLATE_CODELEN_MAX_CODE 18 |
| Maximum value of a code length code. | |
| #define | ZLIB_HEADER_BITS 16 |
| ZLIB header length (in bits) | |
| #define | ZLIB_HEADER_CM_LSB 0 |
| ZLIB header compression method LSB. | |
| #define | ZLIB_HEADER_CM_MASK 0x0f |
| ZLIB header compression method mask. | |
| #define | ZLIB_HEADER_CM_DEFLATE 8 |
| ZLIB header compression method: DEFLATE. | |
| #define | ZLIB_HEADER_FDICT_BIT 13 |
| ZLIB header preset dictionary flag bit. | |
| #define | ZLIB_ADLER32_BITS 32 |
| ZLIB ADLER32 length (in bits) | |
Enumerations | |
| enum | deflate_format { DEFLATE_RAW , DEFLATE_ZLIB } |
| Compression formats. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
| FILE_SECBOOT (PERMITTED) | |
| struct deflate_static_length_pattern | __attribute__ ((packed)) |
| static | __attribute__ ((always_inline)) void deflate_chunk_init(struct deflate_chunk *chunk |
| Initialise chunk of data. | |
| static int | deflate_finished (struct deflate *deflate) |
| Check if decompression has finished. | |
| void | deflate_init (struct deflate *deflate, enum deflate_format format) |
| Initialise decompressor. | |
| int | deflate_inflate (struct deflate *deflate, const void *data, size_t len, struct deflate_chunk *out) |
| Inflate compressed data. | |
Variables | |
| uint8_t | fill |
| Length pair. | |
| uint8_t | count |
| Repetition count. | |
| struct deflate | __attribute__ |
| static void * | data |
| static void size_t | offset = offset |
| static void size_t size_t | len |
DEFLATE decompression algorithm.
Definition in file deflate.h.
| #define DEFLATE_HEADER_BITS 3 |
Block header length (in bits)
Definition at line 25 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_HEADER_BFINAL_BIT 0 |
Block header final block flags bit.
Definition at line 28 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_HEADER_BTYPE_LSB 1 |
| #define DEFLATE_HEADER_BTYPE_MASK 0x03 |
| #define DEFLATE_HEADER_BTYPE_LITERAL 0 |
Block header type: literal data.
Definition at line 37 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_HEADER_BTYPE_STATIC 1 |
Block header type: static Huffman alphabet.
Definition at line 40 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_HEADER_BTYPE_DYNAMIC 2 |
Block header type: dynamic Huffman alphabet.
Definition at line 43 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_LITERAL_LEN_BITS 16 |
Literal header LEN/NLEN field length (in bits)
Definition at line 46 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_BITS 14 |
Dynamic header length (in bits)
Definition at line 49 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HLIT_LSB 0 |
Dynamic header HLIT field LSB.
Definition at line 52 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HLIT_MASK 0x1f |
Dynamic header HLIT field mask.
Definition at line 55 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HDIST_LSB 5 |
Dynamic header HDIST field LSB.
Definition at line 58 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HDIST_MASK 0x1f |
Dynamic header HDIST field mask.
Definition at line 61 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HCLEN_LSB 10 |
Dynamic header HCLEN field LSB.
Definition at line 64 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_DYNAMIC_HCLEN_MASK 0x0f |
Dynamic header HCLEN field mask.
Definition at line 67 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_CODELEN_BITS 3 |
Dynamic header code length length (in bits)
Definition at line 70 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_HUFFMAN_BITS 15 |
Maximum length of a Huffman symbol (in bits)
Definition at line 73 of file deflate.h.
Referenced by deflate_decode().
| #define DEFLATE_HUFFMAN_QL_BITS 7 |
Quick lookup length for a Huffman symbol (in bits)
This is a policy decision.
Definition at line 79 of file deflate.h.
Referenced by deflate_alphabet().
| #define DEFLATE_HUFFMAN_QL_SHIFT ( 16 - DEFLATE_HUFFMAN_QL_BITS ) |
Quick lookup shift.
Definition at line 82 of file deflate.h.
Referenced by deflate_alphabet(), and deflate_decode().
| #define DEFLATE_LITLEN_END 256 |
Literal/length end of block code.
Definition at line 85 of file deflate.h.
Referenced by deflate_inflate().
| #define DEFLATE_LITLEN_MAX_CODE 287 |
| #define DEFLATE_DISTANCE_MAX_CODE 31 |
| #define DEFLATE_CODELEN_MAX_CODE 18 |
Maximum value of a code length code.
Definition at line 94 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_HEADER_BITS 16 |
ZLIB header length (in bits)
Definition at line 97 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_HEADER_CM_LSB 0 |
ZLIB header compression method LSB.
Definition at line 100 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_HEADER_CM_MASK 0x0f |
ZLIB header compression method mask.
Definition at line 103 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_HEADER_CM_DEFLATE 8 |
ZLIB header compression method: DEFLATE.
Definition at line 106 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_HEADER_FDICT_BIT 13 |
ZLIB header preset dictionary flag bit.
Definition at line 109 of file deflate.h.
Referenced by deflate_inflate().
| #define ZLIB_ADLER32_BITS 32 |
ZLIB ADLER32 length (in bits)
Definition at line 112 of file deflate.h.
Referenced by deflate_inflate().
| enum deflate_format |
Compression formats.
| Enumerator | |
|---|---|
| DEFLATE_RAW | Raw DEFLATE data (no header or footer) |
| DEFLATE_ZLIB | ZLIB header and footer. |
Definition at line 17 of file deflate.h.
| FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
| FILE_SECBOOT | ( | PERMITTED | ) |
| struct deflate_static_length_pattern __attribute__ | ( | (packed) | ) |
|
inlinestatic |
Initialise chunk of data.
| chunk | Chunk of data to initialise |
| data | Data |
| offset | Starting offset |
| len | Length |
|
inlinestatic |
Check if decompression has finished.
| deflate | Decompressor |
| finished | Decompression has finished |
Definition at line 278 of file deflate.h.
References NULL, and deflate::resume.
Referenced by deflate_okx(), png_image_end(), and zlib_deflate().
|
extern |
Initialise decompressor.
| deflate | Decompressor |
| format | Compression format code |
Definition at line 992 of file deflate.c.
References assert, base, bit, bits, deflate_distance_base, deflate_litlen_base, deflate_reverse, deflate::format, format, and memset().
Referenced by deflate_okx(), png_pixbuf(), and zlib_deflate().
|
extern |
Inflate compressed data.
| deflate | Decompressor |
| data | Compressed input data |
| len | Length of compressed input data |
| out | Output data buffer |
| rc | Return status code |
The caller can use deflate_finished() to determine whether a successful return indicates that the decompressor is merely waiting for more input.
Data will not be written beyond the specified end of the output data buffer, but the offset within the output data buffer will be updated to reflect the amount that should have been written. The caller can use this to find the length of the decompressed data before allocating the output data buffer.
Definition at line 484 of file deflate.c.
References assert, bits, cm, code, deflate_static_length_pattern::count, data, DBGC, DBGC2, DBGCP, deflate_accumulate(), DEFLATE_CODELEN_BITS, deflate_codelen_map, DEFLATE_CODELEN_MAX_CODE, deflate_copy(), deflate_decode(), deflate_discard_to_byte(), deflate_distance_base, DEFLATE_DYNAMIC_BITS, DEFLATE_DYNAMIC_HCLEN_LSB, DEFLATE_DYNAMIC_HCLEN_MASK, DEFLATE_DYNAMIC_HDIST_LSB, DEFLATE_DYNAMIC_HDIST_MASK, DEFLATE_DYNAMIC_HLIT_LSB, DEFLATE_DYNAMIC_HLIT_MASK, deflate_extract(), DEFLATE_HEADER_BFINAL_BIT, DEFLATE_HEADER_BITS, DEFLATE_HEADER_BTYPE_DYNAMIC, DEFLATE_HEADER_BTYPE_LITERAL, DEFLATE_HEADER_BTYPE_LSB, DEFLATE_HEADER_BTYPE_STATIC, DEFLATE_LITERAL_LEN_BITS, deflate_litlen_base, DEFLATE_LITLEN_END, DEFLATE_RAW, deflate_set_length(), deflate_static_length_patterns, DEFLATE_ZLIB, deflate::distance_codelen, deflate::distance_count, deflate::dup_distance, deflate::dup_len, EINVAL, deflate::end, ENOTSUP, extra, deflate::extra_bits, deflate_static_length_pattern::fill, deflate::format, deflate::header, header, deflate::in, index, isprint(), len, deflate::length, deflate::length_index, deflate::length_target, deflate::lengths, deflate::litlen, deflate::litlen_count, memset(), NULL, out, rc, deflate::remaining, deflate::resume, ZLIB_ADLER32_BITS, ZLIB_HEADER_BITS, ZLIB_HEADER_CM_DEFLATE, ZLIB_HEADER_CM_LSB, ZLIB_HEADER_CM_MASK, and ZLIB_HEADER_FDICT_BIT.
Referenced by deflate_okx(), png_image_data(), and zlib_deflate().