libosmocore  0.9.3.20160317
Osmocom core library
bitcomp.c File Reference

Osmocom bit compression routines. More...

#include <stdint.h>
#include <stdbool.h>
#include <errno.h>
#include <string.h>
#include <osmocom/core/bitvec.h>
#include <osmocom/core/bitcomp.h>

Enumerations

enum  dec_state {
  EXPECT_TERM, TOO_LONG, NEED_MORE_BITS, CORRUPT,
  OK
}
 

Functions

static int t4_rle_term (unsigned w, bool b, unsigned bits)
 Attempt to decode compressed bit vector. More...
 
static int t4_rle_makeup (unsigned w, bool b, unsigned bits)
 
static int t4_rle (struct bitvec *bv, unsigned len, bool b)
 Make-up codes for a given length. More...
 
static enum dec_state _t4_step (struct bitvec *v, uint16_t w, bool b, unsigned bits, bool term_only)
 
int osmo_t4_decode (const struct bitvec *in, bool cc, struct bitvec *out)
 decode T4-encoded bit vector Assumes MSB first encoding. More...
 
int osmo_t4_encode (struct bitvec *bv)
 encode bit vector in-place using T4 encoding Assumes MSB first encoding. More...
 

Variables

static const unsigned t4_term [2][64]
 
static const unsigned t4_term_length [2][64]
 
static const unsigned t4_min_term_length [] = {2, 4}
 
static const unsigned t4_min_make_up_length [] = {10, 5}
 
static const unsigned t4_max_term_length [] = {12, 8}
 
static const unsigned t4_max_make_up_length [] = {13, 9}
 
static const unsigned t4_make_up_length [2][15]
 
static const unsigned t4_make_up_ind [15] = {64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960}
 
static const unsigned t4_make_up [2][15]
 

Detailed Description

Osmocom bit compression routines.