00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * 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 /*! \file */ 00027 00028 #if !defined(_SPANDSP_T4_T6_DECODE_H_) 00029 #define _SPANDSP_T4_T6_DECODE_H_ 00030 00031 /*! \page t4_t6_decode_page T.4 and T.6 FAX image decompression 00032 00033 \section t4_t6_decode_page_sec_1 What does it do? 00034 The T.4 image compression and decompression routines implement the 1D and 2D 00035 encoding methods defined in ITU specification T.4. They also implement the pure 00036 2D encoding method defined in T.6. These are image compression algorithms used 00037 for FAX transmission. 00038 00039 \section t4_t6_decode_page_sec_1 How does it work? 00040 */ 00041 00042 typedef struct t4_t6_decode_state_s t4_t6_decode_state_t; 00043 00044 #if defined(__cplusplus) 00045 extern "C" { 00046 #endif 00047 00048 /*! \brief Put a bit of the current document page. 00049 \param s The T.4/T.6 context. 00050 \param bit The data bit. 00051 \return TRUE when the bit ends the document page, otherwise FALSE. */ 00052 SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit); 00053 00054 /*! \brief Put a byte of the current document page. 00055 \param s The T.4/T.6 context. 00056 \param buf The buffer containing the chunk. 00057 \param len The length of the chunk. 00058 \return T4_DECODE_MORE_DATA when the image is still in progress. T4_DECODE_OK when the image is complete. */ 00059 SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len); 00060 00061 /*! \brief Set the row write handler for a T.4/T.6 decode context. 00062 \param s The T.4/T.6 context. 00063 \param handler A pointer to the handler routine. 00064 \param user_data An opaque pointer passed to the handler routine. 00065 \return 0 for success, otherwise -1. */ 00066 SPAN_DECLARE(int) t4_t6_decode_set_row_write_handler(t4_t6_decode_state_t *s, t4_row_write_handler_t handler, 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_decode_set_encoding(t4_t6_decode_state_t *s, int encoding); 00073 00074 /*! \brief Get the width of the image. 00075 \param s The T.4/T.6 context. 00076 \return The width of the image, in pixels. */ 00077 SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_width(t4_t6_decode_state_t *s); 00078 00079 /*! \brief Get the length of the image. 00080 \param s The T.4/T.6 context. 00081 \return The length of the image, in pixels. */ 00082 SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_length(t4_t6_decode_state_t *s); 00083 00084 /*! \brief Get the size of the compressed image, in bits. 00085 \param s The T.4/T.6 context. 00086 \return The size of the compressed image, in bits. */ 00087 SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s); 00088 00089 SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width); 00090 00091 /*! \brief Prepare to decode an image in T.4 or T.6 format. 00092 \param s The T.4/T.6 context. 00093 \param encoding The encoding mode. 00094 \param image width The image width, in pixels. 00095 \param handler A callback routine to handle decoded image rows. 00096 \param user_data An opaque pointer passed to handler. 00097 \return A pointer to the context, or NULL if there was a problem. */ 00098 SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s, 00099 int encoding, 00100 int image_width, 00101 t4_row_write_handler_t handler, 00102 void *user_data); 00103 00104 SPAN_DECLARE(int) t4_t6_decode_release(t4_t6_decode_state_t *s); 00105 00106 SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s); 00107 00108 #if defined(__cplusplus) 00109 } 00110 #endif 00111 00112 #endif 00113 /*- End of file ------------------------------------------------------------*/
1.6.1