ROHC compression/decompression library
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 2 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * This program is distributed in the hope that it will be useful, 00008 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 * GNU General Public License for more details. 00011 * 00012 * You should have received a copy of the GNU General Public License 00013 * along with this program; if not, write to the Free Software 00014 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00015 */ 00016 00017 /** 00018 * @file sdvl.h 00019 * @brief Self-Describing Variable-Length (SDVL) encoding 00020 * @author Didier Barvaux <didier.barvaux@toulouse.viveris.com> 00021 * @author The hackers from ROHC for Linux 00022 */ 00023 00024 #ifndef SDVL_H 00025 #define SDVL_H 00026 00027 #include "dllexport.h" 00028 00029 #include <stdlib.h> 00030 #include <stdint.h> 00031 #ifdef __KERNEL__ 00032 # include <linux/types.h> 00033 #else 00034 # include <stdbool.h> 00035 #endif 00036 00037 00038 /* 00039 * Constants related to fields length for SDVL-encoding 00040 */ 00041 00042 /** The maximum numbers of bits that can be SDVL-encoded in 1, 2, 3 00043 * and 4 bytes */ 00044 typedef enum 00045 { 00046 /** Maximum number of bits in 1 SDVL-encoded byte */ 00047 ROHC_SDVL_MAX_BITS_IN_1_BYTE = 7U, 00048 /** Maximum number of bits in 2 SDVL-encoded byte */ 00049 ROHC_SDVL_MAX_BITS_IN_2_BYTES = 14U, 00050 /** Maximum number of bits in 3 SDVL-encoded byte */ 00051 ROHC_SDVL_MAX_BITS_IN_3_BYTES = 21U, 00052 /** Maximum number of bits in 4 SDVL-encoded byte */ 00053 ROHC_SDVL_MAX_BITS_IN_4_BYTES = 29U, 00054 } rohc_sdvl_max_bits_t; 00055 00056 00057 /* 00058 * Function prototypes. 00059 */ 00060 00061 bool ROHC_EXPORT sdvl_can_value_be_encoded(uint32_t value); 00062 bool ROHC_EXPORT sdvl_can_length_be_encoded(size_t bits_nr); 00063 00064 size_t ROHC_EXPORT sdvl_get_min_len(const size_t nr_min_required, 00065 const size_t nr_encoded); 00066 00067 size_t ROHC_EXPORT c_bytesSdvl(uint32_t value, size_t length); 00068 00069 int ROHC_EXPORT c_encodeSdvl(unsigned char *dest, 00070 uint32_t value, 00071 size_t length); 00072 00073 int ROHC_EXPORT d_sdvalue_size(const unsigned char *data); 00074 00075 size_t ROHC_EXPORT sdvl_decode(const unsigned char *data, 00076 const size_t length, 00077 uint32_t *const value, 00078 size_t *const bits_nr); 00079 00080 #endif 00081