spandsp  0.0.6
private/v42bis.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/v42bis.h
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2005 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_SPANDSP_PRIVATE_V42BIS_H_)
27 #define _SPANDSP_PRIVATE_V42BIS_H_
28 
29 /*!
30  V.42bis dictionary node.
31 */
32 typedef struct
33 {
34  /*! \brief The prior code for each defined code. */
35  uint16_t parent_code;
36  /*! \brief The number of leaf nodes this node has */
37  int16_t leaves;
38  /*! \brief This leaf octet for each defined code. */
39  uint8_t node_octet;
40  /*! \brief Bit map of the children which exist */
41  uint32_t children[8];
43 
44 /*!
45  V.42bis compression. This defines the working state for a single instance
46  of V.42bis compression.
47 */
48 typedef struct
49 {
50  /*! \brief Compression mode. */
52  /*! \brief Callback function to handle received frames. */
53  v42bis_frame_handler_t handler;
54  /*! \brief An opaque pointer passed in calls to frame_handler. */
55  void *user_data;
56  /*! \brief The maximum frame length allowed */
57  int max_len;
58 
59  uint32_t string_code;
60  uint32_t latest_code;
61  int string_length;
62  uint32_t output_bit_buffer;
63  int output_bit_count;
64  int output_octet_count;
65  uint8_t output_buf[1024];
66  v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
67  /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
69  int change_transparency;
70  /*! \brief IIR filter state, used in assessing compressibility. */
72  int compressibility_persistence;
73 
74  /*! \brief Next empty dictionary entry */
75  uint32_t v42bis_parm_c1;
76  /*! \brief Current codeword size */
78  /*! \brief Threshold for codeword size change */
79  uint32_t v42bis_parm_c3;
80 
81  /*! \brief Mark that this is the first octet/code to be processed */
82  int first;
83  uint8_t escape_code;
85 
86 /*!
87  V.42bis decompression. This defines the working state for a single instance
88  of V.42bis decompression.
89 */
90 typedef struct
91 {
92  /*! \brief Callback function to handle decompressed data. */
93  v42bis_data_handler_t handler;
94  /*! \brief An opaque pointer passed in calls to data_handler. */
95  void *user_data;
96  /*! \brief The maximum decompressed data block length allowed */
97  int max_len;
98 
99  uint32_t old_code;
100  uint32_t last_old_code;
101  uint32_t input_bit_buffer;
102  int input_bit_count;
103  int octet;
104  int last_length;
105  int output_octet_count;
106  uint8_t output_buf[1024];
107  v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
108  /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
110 
111  int last_extra_octet;
112 
113  /*! \brief Next empty dictionary entry */
114  uint32_t v42bis_parm_c1;
115  /*! \brief Current codeword size */
117  /*! \brief Threshold for codeword size change */
118  uint32_t v42bis_parm_c3;
119 
120  /*! \brief Mark that this is the first octet/code to be processed */
121  int first;
122  uint8_t escape_code;
123  int escaped;
125 
126 /*!
127  V.42bis compression/decompression descriptor. This defines the working state for a
128  single instance of V.42bis compress/decompression.
129 */
131 {
132  /*! \brief V.42bis data compression directions. */
134 
135  /*! \brief Compression state. */
137  /*! \brief Decompression state. */
139 
140  /*! \brief Maximum codeword size (bits) */
142  /*! \brief Total number of codewords */
143  uint32_t v42bis_parm_n2;
144  /*! \brief Maximum string length */
146 };
147 
148 #endif
149 /*- End of file ------------------------------------------------------------*/