spandsp
0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/v42bis.h 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2005 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 #if !defined(_SPANDSP_PRIVATE_V42BIS_H_) 00027 #define _SPANDSP_PRIVATE_V42BIS_H_ 00028 00029 /*! 00030 V.42bis dictionary node. 00031 */ 00032 typedef struct 00033 { 00034 /*! \brief The prior code for each defined code. */ 00035 uint16_t parent_code; 00036 /*! \brief The number of leaf nodes this node has */ 00037 int16_t leaves; 00038 /*! \brief This leaf octet for each defined code. */ 00039 uint8_t node_octet; 00040 /*! \brief Bit map of the children which exist */ 00041 uint32_t children[8]; 00042 } v42bis_dict_node_t; 00043 00044 /*! 00045 V.42bis compression. This defines the working state for a single instance 00046 of V.42bis compression. 00047 */ 00048 typedef struct 00049 { 00050 /*! \brief Compression mode. */ 00051 int compression_mode; 00052 /*! \brief Callback function to handle received frames. */ 00053 v42bis_frame_handler_t handler; 00054 /*! \brief An opaque pointer passed in calls to frame_handler. */ 00055 void *user_data; 00056 /*! \brief The maximum frame length allowed */ 00057 int max_len; 00058 00059 uint32_t string_code; 00060 uint32_t latest_code; 00061 int string_length; 00062 uint32_t output_bit_buffer; 00063 int output_bit_count; 00064 int output_octet_count; 00065 uint8_t output_buf[1024]; 00066 v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS]; 00067 /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */ 00068 int transparent; 00069 int change_transparency; 00070 /*! \brief IIR filter state, used in assessing compressibility. */ 00071 int compressibility_filter; 00072 int compressibility_persistence; 00073 00074 /*! \brief Next empty dictionary entry */ 00075 uint32_t v42bis_parm_c1; 00076 /*! \brief Current codeword size */ 00077 int v42bis_parm_c2; 00078 /*! \brief Threshold for codeword size change */ 00079 uint32_t v42bis_parm_c3; 00080 00081 /*! \brief Mark that this is the first octet/code to be processed */ 00082 int first; 00083 uint8_t escape_code; 00084 } v42bis_compress_state_t; 00085 00086 /*! 00087 V.42bis decompression. This defines the working state for a single instance 00088 of V.42bis decompression. 00089 */ 00090 typedef struct 00091 { 00092 /*! \brief Callback function to handle decompressed data. */ 00093 v42bis_data_handler_t handler; 00094 /*! \brief An opaque pointer passed in calls to data_handler. */ 00095 void *user_data; 00096 /*! \brief The maximum decompressed data block length allowed */ 00097 int max_len; 00098 00099 uint32_t old_code; 00100 uint32_t last_old_code; 00101 uint32_t input_bit_buffer; 00102 int input_bit_count; 00103 int octet; 00104 int last_length; 00105 int output_octet_count; 00106 uint8_t output_buf[1024]; 00107 v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS]; 00108 /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */ 00109 int transparent; 00110 00111 int last_extra_octet; 00112 00113 /*! \brief Next empty dictionary entry */ 00114 uint32_t v42bis_parm_c1; 00115 /*! \brief Current codeword size */ 00116 int v42bis_parm_c2; 00117 /*! \brief Threshold for codeword size change */ 00118 uint32_t v42bis_parm_c3; 00119 00120 /*! \brief Mark that this is the first octet/code to be processed */ 00121 int first; 00122 uint8_t escape_code; 00123 int escaped; 00124 } v42bis_decompress_state_t; 00125 00126 /*! 00127 V.42bis compression/decompression descriptor. This defines the working state for a 00128 single instance of V.42bis compress/decompression. 00129 */ 00130 struct v42bis_state_s 00131 { 00132 /*! \brief V.42bis data compression directions. */ 00133 int v42bis_parm_p0; 00134 00135 /*! \brief Compression state. */ 00136 v42bis_compress_state_t compress; 00137 /*! \brief Decompression state. */ 00138 v42bis_decompress_state_t decompress; 00139 00140 /*! \brief Maximum codeword size (bits) */ 00141 int v42bis_parm_n1; 00142 /*! \brief Total number of codewords */ 00143 uint32_t v42bis_parm_n2; 00144 /*! \brief Maximum string length */ 00145 int v42bis_parm_n7; 00146 }; 00147 00148 #endif 00149 /*- End of file ------------------------------------------------------------*/