CCSDS 124.0-B-1 C 1.0.0
CCSDS 124.0-B-1 Lossless Compression
Loading...
Searching...
No Matches
bitbuffer.c File Reference

Variable-length bit buffer for building compressed output. More...

#include "ccsds124.h"
#include <string.h>

Go to the source code of this file.

Functions

Initialization Functions

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.

Bit Ordering
Bits are appended MSB-first within each byte:
  • First bit appended goes to bit position 7
  • Second bit goes to position 6, etc.
Authors
Georges Labrèche georg.nosp@m.es@t.nosp@m.anagr.nosp@m.aspa.nosp@m.ce.co.nosp@m.mhttps://georges.fyi
Claude Code (Anthropic) norep.nosp@m.ly@a.nosp@m.nthro.nosp@m.pic..nosp@m.com
See also
https://ccsds.org/Pubs/124x0b1.pdf CCSDS 124.0-B-1 Standard
void bitbuffer_init (bitbuffer_t *bb)
 Initialize bit buffer to empty state.
 
void bitbuffer_clear (bitbuffer_t *bb)
 Clear bit buffer contents.
 
Bit Appending Functions
static void bitbuffer_flush_acc (bitbuffer_t *bb)
 Flush accumulator to data buffer when it has 8+ bits.
 
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 in a single operation.
 
int bitbuffer_append_bitvector (bitbuffer_t *bb, const bitvector_t *bv)
 Append all bits from a bit vector.
 
Query Functions
size_t bitbuffer_size (const bitbuffer_t *bb)
 Get number of bits in buffer.
 
Byte Conversion Functions
size_t bitbuffer_to_bytes (const bitbuffer_t *bb, uint8_t *data, size_t max_bytes)
 Convert bit buffer to byte array.
 

Detailed Description

Variable-length bit buffer for building compressed output.

Definition in file bitbuffer.c.

Function Documentation

◆ bitbuffer_flush_acc()

static void bitbuffer_flush_acc ( bitbuffer_t bb)
static

Flush accumulator to data buffer when it has 8+ bits.

Parameters
[in,out]bbBit buffer

Definition at line 66 of file bitbuffer.c.

References bitbuffer::acc, bitbuffer::acc_len, bitbuffer::data, and bitbuffer::num_bits.

Referenced by bitbuffer_append_bit(), and bitbuffer_append_value().