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 Note that 0 is not a valid node to point to (0 is always a control code), so 0 is used
32 as a "no such value" marker in this structure.
33*/
34 typedef struct
35{
36 /*! \brief The value of the octet represented by the current dictionary node */
37 uint8_t node_octet;
38 /*! \brief The parent of this node */
39 uint16_t parent;
40 /*! \brief The first child of this node */
41 uint16_t child;
42 /*! \brief The next node at the same depth */
43 uint16_t next;
44} v42bis_dict_node_t;
45
46/*!
47 V.42bis compression or decompression. This defines the working state for a single instance
48 of V.42bis compression or decompression.
49*/
50 typedef struct
51{
52 /*! \brief Compression enabled. */
53 int v42bis_parm_p0;
54 /*! \brief Compression mode. */
55 int compression_mode;
56 /*! \brief Callback function to handle output data. */
57 put_msg_func_t handler;
58 /*! \brief An opaque pointer passed in calls to the data handler. */
59 void *user_data;
60 /*! \brief The maximum amount to be passed to the data handler. */
61 int max_output_len;
62
63 /*! \brief TRUE if we are in transparent (i.e. uncompressable) mode */
64 int transparent;
65 /*! \brief Next empty dictionary entry */
66 uint16_t v42bis_parm_c1;
67 /*! \brief Current codeword size */
68 uint16_t v42bis_parm_c2;
69 /*! \brief Threshold for codeword size change */
70 uint16_t v42bis_parm_c3;
71 /*! \brief The current update point in the dictionary */
72 uint16_t update_at;
73 /*! \brief The last entry matched in the dictionary */
74 uint16_t last_matched;
75 /*! \brief The last entry added to the dictionary */
76 uint16_t last_added;
77 /*! \brief Total number of codewords in the dictionary */
78 int v42bis_parm_n2;
79 /*! \brief Maximum permitted string length */
80 int v42bis_parm_n7;
81 /*! \brief The dictionary */
82 v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS];
83
84 /*! \brief The octet string in progress */
85 uint8_t string[V42BIS_MAX_STRING_SIZE];
86 /*! \brief The current length of the octet string in progress */
87 int string_length;
88 /*! \brief The amount of the octet string in progress which has already
89 been flushed out of the buffer */
90 int flushed_length;
91
92 /*! \brief Compression performance metric */
93 uint16_t compression_performance;
94
95 /*! \brief Outgoing bit buffer (compression), or incoming bit buffer (decompression) */
96 uint32_t bit_buffer;
97 /*! \brief Outgoing bit count (compression), or incoming bit count (decompression) */
98 int bit_count;
99
100 /*! \brief The output composition buffer */
101 uint8_t output_buf[V42BIS_MAX_OUTPUT_LENGTH];
102 /*! \brief The length of the contents of the output composition buffer */
103 int output_octet_count;
104
105 /*! \brief The current value of the escape code */
106 uint8_t escape_code;
107 /*! \brief TRUE if we just hit an escape code, and are waiting for the following octet */
108 int escaped;
109} v42bis_comp_state_t;
110
111/*!
112 V.42bis compression/decompression descriptor. This defines the working state for a
113 single instance of V.42bis compress/decompression.
114*/
115 struct v42bis_state_s
116{
117 /*! \brief Compression state. */
118 v42bis_comp_state_t compress;
119 /*! \brief Decompression state. */
120 v42bis_comp_state_t decompress;
121
122 /*! \brief Error and flow logging control */
123 logging_state_t logging;
124};
125
126#endif
127/*- End of file ------------------------------------------------------------*/
put_msg_func_t
void(* put_msg_func_t)(void *user_data, const uint8_t *msg, int len)
Definition async.h:93
logging_state_t
struct logging_state_s logging_state_t
Definition logging.h:75
v42bis_comp_state_t
Definition private/v42bis.h:51
v42bis_comp_state_t::last_matched
uint16_t last_matched
The last entry matched in the dictionary.
Definition private/v42bis.h:74
v42bis_comp_state_t::max_output_len
int max_output_len
The maximum amount to be passed to the data handler.
Definition private/v42bis.h:61
v42bis_comp_state_t::user_data
void * user_data
An opaque pointer passed in calls to the data handler.
Definition private/v42bis.h:59
v42bis_comp_state_t::escaped
int escaped
TRUE if we just hit an escape code, and are waiting for the following octet.
Definition private/v42bis.h:108
v42bis_comp_state_t::dict
v42bis_dict_node_t dict[V42BIS_MAX_CODEWORDS]
The dictionary.
Definition private/v42bis.h:82
v42bis_comp_state_t::output_octet_count
int output_octet_count
The length of the contents of the output composition buffer.
Definition private/v42bis.h:103
v42bis_comp_state_t::handler
put_msg_func_t handler
Callback function to handle output data.
Definition private/v42bis.h:57
v42bis_comp_state_t::v42bis_parm_n2
int v42bis_parm_n2
Total number of codewords in the dictionary.
Definition private/v42bis.h:78
v42bis_comp_state_t::compression_performance
uint16_t compression_performance
Compression performance metric.
Definition private/v42bis.h:93
v42bis_comp_state_t::v42bis_parm_c3
uint16_t v42bis_parm_c3
Threshold for codeword size change.
Definition private/v42bis.h:70
v42bis_comp_state_t::bit_buffer
uint32_t bit_buffer
Outgoing bit buffer (compression), or incoming bit buffer (decompression).
Definition private/v42bis.h:96
v42bis_comp_state_t::v42bis_parm_p0
int v42bis_parm_p0
Compression enabled.
Definition private/v42bis.h:53
v42bis_comp_state_t::string_length
int string_length
The current length of the octet string in progress.
Definition private/v42bis.h:87
v42bis_comp_state_t::output_buf
uint8_t output_buf[V42BIS_MAX_OUTPUT_LENGTH]
The output composition buffer.
Definition private/v42bis.h:101
v42bis_comp_state_t::transparent
int transparent
TRUE if we are in transparent (i.e. uncompressable) mode.
Definition private/v42bis.h:64
v42bis_comp_state_t::flushed_length
int flushed_length
The amount of the octet string in progress which has already been flushed out of the buffer.
Definition private/v42bis.h:90
v42bis_comp_state_t::v42bis_parm_c1
uint16_t v42bis_parm_c1
Next empty dictionary entry.
Definition private/v42bis.h:66
v42bis_comp_state_t::bit_count
int bit_count
Outgoing bit count (compression), or incoming bit count (decompression).
Definition private/v42bis.h:98
v42bis_comp_state_t::escape_code
uint8_t escape_code
The current value of the escape code.
Definition private/v42bis.h:106
v42bis_comp_state_t::v42bis_parm_c2
uint16_t v42bis_parm_c2
Current codeword size.
Definition private/v42bis.h:68
v42bis_comp_state_t::compression_mode
int compression_mode
Compression mode.
Definition private/v42bis.h:55
v42bis_comp_state_t::update_at
uint16_t update_at
The current update point in the dictionary.
Definition private/v42bis.h:72
v42bis_comp_state_t::v42bis_parm_n7
int v42bis_parm_n7
Maximum permitted string length.
Definition private/v42bis.h:80
v42bis_comp_state_t::last_added
uint16_t last_added
The last entry added to the dictionary.
Definition private/v42bis.h:76
v42bis_dict_node_t
Definition private/v42bis.h:35
v42bis_dict_node_t::parent
uint16_t parent
The parent of this node.
Definition private/v42bis.h:39
v42bis_dict_node_t::node_octet
uint8_t node_octet
The value of the octet represented by the current dictionary node.
Definition private/v42bis.h:37
v42bis_dict_node_t::next
uint16_t next
The next node at the same depth.
Definition private/v42bis.h:43
v42bis_dict_node_t::child
uint16_t child
The first child of this node.
Definition private/v42bis.h:41
v42bis_state_s
Definition private/v42bis.h:116
v42bis_state_s::logging
logging_state_t logging
Error and flow logging control.
Definition private/v42bis.h:123
v42bis_state_s::decompress
v42bis_comp_state_t decompress
Decompression state.
Definition private/v42bis.h:120
v42bis_state_s::compress
v42bis_comp_state_t compress
Compression state.
Definition private/v42bis.h:118