|
CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
|
Variable-length output buffer for compressed data. More...
Data Structures | |
| struct | bitbuffer |
| Variable-length bit buffer structure. More... | |
Functions | |
| void | bitbuffer_init (bitbuffer_t *bb) |
| Initialize bit buffer to empty state. | |
| void | bitbuffer_clear (bitbuffer_t *bb) |
| Clear bit buffer contents. | |
| int | bitbuffer_append_bit (bitbuffer_t *bb, int bit) |
| Append a single bit to buffer. | |
| int | bitbuffer_append_bits (bitbuffer_t *bb, const uint8_t *data, size_t num_bits) |
| Append multiple bits from byte array. | |
| int | bitbuffer_append_value (bitbuffer_t *bb, uint32_t value, size_t num_bits) |
| Append multiple bits from a value directly to accumulator. | |
| int | bitbuffer_append_bitvector (bitbuffer_t *bb, const bitvector_t *bv) |
| Append all bits from a bit vector. | |
| size_t | bitbuffer_size (const bitbuffer_t *bb) |
| Get number of bits in buffer. | |
| size_t | bitbuffer_to_bytes (const bitbuffer_t *bb, uint8_t *data, size_t max_bytes) |
| Convert bit buffer to byte array. | |
Variable-length output buffer for compressed data.
Bit buffers accumulate compressed output bit-by-bit and convert to byte arrays for transmission or storage.
| int bitbuffer_append_bit | ( | bitbuffer_t * | bb, |
| int | bit | ||
| ) |
Append a single bit to buffer.
| [out] | bb | Bit buffer |
| [in] | bit | Bit value (0 or 1) |
Definition at line 77 of file bitbuffer.c.
References acc, acc_len, bitbuffer_flush_acc(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_OVERFLOW, CCSDS124_MAX_OUTPUT_BYTES, CCSDS124_OK, and num_bits.
Referenced by bitbuffer_append_bits(), bitbuffer_append_bitvector(), ccsds124_bit_extract(), ccsds124_bit_extract_forward(), ccsds124_compress_packet(), ccsds124_count_encode(), and ccsds124_rle_encode().
| int bitbuffer_append_bits | ( | bitbuffer_t * | bb, |
| const uint8_t * | data, | ||
| size_t | num_bits | ||
| ) |
Append multiple bits from byte array.
| [out] | bb | Bit buffer |
| [in] | data | Source bytes (MSB first within each byte) |
| [in] | num_bits | Number of bits to append |
Definition at line 105 of file bitbuffer.c.
References bitbuffer_append_bit(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_OVERFLOW, CCSDS124_MAX_OUTPUT_BYTES, CCSDS124_OK, and num_bits.
| int bitbuffer_append_bitvector | ( | bitbuffer_t * | bb, |
| const bitvector_t * | bv | ||
| ) |
Append all bits from a bit vector.
| [out] | bb | Bit buffer |
| [in] | bv | Bit vector to append |
Definition at line 181 of file bitbuffer.c.
References bitbuffer_append_bit(), bitvector_get_bit(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_OK, and bitvector::length.
Referenced by ccsds124_compress_packet().
| int bitbuffer_append_value | ( | bitbuffer_t * | bb, |
| uint32_t | value, | ||
| size_t | num_bits | ||
| ) |
Append multiple bits from a value directly to accumulator.
Efficiently appends up to 24 bits from a uint32_t value MSB-first. The top 'num_bits' bits of the value (shifted left) are appended.
| [out] | bb | Bit buffer |
| [in] | value | Value containing bits to append (left-justified) |
| [in] | num_bits | Number of bits to append (1-24) |
Append multiple bits from a value directly to accumulator.
Batches bit operations to reduce function call overhead vs calling bitbuffer_append_bit() in a loop. Used by COUNT encoding lookup table.
Performance: ~2% compression speedup from this optimization. Combined with DeBruijn bit extraction and word-level operations, achieves 14-16% faster compression and 13-39% faster decompression on real-world datasets.
| [out] | bb | Bit buffer |
| [in] | value | Value containing bits (right-justified) |
| [in] | num_bits | Number of bits to append (1-24) |
Definition at line 151 of file bitbuffer.c.
References acc, acc_len, bitbuffer_flush_acc(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_OVERFLOW, CCSDS124_MAX_OUTPUT_BYTES, CCSDS124_OK, and num_bits.
Referenced by ccsds124_count_encode().
| void bitbuffer_clear | ( | bitbuffer_t * | bb | ) |
Clear bit buffer contents.
| [out] | bb | Bit buffer to clear |
Definition at line 50 of file bitbuffer.c.
References bitbuffer_init().
Referenced by ccsds124_compress_packet().
| void bitbuffer_init | ( | bitbuffer_t * | bb | ) |
Initialize bit buffer to empty state.
| [out] | bb | Bit buffer to initialize |
Definition at line 40 of file bitbuffer.c.
References acc, acc_len, CCSDS124_MAX_OUTPUT_BYTES, data, and num_bits.
Referenced by bitbuffer_clear(), and ccsds124_compress().
| size_t bitbuffer_size | ( | const bitbuffer_t * | bb | ) |
Get number of bits in buffer.
| [in] | bb | Bit buffer |
Definition at line 226 of file bitbuffer.c.
References num_bits.
| size_t bitbuffer_to_bytes | ( | const bitbuffer_t * | bb, |
| uint8_t * | data, | ||
| size_t | max_bytes | ||
| ) |
Convert bit buffer to byte array.
Pads final byte with zeros if not byte-aligned.
| [in] | bb | Bit buffer |
| [out] | data | Destination byte array |
| [in] | max_bytes | Maximum bytes to write |
Definition at line 244 of file bitbuffer.c.
References acc, acc_len, data, and num_bits.
Referenced by ccsds124_compress().