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 #ifdef __KERNEL__
36 # include <linux/types.h>
37 #else
38 # include <stdbool.h>
39 #endif
40 
41 
42 /* The definition of the Least Significant Bits decoding object is private */
43 struct rohc_lsb_decode;
44 
45 
46 /** The different reference values for LSB decoding */
47 typedef enum
48 {
49  ROHC_LSB_REF_MINUS_1 = 0, /**< Use the 'ref -1' reference value */
50  ROHC_LSB_REF_0 = 1, /**< Use the 'ref 0' reference value */
51  ROHC_LSB_REF_MAX /**< The number of different reference values */
52 
54 
55 
56 /** The context to parse and decode one LSB-encoded 32-bit field */
58 {
59  uint32_t bits; /**< The bits extracted from the ROHC packet */
60  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
61  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
62 };
63 
64 
65 /** The context to parse and decode one LSB-encoded 16-bit field */
67 {
68  uint16_t bits; /**< The bits extracted from the ROHC packet */
69  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
70  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
71 };
72 
73 
74 /** The context to parse and decode one LSB-encoded 8-bit field */
76 {
77  uint8_t bits; /**< The bits extracted from the ROHC packet */
78  size_t bits_nr; /**< The number of bits extracted from the ROHC packet */
79  rohc_lsb_shift_t p; /**< The LSB shift parameter to decode extracted bits */
80 };
81 
82 
83 /*
84  * Function prototypes
85  */
86 
87 struct rohc_lsb_decode * rohc_lsb_new(const size_t max_len)
88  __attribute__((warn_unused_result));
89 
90 void rohc_lsb_free(struct rohc_lsb_decode *const lsb)
91  __attribute__((nonnull(1)));
92 
93 bool rohc_lsb_is_ready(const struct rohc_lsb_decode *const lsb)
94  __attribute__((warn_unused_result, nonnull(1), pure));
95 
96 bool rohc_lsb_decode(const struct rohc_lsb_decode *const lsb,
97  const rohc_lsb_ref_t ref_type,
98  const uint32_t v_ref_d_offset,
99  const uint32_t m,
100  const size_t k,
101  const rohc_lsb_shift_t p,
102  uint32_t *const decoded)
103  __attribute__((warn_unused_result, nonnull(1, 7)));
104 
105 void rohc_lsb_set_ref(struct rohc_lsb_decode *const lsb,
106  const uint32_t v_ref_d,
107  const bool keep_ref_minus_1)
108  __attribute__((nonnull(1)));
109 
110 uint32_t rohc_lsb_get_ref(const struct rohc_lsb_decode *const lsb,
111  const rohc_lsb_ref_t ref_type)
112  __attribute__((nonnull(1), warn_unused_result));
113 
114 #endif
115 
rohc_lsb_shift_t
the different values of the shift parameter of the LSB algorithm
Definition: interval.h:42
size_t bits_nr
Definition: decomp_wlsb.h:78
Definition: decomp_wlsb.h:49
size_t max_len
Definition: decomp_wlsb.c:48
Definition: decomp_wlsb.h:66
uint32_t v_ref_d[ROHC_LSB_REF_MAX]
Definition: decomp_wlsb.c:51
Definition: decomp_wlsb.h:50
size_t bits_nr
Definition: decomp_wlsb.h:60
uint16_t bits
Definition: decomp_wlsb.h:68
uint8_t bits
Definition: decomp_wlsb.h:77
The Least Significant Bits (LSB) decoding object.
Definition: decomp_wlsb.c:45
Definition: decomp_wlsb.h:51
Definition: decomp_wlsb.h:75
struct rohc_lsb_decode * rohc_lsb_new(const size_t max_len)
Create a new Least Significant Bits (LSB) decoding context.
Definition: decomp_wlsb.c:100
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:431
uint32_t bits
Definition: decomp_wlsb.h:59
size_t bits_nr
Definition: decomp_wlsb.h:69
Definition: decomp_wlsb.h:57
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:61
rohc_lsb_ref_t
Definition: decomp_wlsb.h:47
void rohc_lsb_free(struct rohc_lsb_decode *const lsb)
Destroy a given Least Significant Bits (LSB) decoding context.
Definition: decomp_wlsb.c:124
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:70
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:160
rohc_lsb_shift_t p
Definition: decomp_wlsb.h:79
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:136
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:407
Compute the interpretation interval for LSB and W-LSB encoding.