ROHC compression/decompression library
Functions
comp_wlsb.c File Reference

Window-based Least Significant Bits (W-LSB) encoding. More...

#include "comp_wlsb.h"
#include "interval.h"
#include <string.h>
#include <assert.h>
Include dependency graph for comp_wlsb.c:

Functions

static size_t wlsb_get_minkp_32bits (const struct c_wlsb *const wlsb, const uint32_t value, const size_t min_k, const rohc_lsb_shift_t p)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
static size_t wlsb_get_next_older (const size_t entry, const size_t max)
 Get the next older entry. More...
 
static size_t wlsb_ack_remove (struct c_wlsb *const wlsb, const size_t pos)
 Removes all W-LSB window entries prior to the given position. More...
 
void wlsb_init (struct c_wlsb *const wlsb, const size_t bits, const size_t window_width, const rohc_lsb_shift_t p)
 Initialize the given W-LSB encoding object. More...
 
void c_add_wlsb (struct c_wlsb *const wlsb, const uint32_t sn, const uint32_t value)
 Add a value into a W-LSB encoding object. More...
 
size_t wlsb_get_k_8bits (const struct c_wlsb *const wlsb, const uint8_t value)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_kp_8bits (const struct c_wlsb *const wlsb, const uint8_t value, const rohc_lsb_shift_t p)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
bool wlsb_is_kp_possible_8bits (const struct c_wlsb *const wlsb, const uint8_t value, const size_t k, const rohc_lsb_shift_t p)
 Find out whether the given number of bits is enough to encode value. More...
 
size_t wlsb_get_k_16bits (const struct c_wlsb *const wlsb, const uint16_t value)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_mink_16bits (const struct c_wlsb *const wlsb, const uint16_t value, const size_t min_k)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_kp_16bits (const struct c_wlsb *const wlsb, const uint16_t value, const rohc_lsb_shift_t p)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_minkp_16bits (const struct c_wlsb *const wlsb, const uint16_t value, const size_t min_k, const rohc_lsb_shift_t p)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
bool wlsb_is_kp_possible_16bits (const struct c_wlsb *const wlsb, const uint16_t value, const size_t k, const rohc_lsb_shift_t p)
 Find out whether the given number of bits is enough to encode value. More...
 
size_t wlsb_get_k_32bits (const struct c_wlsb *const wlsb, const uint32_t value)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_mink_32bits (const struct c_wlsb *const wlsb, const uint32_t value, const size_t min_k)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
size_t wlsb_get_kp_32bits (const struct c_wlsb *const wlsb, const uint32_t value, const rohc_lsb_shift_t p)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window. More...
 
bool wlsb_is_kp_possible_32bits (const struct c_wlsb *const wlsb, const uint32_t value, const size_t k, const rohc_lsb_shift_t p)
 Find out whether the given number of bits is enough to encode value. More...
 
size_t wlsb_ack (struct c_wlsb *const wlsb, const uint32_t sn_bits, const size_t sn_bits_nr)
 Acknowledge based on the Sequence Number (SN) More...
 
bool wlsb_is_sn_present (struct c_wlsb *const wlsb, const uint32_t sn)
 Whether the given SN is present in the given WLSB window. More...
 

Detailed Description

Window-based Least Significant Bits (W-LSB) encoding.

Author
Didier Barvaux didie.nosp@m.r.ba.nosp@m.rvaux.nosp@m.@tou.nosp@m.louse.nosp@m..viv.nosp@m.eris..nosp@m.com
Didier Barvaux didie.nosp@m.r@ba.nosp@m.rvaux.nosp@m..org
David Moreau from TAS

Function Documentation

◆ c_add_wlsb()

void c_add_wlsb ( struct c_wlsb *const  wlsb,
const uint32_t  sn,
const uint32_t  value 
)

Add a value into a W-LSB encoding object.

Parameters
wlsbThe W-LSB object
snThe Sequence Number (SN) for the new entry
valueThe value to base the LSB coding on

◆ wlsb_ack()

size_t wlsb_ack ( struct c_wlsb *const  wlsb,
const uint32_t  sn_bits,
const size_t  sn_bits_nr 
)

Acknowledge based on the Sequence Number (SN)

Removes all window entries older (and including) than the one that matches the given SN bits.

Parameters
wlsbThe W-LSB object
sn_bitsThe LSB of the SN to acknowledge
sn_bits_nrThe number of LSB of the SN to acknowledge
Returns
The number of acked window entries

◆ wlsb_ack_remove()

static size_t wlsb_ack_remove ( struct c_wlsb *const  wlsb,
const size_t  pos 
)
static

Removes all W-LSB window entries prior to the given position.

Parameters
wlsbThe W-LSB object
posThe position to set as the oldest
Returns
The number of acked window entries

◆ wlsb_get_k_16bits()

size_t wlsb_get_k_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 16-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_k_32bits()

size_t wlsb_get_k_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 32-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_k_8bits()

size_t wlsb_get_k_8bits ( const struct c_wlsb *const  wlsb,
const uint8_t  value 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 8-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_kp_16bits()

size_t wlsb_get_kp_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value,
const rohc_lsb_shift_t  p 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 16-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
pThe shift parameter p
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_kp_32bits()

size_t wlsb_get_kp_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const rohc_lsb_shift_t  p 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 32-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
pThe shift parameter p
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_kp_8bits()

size_t wlsb_get_kp_8bits ( const struct c_wlsb *const  wlsb,
const uint8_t  value,
const rohc_lsb_shift_t  p 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 8-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
pThe shift parameter p
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_mink_16bits()

size_t wlsb_get_mink_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value,
const size_t  min_k 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 16-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
min_kThe minimum number of bits to find out
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_mink_32bits()

size_t wlsb_get_mink_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const size_t  min_k 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 32-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
min_kThe minimum number of bits to find out
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_minkp_16bits()

size_t wlsb_get_minkp_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value,
const size_t  min_k,
const rohc_lsb_shift_t  p 
)

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 16-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
min_kThe minimum number of bits to find out
pThe shift parameter p
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_minkp_32bits()

static size_t wlsb_get_minkp_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const size_t  min_k,
const rohc_lsb_shift_t  p 
)
static

Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.

The function is dedicated to 32-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
min_kThe minimum number of bits to find out
pThe shift parameter p
Returns
The number of bits required to uniquely recreate the value

◆ wlsb_get_next_older()

static size_t wlsb_get_next_older ( const size_t  entry,
const size_t  max 
)
static

Get the next older entry.

Parameters
entryThe entry for which to get the next older entry
maxThe max entry value
Returns
The next older entry

◆ wlsb_init()

void wlsb_init ( struct c_wlsb *const  wlsb,
const size_t  bits,
const size_t  window_width,
const rohc_lsb_shift_t  p 
)

Initialize the given W-LSB encoding object.

Parameters
[in,out]wlsbThe W-LSB encoding object to initialize
bitsThe maximal number of bits for representing a value
window_widthThe number of entries in the window (power of 2)
pShift parameter (see 4.5.2 in the RFC 3095)

◆ wlsb_is_kp_possible_16bits()

bool wlsb_is_kp_possible_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value,
const size_t  k,
const rohc_lsb_shift_t  p 
)

Find out whether the given number of bits is enough to encode value.

The function is dedicated to 16-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
kThe number of bits for encoding
pThe shift parameter p
Returns
true if the number of bits is enough for encoding or not

◆ wlsb_is_kp_possible_32bits()

bool wlsb_is_kp_possible_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const size_t  k,
const rohc_lsb_shift_t  p 
)

Find out whether the given number of bits is enough to encode value.

The function is dedicated to 32-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
kThe number of bits for encoding
pThe shift parameter p
Returns
true if the number of bits is enough for encoding or not

◆ wlsb_is_kp_possible_8bits()

bool wlsb_is_kp_possible_8bits ( const struct c_wlsb *const  wlsb,
const uint8_t  value,
const size_t  k,
const rohc_lsb_shift_t  p 
)

Find out whether the given number of bits is enough to encode value.

The function is dedicated to 8-bit fields.

Parameters
wlsbThe W-LSB object
valueThe value to encode using the LSB algorithm
kThe number of bits for encoding
pThe shift parameter p
Returns
true if the number of bits is enough for encoding or not

◆ wlsb_is_sn_present()

bool wlsb_is_sn_present ( struct c_wlsb *const  wlsb,
const uint32_t  sn 
)

Whether the given SN is present in the given WLSB window.

Parameters
wlsbThe WLSB in which to search for the SN
snThe SN to search for
Returns
true if the SN is found, false if not