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

Fixed-length bit vector implementation using 32-bit words. More...

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

Go to the source code of this file.

Functions

Initialization Functions

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.

Bit Numbering Convention (CCSDS 124.0-B-1 Section 1.6.1)
  • Bit 0 = LSB (Least Significant Bit)
  • Bit N-1 = MSB (Most Significant Bit, transmitted first)
Word Packing (Big-Endian)
Within each 32-bit word:
  • Word[i] = (Byte[4i] << 24) | (Byte[4i+1] << 16) | (Byte[4i+2] << 8) | Byte[4i+3]
  • Bit 0 = LSB of word, Bit 31 = MSB of word
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
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.
 
Bitwise Operations

Implements bitwise operations as defined in CCSDS 124.0-B-1 Section 1.6.1. All operations work word-by-word for efficiency.

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.
 
Utility Functions
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.
 
Byte Conversion Functions
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.
 

Detailed Description

Fixed-length bit vector implementation using 32-bit words.

Definition in file bitvector.c.