Moves towards colour FAX
This commit is contained in:
parent
26d5a6eb33
commit
0b6c53217a
|
@ -48,7 +48,6 @@
|
|||
#include <math.h>
|
||||
#endif
|
||||
#include "floating_fudge.h"
|
||||
#include <jpeglib.h>
|
||||
#include <tiffio.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#if !defined(_SPANDSP_EXPOSE_H_)
|
||||
#define _SPANDSP_EXPOSE_H_
|
||||
|
||||
#include <jpeglib.h>
|
||||
|
||||
#include <spandsp/private/logging.h>
|
||||
#include <spandsp/private/schedule.h>
|
||||
#include <spandsp/private/bitstream.h>
|
||||
|
|
|
@ -231,7 +231,11 @@ struct t30_state_s
|
|||
/*! \brief The common group of supported image sizes. */
|
||||
int mutual_image_sizes;
|
||||
/*! \brief The image coding being used on the line. */
|
||||
int line_encoding;
|
||||
int line_compression;
|
||||
/*! \brief The image type being used on the line. */
|
||||
int line_image_type;
|
||||
/*! \brief The width code for the image on the line. */
|
||||
int line_width_code;
|
||||
/*! \brief The current DCS message minimum scan time code. */
|
||||
uint8_t min_scan_time_code;
|
||||
/*! \brief The X direction resolution of the current image, in pixels per metre. */
|
||||
|
|
|
@ -70,6 +70,14 @@
|
|||
#define T30_DCS_BIT_RECEIVE_FAX_DOCUMENT 10
|
||||
|
||||
/* Bits 11, 12, 13, 14 - modem type */
|
||||
#define T30_DIS_BIT_MODEM_TYPE_1 11
|
||||
#define T30_DCS_BIT_MODEM_TYPE_1 11
|
||||
#define T30_DIS_BIT_MODEM_TYPE_2 12
|
||||
#define T30_DCS_BIT_MODEM_TYPE_2 12
|
||||
#define T30_DIS_BIT_MODEM_TYPE_3 13
|
||||
#define T30_DCS_BIT_MODEM_TYPE_3 13
|
||||
#define T30_DIS_BIT_MODEM_TYPE_4 14
|
||||
#define T30_DCS_BIT_MODEM_TYPE_4 14
|
||||
|
||||
#define T30_DIS_BIT_200_200_CAPABLE 15
|
||||
#define T30_DCS_BIT_200_200 15
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#if !defined(_SPANDSP_PRIVATE_T42_H_)
|
||||
#define _SPANDSP_PRIVATE_T42_H_
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <jpeglib.h>
|
||||
|
||||
struct lab_params_s
|
||||
{
|
||||
/* Lab gamut */
|
||||
|
@ -50,11 +53,39 @@ struct t42_encode_state_s
|
|||
t4_row_read_handler_t row_read_handler;
|
||||
/*! \brief Opaque pointer passed to row_read_handler. */
|
||||
void *row_read_user_data;
|
||||
uint32_t image_width;
|
||||
uint32_t image_length;
|
||||
uint16_t samples_per_pixel;
|
||||
int image_type;
|
||||
int no_subsampling;
|
||||
int itu_ycc;
|
||||
int quality;
|
||||
|
||||
lab_params_t lab_params;
|
||||
/* The X or Y direction resolution, in pixels per inch */
|
||||
int spatial_resolution;
|
||||
|
||||
lab_params_t lab;
|
||||
|
||||
uint8_t illuminant_code[4];
|
||||
int illuminant_colour_temperature;
|
||||
|
||||
/*! \brief The size of the compressed image, in bytes. */
|
||||
int compressed_image_size;
|
||||
int compressed_image_ptr;
|
||||
|
||||
int buf_size;
|
||||
uint8_t *compressed_buf;
|
||||
|
||||
FILE *out;
|
||||
#if defined(HAVE_OPEN_MEMSTREAM)
|
||||
size_t outsize;
|
||||
#endif
|
||||
jmp_buf escape;
|
||||
char error_message[JMSG_LENGTH_MAX];
|
||||
struct jpeg_compress_struct compressor;
|
||||
|
||||
JSAMPROW scan_line_out;
|
||||
JSAMPROW scan_line_in;
|
||||
|
||||
/*! \brief Error and flow logging control */
|
||||
logging_state_t logging;
|
||||
|
@ -73,8 +104,19 @@ struct t42_decode_state_s
|
|||
void *comment_user_data;
|
||||
/*! The maximum length of comment to be passed to the comment handler */
|
||||
uint32_t max_comment_len;
|
||||
uint32_t image_width;
|
||||
uint32_t image_length;
|
||||
uint16_t samples_per_pixel;
|
||||
int image_type;
|
||||
int itu_ycc;
|
||||
|
||||
lab_params_t lab_params;
|
||||
/* The X or Y direction resolution, in pixels per inch */
|
||||
int spatial_resolution;
|
||||
|
||||
lab_params_t lab;
|
||||
|
||||
uint8_t illuminant_code[4];
|
||||
int illuminant_colour_temperature;
|
||||
|
||||
/*! The contents for a COMMENT marker segment, to be added to the
|
||||
image at the next opportunity. This is set to NULL when nothing is
|
||||
|
@ -89,6 +131,17 @@ struct t42_decode_state_s
|
|||
int buf_size;
|
||||
uint8_t *compressed_buf;
|
||||
|
||||
FILE *in;
|
||||
jmp_buf escape;
|
||||
char error_message[JMSG_LENGTH_MAX];
|
||||
struct jpeg_decompress_struct decompressor;
|
||||
|
||||
/*! Flag that the data to be decoded has run out. */
|
||||
int end_of_data;
|
||||
|
||||
JSAMPROW scan_line_out;
|
||||
JSAMPROW scan_line_in;
|
||||
|
||||
/*! \brief Error and flow logging control */
|
||||
logging_state_t logging;
|
||||
};
|
||||
|
|
|
@ -37,17 +37,21 @@ struct t43_encode_state_s
|
|||
struct lab_params_s lab;
|
||||
struct t85_encode_state_s t85;
|
||||
|
||||
int image_type;
|
||||
int bit_planes[4];
|
||||
|
||||
int colour_map_entries;
|
||||
uint8_t colour_map[3*256];
|
||||
|
||||
uint8_t illuminant_code[4];
|
||||
int illuminant_colour_temperature;
|
||||
|
||||
/*! The width of the full image, in pixels */
|
||||
uint32_t xd;
|
||||
/*! The height of the full image, in pixels */
|
||||
uint32_t yd;
|
||||
int x_resolution;
|
||||
int y_resolution;
|
||||
/* The X or Y direction resolution, in pixels per inch */
|
||||
int spatial_resolution;
|
||||
|
||||
/*! \brief Error and flow logging control */
|
||||
logging_state_t logging;
|
||||
|
@ -64,6 +68,7 @@ struct t43_decode_state_s
|
|||
struct lab_params_s lab;
|
||||
struct t85_decode_state_s t85;
|
||||
|
||||
int image_type;
|
||||
int bit_planes[4];
|
||||
uint8_t bit_plane_mask;
|
||||
int current_bit_plane;
|
||||
|
@ -72,8 +77,12 @@ struct t43_decode_state_s
|
|||
int colour_map_entries;
|
||||
uint8_t colour_map[3*256];
|
||||
|
||||
int x_resolution;
|
||||
int y_resolution;
|
||||
uint8_t illuminant_code[4];
|
||||
int illuminant_colour_temperature;
|
||||
|
||||
/* The X or Y direction resolution, in pixels per inch */
|
||||
int spatial_resolution;
|
||||
int samples_per_pixel;
|
||||
|
||||
uint8_t *buf;
|
||||
int ptr;
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct
|
|||
/*! Image type - bilevel, gray, colour */
|
||||
int image_type;
|
||||
/*! \brief The compression type for output to the TIFF file. */
|
||||
int output_encoding;
|
||||
int compression;
|
||||
/*! \brief The TIFF photometric setting for the current page. */
|
||||
uint16_t photo_metric;
|
||||
/*! \brief The TIFF fill order setting for the current page. */
|
||||
|
@ -65,6 +65,12 @@ typedef struct
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
/*! \brief The type of compression used on the wire. */
|
||||
int compression;
|
||||
/*! \brief The width of the current page, in pixels. */
|
||||
uint32_t image_width;
|
||||
/*! \brief The length of the current page, in pixels. */
|
||||
uint32_t image_length;
|
||||
/*! \brief Column-to-column (X) resolution in pixels per metre. */
|
||||
int x_resolution;
|
||||
/*! \brief Row-to-row (Y) resolution in pixels per metre. */
|
||||
|
@ -104,14 +110,6 @@ struct t4_rx_state_s
|
|||
/*! \brief The size of the compressed image on the line side, in bits. */
|
||||
int line_image_size;
|
||||
|
||||
/*! \brief The type of compression used between the FAX machines. */
|
||||
int line_encoding;
|
||||
|
||||
/*! \brief The width of the current page, in pixels. */
|
||||
uint32_t image_width;
|
||||
/*! \brief The length of the current page, in pixels. */
|
||||
uint32_t image_length;
|
||||
|
||||
union
|
||||
{
|
||||
t4_t6_decode_state_t t4_t6;
|
||||
|
|
|
@ -58,13 +58,15 @@ typedef struct
|
|||
int row;
|
||||
|
||||
/*! \brief Width of the image in the file. */
|
||||
int image_width;
|
||||
uint32_t image_width;
|
||||
/*! \brief Length of the image in the file. */
|
||||
int image_length;
|
||||
uint32_t image_length;
|
||||
/*! \brief Column-to-column (X) resolution in pixels per metre of the image in the file. */
|
||||
int image_x_resolution;
|
||||
/*! \brief Row-to-row (Y) resolution in pixels per metre of the image in the file. */
|
||||
int image_y_resolution;
|
||||
/*! \brief Code for the combined X and Y resolution of the image in the file. */
|
||||
int resolution_code;
|
||||
|
||||
/*! \brief Row counter used when the image is resized or dithered flat. */
|
||||
int raw_row;
|
||||
|
@ -78,14 +80,23 @@ typedef struct
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
/*! \brief The type of compression used on the wire. */
|
||||
int compression;
|
||||
/*! \brief Image type - bi-level, gray, colour, etc. */
|
||||
int image_type;
|
||||
/*! \brief The width code for the image on the line side. */
|
||||
int width_code;
|
||||
|
||||
/*! \brief The width of the current page on the wire, in pixels. */
|
||||
uint32_t image_width;
|
||||
/*! \brief The length of the current page on the wire, in pixels. */
|
||||
uint32_t image_length;
|
||||
/*! \brief Column-to-column (X) resolution in pixels per metre on the wire. */
|
||||
int x_resolution;
|
||||
/*! \brief Row-to-row (Y) resolution in pixels per metre on the wire. */
|
||||
int y_resolution;
|
||||
/*! \brief Code for the combined X and Y resolution of the image in the file. */
|
||||
/*! \brief Code for the combined X and Y resolution on the wire. */
|
||||
int resolution_code;
|
||||
/*! \brief Image type - bi-level, gray, colour, etc. */
|
||||
int image_type;
|
||||
} t4_tx_metadata_t;
|
||||
|
||||
/*!
|
||||
|
@ -99,19 +110,11 @@ struct t4_tx_state_s
|
|||
/*! \brief Opaque pointer passed to row_read_handler. */
|
||||
void *row_handler_user_data;
|
||||
|
||||
/*! \brief The type of compression used between the FAX machines. */
|
||||
int line_encoding;
|
||||
|
||||
/*! \brief When superfine and fine resolution images need to be squahed vertically
|
||||
to a lower resolution, this value sets the number of source rows which
|
||||
must be squashed to form each row on the wire. */
|
||||
int row_squashing_ratio;
|
||||
|
||||
/*! \brief The width of the current page, in pixels. */
|
||||
uint32_t image_width;
|
||||
/*! \brief The length of the current page, in pixels. */
|
||||
uint32_t image_length;
|
||||
|
||||
/*! \brief The size of the compressed image on the line side, in bits. */
|
||||
int line_image_size;
|
||||
|
||||
|
|
|
@ -525,7 +525,7 @@ static int rx_start_page(t30_state_t *s)
|
|||
t4_rx_set_vendor(&s->t4.rx, s->vendor);
|
||||
t4_rx_set_model(&s->t4.rx, s->model);
|
||||
|
||||
t4_rx_set_rx_encoding(&s->t4.rx, s->line_encoding);
|
||||
t4_rx_set_rx_encoding(&s->t4.rx, s->line_compression);
|
||||
t4_rx_set_x_resolution(&s->t4.rx, s->x_resolution);
|
||||
t4_rx_set_y_resolution(&s->t4.rx, s->y_resolution);
|
||||
|
||||
|
@ -1455,7 +1455,7 @@ static int build_dcs(t30_state_t *s)
|
|||
|
||||
/* Select the compression to use. */
|
||||
use_bilevel = TRUE;
|
||||
switch (s->line_encoding)
|
||||
switch (s->line_compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
/* There is nothing to set to select this encoding. */
|
||||
|
@ -2053,7 +2053,7 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
|
|||
s->x_resolution = -1;
|
||||
s->y_resolution = -1;
|
||||
s->current_page_resolution = 0;
|
||||
s->line_encoding = -1;
|
||||
s->line_compression = -1;
|
||||
x = -1;
|
||||
if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T81_MODE)
|
||||
||
|
||||
|
@ -2157,22 +2157,22 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
|
|||
if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T81_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T42_T81))
|
||||
s->line_encoding = T4_COMPRESSION_T42_T81;
|
||||
s->line_compression = T4_COMPRESSION_T42_T81;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T43_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T43))
|
||||
s->line_encoding = T4_COMPRESSION_T43;
|
||||
s->line_compression = T4_COMPRESSION_T43;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T45_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T45))
|
||||
s->line_encoding = T4_COMPRESSION_T45;
|
||||
s->line_compression = T4_COMPRESSION_T45;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_SYCC_T81_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_SYCC_T81))
|
||||
s->line_encoding = T4_COMPRESSION_SYCC_T81;
|
||||
s->line_compression = T4_COMPRESSION_SYCC_T81;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2333,41 +2333,41 @@ static int analyze_rx_dcs(t30_state_t *s, const uint8_t *msg, int len)
|
|||
test_ctrl_bit(dcs_frame, T30_DCS_BIT_T88_MODE_3))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T88))
|
||||
s->line_encoding = T4_COMPRESSION_T88;
|
||||
s->line_compression = T4_COMPRESSION_T88;
|
||||
}
|
||||
if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_L0_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85_L0))
|
||||
s->line_encoding = T4_COMPRESSION_T85_L0;
|
||||
s->line_compression = T4_COMPRESSION_T85_L0;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T85))
|
||||
s->line_encoding = T4_COMPRESSION_T85;
|
||||
s->line_compression = T4_COMPRESSION_T85;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T6))
|
||||
s->line_encoding = T4_COMPRESSION_T6;
|
||||
s->line_compression = T4_COMPRESSION_T6;
|
||||
}
|
||||
else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_MODE))
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T4_2D))
|
||||
s->line_encoding = T4_COMPRESSION_T4_2D;
|
||||
s->line_compression = T4_COMPRESSION_T4_2D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((s->supported_compressions & T4_SUPPORT_COMPRESSION_T4_1D))
|
||||
s->line_encoding = T4_COMPRESSION_T4_1D;
|
||||
s->line_compression = T4_COMPRESSION_T4_1D;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->line_encoding == -1)
|
||||
if (s->line_compression == -1)
|
||||
{
|
||||
t30_set_status(s, T30_ERR_INCOMPATIBLE);
|
||||
return -1;
|
||||
}
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Far end selected compression %s (%d)\n", t4_encoding_to_str(s->line_encoding), s->line_encoding);
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Far end selected compression %s (%d)\n", t4_encoding_to_str(s->line_compression), s->line_compression);
|
||||
|
||||
if (x < 0)
|
||||
{
|
||||
|
@ -2678,7 +2678,7 @@ static int start_sending_document(t30_state_t *s)
|
|||
}
|
||||
s->operation_in_progress = OPERATION_IN_PROGRESS_T4_TX;
|
||||
t4_tx_get_pages_in_file(&s->t4.tx);
|
||||
t4_tx_set_tx_encoding(&s->t4.tx, s->line_encoding);
|
||||
t4_tx_set_tx_encoding(&s->t4.tx, s->line_compression);
|
||||
t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident);
|
||||
t4_tx_set_header_info(&s->t4.tx, s->header_info);
|
||||
if (s->use_own_tz)
|
||||
|
@ -2778,17 +2778,17 @@ static int process_rx_dis_dtc(t30_state_t *s, const uint8_t *msg, int len)
|
|||
|
||||
/* Choose a compression scheme from amongst those mutually available */
|
||||
if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T85_L0))
|
||||
s->line_encoding = T4_COMPRESSION_T85_L0;
|
||||
s->line_compression = T4_COMPRESSION_T85_L0;
|
||||
else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T85))
|
||||
s->line_encoding = T4_COMPRESSION_T85;
|
||||
s->line_compression = T4_COMPRESSION_T85;
|
||||
else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T6))
|
||||
s->line_encoding = T4_COMPRESSION_T6;
|
||||
s->line_compression = T4_COMPRESSION_T6;
|
||||
else if ((s->mutual_compressions & T4_SUPPORT_COMPRESSION_T4_2D))
|
||||
s->line_encoding = T4_COMPRESSION_T4_2D;
|
||||
s->line_compression = T4_COMPRESSION_T4_2D;
|
||||
else
|
||||
s->line_encoding = T4_COMPRESSION_T4_1D;
|
||||
s->line_compression = T4_COMPRESSION_T4_1D;
|
||||
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Choose compression %s (%d)\n", t4_encoding_to_str(s->line_encoding), s->line_encoding);
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Choose compression %s (%d)\n", t4_encoding_to_str(s->line_compression), s->line_compression);
|
||||
|
||||
if (s->phase_b_handler)
|
||||
{
|
||||
|
|
|
@ -146,7 +146,7 @@ SPAN_DECLARE(int) t43_create_header(t43_decode_state_t *s, uint8_t data[], size_
|
|||
pos += 6;
|
||||
unpack_16(&data[pos], 1997);
|
||||
pos += 2;
|
||||
unpack_16(&data[pos], s->x_resolution);
|
||||
unpack_16(&data[pos], s->spatial_resolution);
|
||||
pos += 2;
|
||||
/* JBIG coding method (0) is the only possible value here */
|
||||
data[pos] = 0;
|
||||
|
@ -523,7 +523,7 @@ static int t43_analyse_header(t43_decode_state_t *s, const uint8_t data[], size_
|
|||
if (seg >= 6 + 10)
|
||||
{
|
||||
val[0] = pack_16(&data[pos + 6 + 0]);
|
||||
s->x_resolution = pack_16(&data[pos + 6 + 2]);
|
||||
s->spatial_resolution = pack_16(&data[pos + 6 + 2]);
|
||||
val[2] = data[pos + 6 + 4];
|
||||
val[3] = data[pos + 6 + 5];
|
||||
s->bit_planes[0] = data[pos + 6 + 6];
|
||||
|
@ -534,7 +534,7 @@ static int t43_analyse_header(t43_decode_state_t *s, const uint8_t data[], size_
|
|||
SPAN_LOG_FLOW,
|
||||
"Version %d, resolution %.2fdpi, coding method %d, type %s (%d), bit planes %d,%d,%d,%d\n",
|
||||
val[0],
|
||||
s->x_resolution/100.0f,
|
||||
s->spatial_resolution/100.0f,
|
||||
val[2],
|
||||
t43_image_type_to_str(val[3]),
|
||||
val[3],
|
||||
|
|
|
@ -202,7 +202,7 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
|
|||
bits_per_sample = 1;
|
||||
samples_per_pixel = 1;
|
||||
photometric = PHOTOMETRIC_MINISWHITE;
|
||||
switch (t->output_encoding)
|
||||
switch (t->compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
default:
|
||||
|
@ -328,7 +328,7 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
|
|||
TIFFSetField(t->tiff_file, TIFFTAG_DATETIME, buf);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_FAXRECVTIME, now - s->tiff.page_start_time);
|
||||
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->metadata.image_width);
|
||||
/* Set the total pages to 1. For any one page document we will get this
|
||||
right. For multi-page documents we will need to come back and fill in
|
||||
the right answer when we know it. */
|
||||
|
@ -336,8 +336,8 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
|
|||
/* TIFF page numbers start from zero, so the number of pages in the file
|
||||
is always one greater than the highest page number in the file. */
|
||||
s->tiff.pages_in_file = s->current_page + 1;
|
||||
s->image_length = 0;
|
||||
switch (s->line_encoding)
|
||||
s->metadata.image_length = 0;
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -357,22 +357,22 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
|
|||
}
|
||||
/* Fall through */
|
||||
case T4_COMPRESSION_T6:
|
||||
s->image_length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
|
||||
s->metadata.image_length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
|
||||
break;
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
s->image_length = t85_decode_get_image_length(&s->decoder.t85);
|
||||
s->metadata.image_length = t85_decode_get_image_length(&s->decoder.t85);
|
||||
break;
|
||||
#if defined(SPANDSP_SUPPORT_T88)
|
||||
case T4_COMPRESSION_T88:
|
||||
break;
|
||||
#endif
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
s->image_length = t42_decode_get_image_length(&s->decoder.t42);
|
||||
s->metadata.image_length = t42_decode_get_image_length(&s->decoder.t42);
|
||||
break;
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
case T4_COMPRESSION_T43:
|
||||
s->image_length = t43_decode_get_image_length(&s->decoder.t43);
|
||||
s->metadata.image_length = t43_decode_get_image_length(&s->decoder.t43);
|
||||
break;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T45)
|
||||
|
@ -380,8 +380,8 @@ static int set_tiff_directory_info(t4_rx_state_t *s)
|
|||
break;
|
||||
#endif
|
||||
}
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, s->image_length);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, s->image_length);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, s->metadata.image_length);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, s->metadata.image_length);
|
||||
#if defined(SPANDSP_SUPPORT_TIFF_FX)
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_PROFILETYPE, PROFILETYPE_G3_FAX);
|
||||
TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, FAXPROFILE_S);
|
||||
|
@ -429,9 +429,9 @@ static int write_tiff_t85_image(t4_rx_state_t *s)
|
|||
/* We need to perform this compression here, as libtiff does not understand it. */
|
||||
packer.buf = s->tiff.image_buffer;
|
||||
packer.ptr = 0;
|
||||
if (t85_encode_init(&t85, s->image_width, s->image_length, row_read_handler, &packer) == NULL)
|
||||
if (t85_encode_init(&t85, s->metadata.image_width, s->metadata.image_length, row_read_handler, &packer) == NULL)
|
||||
return -1;
|
||||
//if (t->output_encoding == T4_COMPRESSION_T85_L0)
|
||||
//if (t->compression == T4_COMPRESSION_T85_L0)
|
||||
// t85_encode_set_options(&t85, 256, -1, -1);
|
||||
buf = NULL;
|
||||
buf_len = 0;
|
||||
|
@ -477,7 +477,7 @@ static int write_tiff_t43_image(t4_rx_state_t *s)
|
|||
|
||||
packer.buf = s->tiff.image_buffer;
|
||||
packer.ptr = 0;
|
||||
if (t43_encode_init(&t43, s->image_width, s->image_length, row_read_handler, &packer) == NULL)
|
||||
if (t43_encode_init(&t43, s->metadata.image_width, s->metadata.image_length, row_read_handler, &packer) == NULL)
|
||||
return -1;
|
||||
buf = NULL;
|
||||
buf_len = 0;
|
||||
|
@ -525,7 +525,7 @@ static int write_tiff_image(t4_rx_state_t *s)
|
|||
if (!TIFFCheckpointDirectory(t->tiff_file))
|
||||
span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to checkpoint directory for page %d.\n", t->file, s->current_page);
|
||||
/* ...and write out the image... */
|
||||
switch (t->output_encoding)
|
||||
switch (t->compression)
|
||||
{
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
|
@ -656,7 +656,7 @@ SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit)
|
|||
SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len)
|
||||
{
|
||||
s->line_image_size += 8*len;
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -733,20 +733,20 @@ static void select_tiff_compression(t4_rx_state_t *s, int output_image_type)
|
|||
/* Only provide for one form of coding throughout the file, even though the
|
||||
coding on the wire could change between pages. */
|
||||
if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T85))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T85;
|
||||
s->tiff.compression = T4_COMPRESSION_T85;
|
||||
else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T6))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T6;
|
||||
s->tiff.compression = T4_COMPRESSION_T6;
|
||||
else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T4_2D))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T4_2D;
|
||||
s->tiff.compression = T4_COMPRESSION_T4_2D;
|
||||
else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T4_1D))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T4_1D;
|
||||
s->tiff.compression = T4_COMPRESSION_T4_1D;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T42_T81))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T42_T81;
|
||||
s->tiff.compression = T4_COMPRESSION_T42_T81;
|
||||
else if ((s->supported_tiff_compressions & T4_SUPPORT_COMPRESSION_T43))
|
||||
s->tiff.output_encoding = T4_COMPRESSION_T43;
|
||||
s->tiff.compression = T4_COMPRESSION_T43;
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
@ -758,22 +758,22 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
break;
|
||||
default:
|
||||
t4_t6_decode_init(&s->decoder.t4_t6, encoding, s->image_width, s->row_handler, s->row_handler_user_data);
|
||||
t4_t6_decode_init(&s->decoder.t4_t6, encoding, s->metadata.image_width, s->row_handler, s->row_handler_user_data);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL);
|
||||
return t4_t6_decode_set_encoding(&s->decoder.t4_t6, encoding);
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
|
@ -787,11 +787,11 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
break;
|
||||
}
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL);
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return 0;
|
||||
#if defined(SPANDSP_SUPPORT_T88)
|
||||
case T4_COMPRESSION_T88:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T88:
|
||||
break;
|
||||
|
@ -799,12 +799,12 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
break;
|
||||
}
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_BILEVEL);
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return 0;
|
||||
#endif
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
case T4_COMPRESSION_SYCC_T81:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
case T4_COMPRESSION_SYCC_T81:
|
||||
|
@ -817,12 +817,12 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
t42_decode_set_image_size_constraints(&s->decoder.t42, T4_WIDTH_1200_A3, 0);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_COLOUR_8BIT);
|
||||
return 0;
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
case T4_COMPRESSION_T43:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T43:
|
||||
break;
|
||||
|
@ -834,20 +834,20 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
t43_decode_set_image_size_constraints(&s->decoder.t43, T4_WIDTH_1200_A3, 0);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_COLOUR_8BIT);
|
||||
return 0;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T45)
|
||||
case T4_COMPRESSION_T45:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T45:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
select_tiff_compression(s, T4_IMAGE_TYPE_COLOUR_8BIT);
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -859,7 +859,7 @@ SPAN_DECLARE(int) t4_rx_set_rx_encoding(t4_rx_state_t *s, int encoding)
|
|||
|
||||
SPAN_DECLARE(void) t4_rx_set_image_width(t4_rx_state_t *s, int width)
|
||||
{
|
||||
s->image_width = width;
|
||||
s->metadata.image_width = width;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
@ -867,7 +867,7 @@ SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_rx_state_t *s, t4_row_write_han
|
|||
{
|
||||
s->row_handler = handler;
|
||||
s->row_handler_user_data = user_data;
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -905,8 +905,8 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t
|
|||
t->image_y_resolution = s->metadata.y_resolution;
|
||||
t->x_resolution = s->metadata.x_resolution;
|
||||
t->y_resolution = s->metadata.y_resolution;
|
||||
t->encoding = s->line_encoding;
|
||||
switch (s->line_encoding)
|
||||
t->encoding = s->metadata.compression;
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -965,14 +965,14 @@ SPAN_DECLARE(void) t4_rx_get_transfer_statistics(t4_rx_state_t *s, t4_stats_t *t
|
|||
|
||||
SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->line_encoding));
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->metadata.compression));
|
||||
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
t4_t6_decode_restart(&s->decoder.t4_t6, s->image_width);
|
||||
t4_t6_decode_restart(&s->decoder.t4_t6, s->metadata.image_width);
|
||||
break;
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
|
@ -1031,7 +1031,7 @@ SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
|
|||
int length;
|
||||
|
||||
length = 0;
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1139,7 +1139,7 @@ SPAN_DECLARE(int) t4_rx_release(t4_rx_state_t *s)
|
|||
{
|
||||
if (s->tiff.file)
|
||||
tiff_rx_release(s);
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
@ -347,11 +347,11 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
|
|||
parm32 = 0;
|
||||
TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32);
|
||||
t->image_width =
|
||||
s->image_width = parm32;
|
||||
s->metadata.image_width = parm32;
|
||||
parm32 = 0;
|
||||
TIFFGetField(t->tiff_file, TIFFTAG_IMAGELENGTH, &parm32);
|
||||
t->image_length =
|
||||
s->image_length = parm32;
|
||||
s->metadata.image_length = parm32;
|
||||
x_resolution = 0.0f;
|
||||
TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution);
|
||||
y_resolution = 0.0f;
|
||||
|
@ -387,8 +387,8 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
|
|||
|
||||
s->metadata.resolution_code = resolution_map[best_y_entry][best_x_entry];
|
||||
|
||||
t4_tx_set_image_width(s, s->image_width);
|
||||
t4_tx_set_image_length(s, s->image_length);
|
||||
t4_tx_set_image_width(s, s->metadata.image_width);
|
||||
t4_tx_set_image_length(s, s->metadata.image_length);
|
||||
t4_tx_set_max_2d_rows_per_1d_row(s, -s->metadata.y_resolution);
|
||||
#if defined(SPANDSP_SUPPORT_TIFF_FX)
|
||||
if (TIFFGetField(t->tiff_file, TIFFTAG_PROFILETYPE, &parm32))
|
||||
|
@ -484,7 +484,7 @@ static int test_tiff_directory_info(t4_tx_state_t *s)
|
|||
|
||||
parm32 = 0;
|
||||
TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm32);
|
||||
if (s->image_width != (int) parm32)
|
||||
if (s->metadata.image_width != (int) parm32)
|
||||
return 1;
|
||||
x_resolution = 0.0f;
|
||||
TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution);
|
||||
|
@ -540,16 +540,16 @@ static int tiff_row_read_handler(void *user_data, uint8_t buf[], size_t len)
|
|||
int j;
|
||||
|
||||
s = (t4_tx_state_t *) user_data;
|
||||
if (s->tiff.row >= s->image_length)
|
||||
if (s->tiff.row >= s->metadata.image_length)
|
||||
return 0;
|
||||
memcpy(buf, &s->tiff.image_buffer[s->tiff.row*len], len);
|
||||
s->tiff.row++;
|
||||
|
||||
/* If this is a bi-level image which has more vertical resolution than the
|
||||
far end will accept, we need to squash it down to size. */
|
||||
for (i = 1; i < s->row_squashing_ratio && s->tiff.row < s->image_length; i++)
|
||||
for (i = 1; i < s->row_squashing_ratio && s->tiff.row < s->metadata.image_length; i++)
|
||||
{
|
||||
for (j = 0; j < s->image_width/8; j++)
|
||||
for (j = 0; j < s->metadata.image_width/8; j++)
|
||||
buf[j] |= s->tiff.image_buffer[s->tiff.row*len + j];
|
||||
s->tiff.row++;
|
||||
}
|
||||
|
@ -624,7 +624,7 @@ static int read_tiff_t85_image(t4_tx_state_t *s)
|
|||
if ((raw_data = malloc(biggest)) == NULL)
|
||||
return -1;
|
||||
|
||||
s->tiff.image_size = s->image_length*((s->image_width + 7)/8);
|
||||
s->tiff.image_size = s->metadata.image_length*((s->metadata.image_width + 7)/8);
|
||||
if (s->tiff.image_size >= s->tiff.image_buffer_size)
|
||||
{
|
||||
if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL)
|
||||
|
@ -657,7 +657,7 @@ static int read_tiff_t85_image(t4_tx_state_t *s)
|
|||
result = t85_decode_put(&t85, NULL, 0);
|
||||
|
||||
len = t85_decode_get_compressed_image_size(&t85);
|
||||
span_log(&s->logging, SPAN_LOG_WARNING, "Compressed image is %d bytes, %d rows\n", len/8, s->image_length);
|
||||
span_log(&s->logging, SPAN_LOG_WARNING, "Compressed image is %d bytes, %d rows\n", len/8, s->metadata.image_length);
|
||||
t85_decode_release(&t85);
|
||||
free(raw_data);
|
||||
return 0;
|
||||
|
@ -700,7 +700,7 @@ static int read_tiff_t43_image(t4_tx_state_t *s, uint8_t **buf)
|
|||
logging = t43_decode_get_logging_state(&t43);
|
||||
span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
|
||||
|
||||
image_size = 3*s->image_length*s->image_width;
|
||||
image_size = 3*s->metadata.image_length*s->metadata.image_width;
|
||||
if ((*buf = malloc(image_size)) == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -762,7 +762,7 @@ static int read_tiff_t42_t81_image(t4_tx_state_t *s, uint8_t **buf)
|
|||
if (total_len != total_image_len)
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Size mismatch %d %d\n", (int) total_len, (int) total_image_len);
|
||||
|
||||
image_size = 3*s->image_length*s->image_width;
|
||||
image_size = 3*s->metadata.image_length*s->metadata.image_width;
|
||||
if ((*buf = malloc(image_size)) == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -788,7 +788,7 @@ static int read_tiff_decompressed_image(t4_tx_state_t *s)
|
|||
|
||||
/* Decode the whole image into a buffer */
|
||||
/* Let libtiff handle the decompression */
|
||||
s->tiff.image_size = s->image_length*TIFFScanlineSize(s->tiff.tiff_file);
|
||||
s->tiff.image_size = s->metadata.image_length*TIFFScanlineSize(s->tiff.tiff_file);
|
||||
if (s->tiff.image_size >= s->tiff.image_buffer_size)
|
||||
{
|
||||
if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL)
|
||||
|
@ -834,14 +834,14 @@ static int read_tiff_image(t4_tx_state_t *s)
|
|||
{
|
||||
/* We need to dither this image down to pure black and white, possibly resizing it
|
||||
along the way. */
|
||||
if ((translator = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, 1728, -1, s->tiff.image_type, s->image_width, s->image_length, row_read, s)) == NULL)
|
||||
if ((translator = image_translate_init(NULL, T4_IMAGE_TYPE_BILEVEL, 1728, -1, s->tiff.image_type, s->metadata.image_width, s->metadata.image_length, row_read, s)) == NULL)
|
||||
return -1;
|
||||
s->image_width = image_translate_get_output_width(translator);
|
||||
s->image_length = image_translate_get_output_length(translator);
|
||||
s->metadata.image_width = image_translate_get_output_width(translator);
|
||||
s->metadata.image_length = image_translate_get_output_length(translator);
|
||||
s->metadata.x_resolution = T4_X_RESOLUTION_R8;
|
||||
s->metadata.y_resolution = T4_Y_RESOLUTION_FINE;
|
||||
s->metadata.resolution_code = T4_RESOLUTION_R8_FINE;
|
||||
s->tiff.image_size = (s->image_width*s->image_length + 7)/8;
|
||||
s->tiff.image_size = (s->metadata.image_width*s->metadata.image_length + 7)/8;
|
||||
if (s->tiff.image_size >= s->tiff.image_buffer_size)
|
||||
{
|
||||
if ((t = realloc(s->tiff.image_buffer, s->tiff.image_size)) == NULL)
|
||||
|
@ -868,8 +868,8 @@ static int read_tiff_image(t4_tx_state_t *s)
|
|||
break;
|
||||
}
|
||||
total_len = 0;
|
||||
for (i = 0; i < s->image_length; i++)
|
||||
total_len += image_translate_row(translator, &s->tiff.image_buffer[total_len], s->image_width/8);
|
||||
for (i = 0; i < s->metadata.image_length; i++)
|
||||
total_len += image_translate_row(translator, &s->tiff.image_buffer[total_len], s->metadata.image_width/8);
|
||||
image_translate_free(translator);
|
||||
}
|
||||
else
|
||||
|
@ -897,7 +897,7 @@ static int read_tiff_image(t4_tx_state_t *s)
|
|||
}
|
||||
}
|
||||
s->tiff.row = 0;
|
||||
return s->image_length;
|
||||
return s->metadata.image_length;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
@ -923,7 +923,7 @@ static void tiff_tx_release(t4_tx_state_t *s)
|
|||
|
||||
static int set_row_read_handler(t4_tx_state_t *s, t4_row_read_handler_t handler, void *user_data)
|
||||
{
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1096,83 +1096,83 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding)
|
|||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
break;
|
||||
default:
|
||||
t4_t6_encode_init(&s->encoder.t4_t6, encoding, s->image_width, s->row_handler, s->row_handler_user_data);
|
||||
t4_t6_encode_init(&s->encoder.t4_t6, encoding, s->metadata.image_width, s->row_handler, s->row_handler_user_data);
|
||||
t4_t6_encode_set_max_2d_rows_per_1d_row(&s->encoder.t4_t6, -s->metadata.y_resolution);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
s->metadata.compression = encoding;
|
||||
if (t4_t6_encode_set_encoding(&s->encoder.t4_t6, encoding))
|
||||
return -1;
|
||||
return s->line_encoding;
|
||||
return s->metadata.compression;
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
break;
|
||||
default:
|
||||
t85_encode_init(&s->encoder.t85, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data);
|
||||
t85_encode_init(&s->encoder.t85, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
return s->line_encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return s->metadata.compression;
|
||||
#if defined(SPANDSP_SUPPORT_T88)
|
||||
case T4_COMPRESSION_T88:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T88:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
return s->line_encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return s->metadata.compression;
|
||||
#endif
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
case T4_COMPRESSION_SYCC_T81:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
case T4_COMPRESSION_SYCC_T81:
|
||||
break;
|
||||
default:
|
||||
t42_encode_init(&s->encoder.t42, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data);
|
||||
t42_encode_init(&s->encoder.t42, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
return s->line_encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return s->metadata.compression;
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
case T4_COMPRESSION_T43:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T43:
|
||||
break;
|
||||
default:
|
||||
t43_encode_init(&s->encoder.t43, s->image_width, s->image_length, s->row_handler, s->row_handler_user_data);
|
||||
t43_encode_init(&s->encoder.t43, s->metadata.image_width, s->metadata.image_length, s->row_handler, s->row_handler_user_data);
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
return s->line_encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return s->metadata.compression;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T45)
|
||||
case T4_COMPRESSION_T45:
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T45:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
s->line_encoding = encoding;
|
||||
return s->line_encoding;
|
||||
s->metadata.compression = encoding;
|
||||
return s->metadata.compression;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1182,7 +1182,7 @@ SPAN_DECLARE(int) t4_tx_set_tx_encoding(t4_tx_state_t *s, int encoding)
|
|||
|
||||
SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits)
|
||||
{
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1195,8 +1195,8 @@ SPAN_DECLARE(void) t4_tx_set_min_bits_per_row(t4_tx_state_t *s, int bits)
|
|||
|
||||
SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width)
|
||||
{
|
||||
s->image_width = image_width;
|
||||
switch (s->line_encoding)
|
||||
s->metadata.image_width = image_width;
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1230,8 +1230,8 @@ SPAN_DECLARE(void) t4_tx_set_image_width(t4_tx_state_t *s, int image_width)
|
|||
|
||||
static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length)
|
||||
{
|
||||
s->image_length = image_length;
|
||||
switch (s->line_encoding)
|
||||
s->metadata.image_length = image_length;
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
|
@ -1260,7 +1260,7 @@ static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length)
|
|||
|
||||
SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max)
|
||||
{
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1273,7 +1273,7 @@ SPAN_DECLARE(void) t4_tx_set_max_2d_rows_per_1d_row(t4_tx_state_t *s, int max)
|
|||
|
||||
SPAN_DECLARE(int) t4_tx_get_image_width(t4_tx_state_t *s)
|
||||
{
|
||||
return s->image_width;
|
||||
return s->metadata.image_width;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
@ -1359,8 +1359,8 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t
|
|||
|
||||
t->x_resolution = s->metadata.x_resolution;
|
||||
t->y_resolution = s->metadata.y_resolution/s->row_squashing_ratio;
|
||||
t->encoding = s->line_encoding;
|
||||
switch (s->line_encoding)
|
||||
t->encoding = s->metadata.compression;
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1406,7 +1406,7 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t
|
|||
|
||||
SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s)
|
||||
{
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1444,7 +1444,7 @@ SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s)
|
|||
|
||||
SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len)
|
||||
{
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
@ -1475,7 +1475,7 @@ SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len)
|
|||
|
||||
SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->line_encoding));
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d - compression %s\n", s->current_page, t4_encoding_to_str(s->metadata.compression));
|
||||
if (s->current_page > s->stop_page)
|
||||
return -1;
|
||||
if (s->tiff.file)
|
||||
|
@ -1488,19 +1488,19 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s)
|
|||
}
|
||||
else
|
||||
{
|
||||
s->image_length = UINT32_MAX;
|
||||
s->metadata.image_length = UINT32_MAX;
|
||||
}
|
||||
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
case T4_COMPRESSION_T6:
|
||||
t4_t6_encode_restart(&s->encoder.t4_t6, s->image_width);
|
||||
t4_t6_encode_restart(&s->encoder.t4_t6, s->metadata.image_width);
|
||||
break;
|
||||
case T4_COMPRESSION_T85:
|
||||
case T4_COMPRESSION_T85_L0:
|
||||
t85_encode_restart(&s->encoder.t85, s->image_width, s->image_length);
|
||||
t85_encode_restart(&s->encoder.t85, s->metadata.image_width, s->metadata.image_length);
|
||||
break;
|
||||
#if defined(SPANDSP_SUPPORT_T88)
|
||||
case T4_COMPRESSION_T88:
|
||||
|
@ -1508,11 +1508,11 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s)
|
|||
#endif
|
||||
case T4_COMPRESSION_T42_T81:
|
||||
case T4_COMPRESSION_SYCC_T81:
|
||||
t42_encode_restart(&s->encoder.t42, s->image_width, s->image_length);
|
||||
t42_encode_restart(&s->encoder.t42, s->metadata.image_width, s->metadata.image_length);
|
||||
break;
|
||||
#if defined(SPANDSP_SUPPORT_T43)
|
||||
case T4_COMPRESSION_T43:
|
||||
t43_encode_restart(&s->encoder.t43, s->image_width, s->image_length);
|
||||
t43_encode_restart(&s->encoder.t43, s->metadata.image_width, s->metadata.image_length);
|
||||
break;
|
||||
#endif
|
||||
#if defined(SPANDSP_SUPPORT_T45)
|
||||
|
@ -1578,7 +1578,7 @@ SPAN_DECLARE(t4_tx_state_t *) t4_tx_init(t4_tx_state_t *s, const char *file, int
|
|||
s->current_page =
|
||||
s->start_page = (start_page >= 0) ? start_page : 0;
|
||||
s->stop_page = (stop_page >= 0) ? stop_page : INT_MAX;
|
||||
s->line_encoding = T4_COMPRESSION_NONE;
|
||||
s->metadata.compression = T4_COMPRESSION_NONE;
|
||||
|
||||
s->row_handler = tiff_row_read_handler;
|
||||
s->row_handler_user_data = (void *) s;
|
||||
|
@ -1623,7 +1623,7 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s)
|
|||
free(s->colour_map);
|
||||
s->colour_map = NULL;
|
||||
}
|
||||
switch (s->line_encoding)
|
||||
switch (s->metadata.compression)
|
||||
{
|
||||
case T4_COMPRESSION_T4_1D:
|
||||
case T4_COMPRESSION_T4_2D:
|
||||
|
|
Loading…
Reference in New Issue