libosmocore  0.9.3.20160317
Osmocom core library
Bit compression

Files

file  bitcomp.h
 Osmocom bit compression routines.
 
file  bitcomp.c
 Osmocom bit compression routines.
 

Enumerations

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

Functions

int osmo_t4_encode (struct bitvec *bv)
 encode bit vector in-place using T4 encoding Assumes MSB first encoding. More...
 
int osmo_t4_decode (const struct bitvec *in, bool cc, struct bitvec *out)
 decode T4-encoded bit vector Assumes MSB first encoding. More...
 
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)
 

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

Function Documentation

int osmo_t4_decode ( const struct bitvec in,
bool  cc,
struct bitvec out 
)

decode T4-encoded bit vector Assumes MSB first encoding.

Parameters
[in]inbit vector with encoded data
[in]cccolor code (whether decoding should start with 1 or 0)
[out]outthe bit vector to store result into returns 0 on success, negative value otherwise

References bitvec_get_int16_msb(), bitvec_shiftl(), bitvec_zero(), bitvec::cur_bit, bitvec::data, and bitvec::data_len.

int osmo_t4_encode ( struct bitvec bv)

encode bit vector in-place using T4 encoding Assumes MSB first encoding.

Parameters
[in]bvbit vector to be encoded returns color code (if the encoding started with 0 or 1) or -1 on failure (encoded is bigger than original)

References bitvec_rl(), bitvec_shiftl(), bitvec_zero(), bitvec::cur_bit, bitvec::data, bitvec::data_len, and t4_rle().

static int t4_rle ( struct bitvec bv,
unsigned  len,
bool  b 
)
inlinestatic

Make-up codes for a given length.

Return proper make-up code word for an uninterrupted sequence of b bits of length len according to modified ITU-T T.4 from TS 44.060 Table 9.1.10.2

References bitvec_set_uint().

Referenced by osmo_t4_encode().

static int t4_rle_term ( unsigned  w,
bool  b,
unsigned  bits 
)
inlinestatic

Attempt to decode compressed bit vector.

Return length of RLE according to modified ITU-T T.4 from TS 44.060 Table 9.1.10.2 or -1 if no applicable RLE found N. B: we need explicit bit length to make decoding unambiguous

Variable Documentation

const unsigned t4_make_up_length[2][15]
static
Initial value:
= {
{10, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13},
{5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9}
}
const unsigned t4_term_length[2][64]
static
Initial value:
= {
{10, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, 7, 7, 8, 8, 9, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
{8, 6, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}
}