?? t4.h
字號:
/* * SpanDSP - a series of DSP components for telephony * * t4.h - definitions for T.4 fax processing * * Written by Steve Underwood <steveu@coppice.org> * * Copyright (C) 2003 Steve Underwood * * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id: t4.h,v 1.34 2007/08/02 13:55:48 steveu Exp $ *//*! \file */#if !defined(_SPANDSP_T4_H_)#define _SPANDSP_T4_H_/*! \page t4_page T.4 image compression and decompression\section t4_page_sec_1 What does it do?The T.4 image compression and decompression routines implement the 1D and 2Dencoding methods defined in ITU specification T.4. They also implement the pure2D encoding method defined in T.6. These are image compression algorithms usedfor FAX transmission.\section t4_page_sec_1 How does it work?*/enum{ T4_COMPRESSION_ITU_T4_1D = 1, T4_COMPRESSION_ITU_T4_2D = 2, T4_COMPRESSION_ITU_T6 = 3};enum{ T4_X_RESOLUTION_R4 = 4019, T4_X_RESOLUTION_R8 = 8037, T4_X_RESOLUTION_R16 = 16074};enum{ T4_Y_RESOLUTION_STANDARD = 3850, T4_Y_RESOLUTION_FINE = 7700, T4_Y_RESOLUTION_SUPERFINE = 15400};/*! T.4 FAX compression/decompression descriptor. This defines the working state for a single instance of a T.4 FAX compression or decompression channel.*/typedef struct{ /* "Background" information about the FAX, which can be stored in a TIFF file. */ /*! \brief The vendor of the machine which produced the TIFF file. */ const char *vendor; /*! \brief The model of machine which produced the TIFF file. */ const char *model; /*! \brief The local ident string. */ const char *local_ident; /*! \brief The remote end's ident string. */ const char *far_ident; /*! \brief The FAX sub-address. */ const char *sub_address; /*! \brief The text which will be used in FAX page header. No text results in no header line. */ const char *header_info; /*! \brief The type of compression used between the FAX machines. */ int line_encoding; /*! \brief The minimum number of bits per scan row. This is a timing thing for hardware FAX machines. */ int min_scan_line_bits; int output_compression; int output_t4_options; time_t page_start_time; int bytes_per_row; int image_size; int image_buffer_size; uint8_t *image_buffer; TIFF *tiff_file; const char *file; int start_page; int stop_page; int pages_transferred; int pages_in_file; /*! Column-to-column (X) resolution in pixels per metre. */ int x_resolution; /*! Row-to-row (Y) resolution in pixels per metre. */ int y_resolution; /*! Width of the current page, in pixels. */ int image_width; /*! Current pixel row number. */ int row; /*! Total pixel rows in the current page. */ int image_length; /*! The current number of consecutive bad rows. */ int curr_bad_row_run; /*! The longest run of consecutive bad rows seen in the current page. */ int longest_bad_row_run; /*! The total number of bad rows in the current page. */ int bad_rows; /* Decode state */ uint32_t bits_to_date; int bits; /*! \brief This variable is set if we are treating the current row as a 2D encoded one. */ int row_is_2d; int its_black; int row_len; /*! \brief This variable is used to record the fact we have seen at least one EOL since we started decoding. We will not try to interpret the received data as an image until we have seen the first EOL. */ int first_eol_seen; /*! \brief This variable is used to count the consecutive EOLS we have seen. If it reaches six, this is the end of the image. */ int consecutive_eols; /*! \brief B&W runs for reference line */ uint32_t *ref_runs; /*! \brief B&W runs for current line */ uint32_t *cur_runs; uint32_t *pa; uint32_t *pb; int a0; int b1; /*! \brief The length of the current run of black or white. */ int run_length; int black_white; uint32_t data; int bit; /*! \brief A point into the image buffer indicating where the last row begins */ int last_row_starts_at; /*! \brief A point into the image buffer indicating where the current row begins */ int row_starts_at; /* Encode state */ /*! Pointer to the buffer for the current pixel row. */ uint8_t *row_buf; int bit_pos; int bit_ptr; /*! \brief The reference pixel row for 2D encoding. */ uint8_t *ref_row_buf; /*! \brief The maximum contiguous rows that will be 2D encoded. */ int max_rows_to_next_1d_row; /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row must be used. */ int rows_to_next_1d_row; /*! \brief The minimum number of encoded bits per row. */ int min_row_bits; /*! \brief The current number of bits in the current encoded row. */ int row_bits; /*! \brief Error and flow logging control */ logging_state_t logging;} t4_state_t;/*! T.4 FAX compression/decompression statistics.*/typedef struct{ /*! \brief The number of pages transferred so far. */ int pages_transferred; /*! \brief The number of pages in the file (<0 if unknown). */ int pages_in_file; /*! \brief The number of horizontal pixels in the most recent page. */ int width; /*! \brief The number of vertical pixels in the most recent page. */ int length; /*! \brief The number of bad pixel rows in the most recent page. */ int bad_rows; /*! \brief The largest number of bad pixel rows in a block in the most recent page. */ int longest_bad_row_run; /*! \brief The horizontal resolution of the page in pixels per metre */ int x_resolution; /*! \brief The vertical resolution of the page in pixels per metre */ int y_resolution; /*! \brief The type of compression used between the FAX machines */ int encoding; /*! \brief The size of the image, in bytes */ int image_size;} t4_stats_t; #if defined(__cplusplus)extern "C" {#endif/*! \brief Allocate a T.4 transmit handling context, and initialise it. \param file The name of the file to be received. \param output_encoding The output encoding. \return The T.4 context, or NULL. */t4_state_t *t4_rx_create(const char *file, int output_encoding);/*! \brief Prepare for reception of a document. \param s The T.4 context. \param file The name of the file to be received. \param output_encoding The output encoding. \return 0 for success, otherwise -1. */int t4_rx_init(t4_state_t *s, const char *file, int output_encoding);/*! \brief Prepare to receive the next page of the current document. \param s The T.4 context. \return zero for success, -1 for failure. */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -