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