ROHC compression/decompression library
sdvl.h
Go to the documentation of this file.
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 #include <stdbool.h>
00032 
00033 
00034 /*
00035  * Constants related to fields length for SDVL-encoding
00036  */
00037 
00038 /** The maximum numbers of bits that can be SDVL-encoded in 1, 2, 3
00039  *  and 4 bytes */
00040 typedef enum
00041 {
00042         /** Maximum number of bits in 1 SDVL-encoded byte */
00043         ROHC_SDVL_MAX_BITS_IN_1_BYTE = 7U,
00044         /** Maximum number of bits in 2 SDVL-encoded byte */
00045         ROHC_SDVL_MAX_BITS_IN_2_BYTES = 14U,
00046         /** Maximum number of bits in 3 SDVL-encoded byte */
00047         ROHC_SDVL_MAX_BITS_IN_3_BYTES = 21U,
00048         /** Maximum number of bits in 4 SDVL-encoded byte */
00049         ROHC_SDVL_MAX_BITS_IN_4_BYTES = 29U,
00050 } rohc_sdvl_max_bits_t;
00051 
00052 
00053 /*
00054  * Function prototypes.
00055  */
00056 
00057 bool ROHC_EXPORT sdvl_can_value_be_encoded(uint32_t value);
00058 bool ROHC_EXPORT sdvl_can_length_be_encoded(size_t bits_nr);
00059 
00060 size_t ROHC_EXPORT sdvl_get_min_len(const size_t nr_min_required,
00061                                     const size_t nr_encoded);
00062 
00063 size_t ROHC_EXPORT c_bytesSdvl(uint32_t value, size_t length);
00064 
00065 int ROHC_EXPORT c_encodeSdvl(unsigned char *dest,
00066                              uint32_t value,
00067                              size_t length);
00068 
00069 int ROHC_EXPORT d_sdvalue_size(const unsigned char *data);
00070 
00071 size_t ROHC_EXPORT sdvl_decode(const unsigned char *data,
00072                                const size_t length,
00073                                uint32_t *const value,
00074                                size_t *const bits_nr);
00075 
00076 #endif
00077