|
CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
|
CCSDS 124.0-B-1 decompression algorithm implementation. More...
Go to the source code of this file.
Data Structures | |
| struct | ccsds124_decompress_flags_t |
| Internal flags extracted during decompression. More... | |
Functions | |
Internal Helper Functions | |
Implements CCSDS 124.0-B-1 decompression (inverse of Section 5.3):
Code follows MISRA C:2012 guidelines.
| |
| static size_t | bitvector_get_set_positions (const bitvector_t *bv, size_t *positions, size_t max_pos) |
| Extract positions of all set bits in a bitvector using word-level processing. | |
Bit Reader Functions | |
| void | bitreader_init (bitreader_t *reader, const uint8_t *data, size_t num_bits) |
| Initialize bit reader. | |
| int | bitreader_read_bit (bitreader_t *reader) |
| Read a single bit. | |
| uint32_t | bitreader_read_bits (bitreader_t *reader, size_t num_bits) |
| Read multiple bits as unsigned value. | |
| size_t | bitreader_position (const bitreader_t *reader) |
| Get current bit position. | |
| size_t | bitreader_remaining (const bitreader_t *reader) |
| Get remaining bits. | |
| void | bitreader_align_byte (bitreader_t *reader) |
| Skip to next byte boundary. | |
Decoding Functions | |
| int | ccsds124_count_decode (bitreader_t *reader, uint32_t *value) |
| Counter decoding (inverse of ccsds124_count_encode). | |
| int | ccsds124_rle_decode (bitreader_t *reader, bitvector_t *result, size_t length) |
| Run-length decoding (inverse of ccsds124_rle_encode). | |
| int | ccsds124_bit_insert (bitreader_t *reader, bitvector_t *data, const bitvector_t *mask) |
| Bit insertion (inverse of ccsds124_bit_extract). | |
Decompressor Initialization | |
| int | ccsds124_decompressor_init (ccsds124_decompressor_t *decomp, size_t F, const bitvector_t *initial_mask, uint8_t robustness) |
| Initialize decompressor state. | |
| void | ccsds124_decompressor_reset (ccsds124_decompressor_t *decomp) |
| Reset decompressor to initial state. | |
| int | ccsds124_decompressor_notify_packet_loss (ccsds124_decompressor_t *decomp, uint32_t lost_count) |
| Notify decompressor of packet loss. | |
Packet Decompression | |
| static int | ccsds124_decompress_packet_internal (ccsds124_decompressor_t *decomp, bitreader_t *reader, bitvector_t *output, ccsds124_decompress_flags_t *flags) |
| Internal decompression with optional flag extraction. | |
| int | ccsds124_decompress_packet (ccsds124_decompressor_t *decomp, bitreader_t *reader, bitvector_t *output) |
| Decompress a single compressed packet. | |
| int | ccsds124_decompress_packet_checked (ccsds124_decompressor_t *decomp, const uint8_t *data, size_t num_bits, bitvector_t *output, ccsds124_decompress_result_t *result) |
| Decompress a single packet with accuracy guarantee checking. | |
| static int | skip_rle_sequence_span (bitreader_t *reader, uint32_t *hamming_weight, uint64_t *span) |
| Skip COUNT values in an RLE sequence until the terminator. | |
| int | ccsds124_discover_packet_length (const uint8_t *data, size_t num_bits, uint32_t *packet_length) |
| Discover packet length (F) from a compressed packet. | |
| int | ccsds124_decompress (ccsds124_decompressor_t *decomp, const uint8_t *input_data, size_t input_size, uint8_t *output_buffer, size_t output_buffer_size, size_t *output_size) |
| Decompress entire compressed data stream. | |
CCSDS 124.0-B-1 decompression algorithm implementation.
Definition in file decompress.c.
|
static |
Extract positions of all set bits in a bitvector using word-level processing.
Much faster than iterating bit-by-bit when the bitvector is sparse. Uses __builtin_clz for O(1) MSB position finding.
| [in] | bv | Bitvector to scan |
| [out] | positions | Array to store positions (must be at least hamming_weight elements) |
| [in] | max_pos | Maximum positions to extract |
Definition at line 48 of file decompress.c.
References bitvector::data, and bitvector::num_words.
Referenced by ccsds124_bit_insert(), and ccsds124_decompress_packet_internal().
|
static |
Internal decompression with optional flag extraction.
Core decompression logic shared by both ccsds124_decompress_packet() and ccsds124_decompress_packet_checked().
| [in,out] | decomp | Decompressor state |
| [in,out] | reader | Bit reader |
| [out] | output | Decompressed output |
| [out] | flags | Optional extracted flags (NULL to skip) |
Definition at line 491 of file decompress.c.
References bitreader_read_bit(), bitreader_read_bits(), bitreader_remaining(), bitvector_copy(), bitvector_equals(), bitvector_get_bit(), bitvector_get_set_positions(), bitvector_hamming_weight(), bitvector_init(), bitvector_or(), bitvector_set_bit(), bitvector_zero(), ccsds124_bit_insert(), ccsds124_count_decode(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_UNDERFLOW, CCSDS124_MAX_PACKET_LENGTH, CCSDS124_OK, ccsds124_rle_decode(), ccsds124_decompressor::count_f_mismatch, ccsds124_decompressor::F, ccsds124_decompress_flags_t::ft, ccsds124_decompressor::mask, ccsds124_decompressor::mask_inconsistent, ccsds124_decompressor::prev_output, ccsds124_decompress_flags_t::rt, ccsds124_decompressor::t, ccsds124_decompress_flags_t::Vt, and ccsds124_decompressor::Xt.
Referenced by ccsds124_decompress_packet(), and ccsds124_decompress_packet_checked().
|
static |
Skip COUNT values in an RLE sequence until the terminator.
Reads and discards COUNT values from the reader until a terminator (COUNT value 0) is found. Returns the hamming weight (number of non-terminator values decoded) via output parameter.
| [in,out] | reader | Bit reader |
| [out] | hamming_weight | Number of non-terminator COUNTs decoded |
Skip an RLE-encoded sequence, tracking hamming weight and span.
The span is the sum of all RLE deltas, which equals one plus the highest '1' position encoded. An RLE sequence for a vector of length F must have span <= F — a larger span means the h or q vector is inconsistent with F (cross-validation rule v1.6).
| [in,out] | reader | Bit reader |
| [out] | hamming_weight | Number of non-terminator COUNTs decoded |
| [out] | span | Sum of decoded deltas (1 + highest position) |
Definition at line 932 of file decompress.c.
References ccsds124_count_decode(), and CCSDS124_OK.
Referenced by ccsds124_discover_packet_length().