00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/t4_t6_decode.h - definitions for T.4/T.6 fax decoding 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003, 2009 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 #if !defined(_SPANDSP_PRIVATE_T4_T6_DECODE_H_) 00027 #define _SPANDSP_PRIVATE_T4_T6_DECODE_H_ 00028 00029 /*! 00030 T.4 1D, T4 2D and T6 decompressor state. 00031 */ 00032 struct t4_t6_decode_state_s 00033 { 00034 /*! \brief Callback function to write a row of pixels to the image destination. */ 00035 t4_row_write_handler_t row_write_handler; 00036 /*! \brief Opaque pointer passed to row_write_handler. */ 00037 void *row_write_user_data; 00038 00039 /*! \brief The type of compression used between the FAX machines. */ 00040 int encoding; 00041 /*! \brief Width of the current page, in pixels. */ 00042 int image_width; 00043 00044 /*! \brief Length of the current page, in pixels. */ 00045 int image_length; 00046 /*! \brief The current number of bytes per row of uncompressed image data. */ 00047 int bytes_per_row; 00048 00049 /*! \brief The current number of bits in the current encoded row. */ 00050 int row_bits; 00051 /*! \brief Pointer to the buffer for the current pixel row. */ 00052 uint8_t *row_buf; 00053 00054 /*! \brief This variable is set if we are treating the current row as a 2D encoded 00055 one. */ 00056 int row_is_2d; 00057 /*! \brief The current length of the current row. */ 00058 int row_len; 00059 00060 /*! \brief Black and white run-lengths for the current row. */ 00061 uint32_t *cur_runs; 00062 /*! \brief Black and white run-lengths for the reference row. */ 00063 uint32_t *ref_runs; 00064 00065 /*! \brief This variable is used to count the consecutive EOLS we have seen. If it 00066 reaches six, this is the end of the image. It is initially set to -1 for 00067 1D and 2D decoding, as an indicator that we must wait for the first EOL, 00068 before decoding any image data. */ 00069 int consecutive_eols; 00070 00071 /*! \brief The reference or starting changing element on the coding line. At the 00072 start of the coding line, a0 is set on an imaginary white changing element 00073 situated just before the first element on the line. During the coding of 00074 the coding line, the position of a0 is defined by the previous coding mode. 00075 (See T.4/4.2.1.3.2.). */ 00076 int a0; 00077 /*! \brief The first changing element on the reference line to the right of a0 and of 00078 opposite colour to a0. */ 00079 int b1; 00080 /*! \brief The length of the in-progress run of black or white. */ 00081 int run_length; 00082 /*! \brief 2D horizontal mode control. */ 00083 int black_white; 00084 /*! \brief TRUE if the current run is black */ 00085 int in_black; 00086 00087 /*! \brief The current step into the current row run-lengths buffer. */ 00088 int a_cursor; 00089 /*! \brief The current step into the reference row run-lengths buffer. */ 00090 int b_cursor; 00091 00092 /*! \brief Incoming bit buffer for decompression. */ 00093 uint32_t rx_bitstream; 00094 /*! \brief The number of bits currently in rx_bitstream. */ 00095 int rx_bits; 00096 /*! \brief The number of bits to be skipped before trying to match the next code word. */ 00097 int rx_skip_bits; 00098 00099 /*! \brief Decoded pixel stream buffer. */ 00100 uint32_t pixel_stream; 00101 /*! \brief The number of pixels currently in pixel_stream. */ 00102 int pixels; 00103 00104 /*! \brief The minimum bits in any row of the current page. For monitoring only. */ 00105 int min_row_bits; 00106 /*! \brief The maximum bits in any row of the current page. For monitoring only. */ 00107 int max_row_bits; 00108 00109 /*! \brief The size of the compressed image, in bits. */ 00110 int compressed_image_size; 00111 /*! \brief The current number of consecutive bad rows. */ 00112 int curr_bad_row_run; 00113 /*! \brief The longest run of consecutive bad rows seen in the current page. */ 00114 int longest_bad_row_run; 00115 /*! \brief The total number of bad rows in the current page. */ 00116 int bad_rows; 00117 00118 /*! \brief Error and flow logging control */ 00119 logging_state_t logging; 00120 }; 00121 00122 #endif 00123 /*- End of file ------------------------------------------------------------*/
1.6.1