spandsp 3.0.0
t4_t6_decode.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * t4_t6_decode.h - definitions for T.4/T.6 fax decoding
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2003, 2009 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/*! \file */
27
28#if !defined(_SPANDSP_T4_T6_DECODE_H_)
29#define _SPANDSP_T4_T6_DECODE_H_
30
31/*! \page t4_t6_decode_page T.4 and T.6 FAX image decompression
32
33\section t4_t6_decode_page_sec_1 What does it do?
34The T.4 image compression and decompression routines implement the 1D and 2D
35encoding methods defined in ITU specification T.4. They also implement the pure
362D encoding method defined in T.6. These are image compression algorithms used
37for FAX transmission.
38
39\section t4_t6_decode_page_sec_1 How does it work?
40*/
41
42typedef struct t4_t6_decode_state_s t4_t6_decode_state_t;
43
44#if defined(__cplusplus)
45extern "C" {
46#endif
47
48/*! \brief Put a bit of the current document page.
49 \param s The T.4/T.6 context.
50 \param bit The data bit.
51 \return Decode status. */
52SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit);
53
54/*! \brief Put a byte of the current document page.
55 \param s The T.4/T.6 context.
56 \param buf The buffer containing the chunk.
57 \param len The length of the chunk.
58 \return T4_DECODE_MORE_DATA when the image is still in progress. T4_DECODE_OK when the image is complete. */
59SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len);
60
61/*! \brief Set the row write handler for a T.4/T.6 decode context.
62 \param s The T.4/T.6 context.
63 \param handler A pointer to the handler routine.
64 \param user_data An opaque pointer passed to the handler routine.
65 \return 0 for success, otherwise -1. */
66SPAN_DECLARE(int) t4_t6_decode_set_row_write_handler(t4_t6_decode_state_t *s, t4_row_write_handler_t handler, void *user_data);
67
68/*! \brief Set the encoding for the encoded data.
69 \param s The T.4/T.6 context.
70 \param encoding The encoding.
71 \return 0 for success, otherwise -1. */
72SPAN_DECLARE(int) t4_t6_decode_set_encoding(t4_t6_decode_state_t *s, int encoding);
73
74/*! \brief Get the width of the image.
75 \param s The T.4/T.6 context.
76 \return The width of the image, in pixels. */
77SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_width(t4_t6_decode_state_t *s);
78
79/*! \brief Get the length of the image.
80 \param s The T.4/T.6 context.
81 \return The length of the image, in pixels. */
82SPAN_DECLARE(uint32_t) t4_t6_decode_get_image_length(t4_t6_decode_state_t *s);
83
84/*! \brief Get the size of the compressed image, in bits.
85 \param s The T.4/T.6 context.
86 \return The size of the compressed image, in bits. */
87SPAN_DECLARE(int) t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s);
88
89/*! Get the logging context associated with a T.4 or T.6 decode context.
90 \brief Get the logging context associated with a T.4 or T.6 decode context.
91 \param s The T.4/T.6 context.
92 \return A pointer to the logging context */
93SPAN_DECLARE(logging_state_t *) t4_t6_decode_get_logging_state(t4_t6_decode_state_t *s);
94
95SPAN_DECLARE(int) t4_t6_decode_restart(t4_t6_decode_state_t *s, int image_width);
96
97/*! \brief Prepare to decode an image in T.4 or T.6 format.
98 \param s The T.4/T.6 context.
99 \param encoding The encoding mode.
100 \param image width The image width, in pixels.
101 \param handler A callback routine to handle decoded image rows.
102 \param user_data An opaque pointer passed to handler.
103 \return A pointer to the context, or NULL if there was a problem. */
104SPAN_DECLARE(t4_t6_decode_state_t *) t4_t6_decode_init(t4_t6_decode_state_t *s,
105 int encoding,
106 int image_width,
108 void *user_data);
109
110SPAN_DECLARE(int) t4_t6_decode_release(t4_t6_decode_state_t *s);
111
112SPAN_DECLARE(int) t4_t6_decode_free(t4_t6_decode_state_t *s);
113
114#if defined(__cplusplus)
115}
116#endif
117
118#endif
119/*- End of file ------------------------------------------------------------*/
struct logging_state_s logging_state_t
Definition logging.h:72
Definition private/t4_t6_decode.h:33
int encoding
The type of compression used between the FAX machines.
Definition private/t4_t6_decode.h:40
int(* t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size_t len)
Definition t4_rx.h:46
int t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len)
Put a byte of the current document page.
Definition t4_t6_decode.c:752
int t4_t6_decode_set_row_write_handler(t4_t6_decode_state_t *s, t4_row_write_handler_t handler, void *user_data)
Set the row write handler for a T.4/T.6 decode context.
Definition t4_t6_decode.c:800
logging_state_t * t4_t6_decode_get_logging_state(t4_t6_decode_state_t *s)
Get the logging context associated with a T.4 or T.6 decode context.
Definition t4_t6_decode.c:843
int t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit)
Put a bit of the current document page.
Definition t4_t6_decode.c:736
int t4_t6_decode_set_encoding(t4_t6_decode_state_t *s, int encoding)
Set the encoding for the encoded data.
Definition t4_t6_decode.c:810
int t4_t6_decode_get_compressed_image_size(t4_t6_decode_state_t *s)
Get the size of the compressed image, in bits.
Definition t4_t6_decode.c:837
t4_t6_decode_state_t * t4_t6_decode_init(t4_t6_decode_state_t *s, int encoding, int image_width, t4_row_write_handler_t handler, void *user_data)
Prepare to decode an image in T.4 or T.6 format.
Definition t4_t6_decode.c:929
uint32_t t4_t6_decode_get_image_length(t4_t6_decode_state_t *s)
Get the length of the image.
Definition t4_t6_decode.c:831
uint32_t t4_t6_decode_get_image_width(t4_t6_decode_state_t *s)
Get the width of the image.
Definition t4_t6_decode.c:825