Huffman Table APIs#
Functions#
Creation and Destruction of Huffman table#
-
qpl_status qpl_deflate_huffman_table_create(const qpl_huffman_table_type_e type, const qpl_path_t path, const allocator_t allocator, qpl_huffman_table_t *table_ptr)#
Creates a qpl_huffman_table_t object for deflate. Allocate and markup of internal structures.
- Parameters:
type – [in] qpl_huffman_table_type_e
path – [in] qpl_path_t
allocator – [in] allocator_t that must be used
table_ptr – [out] output parameter for created object
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_only_table_create(const qpl_huffman_table_type_e type, const qpl_path_t path, const allocator_t allocator, qpl_huffman_table_t *table_ptr)#
Creates a qpl_huffman_table_t object for Huffman Only. Allocate and markup of internal structures.
- Parameters:
type – [in] qpl_huffman_table_type_e
path – [in] qpl_path_t
allocator – [in] allocator that must be used
table_ptr – [out] output parameter for created object
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_table_destroy(qpl_huffman_table_t table)#
Destroy an qpl_huffman_table_t object. Deallocates internal structures.
- Parameters:
table – [inout] qpl_huffman_table_t object to destroy
- Returns:
status from qpl_status
Initialization of Huffman table#
-
qpl_status qpl_huffman_table_init_with_triplets(qpl_huffman_table_t table, const qpl_huffman_triplet *const triplet_ptr, const uint32_t triplet_count)#
Initializes huffman table with provided triplets.
- Parameters:
table – [inout] qpl_huffman_table_t object to init
triplet_ptr – [in] user defined triplet huffman codes
triplet_count – [in] huffman codes count
- Returns:
status from qpl_status
-
qpl_status qpl_gather_deflate_statistics(uint8_t *source_ptr, const uint32_t source_length, qpl_histogram *histogram_ptr, const qpl_compression_levels level, const qpl_path_t path)#
Gathers deflate statistics (literals/lengths and offsets histogram)
- Parameters:
source_ptr – [in] Pointer to source vector that should be processed
source_length – [in] Source vector length
histogram_ptr – [out] Pointer to histogram to be updated
level – [in] Level of compression algorithm
path – [in] Execution path
- Returns:
One of statuses presented in the qpl_status
-
qpl_status qpl_huffman_table_init_with_histogram(qpl_huffman_table_t table, const qpl_histogram *const histogram_ptr)#
Initializes huffman table with provided histogram.
- Parameters:
table – [inout] qpl_huffman_table_t object to init
histogram_ptr – [in] source statistics
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_table_init_with_other(qpl_huffman_table_t table, const qpl_huffman_table_t other)#
Initializes huffman table with information from another table.
- Parameters:
table – [inout] qpl_huffman_table_t object to init
other – [in] base qpl_huffman_table_t object
- Returns:
status from qpl_status
Serialization APIs#
-
qpl_status qpl_huffman_table_get_serialized_size(const qpl_huffman_table_t table, const serialization_options_t options, size_t *const size_ptr)#
API to get size of the table to be serialized.
Note
Serialization is only supported for serialization_raw format.
- Parameters:
table – [in] qpl_huffman_table_t object to serialize
options – [in] serialization_options_t
size_ptr – [out] output parameter for size
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_table_serialize(const qpl_huffman_table_t table, uint8_t *const dump_buffer_ptr, const size_t dump_buffer_size, const serialization_options_t options)#
Serializes qpl_huffman_table_t object.
Note
Serialization is only supported for serialization_raw format.
- Parameters:
table – [in] qpl_huffman_table_t object to serialize
dump_buffer_ptr – [out] serialized object buffer
dump_buffer_size – [in] serialized object buffer size
options – [in] serialization_options_t
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_table_deserialize(const uint8_t *const dump_buffer_ptr, const size_t dump_buffer_size, allocator_t allocator, qpl_huffman_table_t *table_ptr)#
Deserializes previously serialized huffman table.
- Parameters:
dump_buffer_ptr – [in] serialized object buffer
dump_buffer_size – [in] serialized object buffer size
allocator – [in] allocator that must be used
table_ptr – [out] output parameter for created object
- Returns:
status from qpl_status
-
qpl_status qpl_huffman_table_get_type(const qpl_huffman_table_t table, qpl_huffman_table_type_e *const type_ptr)#
Returns type of qpl_huffman_table_t.
- Parameters:
table – [in] source qpl_huffman_table_t object
type_ptr – [out] output parameter for table type according to qpl_huffman_table_type_e
- Returns:
status from qpl_status
Types#
-
typedef struct qpl_huffman_table *qpl_huffman_table_t#
Special data type that is an opaque pointer to unified compression/decompression table.
Enums#
-
enum qpl_huffman_table_type_e#
Type used to specify whether Huffman table would store compression, decompression or both tables internally.
Values:
-
enumerator combined_table_type#
qpl_huffman_table_t contains both tables
-
enumerator compression_table_type#
qpl_huffman_table_t contains compression table only
-
enumerator decompression_table_type#
qpl_huffman_table_t contains decompression table only
-
enumerator combined_table_type#
-
enum qpl_serialization_format_e#
Describes how to perform serialization
Values:
-
enumerator serialization_compact#
More compact representation, useful for saving up memory on the disk
-
enumerator serialization_raw#
Faster but more straightforward implementation, use to save speed of serialization/deserialization in case high load
-
enumerator serialization_compact#
Structures#
-
struct qpl_huffman_triplet#
Structure for intermediate representation of Huffman token.
-
struct qpl_histogram#
Structure that represents histogram of literals, lengths and offsets symbols.
Public Members
-
uint32_t literal_lengths[QPL_LITERALS_MATCHES_TABLE_SIZE]#
Combined histogram for literals and match lengths tokens
-
uint32_t reserved_literal_lengths[2U]#
Reserved match lengths tokens
-
uint32_t distances[QPL_DEFAULT_OFFSETS_NUMBER]#
Histogram for distance tokens
-
uint32_t reserved_distances[2U]#
Reserved distance tokens
-
uint32_t literal_lengths[QPL_LITERALS_MATCHES_TABLE_SIZE]#
-
struct serialization_options_t#
Describes serialization options.
Public Members
-
qpl_serialization_format_e format#
qpl_serialization_format_e of serialized object
-
serialization_flags_t flags#
Advanced serialization options, placeholder for later
-
qpl_serialization_format_e format#