|
CCSDS 124.0-B-1 C++ 1.0.0
CCSDS 124.0-B-1 Lossless Compression
|
Namespaces | |
| namespace | detail |
| Pre-computed COUNT encodings for values 1-33. | |
Classes | |
| class | BitBuffer |
| Variable-length bit buffer with static allocation. More... | |
| class | BitReader |
| Sequential bit reader for compressed data. More... | |
| class | BitVector |
| Fixed-length bit vector with compile-time size. More... | |
| class | Ccsds124Exception |
| Base exception for CCSDS 124.0-B-1 errors. More... | |
| class | Compressor |
| CCSDS 124.0-B-1 compressor with static memory allocation. More... | |
| struct | CompressParams |
| Compression parameters for a single packet. More... | |
| class | Decompressor |
| CCSDS 124.0-B-1 decompressor with static memory allocation. More... | |
| class | InvalidArgumentException |
| Exception for invalid arguments. More... | |
| class | InvalidDataException |
| Exception for invalid/corrupted data. More... | |
| class | OverflowException |
| Exception for buffer overflow. More... | |
| class | UnderflowException |
| Exception for buffer underflow. More... | |
Typedefs | |
| using | word_t = std::uint32_t |
| 32-bit word type for bit vector storage (matches C implementation) | |
Enumerations | |
| enum class | Error { Ok = 0 , InvalidArg = -1 , Overflow = -2 , Underflow = -3 , InvalidData = -4 } |
| Error codes for error-code-based error handling. More... | |
Functions | |
| template<std::size_t N> | |
| Error | compress (const std::uint8_t *input_data, std::size_t input_size, std::uint8_t *output_buffer, std::size_t output_buffer_size, std::size_t &output_size, std::uint8_t robustness=0, int pt_limit=0, int ft_limit=0, int rt_limit=0) noexcept |
| Compress multi-packet data stream. | |
| template<std::size_t N> | |
| Error | decompress (const std::uint8_t *input_data, std::size_t input_size, std::uint8_t *output_buffer, std::size_t output_buffer_size, std::size_t &output_size, std::uint8_t robustness=0) noexcept |
| Decompress multi-packet data stream. | |
| const char * | version () noexcept |
| Get library version. | |
| Error | count_decode (BitReader &reader, std::uint32_t &value) noexcept |
| Counter decoding (inverse of CCSDS Section 5.2.2, Equation 9). | |
| template<std::size_t N> | |
| Error | rle_decode (BitReader &reader, BitVector< N > &result) noexcept |
| Run-length decoding (inverse of CCSDS Section 5.2.3, Equation 10). | |
| template<std::size_t N> | |
| Error | bit_insert (BitReader &reader, BitVector< N > &data, const BitVector< N > &mask) noexcept |
| Bit insertion (inverse of CCSDS Section 5.2.4, Equation 11). | |
| template<std::size_t N> | |
| Error | bit_insert_forward (BitReader &reader, BitVector< N > &data, const BitVector< N > &mask) noexcept |
| Bit insertion with forward order. | |
| template<std::size_t MaxBytes> | |
| Error | count_encode (BitBuffer< MaxBytes > &output, std::uint32_t A) noexcept |
| Counter encoding (CCSDS Section 5.2.2, Equation 9). | |
| template<std::size_t MaxBytes, std::size_t N> | |
| Error | rle_encode (BitBuffer< MaxBytes > &output, const BitVector< N > &input) noexcept |
| Run-length encoding (CCSDS Section 5.2.3, Equation 10). | |
| template<std::size_t MaxBytes, std::size_t N> | |
| Error | bit_extract (BitBuffer< MaxBytes > &output, const BitVector< N > &data, const BitVector< N > &mask) noexcept |
| Bit extraction in reverse order (CCSDS Section 5.2.4, Equation 11). | |
| template<std::size_t MaxBytes, std::size_t N> | |
| Error | bit_extract_forward (BitBuffer< MaxBytes > &output, const BitVector< N > &data, const BitVector< N > &mask) noexcept |
| Bit extraction in forward order. | |
| template<std::size_t MaxBytes, std::size_t N1, std::size_t N2> | |
| Error | bit_extract (BitBuffer< MaxBytes > &output, const BitVector< N1 > &data, const BitVector< N2 > &mask) noexcept |
| Bit extraction with different length vectors (for flexibility). | |
| const char * | error_string (Error error) noexcept |
| Get error message for error code. | |
| template<std::size_t N> | |
| void | update_build (BitVector< N > &build, const BitVector< N > &input, const BitVector< N > &prev_input, bool new_mask_flag, std::size_t t) noexcept |
| Update build vector (CCSDS Equation 6). | |
| template<std::size_t N> | |
| void | update_mask (BitVector< N > &mask, const BitVector< N > &input, const BitVector< N > &prev_input, const BitVector< N > &build_prev, bool new_mask_flag) noexcept |
| Update mask vector (CCSDS Equation 7). | |
| template<std::size_t N> | |
| void | compute_change (BitVector< N > &change, const BitVector< N > &mask, const BitVector< N > &prev_mask, std::size_t t) noexcept |
| Compute change vector (CCSDS Equation 8). | |
Variables | |
| constexpr int | VERSION_MAJOR = 1 |
| constexpr int | VERSION_MINOR = 0 |
| constexpr int | VERSION_PATCH = 0 |
| constexpr std::size_t | MAX_PACKET_LENGTH = 65535U |
| constexpr std::size_t | MAX_PACKET_BYTES = (MAX_PACKET_LENGTH + 7U) / 8U |
| constexpr std::size_t | MAX_ROBUSTNESS = 7U |
| constexpr std::size_t | MAX_HISTORY = 16U |
| constexpr std::size_t | MAX_VT_HISTORY = 16U |
| constexpr std::size_t | MAX_OUTPUT_BYTES = MAX_PACKET_BYTES * 6U |
| constexpr std::size_t | BITS_PER_WORD = 32U |
This module provides a dynamically-growing bit buffer for constructing compressed output streams. Bits are appended sequentially using MSB-first ordering as required by CCSDS 124.0-B-1.
The bit reader provides stateful bit-level access to compressed packet data, reading MSB-first within each byte.
This module provides fixed-length bit vector operations optimized for CCSDS 124.0-B-1 compression. Uses 32-bit words with big-endian byte packing to match ESA/ESOC reference implementation.
Provides high-level compress() and decompress() functions for bulk data processing, suitable for file-level operations.
Implements CCSDS 124.0-B-1 Section 5.3 (Encoding Step):
CCSDS 124.0-B-1: Robust Compression of Fixed-Length Housekeeping Data
Implements CCSDS 124.0-B-1 decoding (inverse of Section 5.2):
Implements CCSDS 124.0-B-1 decompression (inverse of Section 5.3):
Implements CCSDS 124.0-B-1 Section 5.2 encoding schemes:
Implements CCSDS 124.0-B-1 Section 4 (Mask Update):
|
strong |
|
noexcept |
Bit extraction in reverse order (CCSDS Section 5.2.4, Equation 11).
BE(a, b) = a_{g_{H(b)-1}} ∥ ... ∥ a_{g₁} ∥ a_{g₀}
| output | Bit buffer to append extracted bits |
| data | Source data vector |
| mask | Mask indicating which bits to extract |
Definition at line 167 of file encoder.hpp.
References Ok.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
|
noexcept |
Bit extraction with different length vectors (for flexibility).
Definition at line 286 of file encoder.hpp.
References InvalidArg.
|
noexcept |
Bit extraction in forward order.
Used specifically for kₜ component encoding where forward order is required.
| output | Bit buffer to append extracted bits |
| data | Source data vector |
| mask | Mask indicating which bits to extract |
Definition at line 234 of file encoder.hpp.
References ccsds124::detail::extract_msb(), and Ok.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
|
noexcept |
Bit insertion (inverse of CCSDS Section 5.2.4, Equation 11).
Inserts bits from reader at positions where mask has '1' bits. This is the inverse of bit_extract.
| N | BitVector length |
| reader | Bit reader with bits to insert | |
| [in,out] | data | Data vector to insert bits into |
| mask | Mask indicating where to insert |
Definition at line 175 of file decoder.hpp.
References ccsds124::detail::extract_lsb(), Ok, and Underflow.
Referenced by ccsds124::Decompressor< N >::decompress_packet().
|
noexcept |
Bit insertion with forward order.
Inserts bits from reader at positions where mask has '1' bits, in forward order (MSB to LSB).
| N | BitVector length |
| reader | Bit reader with bits to insert | |
| [in,out] | data | Data vector to insert bits into |
| mask | Mask indicating where to insert |
Definition at line 227 of file decoder.hpp.
References ccsds124::detail::extract_msb(), Ok, and Underflow.
|
noexcept |
Compress multi-packet data stream.
Compresses input data as a sequence of fixed-size packets using CCSDS 124.0-B-1 algorithm.
| N | Packet length in bits |
| input_data | Input data bytes | |
| input_size | Input size in bytes (must be multiple of packet size) | |
| output_buffer | Output buffer for compressed data | |
| output_buffer_size | Maximum output buffer size | |
| [out] | output_size | Actual compressed output size |
| robustness | Robustness level R (0-7) | |
| pt_limit | New mask period (pt parameter) | |
| ft_limit | Send mask period (ft parameter) | |
| rt_limit | Uncompressed period (rt parameter) |
Definition at line 59 of file ccsds124.hpp.
References ccsds124::Compressor< N, MaxOutputBytes >::compress_packet(), ccsds124::BitVector< N >::from_bytes(), InvalidArg, ccsds124::CompressParams::min_robustness, ccsds124::CompressParams::new_mask_flag, Ok, Overflow, ccsds124::CompressParams::send_mask_flag, ccsds124::BitBuffer< MaxBytes >::to_bytes(), and ccsds124::CompressParams::uncompressed_flag.
|
noexcept |
Compute change vector (CCSDS Equation 8).
The change vector tracks mask changes between iterations.
| N | BitVector length |
| [out] | change | Change vector D_t |
| [in] | mask | Current mask M_t |
| [in] | prev_mask | Previous mask M_{t-1} |
| [in] | t | Time index (0 = first packet) |
Definition at line 115 of file mask.hpp.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
Counter decoding (inverse of CCSDS Section 5.2.2, Equation 9).
Decodes a COUNT-encoded value from a bit reader.
| reader | Bit reader positioned at COUNT-encoded data | |
| [out] | value | Decoded value (0 for terminator, 1+ for values) |
Definition at line 50 of file decoder.hpp.
Referenced by ccsds124::Decompressor< N >::decompress_packet(), and rle_decode().
|
noexcept |
Counter encoding (CCSDS Section 5.2.2, Equation 9).
Encodes an integer A as a unary prefix followed by binary suffix.
| MaxBytes | BitBuffer capacity |
| output | Bit buffer to append encoded value |
| A | Value to encode (1 to 65535) |
Definition at line 71 of file encoder.hpp.
References ccsds124::detail::COUNT_BITS, ccsds124::detail::COUNT_VALUES, InvalidArg, and Ok.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet(), and rle_encode().
|
noexcept |
Decompress multi-packet data stream.
Decompresses CCSDS 124.0-B-1 compressed data back to original packets.
| N | Packet length in bits |
| input_data | Compressed input data bytes | |
| input_size | Compressed input size in bytes | |
| output_buffer | Output buffer for decompressed data | |
| output_buffer_size | Maximum output buffer size | |
| [out] | output_size | Actual decompressed output size |
| robustness | Robustness level R (0-7) |
Definition at line 184 of file ccsds124.hpp.
References ccsds124::BitReader::align_byte(), ccsds124::Decompressor< N >::decompress_packet(), Ok, Overflow, ccsds124::BitReader::remaining(), and ccsds124::BitVector< N >::to_bytes().
|
inlinenoexcept |
Get error message for error code.
| error | Error code |
Definition at line 42 of file error.hpp.
References InvalidArg, InvalidData, Ok, Overflow, and Underflow.
|
noexcept |
Run-length decoding (inverse of CCSDS Section 5.2.3, Equation 10).
Decodes RLE-encoded data back to a BitVector.
| N | BitVector length |
| reader | Bit reader positioned at RLE-encoded data | |
| [out] | result | Decoded bit vector |
Definition at line 132 of file decoder.hpp.
References count_decode(), Ok, and Overflow.
Referenced by ccsds124::Decompressor< N >::decompress_packet().
|
noexcept |
Run-length encoding (CCSDS Section 5.2.3, Equation 10).
RLE(a) = COUNT(C₀) ∥ COUNT(C₁) ∥ ... ∥ COUNT(C_{H(a)-1}) ∥ '10'
| output | Bit buffer to append encoded runs |
| input | Bit vector to encode |
Definition at line 114 of file encoder.hpp.
References count_encode(), and Ok.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
|
noexcept |
Update build vector (CCSDS Equation 6).
The build vector accumulates XOR differences between consecutive packets to track which bits have changed.
| N | BitVector length |
| [in,out] | build | Updated build vector B_t |
| [in] | input | Current input I_t |
| [in] | prev_input | Previous input I_{t-1} |
| [in] | new_mask_flag | p_t flag (true = reset build) |
| [in] | t | Time index (0 = first packet) |
Definition at line 53 of file mask.hpp.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
|
noexcept |
Update mask vector (CCSDS Equation 7).
The mask vector identifies unpredictable bits (1 = unpredictable).
| N | BitVector length |
| [in,out] | mask | Updated mask vector M_t |
| [in] | input | Current input I_t |
| [in] | prev_input | Previous input I_{t-1} |
| [in] | build_prev | Previous build vector B_{t-1} |
| [in] | new_mask_flag | p_t flag (true = update from build) |
Definition at line 84 of file mask.hpp.
Referenced by ccsds124::Compressor< N, MaxOutputBytes >::compress_packet().
|
inlinenoexcept |
Get library version.
Definition at line 228 of file ccsds124.hpp.
Referenced by print_help(), and print_version().