00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t4.h - definitions for T.4 fax 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.h,v 1.52 2008/07/22 13:48:15 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 #if !defined(_SPANDSP_T4_H_) 00031 #define _SPANDSP_T4_H_ 00032 00033 /*! \page t4_page T.4 image compression and decompression 00034 00035 \section t4_page_sec_1 What does it do? 00036 The T.4 image compression and decompression routines implement the 1D and 2D 00037 encoding methods defined in ITU specification T.4. They also implement the pure 00038 2D encoding method defined in T.6. These are image compression algorithms used 00039 for FAX transmission. 00040 00041 \section t4_page_sec_1 How does it work? 00042 */ 00043 00044 typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len); 00045 typedef int (*t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size_t len); 00046 00047 /*! Supported compression modes. */ 00048 typedef enum 00049 { 00050 T4_COMPRESSION_ITU_T4_1D = 1, 00051 T4_COMPRESSION_ITU_T4_2D = 2, 00052 T4_COMPRESSION_ITU_T6 = 3 00053 } t4_image_compression_t; 00054 00055 /*! Supported X resolutions, in pixels per metre. */ 00056 typedef enum 00057 { 00058 T4_X_RESOLUTION_R4 = 4016, 00059 T4_X_RESOLUTION_R8 = 8031, 00060 T4_X_RESOLUTION_300 = 11811, 00061 T4_X_RESOLUTION_R16 = 16063, 00062 T4_X_RESOLUTION_600 = 23622, 00063 T4_X_RESOLUTION_800 = 31496, 00064 T4_X_RESOLUTION_1200 = 47244 00065 } t4_image_x_resolution_t; 00066 00067 /*! Supported Y resolutions, in pixels per metre. */ 00068 typedef enum 00069 { 00070 T4_Y_RESOLUTION_STANDARD = 3850, 00071 T4_Y_RESOLUTION_FINE = 7700, 00072 T4_Y_RESOLUTION_300 = 11811, 00073 T4_Y_RESOLUTION_SUPERFINE = 15400, /* 400 is 15748 */ 00074 T4_Y_RESOLUTION_600 = 23622, 00075 T4_Y_RESOLUTION_800 = 31496, 00076 T4_Y_RESOLUTION_1200 = 47244 00077 } t4_image_y_resolution_t; 00078 00079 /*! 00080 Exact widths in PELs for the difference resolutions, and page widths. 00081 Note: 00082 The A4 widths also apply to North American letter and legal. 00083 The R4 resolution widths are not supported in recent versions of T.30 00084 Only images of exactly these widths are acceptable for FAX transmisson. 00085 00086 R4 864 pels/215mm for ISO A4, North American Letter and Legal 00087 R4 1024 pels/255mm for ISO B4 00088 R4 1216 pels/303mm for ISO A3 00089 R8 1728 pels/215mm for ISO A4, North American Letter and Legal 00090 R8 2048 pels/255mm for ISO B4 00091 R8 2432 pels/303mm for ISO A3 00092 R16 3456 pels/215mm for ISO A4, North American Letter and Legal 00093 R16 4096 pels/255mm for ISO B4 00094 R16 4864 pels/303mm for ISO A3 00095 */ 00096 typedef enum 00097 { 00098 T4_WIDTH_R4_A4 = 864, 00099 T4_WIDTH_R4_B4 = 1024, 00100 T4_WIDTH_R4_A3 = 1216, 00101 T4_WIDTH_R8_A4 = 1728, 00102 T4_WIDTH_R8_B4 = 2048, 00103 T4_WIDTH_R8_A3 = 2432, 00104 T4_WIDTH_300_A4 = 2592, 00105 T4_WIDTH_300_B4 = 3072, 00106 T4_WIDTH_300_A3 = 3648, 00107 T4_WIDTH_R16_A4 = 3456, 00108 T4_WIDTH_R16_B4 = 4096, 00109 T4_WIDTH_R16_A3 = 4864, 00110 T4_WIDTH_600_A4 = 5184, 00111 T4_WIDTH_600_B4 = 6144, 00112 T4_WIDTH_600_A3 = 7296, 00113 T4_WIDTH_1200_A4 = 10368, 00114 T4_WIDTH_1200_B4 = 12288, 00115 T4_WIDTH_1200_A3 = 14592 00116 } t4_image_width_t; 00117 00118 /*! 00119 Length of the various supported paper sizes, in pixels at the various Y resolutions. 00120 Paper sizes are 00121 A4 (215mm x 297mm) 00122 B4 (255mm x 364mm) 00123 A3 (303mm x 418.56mm) 00124 North American Letter (215.9mm x 279.4mm) 00125 North American Legal (215.9mm x 355.6mm) 00126 Unlimited 00127 00128 T.4 does not accurately define the maximum number of scan lines in a page. A wide 00129 variety of maximum row counts are used in the real world. It is important not to 00130 set our sending limit too high, or a receiving machine might split pages. It is 00131 important not to set it too low, or we might clip pages. 00132 00133 Values seen for standard resolution A4 pages include 1037, 1045, 1109, 1126 and 1143. 00134 1109 seems the most-popular. At fine res 2150, 2196, 2200, 2237, 2252-2262, 2264, 00135 2286, and 2394 are used. 2255 seems the most popular. We try to use balanced choices 00136 here. 00137 */ 00138 typedef enum 00139 { 00140 /* A4 is 297mm long */ 00141 T4_LENGTH_STANDARD_A4 = 1143, 00142 T4_LENGTH_FINE_A4 = 2286, 00143 T4_LENGTH_300_A4 = 4665, 00144 T4_LENGTH_SUPERFINE_A4 = 4573, 00145 T4_LENGTH_600_A4 = 6998, 00146 T4_LENGTH_800_A4 = 9330, 00147 T4_LENGTH_1200_A4 = 13996, 00148 /* B4 is 364mm long */ 00149 T4_LENGTH_STANDARD_B4 = 1401, 00150 T4_LENGTH_FINE_B4 = 2802, 00151 T4_LENGTH_300_B4 = 0, 00152 T4_LENGTH_SUPERFINE_B4 = 5605, 00153 T4_LENGTH_600_B4 = 0, 00154 T4_LENGTH_800_B4 = 0, 00155 T4_LENGTH_1200_B4 = 0, 00156 /* North American letter is 279.4mm long */ 00157 T4_LENGTH_STANDARD_US_LETTER = 1075, 00158 T4_LENGTH_FINE_US_LETTER = 2151, 00159 T4_LENGTH_300_US_LETTER = 0, 00160 T4_LENGTH_SUPERFINE_US_LETTER = 4302, 00161 T4_LENGTH_600_US_LETTER = 0, 00162 T4_LENGTH_800_US_LETTER = 0, 00163 T4_LENGTH_1200_US_LETTER = 0, 00164 /* North American legal is 355.6mm long */ 00165 T4_LENGTH_STANDARD_US_LEGAL = 1369, 00166 T4_LENGTH_FINE_US_LEGAL = 2738, 00167 T4_LENGTH_300_US_LEGAL = 0, 00168 T4_LENGTH_SUPERFINE_US_LEGAL = 5476, 00169 T4_LENGTH_600_US_LEGAL = 0, 00170 T4_LENGTH_800_US_LEGAL = 0, 00171 T4_LENGTH_1200_US_LEGAL = 0 00172 } t4_image_length_t; 00173 00174 /*! 00175 T.4 FAX compression/decompression descriptor. This defines the working state 00176 for a single instance of a T.4 FAX compression or decompression channel. 00177 */ 00178 typedef struct 00179 { 00180 /*! \brief The same structure is used for T.4 transmit and receive. This variable 00181 records which mode is in progress. */ 00182 int rx; 00183 /* "Background" information about the FAX, which can be stored in a TIFF file. */ 00184 /*! \brief The vendor of the machine which produced the TIFF file. */ 00185 const char *vendor; 00186 /*! \brief The model of machine which produced the TIFF file. */ 00187 const char *model; 00188 /*! \brief The local ident string. */ 00189 const char *local_ident; 00190 /*! \brief The remote end's ident string. */ 00191 const char *far_ident; 00192 /*! \brief The FAX sub-address. */ 00193 const char *sub_address; 00194 /*! \brief The FAX DCS information, as an ASCII string. */ 00195 const char *dcs; 00196 /*! \brief The text which will be used in FAX page header. No text results 00197 in no header line. */ 00198 const char *header_info; 00199 00200 /*! \brief The type of compression used between the FAX machines. */ 00201 int line_encoding; 00202 /*! \brief The minimum number of encoded bits per row. This is a timing thing 00203 for hardware FAX machines. */ 00204 int min_bits_per_row; 00205 00206 /*! \brief The compression type for output to the TIFF file. */ 00207 int output_compression; 00208 /*! \brief The TIFF G3 FAX options. */ 00209 int output_t4_options; 00210 00211 /*! \brief Callback function to read a row of pixels from the image source. */ 00212 t4_row_read_handler_t row_read_handler; 00213 /*! \brief Opaque pointer passed to row_read_handler. */ 00214 void *row_read_user_data; 00215 /*! \brief Callback function to write a row of pixels to the image destination. */ 00216 t4_row_write_handler_t row_write_handler; 00217 /*! \brief Opaque pointer passed to row_write_handler. */ 00218 void *row_write_user_data; 00219 00220 /*! \brief The time at which handling of the current page began. */ 00221 time_t page_start_time; 00222 00223 /*! \brief The current number of bytes per row of uncompressed image data. */ 00224 int bytes_per_row; 00225 /*! \brief The size of the image in the image buffer, in bytes. */ 00226 int image_size; 00227 /*! \brief The size of the compressed image on the line side, in bits. */ 00228 int line_image_size; 00229 /*! \brief The current size of the image buffer. */ 00230 int image_buffer_size; 00231 /*! \brief A point to the image buffer. */ 00232 uint8_t *image_buffer; 00233 00234 /*! \brief The libtiff context for the current TIFF file */ 00235 TIFF *tiff_file; 00236 /*! \brief The current file name. */ 00237 const char *file; 00238 /*! \brief The first page to transfer. -1 to start at the beginning of the file. */ 00239 int start_page; 00240 /*! \brief The last page to transfer. -1 to continue to the end of the file. */ 00241 int stop_page; 00242 00243 /*! \brief The number of pages transferred to date. */ 00244 int pages_transferred; 00245 /*! \brief The number of pages in the current TIFF file. */ 00246 int pages_in_file; 00247 /*! \brief Column-to-column (X) resolution in pixels per metre. */ 00248 int x_resolution; 00249 /*! \brief Row-to-row (Y) resolution in pixels per metre. */ 00250 int y_resolution; 00251 /*! \brief Width of the current page, in pixels. */ 00252 int image_width; 00253 /*! \brief Length of the current page, in pixels. */ 00254 int image_length; 00255 /*! \brief Current pixel row number. */ 00256 int row; 00257 /*! \brief The current number of consecutive bad rows. */ 00258 int curr_bad_row_run; 00259 /*! \brief The longest run of consecutive bad rows seen in the current page. */ 00260 int longest_bad_row_run; 00261 /*! \brief The total number of bad rows in the current page. */ 00262 int bad_rows; 00263 00264 /*! \brief Incoming bit buffer for decompression. */ 00265 uint32_t rx_bitstream; 00266 /*! \brief The number of bits currently in rx_bitstream. */ 00267 int rx_bits; 00268 /*! \brief The number of bits to be skipped before trying to match the next code word. */ 00269 int rx_skip_bits; 00270 00271 /*! \brief This variable is set if we are treating the current row as a 2D encoded 00272 one. */ 00273 int row_is_2d; 00274 /*! \brief TRUE if the current run is black */ 00275 int its_black; 00276 /*! \brief The current length of the current row. */ 00277 int row_len; 00278 /*! \brief This variable is used to count the consecutive EOLS we have seen. If it 00279 reaches six, this is the end of the image. It is initially set to -1 for 00280 1D and 2D decoding, as an indicator that we must wait for the first EOL, 00281 before decodin any image data. */ 00282 int consecutive_eols; 00283 00284 /*! \brief Black and white run-lengths for the current row. */ 00285 uint32_t *cur_runs; 00286 /*! \brief Black and white run-lengths for the reference row. */ 00287 uint32_t *ref_runs; 00288 /*! \brief The number of runs currently in the reference row. */ 00289 int ref_steps; 00290 /*! \brief The current step into the reference row run-lengths buffer. */ 00291 int b_cursor; 00292 /*! \brief The current step into the current row run-lengths buffer. */ 00293 int a_cursor; 00294 00295 /*! \brief The reference or starting changing element on the coding line. At the 00296 start of the coding line, a0 is set on an imaginary white changing element 00297 situated just before the first element on the line. During the coding of 00298 the coding line, the position of a0 is defined by the previous coding mode. 00299 (See 4.2.1.3.2.). */ 00300 int a0; 00301 /*! \brief The first changing element on the reference line to the right of a0 and of 00302 opposite colour to a0. */ 00303 int b1; 00304 /*! \brief The length of the in-progress run of black or white. */ 00305 int run_length; 00306 /*! \brief 2D horizontal mode control. */ 00307 int black_white; 00308 00309 /*! \brief Encoded data bits buffer. */ 00310 uint32_t tx_bitstream; 00311 /*! \brief The number of bits currently in tx_bitstream. */ 00312 int tx_bits; 00313 00314 /*! \brief A pointer into the image buffer indicating where the last row begins */ 00315 int last_row_starts_at; 00316 /*! \brief A pointer into the image buffer indicating where the current row begins */ 00317 int row_starts_at; 00318 00319 /*! \brief Pointer to the buffer for the current pixel row. */ 00320 uint8_t *row_buf; 00321 00322 /*! \brief Pointer to the byte containing the next image bit to transmit. */ 00323 int bit_pos; 00324 /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */ 00325 int bit_ptr; 00326 00327 /*! \brief The current maximum contiguous rows that may be 2D encoded. */ 00328 int max_rows_to_next_1d_row; 00329 /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row 00330 must be used. */ 00331 int rows_to_next_1d_row; 00332 /*! \brief The current number of bits in the current encoded row. */ 00333 int row_bits; 00334 /*! \brief The minimum bits in any row of the current page. For monitoring only. */ 00335 int min_row_bits; 00336 /*! \brief The maximum bits in any row of the current page. For monitoring only. */ 00337 int max_row_bits; 00338 00339 /*! \brief Error and flow logging control */ 00340 logging_state_t logging; 00341 } t4_state_t; 00342 00343 /*! 00344 T.4 FAX compression/decompression statistics. 00345 */ 00346 typedef struct 00347 { 00348 /*! \brief The number of pages transferred so far. */ 00349 int pages_transferred; 00350 /*! \brief The number of pages in the file (<0 if unknown). */ 00351 int pages_in_file; 00352 /*! \brief The number of horizontal pixels in the most recent page. */ 00353 int width; 00354 /*! \brief The number of vertical pixels in the most recent page. */ 00355 int length; 00356 /*! \brief The number of bad pixel rows in the most recent page. */ 00357 int bad_rows; 00358 /*! \brief The largest number of bad pixel rows in a block in the most recent page. */ 00359 int longest_bad_row_run; 00360 /*! \brief The horizontal resolution of the page in pixels per metre */ 00361 int x_resolution; 00362 /*! \brief The vertical resolution of the page in pixels per metre */ 00363 int y_resolution; 00364 /*! \brief The type of compression used between the FAX machines */ 00365 int encoding; 00366 /*! \brief The size of the image on the line, in bytes */ 00367 int line_image_size; 00368 } t4_stats_t; 00369 00370 #if defined(__cplusplus) 00371 extern "C" { 00372 #endif 00373 00374 /*! \brief Prepare for reception of a document. 00375 \param s The T.4 context. 00376 \param file The name of the file to be received. 00377 \param output_encoding The output encoding. 00378 \return A pointer to the context, or NULL if there was a problem. */ 00379 t4_state_t *t4_rx_init(t4_state_t *s, const char *file, int output_encoding); 00380 00381 /*! \brief Prepare to receive the next page of the current document. 00382 \param s The T.4 context. 00383 \return zero for success, -1 for failure. */ 00384 int t4_rx_start_page(t4_state_t *s); 00385 00386 /*! \brief Put a bit of the current document page. 00387 \param s The T.4 context. 00388 \param bit The data bit. 00389 \return TRUE when the bit ends the document page, otherwise FALSE. */ 00390 int t4_rx_put_bit(t4_state_t *s, int bit); 00391 00392 /*! \brief Put a byte of the current document page. 00393 \param s The T.4 context. 00394 \param byte The data byte. 00395 \return TRUE when the byte ends the document page, otherwise FALSE. */ 00396 int t4_rx_put_byte(t4_state_t *s, uint8_t byte); 00397 00398 /*! \brief Put a byte of the current document page. 00399 \param s The T.4 context. 00400 \param buf The buffer containing the chunk. 00401 \param len The length of the chunk. 00402 \return TRUE when the byte ends the document page, otherwise FALSE. */ 00403 int t4_rx_put_chunk(t4_state_t *s, const uint8_t buf[], int len); 00404 00405 /*! \brief Complete the reception of a page. 00406 \param s The T.4 receive context. 00407 \return 0 for success, otherwise -1. */ 00408 int t4_rx_end_page(t4_state_t *s); 00409 00410 /*! \brief End reception of a document. Tidy up, close the file and 00411 free the context. This should be used to end T.4 reception 00412 started with t4_rx_init. 00413 \param s The T.4 receive context. 00414 \return 0 for success, otherwise -1. */ 00415 int t4_rx_delete(t4_state_t *s); 00416 00417 /*! \brief End reception of a document. Tidy up and close the file. 00418 This should be used to end T.4 reception started with 00419 t4_rx_init. 00420 \param s The T.4 context. 00421 \return 0 for success, otherwise -1. */ 00422 int t4_rx_end(t4_state_t *s); 00423 00424 int t4_rx_set_row_write_handler(t4_state_t *s, t4_row_write_handler_t handler, void *user_data); 00425 00426 /*! \brief Set the encoding for the received data. 00427 \param s The T.4 context. 00428 \param encoding The encoding. */ 00429 void t4_rx_set_rx_encoding(t4_state_t *s, int encoding); 00430 00431 /*! \brief Set the expected width of the received image, in pixel columns. 00432 \param s The T.4 context. 00433 \param width The number of pixels across the image. */ 00434 void t4_rx_set_image_width(t4_state_t *s, int width); 00435 00436 /*! \brief Set the row-to-row (y) resolution to expect for a received image. 00437 \param s The T.4 context. 00438 \param resolution The resolution, in pixels per metre. */ 00439 void t4_rx_set_y_resolution(t4_state_t *s, int resolution); 00440 00441 /*! \brief Set the column-to-column (x) resolution to expect for a received image. 00442 \param s The T.4 context. 00443 \param resolution The resolution, in pixels per metre. */ 00444 void t4_rx_set_x_resolution(t4_state_t *s, int resolution); 00445 00446 /*! \brief Set the DCS information of the fax, for inclusion in the file. 00447 \param s The T.4 context. 00448 \param dcs The DCS information, formatted as an ASCII string. */ 00449 void t4_rx_set_dcs(t4_state_t *s, const char *dcs); 00450 00451 /*! \brief Set the sub-address of the fax, for inclusion in the file. 00452 \param s The T.4 context. 00453 \param sub_address The sub-address string. */ 00454 void t4_rx_set_sub_address(t4_state_t *s, const char *sub_address); 00455 00456 /*! \brief Set the identity of the remote machine, for inclusion in the file. 00457 \param s The T.4 context. 00458 \param ident The identity string. */ 00459 void t4_rx_set_far_ident(t4_state_t *s, const char *ident); 00460 00461 /*! \brief Set the vendor of the remote machine, for inclusion in the file. 00462 \param s The T.4 context. 00463 \param vendor The vendor string, or NULL. */ 00464 void t4_rx_set_vendor(t4_state_t *s, const char *vendor); 00465 00466 /*! \brief Set the model of the remote machine, for inclusion in the file. 00467 \param s The T.4 context. 00468 \param model The model string, or NULL. */ 00469 void t4_rx_set_model(t4_state_t *s, const char *model); 00470 00471 /*! \brief Prepare for transmission of a document. 00472 \param s The T.4 context. 00473 \param file The name of the file to be sent. 00474 \param start_page The first page to send. -1 for no restriction. 00475 \param stop_page The last page to send. -1 for no restriction. 00476 \return A pointer to the context, or NULL if there was a problem. */ 00477 t4_state_t *t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page); 00478 00479 /*! \brief Prepare to send the next page of the current document. 00480 \param s The T.4 context. 00481 \return zero for success, -1 for failure. */ 00482 int t4_tx_start_page(t4_state_t *s); 00483 00484 /*! \brief Prepare the current page for a resend. 00485 \param s The T.4 context. 00486 \return zero for success, -1 for failure. */ 00487 int t4_tx_restart_page(t4_state_t *s); 00488 00489 /*! \brief Check for the existance of the next page. This information can 00490 be needed before it is determined that the current page is finished with. 00491 \param s The T.4 context. 00492 \return zero for next page found, -1 for failure. */ 00493 int t4_tx_more_pages(t4_state_t *s); 00494 00495 /*! \brief Complete the sending of a page. 00496 \param s The T.4 context. 00497 \return zero for success, -1 for failure. */ 00498 int t4_tx_end_page(t4_state_t *s); 00499 00500 /*! \brief Get the next bit of the current document page. The document will 00501 be padded for the current minimum scan line time. If the 00502 file does not contain an RTC (return to control) code at 00503 the end of the page, one will be added where appropriate. 00504 \param s The T.4 context. 00505 \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is 00506 set (i.e. the returned value is 2 or 3). */ 00507 int t4_tx_get_bit(t4_state_t *s); 00508 00509 /*! \brief Get the next byte of the current document page. The document will 00510 be padded for the current minimum scan line time. If the 00511 file does not contain an RTC (return to control) code at 00512 the end of the page, one will be added where appropriate. 00513 \param s The T.4 context. 00514 \return The next byte. For the last byte of data, bit 8 is 00515 set. In this case, one or more bits of the byte may be padded with 00516 zeros, to complete the byte. */ 00517 int t4_tx_get_byte(t4_state_t *s); 00518 00519 /*! \brief Get the next chunk of the current document page. The document will 00520 be padded for the current minimum scan line time. If the 00521 file does not contain an RTC (return to control) code at 00522 the end of the page, one will be added where appropriate. 00523 \param s The T.4 context. 00524 \param buf The buffer into which the chunk is to written. 00525 \param max_len The maximum length of the chunk. 00526 \return The actual length of the chunk. If this is less than max_len it 00527 indicates that the end of the document has been reached. */ 00528 int t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len); 00529 00530 /*! \brief Return the next bit of the current document page, without actually 00531 moving forward in the buffer. The document will be padded for the 00532 current minimum scan line time. If the file does not contain an 00533 RTC (return to control) code at the end of the page, one will be 00534 added. 00535 \param s The T.4 context. 00536 \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is 00537 set (i.e. the returned value is 2 or 3). */ 00538 int t4_tx_check_bit(t4_state_t *s); 00539 00540 /*! \brief End the transmission of a document. Tidy up, close the file and 00541 free the context. This should be used to end T.4 transmission 00542 started with t4_tx_init. 00543 \param s The T.4 context. 00544 \return 0 for success, otherwise -1. */ 00545 int t4_tx_delete(t4_state_t *s); 00546 00547 /*! \brief End the transmission of a document. Tidy up and close the file. 00548 This should be used to end T.4 transmission started with t4_tx_init. 00549 \param s The T.4 context. 00550 \return 0 for success, otherwise -1. */ 00551 int t4_tx_end(t4_state_t *s); 00552 00553 /*! \brief Set the encoding for the encoded data. 00554 \param s The T.4 context. 00555 \param encoding The encoding. */ 00556 void t4_tx_set_tx_encoding(t4_state_t *s, int encoding); 00557 00558 /*! \brief Set the minimum number of encoded bits per row. This allows the 00559 makes the encoding process to be set to comply with the minimum row 00560 time specified by a remote receiving machine. 00561 \param s The T.4 context. 00562 \param bits The minimum number of bits per row. */ 00563 void t4_tx_set_min_row_bits(t4_state_t *s, int bits); 00564 00565 /*! \brief Set the identity of the local machine, for inclusion in page headers. 00566 \param s The T.4 context. 00567 \param ident The identity string. */ 00568 void t4_tx_set_local_ident(t4_state_t *s, const char *ident); 00569 00570 /*! Set the info field, included in the header line included in each page of an encoded 00571 FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.) 00572 are automatically included in the header. If the header info is set to NULL or a zero 00573 length string, no header lines will be added to the encoded FAX. 00574 \brief Set the header info. 00575 \param s The T.4 context. 00576 \param info A string, of up to 50 bytes, which will form the info field. */ 00577 void t4_tx_set_header_info(t4_state_t *s, const char *info); 00578 00579 int t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data); 00580 00581 /*! \brief Get the row-to-row (y) resolution of the current page. 00582 \param s The T.4 context. 00583 \return The resolution, in pixels per metre. */ 00584 int t4_tx_get_y_resolution(t4_state_t *s); 00585 00586 /*! \brief Get the column-to-column (x) resolution of the current page. 00587 \param s The T.4 context. 00588 \return The resolution, in pixels per metre. */ 00589 int t4_tx_get_x_resolution(t4_state_t *s); 00590 00591 /*! \brief Get the width of the current page, in pixel columns. 00592 \param s The T.4 context. 00593 \return The number of columns. */ 00594 int t4_tx_get_image_width(t4_state_t *s); 00595 00596 /*! \brief Get the number of pages in the file. 00597 \param s The T.4 context. 00598 \return The number of pages, or -1 if there is an error. */ 00599 int t4_tx_get_pages_in_file(t4_state_t *s); 00600 00601 /*! Get the current image transfer statistics. 00602 \brief Get the current transfer statistics. 00603 \param s The T.4 context. 00604 \param t A pointer to a statistics structure. */ 00605 void t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t); 00606 00607 /*! Get the short text name of an encoding format. 00608 \brief Get the short text name of an encoding format. 00609 \param encoding The encoding type. 00610 \return A pointer to the string. */ 00611 const char *t4_encoding_to_str(int encoding); 00612 00613 #if defined(__cplusplus) 00614 } 00615 #endif 00616 00617 #endif 00618 /*- End of file ------------------------------------------------------------*/