|
CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
|
CCSDS Section 5.2: Encoding primitives. More...
Functions | |
| int | ccsds124_count_encode (bitbuffer_t *output, uint32_t A) |
| Counter encoding (CCSDS Section 5.2.2, Equation 9). | |
| int | ccsds124_rle_encode (bitbuffer_t *output, const bitvector_t *input) |
| Run-length encoding (CCSDS Section 5.2.3, Equation 10). | |
| int | ccsds124_bit_extract (bitbuffer_t *output, const bitvector_t *data, const bitvector_t *mask) |
| Bit extraction (CCSDS Section 5.2.4, Equation 11). | |
| int | ccsds124_bit_extract_forward (bitbuffer_t *output, const bitvector_t *data, const bitvector_t *mask) |
| Bit extraction in forward order (LSB to MSB). | |
CCSDS Section 5.2: Encoding primitives.
These functions implement the three encoding methods used in CCSDS 124.0-B-1 compressed packets.
| int ccsds124_bit_extract | ( | bitbuffer_t * | output, |
| const bitvector_t * | data, | ||
| const bitvector_t * | mask | ||
| ) |
Bit extraction (CCSDS Section 5.2.4, Equation 11).
Extracts bits from data where mask bit is 1, in reverse order (MSB to LSB). Used for unpredictable bit encoding.
| [out] | output | Bit buffer to append extracted bits |
| [in] | data | Source data vector |
| [in] | mask | Mask indicating which bits to extract |
Definition at line 220 of file encode.c.
References bitbuffer_append_bit(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_OK, bitvector::data, bitvector::length, and bitvector::num_words.
Referenced by ccsds124_compress_packet().
| int ccsds124_bit_extract_forward | ( | bitbuffer_t * | output, |
| const bitvector_t * | data, | ||
| const bitvector_t * | mask | ||
| ) |
Bit extraction in forward order (LSB to MSB).
Used specifically for kₜ component encoding where forward order is required.
| [out] | output | Bit buffer to append extracted bits |
| [in] | data | Source data vector |
| [in] | mask | Mask indicating which bits to extract |
Definition at line 273 of file encode.c.
References bitbuffer_append_bit(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_OK, bitvector::data, bitvector::length, and bitvector::num_words.
Referenced by ccsds124_compress_packet().
| int ccsds124_count_encode | ( | bitbuffer_t * | output, |
| uint32_t | A | ||
| ) |
Counter encoding (CCSDS Section 5.2.2, Equation 9).
Encodes an integer A as a unary prefix followed by binary suffix. Used for run lengths and counts in compressed output.
| [out] | output | Bit buffer to append encoded value |
| [in] | A | Value to encode (0 to MAX) |
Pre-computed COUNT encodings for values 1-33.
Eliminates per-value bit-by-bit encoding for the most common COUNT values by using bitbuffer_append_value() with pre-computed patterns.
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.
Values 1-33 cover the fast path; larger values (A≥34) use bit-by-bit encoding for MISRA-C:2012 compliance (shift bounds verification).
Definition at line 40 of file encode.c.
References bitbuffer_append_bit(), bitbuffer_append_value(), CCSDS124_ERROR_INVALID_ARG, and CCSDS124_OK.
Referenced by ccsds124_compress_packet(), and ccsds124_rle_encode().
| int ccsds124_rle_encode | ( | bitbuffer_t * | output, |
| const bitvector_t * | input | ||
| ) |
Run-length encoding (CCSDS Section 5.2.3, Equation 10).
Encodes a bit vector as alternating run lengths of 0s and 1s. Starts with run of 0s from MSB.
| [out] | output | Bit buffer to append encoded runs |
| [in] | input | Bit vector to encode (typically reversed) |
Definition at line 135 of file encode.c.
References bitbuffer_append_bit(), ccsds124_count_encode(), CCSDS124_ERROR_INVALID_ARG, CCSDS124_OK, bitvector::data, bitvector::length, and bitvector::num_words.
Referenced by ccsds124_compress_packet().