ROHC compression/decompression library
decomp_wlsb.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011,2012,2013 Didier Barvaux
3  * Copyright 2007,2009,2010,2013 Viveris Technologies
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 /**
21  * @file schemes/decomp_wlsb.h
22  * @brief Window-based Least Significant Bits (W-LSB) decoding
23  * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com>
24  * @author Didier Barvaux <didier@barvaux.org>
25  */
26 
27 #ifndef ROHC_DECOMP_SCHEMES_WLSB_H
28 #define ROHC_DECOMP_SCHEMES_WLSB_H
29 
30 #include "interval.h" /* for rohc_lsb_shift_t */
31 
32 #include <stdlib.h>
33 #include <stdint.h>
34 #include <stddef.h>
35 #include <stdbool.h>
36 
37 
38 /*
39  * Public structures and types
40  */
41 
42 /** The different reference values for LSB decoding */
43 typedef enum
44 {
45  ROHC_LSB_REF_MINUS_1 = 0, /**< Use the 'ref -1' reference value */
46  ROHC_LSB_REF_0 = 1, /**< Use the 'ref 0' reference value */
47  ROHC_LSB_REF_MAX /**< The number of different reference values */
48 
50 
51 
52 /**
53  * @brief The Least Significant Bits (LSB) decoding object
54  *
55  * See RFC 3095, ยง4.5.1
56  */
58 {
59  bool is_init; /**< Whether the reference value was initialized */
60  size_t max_len; /**< The max length (in bits) of the uncomp. field */
61 
62  /** The reference values (ref -1 and ref 0) */
64 };
65 
66 
67 /** The context to parse and decode one LSB-encoded 32-bit field */
69 {
70  uint32_t bits; /**< The bits extracted from the ROHC packet */
71  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
72  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
73 };
74 
75 
76 /** The context to parse and decode one LSB-encoded 16-bit field */
78 {
79  uint16_t bits; /**< The bits extracted from the ROHC packet */
80  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
81  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
82 };
83 
84 
85 /** The context to parse and decode one LSB-encoded 8-bit field */
87 {
88  uint8_t bits; /**< The bits extracted from the ROHC packet */
89  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
90  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
91 };
92 
93 
94 /*
95  * Function prototypes
96  */
97 
98 void rohc_lsb_init(struct rohc_lsb_decode *const lsb, const size_t max_len)
99  __attribute__((nonnull(1)));
100 
101 bool rohc_lsb_is_ready(const struct rohc_lsb_decode *const lsb)
102  __attribute__((warn_unused_result, nonnull(1), pure));
103 
104 bool rohc_lsb_decode(const struct rohc_lsb_decode *const lsb,
105  const rohc_lsb_ref_t ref_type,
106  const uint32_t v_ref_d_offset,
107  const uint32_t m,
108  const size_t k,
109  const rohc_lsb_shift_t p,
110  uint32_t *const decoded)
111  __attribute__((warn_unused_result, nonnull(1, 7)));
112 
113 void rohc_lsb_set_ref(struct rohc_lsb_decode *const lsb,
114  const uint32_t v_ref_d,
115  const bool keep_ref_minus_1)
116  __attribute__((nonnull(1)));
117 
118 uint32_t rohc_lsb_get_ref(const struct rohc_lsb_decode *const lsb,
119  const rohc_lsb_ref_t ref_type)
120  __attribute__((nonnull(1), warn_unused_result));
121 
122 #endif
123 
rohc_lsb_shift_t
the different values of the shift parameter of the LSB algorithm
Definition: interval.h:45
size_t bits_nr
Definition: decomp_wlsb.h:89
void rohc_lsb_init(struct rohc_lsb_decode *const lsb, const size_t max_len)
Initialize a given Least Significant Bits (LSB) decoding context.
Definition: decomp_wlsb.c:78
Definition: decomp_wlsb.h:45
size_t max_len
Definition: decomp_wlsb.h:60
bool is_init
Definition: decomp_wlsb.h:59
Definition: decomp_wlsb.h:77
uint32_t v_ref_d[ROHC_LSB_REF_MAX]
Definition: decomp_wlsb.h:63
Definition: decomp_wlsb.h:46
size_t bits_nr
Definition: decomp_wlsb.h:71
uint16_t bits
Definition: decomp_wlsb.h:79
uint8_t bits
Definition: decomp_wlsb.h:88
The Least Significant Bits (LSB) decoding object.
Definition: decomp_wlsb.h:57
Definition: decomp_wlsb.h:47
Definition: decomp_wlsb.h:86
uint32_t rohc_lsb_get_ref(const struct rohc_lsb_decode *const lsb, const rohc_lsb_ref_t ref_type)
Get the current LSB reference value (ref 0)
Definition: decomp_wlsb.c:387
uint32_t bits
Definition: decomp_wlsb.h:70
size_t bits_nr
Definition: decomp_wlsb.h:80
Definition: decomp_wlsb.h:68
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:72
rohc_lsb_ref_t
Definition: decomp_wlsb.h:43
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:81
bool rohc_lsb_decode(const struct rohc_lsb_decode *const lsb, const rohc_lsb_ref_t ref_type, const uint32_t v_ref_d_offset, const uint32_t m, const size_t k, const rohc_lsb_shift_t p, uint32_t *const decoded)
Decode a LSB-encoded value.
Definition: decomp_wlsb.c:116
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:90
bool rohc_lsb_is_ready(const struct rohc_lsb_decode *const lsb)
Is the LSB decoding context ready to decode a compressed value.
Definition: decomp_wlsb.c:93
void rohc_lsb_set_ref(struct rohc_lsb_decode *const lsb, const uint32_t v_ref_d, const bool keep_ref_minus_1)
Update the LSB reference value.
Definition: decomp_wlsb.c:363
Compute the interpretation interval for LSB and W-LSB encoding.