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 * $Id: v42bis.h,v 1.1 2008/11/15 14:43:08 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_PRIVATE_V42BIS_H_) 00029 #define _SPANDSP_PRIVATE_V42BIS_H_ 00030 00031 /*! 00032 V.42bis dictionary node. 00033 */ 00034 typedef struct 00035 { 00036 /*! \brief The prior code for each defined code. */ 00037 uint16_t parent_code; 00038 /*! \brief The number of leaf nodes this node has */ 00039 int16_t leaves; 00040 /*! \brief This leaf octet for each defined code. */ 00041 uint8_t node_octet; 00042 /*! \brief Bit map of the children which exist */ 00043 uint32_t children[8]; 00044 } v42bis_dict_node_t; 00045 00046 /*! 00047 V.42bis compression. This defines the working state for a single instance 00048 of V.42bis compression. 00049 */ 00050 typedef struct 00051 { 00052 /*! \brief Compression mode. */ 00053 int compression_mode; 00054 /*! \brief Callback function to handle received frames. */ 00055 v42bis_frame_handler_t handler; 00056 /*! \brief An opaque pointer passed in calls to frame_handler. */ 00057 void *user_data; 00058 /*! \brief The maximum frame length allowed */ 00059 int max_len; 00060 00061 uint32_t string_code; 00062 uint32_t latest_code; 00063 int string_length; 00064 uint32_t output_bit_buffer; 00065 int output_bit_count; 00066 int output_octet_count; 00067 uint8_t output_buf[1024]; 00068 v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS]; 00069 /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */ 00070 int transparent; 00071 int change_transparency; 00072 /*! \brief IIR filter state, used in assessing compressibility. */ 00073 int compressibility_filter; 00074 int compressibility_persistence; 00075 00076 /*! \brief Next empty dictionary entry */ 00077 uint32_t v42bis_parm_c1; 00078 /*! \brief Current codeword size */ 00079 int v42bis_parm_c2; 00080 /*! \brief Threshold for codeword size change */ 00081 uint32_t v42bis_parm_c3; 00082 00083 /*! \brief Mark that this is the first octet/code to be processed */ 00084 int first; 00085 uint8_t escape_code; 00086 } v42bis_compress_state_t; 00087 00088 /*! 00089 V.42bis decompression. This defines the working state for a single instance 00090 of V.42bis decompression. 00091 */ 00092 typedef struct 00093 { 00094 /*! \brief Callback function to handle decompressed data. */ 00095 v42bis_data_handler_t handler; 00096 /*! \brief An opaque pointer passed in calls to data_handler. */ 00097 void *user_data; 00098 /*! \brief The maximum decompressed data block length allowed */ 00099 int max_len; 00100 00101 uint32_t old_code; 00102 uint32_t last_old_code; 00103 uint32_t input_bit_buffer; 00104 int input_bit_count; 00105 int octet; 00106 int last_length; 00107 int output_octet_count; 00108 uint8_t output_buf[1024]; 00109 v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS]; 00110 /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */ 00111 int transparent; 00112 00113 int last_extra_octet; 00114 00115 /*! \brief Next empty dictionary entry */ 00116 uint32_t v42bis_parm_c1; 00117 /*! \brief Current codeword size */ 00118 int v42bis_parm_c2; 00119 /*! \brief Threshold for codeword size change */ 00120 uint32_t v42bis_parm_c3; 00121 00122 /*! \brief Mark that this is the first octet/code to be processed */ 00123 int first; 00124 uint8_t escape_code; 00125 int escaped; 00126 } v42bis_decompress_state_t; 00127 00128 /*! 00129 V.42bis compression/decompression descriptor. This defines the working state for a 00130 single instance of V.42bis compress/decompression. 00131 */ 00132 struct v42bis_state_s 00133 { 00134 /*! \brief V.42bis data compression directions. */ 00135 int v42bis_parm_p0; 00136 00137 /*! \brief Compression state. */ 00138 v42bis_compress_state_t compress; 00139 /*! \brief Decompression state. */ 00140 v42bis_decompress_state_t decompress; 00141 00142 /*! \brief Maximum codeword size (bits) */ 00143 int v42bis_parm_n1; 00144 /*! \brief Total number of codewords */ 00145 uint32_t v42bis_parm_n2; 00146 /*! \brief Maximum string length */ 00147 int v42bis_parm_n7; 00148 }; 00149 00150 #endif 00151 /*- End of file ------------------------------------------------------------*/