spandsp 3.0.0
private/t81_t82_arith_coding.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * t81_t82_arith_coding.h - ITU T.81 and T.82 QM-coder arithmetic encoding
5 * and decoding
6 *
7 * Written by Steve Underwood <steveu@coppice.org>
8 *
9 * Copyright (C) 2009 Steve Underwood
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License version 2.1,
15 * as published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */
26
27/*! \file */
28
29#if !defined(_SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_)
30#define _SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_
31
32/* State of a working instance of the QM-coder arithmetic encoder */
34{
35 /*! A register - see T.82 Table 23 */
36 uint32_t a;
37 /*! C register - see T.82 Table 23 */
38 uint32_t c;
39 /*! Probability status for contexts. MSB = MPS */
40 uint8_t st[4096];
41 /*! Number of buffered 0xFF values that might still overflow */
42 int32_t sc;
43 /*! Bit shift counter. This determines when the next byte will be written */
44 int ct;
45 /*! Buffer for the most recent output byte which is not 0xFF */
46 int buffer;
47 /*! Callback function to deliver the encoded data, byte by byte */
48 void (*output_byte_handler)(void *, int);
49 /*! Opaque pointer passed to byte_out */
50 void *user_data;
51};
52
53/* State of a working instance of the QM-coder arithmetic decoder */
55{
56 /*! A register - see T.82 Table 25 */
57 uint32_t a;
58 /*! C register - see T.82 Table 25 */
59 uint32_t c;
60 /*! Probability status for contexts. MSB = MPS */
61 uint8_t st[4096];
62 /*! Bit-shift counter. Determines when next byte will be read.
63 Special value -1 signals that zero-padding has started */
64 int ct;
65 /*! Pointer to next PSCD data byte */
66 const uint8_t *pscd_ptr;
67 /*! Pointer to byte after PSCD */
68 const uint8_t *pscd_end;
69 /*! Boolean flag that controls initial fill of s->c */
71 /*! Boolean flag that triggers return -2 between reaching PSCD end
72 and decoding the first symbol that might never have been encoded
73 in the first place */
75};
76
77#endif
78
79/*- End of file ------------------------------------------------------------*/
Definition: private/t81_t82_arith_coding.h:55
uint32_t c
Definition: private/t81_t82_arith_coding.h:59
const uint8_t * pscd_end
Definition: private/t81_t82_arith_coding.h:68
uint32_t a
Definition: private/t81_t82_arith_coding.h:57
int startup
Definition: private/t81_t82_arith_coding.h:70
int ct
Definition: private/t81_t82_arith_coding.h:64
uint8_t st[4096]
Definition: private/t81_t82_arith_coding.h:61
const uint8_t * pscd_ptr
Definition: private/t81_t82_arith_coding.h:66
int nopadding
Definition: private/t81_t82_arith_coding.h:74
Definition: private/t81_t82_arith_coding.h:34
uint32_t c
Definition: private/t81_t82_arith_coding.h:38
uint32_t a
Definition: private/t81_t82_arith_coding.h:36
int32_t sc
Definition: private/t81_t82_arith_coding.h:42
void * user_data
Definition: private/t81_t82_arith_coding.h:50
int buffer
Definition: private/t81_t82_arith_coding.h:46
uint8_t st[4096]
Definition: private/t81_t82_arith_coding.h:40
void(* output_byte_handler)(void *, int)
Definition: private/t81_t82_arith_coding.h:48
int ct
Definition: private/t81_t82_arith_coding.h:44