spandsp 3.0.0
private/t42.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * private/t42.h - ITU T.42 JPEG for FAX image processing
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2011 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_T42_H_)
27#define _SPANDSP_PRIVATE_T42_H_
28
29#include <setjmp.h>
30#include <jpeglib.h>
31
33{
34 /* Lab gamut */
35 float range_L;
36 float range_a;
37 float range_b;
38 float offset_L;
39 float offset_a;
40 float offset_b;
41 int ab_are_signed;
42
43 /* Illuminant, forward and reverse */
44 float x_n;
45 float y_n;
46 float z_n;
47 float x_rn;
48 float y_rn;
49 float z_rn;
50};
51
52/* State of a working instance of the T.42 JPEG FAX encoder */
54{
55 /*! \brief Callback function to read a row of pixels from the image source. */
57 /*! \brief Opaque pointer passed to row_read_handler. */
59 uint32_t image_width;
60 uint32_t image_length;
61 uint16_t samples_per_pixel;
62 int image_type;
63 int no_subsampling;
64 int itu_ycc;
65 int quality;
66
67 /* The X or Y direction resolution, in pixels per inch */
68 int spatial_resolution;
69
70 lab_params_t lab;
71
72 uint8_t illuminant_code[4];
73 int illuminant_colour_temperature;
74
75 /*! \brief The size of the compressed image, in bytes. */
77 int compressed_image_ptr;
78
79 int buf_size;
80 uint8_t *compressed_buf;
81
82 FILE *out;
83#if defined(HAVE_OPEN_MEMSTREAM)
84 size_t outsize;
85#endif
86 jmp_buf escape;
87 char error_message[JMSG_LENGTH_MAX];
88 struct jpeg_compress_struct compressor;
89
90 JSAMPROW scan_line_out;
91 JSAMPROW scan_line_in;
92
93 /*! \brief Error and flow logging control */
95};
96
97/* State of a working instance of the T.42 JPEG FAX decoder */
99{
100 /*! A callback routine to handle decoded pixel rows */
102 /*! An opaque pointer passed to row_write_handler() */
104 /*! A callback routine to handle decoded comments */
106 /*! An opaque pointer passed to comment_handler() */
108 /*! The maximum length of comment to be passed to the comment handler */
110 uint32_t image_width;
111 uint32_t image_length;
112 uint16_t samples_per_pixel;
113 int image_type;
114 int itu_ycc;
115
116 /* The X or Y direction resolution, in pixels per inch */
117 int spatial_resolution;
118
119 lab_params_t lab;
120
121 uint8_t illuminant_code[4];
122 int illuminant_colour_temperature;
123
124 /*! The contents for a COMMENT marker segment, to be added to the
125 image at the next opportunity. This is set to NULL when nothing is
126 pending. */
127 uint8_t *comment;
128 /*! Length of data pointed to by comment */
130
131 /*! \brief The size of the compressed image, in bytes. */
133
134 int buf_size;
135 uint8_t *compressed_buf;
136
137 FILE *in;
138 jmp_buf escape;
139 char error_message[JMSG_LENGTH_MAX];
140 struct jpeg_decompress_struct decompressor;
141
142 /*! Flag that the data to be decoded has run out. */
144
145 JSAMPROW scan_line_out;
146 JSAMPROW scan_line_in;
147
148 /*! \brief Error and flow logging control */
150};
151
152#endif
153/*- End of file ------------------------------------------------------------*/
struct logging_state_s logging_state_t
Definition logging.h:72
Definition private/t42.h:33
Definition private/t42.h:99
t4_row_write_handler_t comment_handler
Definition private/t42.h:105
t4_row_write_handler_t row_write_handler
Definition private/t42.h:101
uint8_t * comment
Definition private/t42.h:127
uint32_t max_comment_len
Definition private/t42.h:109
void * comment_user_data
Definition private/t42.h:107
int compressed_image_size
The size of the compressed image, in bytes.
Definition private/t42.h:132
void * row_write_user_data
Definition private/t42.h:103
size_t comment_len
Definition private/t42.h:129
int end_of_data
Definition private/t42.h:143
logging_state_t logging
Error and flow logging control.
Definition private/t42.h:149
Definition private/t42.h:54
int compressed_image_size
The size of the compressed image, in bytes.
Definition private/t42.h:76
logging_state_t logging
Error and flow logging control.
Definition private/t42.h:94
void * row_read_user_data
Opaque pointer passed to row_read_handler.
Definition private/t42.h:58
t4_row_read_handler_t row_read_handler
Callback function to read a row of pixels from the image source.
Definition private/t42.h:56
int(* t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size_t len)
Definition t4_rx.h:46
int(* t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len)
Definition t4_tx.h:34