00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * t4_t6_encode.h - definitions for T.4/T.6 fax encoding 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 /*! \file */ 00027 00028 #if !defined(_SPANDSP_T4_T6_ENCODE_H_) 00029 #define _SPANDSP_T4_T6_ENCODE_H_ 00030 00031 typedef struct t4_t6_encode_state_s t4_t6_encode_state_t; 00032 00033 #if defined(__cplusplus) 00034 extern "C" { 00035 #endif 00036 00037 /*! \brief Return the next bit of the current document page, without actually 00038 moving forward in the buffer. The document will be padded for the 00039 current minimum scan line time. 00040 \param s The T.4/T.6 context. 00041 \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */ 00042 SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s); 00043 00044 /*! \brief Get the next bit of the current image. The image will 00045 be padded for the current minimum scan line time. 00046 \param s The T.4/T.6 context. 00047 \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */ 00048 SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s); 00049 00050 /*! \brief Get the next chunk of the current document page. The document will 00051 be padded for the current minimum scan line time. 00052 \param s The T.4/T.6 context. 00053 \param buf The buffer into which the chunk is to written. 00054 \param max_len The maximum length of the chunk. 00055 \return The actual length of the chunk. If this is less than max_len it 00056 indicates that the end of the document has been reached. */ 00057 SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len); 00058 00059 /*! \brief Set the row read handler for a T.4/T.6 encode context. 00060 \param s The T.4/T.6 context. 00061 \param handler A pointer to the handler routine. 00062 \param user_data An opaque pointer passed to the handler routine. 00063 \return 0 for success, otherwise -1. */ 00064 SPAN_DECLARE(int) t4_t6_encode_set_row_read_handler(t4_t6_encode_state_t *s, 00065 t4_row_read_handler_t handler, 00066 void *user_data); 00067 00068 /*! \brief Set the encoding for the encoded data. 00069 \param s The T.4/T.6 context. 00070 \param encoding The encoding. 00071 \return 0 for success, otherwise -1. */ 00072 SPAN_DECLARE(int) t4_t6_encode_set_encoding(t4_t6_encode_state_t *s, int encoding); 00073 00074 /*! \brief Set the width of the image. 00075 \param s The T.4/T.6 context. 00076 \param image_width The image width, in pixels. 00077 \return 0 for success, otherwise -1. */ 00078 SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int image_width); 00079 00080 /*! \brief Get the width of the image. 00081 \param s The T.4/T.6 context. 00082 \return The width of the image, in pixels. */ 00083 SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_width(t4_t6_encode_state_t *s); 00084 00085 /*! \brief Get the length of the image. 00086 \param s The T.4/T.6 context. 00087 \return The length of the image, in pixels. */ 00088 SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_length(t4_t6_encode_state_t *s); 00089 00090 /*! \brief Get the size of the compressed image, in bits. 00091 \param s The T.4/T.6 context. 00092 \return The size of the compressed image, in bits. */ 00093 SPAN_DECLARE(int) t4_t6_encode_get_compressed_image_size(t4_t6_encode_state_t *s); 00094 00095 /*! \brief Set the minimum number of encoded bits per row. This allows the 00096 makes the encoding process to be set to comply with the minimum row 00097 time specified by a remote receiving machine. 00098 \param s The T.4/T.6 context. 00099 \param bits The minimum number of bits per row. */ 00100 SPAN_DECLARE(void) t4_t6_encode_set_min_bits_per_row(t4_t6_encode_state_t *s, int bits); 00101 00102 /*! \brief Set the maximum number of 2D encoded rows between 1D encoded rows. This 00103 is only valid for T.4 2D encoding. 00104 \param s The T.4/T.6 context. 00105 \param max The "K" parameter defined in the T.4 specification. This means the value is one 00106 greater than the maximum number of 2D rows between each 1D row. */ 00107 SPAN_DECLARE(void) t4_t6_encode_set_max_2d_rows_per_1d_row(t4_t6_encode_state_t *s, int max); 00108 00109 /*! \brief Restart a T.4 or T.6 encode context. 00110 \param s The T.4/T.6 context. 00111 \param image width The image width, in pixels. 00112 \return 0 for success, otherwise -1. */ 00113 SPAN_DECLARE(int) t4_t6_encode_restart(t4_t6_encode_state_t *s, int image_width); 00114 00115 /*! \brief Prepare to encode an image in T.4 or T.6 format. 00116 \param s The T.4/T.6 context. 00117 \param encoding The encoding mode. 00118 \param image width The image width, in pixels. 00119 \param handler A callback routine to handle decoded image rows. 00120 \param user_data An opaque pointer passed to handler. 00121 \return A pointer to the context, or NULL if there was a problem. */ 00122 SPAN_DECLARE(t4_t6_encode_state_t *) t4_t6_encode_init(t4_t6_encode_state_t *s, 00123 int encoding, 00124 int image_width, 00125 t4_row_read_handler_t handler, 00126 void *user_data); 00127 00128 SPAN_DECLARE(int) t4_t6_encode_release(t4_t6_encode_state_t *s); 00129 00130 SPAN_DECLARE(int) t4_t6_encode_free(t4_t6_encode_state_t *s); 00131 00132 #if defined(__cplusplus) 00133 } 00134 #endif 00135 00136 #endif 00137 /*- End of file ------------------------------------------------------------*/
1.6.1