spandsp 3.0.0
private/t4_tx.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/t4_tx.h - definitions for T.4 FAX transmit processing
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2003 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_TX_H_)
27#define _SPANDSP_PRIVATE_T4_TX_H_
28
29typedef int (*t4_image_get_handler_t)(void *user_data, uint8_t buf[], size_t len);
30
31/*!
32 TIFF specific state information to go with T.4 compression or decompression handling.
33*/
34typedef struct
35{
36 /*! \brief The current file name. */
37 const char *file;
38 /*! \brief The libtiff context for the current TIFF file */
39 TIFF *tiff_file;
40
41 /*! \brief The compression type used in the TIFF file */
42 uint16_t compression;
43 /*! \brief Image type - bi-level, gray, colour, etc. */
45 /*! \brief The TIFF photometric setting for the current page. */
46 uint16_t photo_metric;
47 /*! \brief The TIFF fill order setting for the current page. */
48 uint16_t fill_order;
49
50 /*! \brief Width of the image in the file. */
51 uint32_t image_width;
52 /*! \brief Length of the image in the file. */
53 uint32_t image_length;
54 /*! \brief Column-to-column (X) resolution in pixels per metre of the image in the file. */
56 /*! \brief Row-to-row (Y) resolution in pixels per metre of the image in the file. */
58 /*! \brief Code for the combined X and Y resolution of the image in the file. */
60
61 /*! \brief The number of pages in the current image file. */
63
64 /*! \brief A pointer to the image buffer. */
65 uint8_t *image_buffer;
66 /*! \brief The size of the image in the image buffer, in bytes. */
68 /*! \brief The current size of the image buffer. */
70 /*! \brief Row counter for playing out the rows of the image. */
71 int row;
72 /*! \brief Row counter used when the image is resized or dithered flat. */
75
76/*!
77 T.4 FAX compression metadata descriptor. This contains information about the image
78 which may be relevant to the backend, but is not generally relevant to the image
79 encoding process. The exception here is the y-resolution, which is used in T.4 2-D
80 encoding for non-ECM applications, to optimise the balance of density and robustness.
81*/
82typedef struct
83{
84 /*! \brief The type of compression used on the wire. */
86 /*! \brief Image type - bi-level, gray, colour, etc. */
88 /*! \brief The width code for the image on the line side. */
90
91 /*! \brief The width of the current page on the wire, in pixels. */
92 uint32_t image_width;
93 /*! \brief The length of the current page on the wire, in pixels. */
94 uint32_t image_length;
95 /*! \brief Column-to-column (X) resolution in pixels per metre on the wire. */
97 /*! \brief Row-to-row (Y) resolution in pixels per metre on the wire. */
99 /*! \brief Code for the combined X and Y resolution on the wire. */
102
103typedef struct
104{
105 uint8_t *buf;
106 int buf_len;
107 int buf_ptr;
108 int bit;
110
111/*!
112 T.4 FAX compression descriptor. This defines the working state
113 for a single instance of a T.4 FAX compression channel.
114*/
116{
117 /*! \brief Callback function to read a row of pixels from the image source. */
119 /*! \brief Opaque pointer passed to row_read_handler. */
121
122 /*! \brief When superfine and fine resolution images need to be squahed vertically
123 to a lower resolution, this value sets the number of source rows which
124 must be squashed to form each row on the wire. */
126
127 /*! \brief The size of the compressed image on the line side, in bits. */
129
130 /*! \brief The first page to transfer. -1 to start at the beginning of the file. */
132 /*! \brief The last page to transfer. -1 to continue to the end of the file. */
134
135 /*! \brief True for FAX page headers to overlay (i.e. replace) the beginning of the
136 page image. False for FAX page headers to add to the overall length of
137 the page. */
139 /*! \brief The text which will be used in FAX page header. No text results
140 in no header line. */
141 const char *header_info;
142 /*! \brief The local ident string. This is used with header_info to form a
143 page header line. */
144 const char *local_ident;
145 /*! \brief The page number of current page. The first page is zero. If FAX page
146 headers are used, the page number in the header will be one more than
147 this value (i.e. they start from 1). */
149
150 /*! \brief The composed text of the FAX page header, if there is one. */
152 /*! \brief Optional per instance time zone for the FAX page header timestamp. */
154
155 /*! \brief Row counter for playing out the rows of the header line. */
157
158 union
159 {
160 no_encoder_state_t no_encoder;
163#if defined(SPANDSP_SUPPORT_T88)
164 t88_encode_state_t t88;
165#endif
168#if defined(SPANDSP_SUPPORT_T45)
169 t45_encode_state_t t45;
170#endif
171 } encoder;
172
173 t4_image_get_handler_t image_get_handler;
174
175 int apply_lab;
176 lab_params_t lab_params;
177 uint8_t *colour_map;
178 int colour_map_entries;
179
180 image_translate_state_t translator;
181 uint8_t *pack_buf;
182 int pack_ptr;
183 int pack_row;
184 int pack_bit_mask;
185
186 no_encoder_state_t no_encoder;
187
188 /*! \brief Supporting information, like resolutions, which the backend may want. */
190
191 /*! \brief All TIFF file specific state information for the T.4 context. */
193
194 /*! \brief Error and flow logging control */
196};
197
198#endif
199/*- End of file ------------------------------------------------------------*/
Definition private/image_translate.h:32
Definition private/t42.h:33
Definition private/logging.h:34
Definition private/t4_tx.h:104
Definition private/t42.h:54
Definition private/t43.h:31
Definition private/t4_t6_encode.h:33
Definition private/t4_tx.h:83
int y_resolution
Row-to-row (Y) resolution in pixels per metre on the wire.
Definition private/t4_tx.h:98
int resolution_code
Code for the combined X and Y resolution on the wire.
Definition private/t4_tx.h:100
uint32_t image_length
The length of the current page on the wire, in pixels.
Definition private/t4_tx.h:94
int image_type
Image type - bi-level, gray, colour, etc.
Definition private/t4_tx.h:87
int x_resolution
Column-to-column (X) resolution in pixels per metre on the wire.
Definition private/t4_tx.h:96
uint32_t image_width
The width of the current page on the wire, in pixels.
Definition private/t4_tx.h:92
int compression
The type of compression used on the wire.
Definition private/t4_tx.h:85
int width_code
The width code for the image on the line side.
Definition private/t4_tx.h:89
Definition private/t4_tx.h:116
void * row_handler_user_data
Opaque pointer passed to row_read_handler.
Definition private/t4_tx.h:120
logging_state_t logging
Error and flow logging control.
Definition private/t4_tx.h:195
const char * local_ident
The local ident string. This is used with header_info to form a page header line.
Definition private/t4_tx.h:144
tz_t * tz
Optional per instance time zone for the FAX page header timestamp.
Definition private/t4_tx.h:153
int header_row
Row counter for playing out the rows of the header line.
Definition private/t4_tx.h:156
t4_tx_metadata_t metadata
Supporting information, like resolutions, which the backend may want.
Definition private/t4_tx.h:189
t4_tx_tiff_state_t tiff
All TIFF file specific state information for the T.4 context.
Definition private/t4_tx.h:192
t4_row_read_handler_t row_handler
Callback function to read a row of pixels from the image source.
Definition private/t4_tx.h:118
int row_squashing_ratio
When superfine and fine resolution images need to be squahed vertically to a lower resolution,...
Definition private/t4_tx.h:125
int stop_page
The last page to transfer. -1 to continue to the end of the file.
Definition private/t4_tx.h:133
int line_image_size
The size of the compressed image on the line side, in bits.
Definition private/t4_tx.h:128
int current_page
The page number of current page. The first page is zero. If FAX page headers are used,...
Definition private/t4_tx.h:148
char * header_text
The composed text of the FAX page header, if there is one.
Definition private/t4_tx.h:151
bool header_overlays_image
True for FAX page headers to overlay (i.e. replace) the beginning of the page image....
Definition private/t4_tx.h:138
int start_page
The first page to transfer. -1 to start at the beginning of the file.
Definition private/t4_tx.h:131
const char * header_info
The text which will be used in FAX page header. No text results in no header line.
Definition private/t4_tx.h:141
Definition private/t4_tx.h:35
int y_resolution
Row-to-row (Y) resolution in pixels per metre of the image in the file.
Definition private/t4_tx.h:57
int x_resolution
Column-to-column (X) resolution in pixels per metre of the image in the file.
Definition private/t4_tx.h:55
TIFF * tiff_file
The libtiff context for the current TIFF file.
Definition private/t4_tx.h:39
uint8_t * image_buffer
A pointer to the image buffer.
Definition private/t4_tx.h:65
int image_type
Image type - bi-level, gray, colour, etc.
Definition private/t4_tx.h:44
uint32_t image_width
Width of the image in the file.
Definition private/t4_tx.h:51
int image_buffer_size
The current size of the image buffer.
Definition private/t4_tx.h:69
uint16_t compression
The compression type used in the TIFF file.
Definition private/t4_tx.h:42
const char * file
The current file name.
Definition private/t4_tx.h:37
int raw_row
Row counter used when the image is resized or dithered flat.
Definition private/t4_tx.h:73
uint16_t photo_metric
The TIFF photometric setting for the current page.
Definition private/t4_tx.h:46
int resolution_code
Code for the combined X and Y resolution of the image in the file.
Definition private/t4_tx.h:59
int image_size
The size of the image in the image buffer, in bytes.
Definition private/t4_tx.h:67
uint16_t fill_order
The TIFF fill order setting for the current page.
Definition private/t4_tx.h:48
int pages_in_file
The number of pages in the current image file.
Definition private/t4_tx.h:62
int row
Row counter for playing out the rows of the image.
Definition private/t4_tx.h:71
uint32_t image_length
Length of the image in the file.
Definition private/t4_tx.h:53
Definition private/t85.h:52
Definition private/timezone.h:82
int(* t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len)
Definition t4_tx.h:34