00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t81_t82_arith_coding.h - ITU T.81 and T.82 QM-coder arithmetic encoding 00005 * and decoding 00006 * 00007 * Written by Steve Underwood <steveu@coppice.org> 00008 * 00009 * Copyright (C) 2009 Steve Underwood 00010 * 00011 * All rights reserved. 00012 * 00013 * This program is free software; you can redistribute it and/or modify 00014 * it under the terms of the GNU Lesser General Public License version 2.1, 00015 * as published by the Free Software Foundation. 00016 * 00017 * This program is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU Lesser General Public License for more details. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this program; if not, write to the Free Software 00024 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 */ 00026 00027 /*! \file */ 00028 00029 #if !defined(_SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_) 00030 #define _SPANDSP_PRIVATE_T81_T82_ARITH_CODING_H_ 00031 00032 /* State of a working instance of the QM-coder arithmetic encoder */ 00033 struct t81_t82_arith_encode_state_s 00034 { 00035 /*! A register - see T.82 Table 23 */ 00036 uint32_t a; 00037 /*! C register - see T.82 Table 23 */ 00038 uint32_t c; 00039 /*! Probability status for contexts. MSB = MPS */ 00040 uint8_t st[4096]; 00041 /*! Number of buffered 0xFF values that might still overflow */ 00042 int32_t sc; 00043 /*! Bit shift counter. This determines when the next byte will be written */ 00044 int ct; 00045 /*! Buffer for the most recent output byte which is not 0xFF */ 00046 int buffer; 00047 /*! Callback function to deliver the encoded data, byte by byte */ 00048 void (*output_byte_handler)(void *, int); 00049 /*! Opaque pointer passed to byte_out */ 00050 void *user_data; 00051 }; 00052 00053 /* State of a working instance of the QM-coder arithmetic decoder */ 00054 struct t81_t82_arith_decode_state_s 00055 { 00056 /*! A register - see T.82 Table 25 */ 00057 uint32_t a; 00058 /*! C register - see T.82 Table 25 */ 00059 uint32_t c; 00060 /*! Probability status for contexts. MSB = MPS */ 00061 uint8_t st[4096]; 00062 /*! Bit-shift counter. Determines when next byte will be read. 00063 Special value -1 signals that zero-padding has started */ 00064 int ct; 00065 /*! Pointer to next PSCD data byte */ 00066 const uint8_t *pscd_ptr; 00067 /*! Pointer to byte after PSCD */ 00068 const uint8_t *pscd_end; 00069 /*! Boolean flag that controls initial fill of s->c */ 00070 int startup; 00071 /*! Boolean flag that triggers return -2 between reaching PSCD end 00072 and decoding the first symbol that might never have been encoded 00073 in the first place */ 00074 int nopadding; 00075 }; 00076 00077 #endif 00078 00079 /*- End of file ------------------------------------------------------------*/
1.6.1