libaaruformat 1.0
Aaru Data Preservation Suite - Format Library
Loading...
Searching...
No Matches
zstd.c File Reference
#include <stddef.h>
#include <stdint.h>
#include <aaruformat.h>
#include <zstd.h>

Go to the source code of this file.

Functions

size_t aaruf_zstd_decode_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size)
 Decodes a Zstandard-compressed buffer.
size_t aaruf_zstd_encode_buffer (uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, int level, int num_threads)
 Encodes a buffer using Zstandard compression.

Function Documentation

◆ aaruf_zstd_decode_buffer()

size_t aaruf_zstd_decode_buffer ( uint8_t * dst_buffer,
size_t dst_size,
const uint8_t * src_buffer,
size_t src_size )

Decodes a Zstandard-compressed buffer.

Parameters
dst_bufferPointer to the destination buffer.
dst_sizeSize of the destination buffer.
src_bufferPointer to the source (compressed) buffer.
src_sizeSize of the source buffer.
Returns
Number of decompressed bytes, or 0 on error.

Definition at line 34 of file zstd.c.

References AARU_CALL, and AARU_EXPORT.

Referenced by aaruf_read_sector(), decode_ddt_multi_level_v2(), ec_load_ecmb(), ec_recover_data_block(), process_data_block(), process_ddt_v1(), process_ddt_v2(), and read_zstd_compressed_payload().

◆ aaruf_zstd_encode_buffer()

size_t aaruf_zstd_encode_buffer ( uint8_t * dst_buffer,
size_t dst_size,
const uint8_t * src_buffer,
size_t src_size,
int level,
int num_threads )

Encodes a buffer using Zstandard compression.

Uses the advanced API (ZSTD_CCtx) to support multi-threaded compression when num_threads > 1. With num_threads <= 1 the output is bit-identical to the simple ZSTD_compress() API.

Parameters
dst_bufferPointer to the destination buffer.
dst_sizeSize of the destination buffer.
src_bufferPointer to the source (uncompressed) buffer.
src_sizeSize of the source buffer.
levelCompression level (1-22).
num_threadsNumber of worker threads (1 = single-threaded).
Returns
Number of compressed bytes, or 0 on error.

Definition at line 59 of file zstd.c.

References AARU_CALL, and AARU_EXPORT.

Referenced by aaruf_close_current_block(), ec_flush_data_stripe(), ec_write_batch_parity(), set_ddt_multi_level_v2(), write_cached_secondary_ddt(), write_dvd_long_sector_blocks(), write_dvd_title_key_decrypted_block(), write_flux_capture_payload(), write_media_tags(), write_mode2_subheaders_block(), write_sector_prefix(), write_sector_prefix_ddt(), write_sector_subchannel(), write_sector_suffix(), write_sector_suffix_ddt(), and write_single_level_ddt().