00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * private/t4_tx.h - definitions for T.4 FAX transmit processing 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2003 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 * $Id: t4_tx.h,v 1.7.2.4 2009/12/21 17:18:40 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_PRIVATE_T4_TX_H_) 00029 #define _SPANDSP_PRIVATE_T4_TX_H_ 00030 00031 typedef struct t4_t6_encode_state_s t4_t6_encode_state_t; 00032 00033 /*! 00034 T.4 1D, T4 2D and T6 compressor state. 00035 */ 00036 struct t4_t6_encode_state_s 00037 { 00038 /*! \brief The minimum number of encoded bits per row. This is a timing thing 00039 for hardware FAX machines. */ 00040 int min_bits_per_row; 00041 /*! \brief The current maximum contiguous rows that may be 2D encoded. */ 00042 int max_rows_to_next_1d_row; 00043 00044 /*! \brief The text which will be used in FAX page header. No text results 00045 in no header line. */ 00046 const char *header_info; 00047 00048 /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row 00049 must be used. */ 00050 int rows_to_next_1d_row; 00051 00052 /*! \brief The number of runs currently in the reference row. */ 00053 int ref_steps; 00054 00055 /*! \brief Pointer to the byte containing the next image bit to transmit. */ 00056 int bit_pos; 00057 /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */ 00058 int bit_ptr; 00059 00060 /*! \brief Callback function to read a row of pixels from the image source. */ 00061 t4_row_read_handler_t row_read_handler; 00062 /*! \brief Opaque pointer passed to row_read_handler. */ 00063 void *row_read_user_data; 00064 }; 00065 00066 /*! 00067 T.4 FAX compression/decompression descriptor. This defines the working state 00068 for a single instance of a T.4 FAX compression or decompression channel. 00069 */ 00070 struct t4_state_s 00071 { 00072 /*! \brief The same structure is used for T.4 transmit and receive. This variable 00073 records which mode is in progress. */ 00074 int rx; 00075 00076 /*! \brief The type of compression used between the FAX machines. */ 00077 int line_encoding; 00078 00079 /*! \brief The time at which handling of the current page began. */ 00080 time_t page_start_time; 00081 00082 /*! \brief The size of the compressed image on the line side, in bits. */ 00083 int line_image_size; 00084 00085 /*! \brief The current number of bytes per row of uncompressed image data. */ 00086 int bytes_per_row; 00087 /*! \brief The size of the image in the image buffer, in bytes. */ 00088 int image_size; 00089 /*! \brief The current size of the image buffer. */ 00090 int image_buffer_size; 00091 /*! \brief A point to the image buffer. */ 00092 uint8_t *image_buffer; 00093 00094 /*! \brief The number of pages transferred to date. */ 00095 int current_page; 00096 /*! \brief Column-to-column (X) resolution in pixels per metre. */ 00097 int x_resolution; 00098 /*! \brief Row-to-row (Y) resolution in pixels per metre. */ 00099 int y_resolution; 00100 /*! \brief Width of the current page, in pixels. */ 00101 int image_width; 00102 /*! \brief Length of the current page, in pixels. */ 00103 int image_length; 00104 /*! \brief Current pixel row number. */ 00105 int row; 00106 00107 /*! \brief This variable is set if we are treating the current row as a 2D encoded 00108 one. */ 00109 int row_is_2d; 00110 /*! \brief The current length of the current row. */ 00111 int row_len; 00112 00113 /*! \brief Black and white run-lengths for the current row. */ 00114 uint32_t *cur_runs; 00115 /*! \brief Black and white run-lengths for the reference row. */ 00116 uint32_t *ref_runs; 00117 /*! \brief Pointer to the buffer for the current pixel row. */ 00118 uint8_t *row_buf; 00119 00120 /*! \brief Encoded data bits buffer. */ 00121 uint32_t tx_bitstream; 00122 /*! \brief The number of bits currently in tx_bitstream. */ 00123 int tx_bits; 00124 00125 /*! \brief The current number of bits in the current encoded row. */ 00126 int row_bits; 00127 /*! \brief The minimum bits in any row of the current page. For monitoring only. */ 00128 int min_row_bits; 00129 /*! \brief The maximum bits in any row of the current page. For monitoring only. */ 00130 int max_row_bits; 00131 00132 /*! \brief Error and flow logging control */ 00133 logging_state_t logging; 00134 00135 /*! \brief All TIFF file specific state information for the T.4 context. */ 00136 t4_tiff_state_t tiff; 00137 t4_t6_decode_state_t t4_t6_rx; 00138 t4_t6_encode_state_t t4_t6_tx; 00139 }; 00140 00141 #endif 00142 /*- End of file ------------------------------------------------------------*/