ROHC compression/decompression library
Enumerations | Functions
sdvl.h File Reference

Self-Describing Variable-Length (SDVL) encoding. More...

#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for sdvl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  rohc_sdvl_max_bits_t { ROHC_SDVL_MAX_BITS_IN_1_BYTE = 7U, ROHC_SDVL_MAX_BITS_IN_2_BYTES = 14U, ROHC_SDVL_MAX_BITS_IN_3_BYTES = 21U, ROHC_SDVL_MAX_BITS_IN_4_BYTES = 29U }
 

Functions

bool sdvl_can_value_be_encoded (const uint32_t value)
 Can the given value be encoded with SDVL? More...
 
bool sdvl_can_length_be_encoded (const size_t bits_nr)
 Is the given length (in bits) compatible with SDVL? More...
 
size_t sdvl_get_min_len (const size_t nr_min_required, const size_t nr_encoded)
 Find out how many SDVL bits are needed to represent a value. More...
 
size_t sdvl_get_encoded_len (const uint32_t value)
 Find out how many bytes are needed to represent the value using Self-Describing Variable-Length (SDVL) encoding. More...
 
bool sdvl_encode (uint8_t *const packet, const size_t packet_max_len, size_t *const packet_len, const uint32_t value, const size_t bits_nr)
 Encode a value using Self-Describing Variable-Length (SDVL) encoding. More...
 
bool sdvl_encode_full (uint8_t *const packet, const size_t packet_max_len, size_t *const packet_len, const uint32_t value)
 Encode a value using Self-Describing Variable-Length (SDVL) encoding. More...
 
size_t sdvl_decode (const uint8_t *const data, const size_t length, uint32_t *const value, size_t *const bits_nr)
 Decode a Self-Describing Variable-Length (SDVL) value. More...
 

Detailed Description

Self-Describing Variable-Length (SDVL) 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

Enumeration Type Documentation

The maximum numbers of bits that can be SDVL-encoded in 1, 2, 3 and 4 bytes

Enumerator
ROHC_SDVL_MAX_BITS_IN_1_BYTE 

Maximum number of bits in 1 SDVL-encoded byte

ROHC_SDVL_MAX_BITS_IN_2_BYTES 

Maximum number of bits in 2 SDVL-encoded byte

ROHC_SDVL_MAX_BITS_IN_3_BYTES 

Maximum number of bits in 3 SDVL-encoded byte

ROHC_SDVL_MAX_BITS_IN_4_BYTES 

Maximum number of bits in 4 SDVL-encoded byte

Function Documentation

bool sdvl_can_length_be_encoded ( const size_t  bits_nr)

Is the given length (in bits) compatible with SDVL?

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Parameters
bits_nrThe length (in bits) of the value to encode
Returns
Whether the value can be encoded with SDVL or not
bool sdvl_can_value_be_encoded ( const uint32_t  value)

Can the given value be encoded with SDVL?

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Parameters
valueThe value to encode
Returns
Whether the value can be encoded with SDVL or not
size_t sdvl_decode ( const uint8_t *const  data,
const size_t  length,
uint32_t *const  value,
size_t *const  bits_nr 
)

Decode a Self-Describing Variable-Length (SDVL) value.

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Parameters
dataThe SDVL data to decode
lengthThe maximum data length available (in bytes)
valueOUT: The decoded value
bits_nrOUT: The number of useful bits
Returns
The number of bytes used by the SDVL field (value between 1 and 4), 0 in case of problem
bool sdvl_encode ( uint8_t *const  sdvl_bytes,
const size_t  sdvl_bytes_max_nr,
size_t *const  sdvl_bytes_nr,
const uint32_t  value,
const size_t  bits_nr 
)

Encode a value using Self-Describing Variable-Length (SDVL) encoding.

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Encoding failures may be due to a value greater than 2^29.

Parameters
sdvl_bytesIN/OUT: The SDVL-encoded bytes
sdvl_bytes_max_nrThe maximum available free bytes for SDVL
sdvl_bytes_nrOUT: The number of SDVL bytes written
valueThe value to encode
bits_nrThe number of bits to encode
Returns
true if SDVL encoding is successful, false in case of failure
bool sdvl_encode_full ( uint8_t *const  sdvl_bytes,
const size_t  sdvl_bytes_max_nr,
size_t *const  sdvl_bytes_nr,
const uint32_t  value 
)

Encode a value using Self-Describing Variable-Length (SDVL) encoding.

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Encoding failures may be due to a value greater than 2^29.

Parameters
sdvl_bytesIN/OUT: The SDVL-encoded bytes
sdvl_bytes_max_nrThe maximum available free bytes for SDVL
sdvl_bytes_nrOUT: The number of SDVL bytes written
valueThe value to encode
Returns
true if SDVL encoding is successful, false in case of failure
size_t sdvl_get_encoded_len ( const uint32_t  value)

Find out how many bytes are needed to represent the value using Self-Describing Variable-Length (SDVL) encoding.

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Parameters
valueThe value to encode
Returns
The size needed to represent the SDVL-encoded value
size_t sdvl_get_min_len ( const size_t  nr_min_required,
const size_t  nr_encoded 
)

Find out how many SDVL bits are needed to represent a value.

The number of bits already encoded in another field may be specified.

See 4.5.6 in the RFC 3095 for details about SDVL encoding.

Parameters
nr_min_requiredThe minimum required number of bits to encode
nr_encodedThe number of bits already encoded in another field
Returns
The number of bits needed to encode the value