spandsp 3.0.0
private/t4_t6_decode.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/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#if !defined(_SPANDSP_PRIVATE_T4_T6_DECODE_H_)
27#define _SPANDSP_PRIVATE_T4_T6_DECODE_H_
28
29/*!
30 T.4 1D, T4 2D and T6 decompressor state.
31*/
33{
34 /*! \brief Callback function to write a row of pixels to the image destination. */
36 /*! \brief Opaque pointer passed to row_write_handler. */
38
39 /*! \brief The type of compression used between the FAX machines. */
41 /*! \brief Width of the current page, in pixels. */
43
44 /*! \brief Length of the current page, in pixels. */
46 /*! \brief The current number of bytes per row of uncompressed image data. */
48
49 /*! \brief The current number of bits in the current encoded row. */
51 /*! \brief Pointer to the buffer for the current pixel row. */
52 uint8_t *row_buf;
53
54 /*! \brief This variable is set if we are treating the current row as a 2D encoded
55 one. */
57 /*! \brief The current length of the current row. */
59
60 /*! \brief Black and white run-lengths for the current row. */
61 uint32_t *cur_runs;
62 /*! \brief Black and white run-lengths for the reference row. */
63 uint32_t *ref_runs;
64
65 /*! \brief This variable is used to count the consecutive EOLS we have seen. If it
66 reaches six, this is the end of the image. It is initially set to -1 for
67 1D and 2D decoding, as an indicator that we must wait for the first EOL,
68 before decoding any image data. */
70
71 /*! \brief The reference or starting changing element on the coding line. At the
72 start of the coding line, a0 is set on an imaginary white changing element
73 situated just before the first element on the line. During the coding of
74 the coding line, the position of a0 is defined by the previous coding mode.
75 (See T.4/4.2.1.3.2.). */
76 int a0;
77 /*! \brief The first changing element on the reference line to the right of a0 and of
78 opposite colour to a0. */
79 int b1;
80 /*! \brief The length of the in-progress run of black or white. */
82 /*! \brief 2D horizontal mode control. */
84 /*! \brief True if the current run is black */
86
87 /*! \brief The current step into the current row run-lengths buffer. */
89 /*! \brief The current step into the reference row run-lengths buffer. */
91
92 /*! \brief Incoming bit buffer for decompression. */
93 uint32_t rx_bitstream;
94 /*! \brief The number of bits currently in rx_bitstream. */
96 /*! \brief The number of bits to be skipped before trying to match the next code word. */
98
99 /*! \brief Decoded pixel stream buffer. */
100 uint32_t pixel_stream;
101 /*! \brief The number of pixels currently in pixel_stream. */
103
104 /*! \brief The minimum bits in any row of the current page. For monitoring only. */
106 /*! \brief The maximum bits in any row of the current page. For monitoring only. */
108
109 /*! \brief The size of the compressed image, in bits. */
111 /*! \brief The current number of consecutive bad rows. */
113 /*! \brief The longest run of consecutive bad rows seen in the current page. */
115 /*! \brief The total number of bad rows in the current page. */
117
118 /*! \brief Error and flow logging control */
120};
121
122#endif
123/*- 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
uint32_t * cur_runs
Black and white run-lengths for the current row.
Definition private/t4_t6_decode.h:61
int longest_bad_row_run
The longest run of consecutive bad rows seen in the current page.
Definition private/t4_t6_decode.h:114
int a0
The reference or starting changing element on the coding line. At the start of the coding line,...
Definition private/t4_t6_decode.h:76
int bytes_per_row
The current number of bytes per row of uncompressed image data.
Definition private/t4_t6_decode.h:47
int min_row_bits
The minimum bits in any row of the current page. For monitoring only.
Definition private/t4_t6_decode.h:105
int b1
The first changing element on the reference line to the right of a0 and of opposite colour to a0.
Definition private/t4_t6_decode.h:79
int row_len
The current length of the current row.
Definition private/t4_t6_decode.h:58
int bad_rows
The total number of bad rows in the current page.
Definition private/t4_t6_decode.h:116
int black_white
2D horizontal mode control.
Definition private/t4_t6_decode.h:83
uint32_t * ref_runs
Black and white run-lengths for the reference row.
Definition private/t4_t6_decode.h:63
int image_width
Width of the current page, in pixels.
Definition private/t4_t6_decode.h:42
uint8_t * row_buf
Pointer to the buffer for the current pixel row.
Definition private/t4_t6_decode.h:52
t4_row_write_handler_t row_write_handler
Callback function to write a row of pixels to the image destination.
Definition private/t4_t6_decode.h:35
int row_is_2d
This variable is set if we are treating the current row as a 2D encoded one.
Definition private/t4_t6_decode.h:56
int compressed_image_size
The size of the compressed image, in bits.
Definition private/t4_t6_decode.h:110
uint32_t pixel_stream
Decoded pixel stream buffer.
Definition private/t4_t6_decode.h:100
logging_state_t logging
Error and flow logging control.
Definition private/t4_t6_decode.h:119
int image_length
Length of the current page, in pixels.
Definition private/t4_t6_decode.h:45
bool in_black
True if the current run is black.
Definition private/t4_t6_decode.h:85
int max_row_bits
The maximum bits in any row of the current page. For monitoring only.
Definition private/t4_t6_decode.h:107
int pixels
The number of pixels currently in pixel_stream.
Definition private/t4_t6_decode.h:102
void * row_write_user_data
Opaque pointer passed to row_write_handler.
Definition private/t4_t6_decode.h:37
uint32_t rx_bitstream
Incoming bit buffer for decompression.
Definition private/t4_t6_decode.h:93
int b_cursor
The current step into the reference row run-lengths buffer.
Definition private/t4_t6_decode.h:90
int rx_skip_bits
The number of bits to be skipped before trying to match the next code word.
Definition private/t4_t6_decode.h:97
int row_bits
The current number of bits in the current encoded row.
Definition private/t4_t6_decode.h:50
int curr_bad_row_run
The current number of consecutive bad rows.
Definition private/t4_t6_decode.h:112
int a_cursor
The current step into the current row run-lengths buffer.
Definition private/t4_t6_decode.h:88
int rx_bits
The number of bits currently in rx_bitstream.
Definition private/t4_t6_decode.h:95
int run_length
The length of the in-progress run of black or white.
Definition private/t4_t6_decode.h:81
int consecutive_eols
This variable is used to count the consecutive EOLS we have seen. If it reaches six,...
Definition private/t4_t6_decode.h:69
int(* t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size_t len)
Definition t4_rx.h:46