|
CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
|
Fixed-length binary vector operations. More...
Data Structures | |
| struct | bitvector |
| Fixed-length bit vector structure. More... | |
Functions | |
| int | bitvector_init (bitvector_t *bv, size_t num_bits) |
| Initialize a bit vector with specified length. | |
| void | bitvector_zero (bitvector_t *bv) |
| Set all bits to zero. | |
| void | bitvector_copy (bitvector_t *dest, const bitvector_t *src) |
| Copy bit vector contents. | |
| static int | bitvector_get_bit (const bitvector_t *bv, size_t pos) |
| Get bit value at position (inline for performance). | |
| static void | bitvector_set_bit (bitvector_t *bv, size_t pos, int value) |
| Set bit value at position (inline for performance). | |
| void | bitvector_xor (bitvector_t *result, const bitvector_t *a, const bitvector_t *b) |
| Bitwise XOR operation. | |
| void | bitvector_or (bitvector_t *result, const bitvector_t *a, const bitvector_t *b) |
| Bitwise OR operation. | |
| void | bitvector_and (bitvector_t *result, const bitvector_t *a, const bitvector_t *b) |
| Bitwise AND operation. | |
| void | bitvector_not (bitvector_t *result, const bitvector_t *a) |
| Bitwise NOT operation. | |
| void | bitvector_left_shift (bitvector_t *result, const bitvector_t *a) |
| Left shift by one bit. | |
| void | bitvector_reverse (bitvector_t *result, const bitvector_t *a) |
| Reverse bit order. | |
| size_t | bitvector_hamming_weight (const bitvector_t *bv) |
| Count number of set bits (Hamming weight). | |
| int | bitvector_equals (const bitvector_t *a, const bitvector_t *b) |
| Compare two bit vectors for equality. | |
| int | bitvector_from_bytes (bitvector_t *bv, const uint8_t *data, size_t num_bytes) |
| Load bit vector from byte array. | |
| int | bitvector_to_bytes (const bitvector_t *bv, uint8_t *data, size_t num_bytes) |
| Store bit vector to byte array. | |
Fixed-length binary vector operations.
Bit vectors are the fundamental data structure for CCSDS 124.0-B-1 compression. They represent fixed-length binary sequences with operations for bitwise logic, shifting, and counting.
| void bitvector_and | ( | bitvector_t * | result, |
| const bitvector_t * | a, | ||
| const bitvector_t * | b | ||
| ) |
Bitwise AND operation.
| [out] | result | Result vector (result = a AND b) |
| [in] | a | First operand |
| [in] | b | Second operand |
Definition at line 127 of file bitvector.c.
| void bitvector_copy | ( | bitvector_t * | dest, |
| const bitvector_t * | src | ||
| ) |
Copy bit vector contents.
| [out] | dest | Destination bit vector |
| [in] | src | Source bit vector |
Definition at line 72 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_compress_packet(), ccsds124_compressor_init(), ccsds124_compressor_reset(), ccsds124_compute_robustness_window(), ccsds124_decompress_packet_internal(), ccsds124_decompressor_init(), and ccsds124_decompressor_reset().
| int bitvector_equals | ( | const bitvector_t * | a, |
| const bitvector_t * | b | ||
| ) |
Compare two bit vectors for equality.
| [in] | a | First bit vector |
| [in] | b | Second bit vector |
Definition at line 247 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_decompress_packet_internal().
| int bitvector_from_bytes | ( | bitvector_t * | bv, |
| const uint8_t * | data, | ||
| size_t | num_bytes | ||
| ) |
Load bit vector from byte array.
Loads bytes in big-endian order (first byte contains MSB bits).
| [out] | bv | Bit vector to load into |
| [in] | data | Source byte array |
| [in] | num_bytes | Number of bytes to load |
Definition at line 269 of file bitvector.c.
References CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_OVERFLOW, CCSDS124_OK, data, length, and num_words.
Referenced by ccsds124_compress().
|
inlinestatic |
Get bit value at position (inline for performance).
| [in] | bv | Bit vector |
| [in] | pos | Bit position (0 = LSB, length-1 = MSB) |
Definition at line 169 of file ccsds124.h.
References data.
Referenced by bitbuffer_append_bitvector(), bitvector_reverse(), and ccsds124_decompress_packet_internal().
| size_t bitvector_hamming_weight | ( | const bitvector_t * | bv | ) |
Count number of set bits (Hamming weight).
| [in] | bv | Bit vector |
Definition at line 222 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_bit_insert(), ccsds124_compress_packet(), ccsds124_compute_effective_robustness(), and ccsds124_decompress_packet_internal().
| int bitvector_init | ( | bitvector_t * | bv, |
| size_t | num_bits | ||
| ) |
Initialize a bit vector with specified length.
Allocates internal storage and sets all bits to zero.
| [out] | bv | Bit vector to initialize (caller-allocated) |
| [in] | num_bits | Number of bits (1 to CCSDS124_MAX_PACKET_LENGTH) |
Definition at line 44 of file bitvector.c.
References CCSDS124_ERROR_INVALID_ARG, CCSDS124_MAX_PACKET_LENGTH, CCSDS124_OK, data, length, and num_words.
Referenced by ccsds124_compress(), ccsds124_compressor_init(), ccsds124_decompress_packet_internal(), ccsds124_decompressor_init(), ccsds124_rle_decode(), ccsds124_update_build(), and ccsds124_update_mask().
| void bitvector_left_shift | ( | bitvector_t * | result, |
| const bitvector_t * | a | ||
| ) |
Left shift by one bit.
Shifts all bits left, inserting 0 at LSB position.
| [out] | result | Result vector (result = a << 1) |
| [in] | a | Operand |
Definition at line 178 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_compress_packet().
| void bitvector_not | ( | bitvector_t * | result, |
| const bitvector_t * | a | ||
| ) |
Bitwise NOT operation.
| [out] | result | Result vector (result = NOT a) |
| [in] | a | Operand |
Definition at line 144 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_compress_packet().
| void bitvector_or | ( | bitvector_t * | result, |
| const bitvector_t * | a, | ||
| const bitvector_t * | b | ||
| ) |
Bitwise OR operation.
| [out] | result | Result vector (result = a OR b) |
| [in] | a | First operand |
| [in] | b | Second operand |
Definition at line 110 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_compress_packet(), ccsds124_decompress_packet_internal(), ccsds124_update_build(), and ccsds124_update_mask().
| void bitvector_reverse | ( | bitvector_t * | result, |
| const bitvector_t * | a | ||
| ) |
Reverse bit order.
Reverses the bit order: MSB becomes LSB and vice versa. CCSDS notation: result =
| [out] | result | Result vector with reversed bits |
| [in] | a | Operand |
Definition at line 200 of file bitvector.c.
References bitvector_get_bit(), bitvector_set_bit(), bitvector_zero(), length, and num_words.
|
inlinestatic |
Set bit value at position (inline for performance).
| [out] | bv | Bit vector to modify |
| [in] | pos | Bit position (0 = LSB, length-1 = MSB) |
| [in] | value | Bit value (0 or 1) |
Definition at line 188 of file ccsds124.h.
References data.
Referenced by bitvector_reverse(), ccsds124_bit_insert(), ccsds124_decompress_packet_internal(), and ccsds124_rle_decode().
| int bitvector_to_bytes | ( | const bitvector_t * | bv, |
| uint8_t * | data, | ||
| size_t | num_bytes | ||
| ) |
Store bit vector to byte array.
Stores bytes in big-endian order (first byte contains MSB bits).
| [in] | bv | Bit vector to store |
| [out] | data | Destination byte array |
| [in] | num_bytes | Number of bytes to store |
Definition at line 311 of file bitvector.c.
References CCSDS124_ERROR_INVALID_ARG, CCSDS124_ERROR_UNDERFLOW, CCSDS124_OK, data, length, and num_words.
Referenced by ccsds124_decompress().
| void bitvector_xor | ( | bitvector_t * | result, |
| const bitvector_t * | a, | ||
| const bitvector_t * | b | ||
| ) |
Bitwise XOR operation.
| [out] | result | Result vector (result = a XOR b) |
| [in] | a | First operand |
| [in] | b | Second operand |
Definition at line 93 of file bitvector.c.
References data, length, and num_words.
Referenced by ccsds124_compress_packet(), ccsds124_compute_change(), ccsds124_update_build(), and ccsds124_update_mask().
| void bitvector_zero | ( | bitvector_t * | bv | ) |
Set all bits to zero.
| [out] | bv | Bit vector to clear |
Definition at line 65 of file bitvector.c.
References data, and num_words.
Referenced by bitvector_reverse(), ccsds124_compressor_init(), ccsds124_compressor_reset(), ccsds124_decompress_packet_internal(), ccsds124_decompressor_init(), ccsds124_decompressor_reset(), ccsds124_rle_decode(), and ccsds124_update_build().