ROHC compression/decompression library
Data Structures | Functions
wlsb.c File Reference

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

#include "wlsb.h"
#include "interval.h"
#include <string.h>
#include <assert.h>
Include dependency graph for comp/schemes/wlsb.c:

Data Structures

struct  c_window
 Define a W-LSB window entry. More...
struct  c_wlsb
 Defines a W-LSB encoding object. More...

Functions

static void c_ack_remove (struct c_wlsb *const s, const size_t pos)
 Removes all W-LSB window entries prior to the given position.
static size_t rohc_g_16bits (const uint16_t v_ref, const uint16_t v, const rohc_lsb_shift_t p, const size_t bits_nr)
 The g function as defined in LSB encoding for 16-bit fields.
static size_t rohc_g_32bits (const uint32_t v_ref, const uint32_t v, const rohc_lsb_shift_t p, const size_t bits_nr)
 The g function as defined in LSB encoding for 32-bit fields.
struct c_wlsbc_create_wlsb (const size_t bits, const size_t window_width, const rohc_lsb_shift_t p)
 Create a new Window-based Least Significant Bits (W-LSB) encoding object.
void c_destroy_wlsb (struct c_wlsb *const wlsb)
 Destroy a Window-based LSB (W-LSB) encoding object.
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.
bool wlsb_get_k_16bits (const struct c_wlsb *const wlsb, const uint16_t value, size_t *const bits_nr)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.
bool wlsb_get_k_32bits (const struct c_wlsb *const wlsb, const uint32_t value, size_t *const bits_nr)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.
bool wlsb_get_kp_32bits (const struct c_wlsb *const wlsb, const uint32_t value, const rohc_lsb_shift_t p, size_t *const bits_nr)
 Find out the minimal number of bits of the to-be-encoded value required to be able to uniquely recreate it given the window.
void c_ack_sn_wlsb (struct c_wlsb *const s, const uint32_t sn)
 Acknowledge based on the Sequence Number (SN)

Detailed Description

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

Author:
Didier Barvaux <didier.barvaux@toulouse.viveris.com>
Didier Barvaux <didier@barvaux.org>
David Moreau from TAS

Function Documentation

static void c_ack_remove ( struct c_wlsb *const  s,
const size_t  pos 
) [static]

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

Parameters:
sThe W-LSB object
posThe position to set as the oldest
void c_ack_sn_wlsb ( struct c_wlsb *const  s,
const uint32_t  sn 
)

Acknowledge based on the Sequence Number (SN)

Removes all entries older than the given SN in the window.

Parameters:
sThe W-LSB object
snThe SN to acknowledge
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
struct c_wlsb* c_create_wlsb ( const size_t  bits,
const size_t  window_width,
const rohc_lsb_shift_t  p 
) [read]

Create a new Window-based Least Significant Bits (W-LSB) encoding object.

Parameters:
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)
Returns:
The newly-created W-LSB encoding object
void c_destroy_wlsb ( struct c_wlsb *const  wlsb)

Destroy a Window-based LSB (W-LSB) encoding object.

Parameters:
wlsbThe W-LSB object to destroy
static size_t rohc_g_16bits ( const uint16_t  v_ref,
const uint16_t  v,
const rohc_lsb_shift_t  p,
const size_t  bits_nr 
) [static]

The g function as defined in LSB encoding for 16-bit fields.

Find the minimal k value so that v falls into the interval given by $f(v\_ref, k)$. See 4.5.1 in the RFC 3095.

Parameters:
v_refThe reference value
vThe value to encode
pThe shift parameter
bits_nrThe number of bits that may be used to represent the LSB-encoded value
Returns:
The minimal k value as defined by the LSB algorithm
static size_t rohc_g_32bits ( const uint32_t  v_ref,
const uint32_t  v,
const rohc_lsb_shift_t  p,
const size_t  bits_nr 
) [static]

The g function as defined in LSB encoding for 32-bit fields.

Find the minimal k value so that v falls into the interval given by $f(v\_ref, k)$. See 4.5.1 in the RFC 3095.

Parameters:
v_refThe reference value
vThe value to encode
pThe shift parameter
bits_nrThe number of bits that may be used to represent the LSB-encoded value
Returns:
The minimal k value as defined by the LSB algorithm
bool wlsb_get_k_16bits ( const struct c_wlsb *const  wlsb,
const uint16_t  value,
size_t *const  bits_nr 
)

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
bits_nrOUT: The number of bits required to uniquely recreate the value
Returns:
true in case of success, false if the minimal number of bits can not be found
bool wlsb_get_k_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
size_t *const  bits_nr 
)

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
bits_nrOUT: The number of bits required to uniquely recreate the value
Returns:
true in case of success, false if the minimal number of bits can not be found
bool wlsb_get_kp_32bits ( const struct c_wlsb *const  wlsb,
const uint32_t  value,
const rohc_lsb_shift_t  p,
size_t *const  bits_nr 
)

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
bits_nrOUT: The number of bits required to uniquely recreate the value
Returns:
true in case of success, false if the minimal number of bits can not be found