提交 88b3b54e authored 作者: Steve Underwood's avatar Steve Underwood

More movement towards colour FAXing

上级 8e49f7a5
......@@ -261,6 +261,8 @@ fi
SPANDSP_SUPPORT_T42="#undef SPANDSP_SUPPORT_T42"
#AC_DEFINE([SPANDSP_SUPPORT_T43], [1], [Support T.43 JBIG gray and colour compression])
SPANDSP_SUPPORT_T43="#undef SPANDSP_SUPPORT_T43"
#AC_DEFINE([SPANDSP_SUPPORT_V32BIS], [1], [Support the V.32bis modem])
SPANDSP_SUPPORT_V32BIS="#undef SPANDSP_SUPPORT_V32BIS"
#AC_DEFINE([SPANDSP_SUPPORT_V34], [1], [Support the V.34 FAX modem])
SPANDSP_SUPPORT_V34="#undef SPANDSP_SUPPORT_V34"
......@@ -567,6 +569,7 @@ AC_SUBST(SPANDSP_MISALIGNED_ACCESS_FAILS)
AC_SUBST(SPANDSP_USE_EXPORT_CAPABILITY)
AC_SUBST(SPANDSP_SUPPORT_T42)
AC_SUBST(SPANDSP_SUPPORT_T43)
AC_SUBST(SPANDSP_SUPPORT_V32BIS)
AC_SUBST(SPANDSP_SUPPORT_V34)
AC_SUBST(SPANDSP_SUPPORT_TIFF_FX)
AC_SUBST(INSERT_INTTYPES_HEADER)
......
......@@ -22,28 +22,17 @@ AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \
$(srcdir)/cielab_luts.h \
$(srcdir)/math_fixed_tables.h \
$(srcdir)/v17_v32bis_rx_fixed_rrc.h \
$(srcdir)/v17_v32bis_rx_floating_rrc.h \
$(srcdir)/v17_v32bis_tx_fixed_rrc.h \
$(srcdir)/v17_v32bis_tx_floating_rrc.h \
$(srcdir)/v22bis_rx_1200_fixed_rrc.h \
$(srcdir)/v22bis_rx_2400_fixed_rrc.h \
$(srcdir)/v22bis_rx_1200_floating_rrc.h \
$(srcdir)/v22bis_rx_2400_floating_rrc.h \
$(srcdir)/v22bis_tx_fixed_rrc.h \
$(srcdir)/v22bis_tx_floating_rrc.h \
$(srcdir)/v27ter_rx_2400_fixed_rrc.h \
$(srcdir)/v27ter_rx_4800_fixed_rrc.h \
$(srcdir)/v27ter_rx_2400_floating_rrc.h \
$(srcdir)/v27ter_rx_4800_floating_rrc.h \
$(srcdir)/v27ter_tx_2400_fixed_rrc.h \
$(srcdir)/v27ter_tx_4800_fixed_rrc.h \
$(srcdir)/v27ter_tx_2400_floating_rrc.h \
$(srcdir)/v27ter_tx_4800_floating_rrc.h \
$(srcdir)/v29rx_fixed_rrc.h \
$(srcdir)/v29rx_floating_rrc.h \
$(srcdir)/v29tx_fixed_rrc.h \
$(srcdir)/v29tx_floating_rrc.h
$(srcdir)/v17_v32bis_rx_rrc.h \
$(srcdir)/v17_v32bis_tx_rrc.h \
$(srcdir)/v22bis_rx_1200_rrc.h \
$(srcdir)/v22bis_rx_2400_rrc.h \
$(srcdir)/v22bis_tx_rrc.h \
$(srcdir)/v27ter_rx_2400_rrc.h \
$(srcdir)/v27ter_rx_4800_rrc.h \
$(srcdir)/v27ter_tx_2400_rrc.h \
$(srcdir)/v27ter_tx_4800_rrc.h \
$(srcdir)/v29rx_rrc.h \
$(srcdir)/v29tx_rrc.h
CLEANFILES = ${DISTCLEANFILES}
MOSTLYCLEANFILES = ${DISTCLEANFILES}
......@@ -160,6 +149,7 @@ libspandsp_la_SOURCES = ademco_contactid.c \
t4_rx.c \
t4_tx.c \
t42.c \
t43.c \
t81_t82_arith_coding.c \
t85_decode.c \
t85_encode.c \
......@@ -251,6 +241,7 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \
spandsp/t4_t6_decode.h \
spandsp/t4_t6_encode.h \
spandsp/t42.h \
spandsp/t43.h \
spandsp/t81_t82_arith_coding.h \
spandsp/t85.h \
spandsp/telephony.h \
......@@ -318,6 +309,7 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \
spandsp/private/t4_t6_decode.h \
spandsp/private/t4_t6_encode.h \
spandsp/private/t42.h \
spandsp/private/t43.h \
spandsp/private/t81_t82_arith_coding.h \
spandsp/private/t85.h \
spandsp/private/time_scale.h \
......
......@@ -511,6 +511,9 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
s->use_tep = use_tep;
modem_connect_tones_tx_init(&s->connect_tx, MODEM_CONNECT_TONES_FAX_CNG);
span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "FAX modems");
s->tone_callback = tone_callback;
s->tone_callback_user_data = user_data;
if (tone_callback)
......@@ -521,9 +524,6 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
s->tone_callback_user_data);
}
/*endif*/
span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "FAX modems");
dc_restore_init(&s->dc_restore);
s->get_bit = non_ecm_get_bit;
......
......@@ -35,6 +35,7 @@
@SPANDSP_SUPPORT_T42@
@SPANDSP_SUPPORT_T43@
@SPANDSP_SUPPORT_V32BIS@
@SPANDSP_SUPPORT_V34@
@SPANDSP_SUPPORT_TIFF_FX@
......@@ -96,11 +97,15 @@
#include <spandsp/v29tx.h>
#include <spandsp/v17rx.h>
#include <spandsp/v17tx.h>
/*#include <spandsp/v32bis.h>*/
#if defined(SPANDSP_SUPPORT_V32BIS)
#include <spandsp/v32bis.h>
#endif
#include <spandsp/v22bis.h>
#include <spandsp/v27ter_rx.h>
#include <spandsp/v27ter_tx.h>
/*#include <spandsp/v34.h>*/
#if defined(SPANDSP_SUPPORT_V34)
#include <spandsp/v34.h>
#endif
#include <spandsp/v18.h>
#include <spandsp/timezone.h>
#include <spandsp/t4_rx.h>
......@@ -111,7 +116,9 @@
#include <spandsp/t81_t82_arith_coding.h>
#include <spandsp/t85.h>
#include <spandsp/t42.h>
/*#include <spandsp/t43.h>*/
#if defined(SPANDSP_SUPPORT_T43)
#include <spandsp/t43.h>
#endif
#include <spandsp/t30.h>
#include <spandsp/t30_api.h>
#include <spandsp/t30_fcf.h>
......
......@@ -35,6 +35,10 @@ struct fax_modems_state_s
{
/*! TRUE is talker echo protection should be sent for the image modems */
int use_tep;
/*! \brief The callback function used to report detected tones. */
tone_report_func_t tone_callback;
/*! \brief A user specified opaque pointer passed to the tone_callback function. */
void *tone_callback_user_data;
/*! If TRUE, transmit silence when there is nothing else to transmit. If FALSE return only
the actual generated audio. Note that this only affects untimed silences. Timed silences
......@@ -82,11 +86,6 @@ struct fax_modems_state_s
/*! \brief */
dc_restore_state_t dc_restore;
/*! \brief The callback function used to report detected tones. */
tone_report_func_t tone_callback;
/*! \brief A user specified opaque pointer passed to the tone_callback function. */
void *tone_callback_user_data;
/*! \brief The fast modem type currently in use */
int fast_modem;
......
......@@ -50,8 +50,12 @@ struct t30_state_s
int iaf;
/*! \brief A bit mask of the currently supported modem types. */
int supported_modems;
/*! \brief A bit mask of the currently supported image compression modes. */
/*! \brief A bit mask of the currently supported image compression modes for use
between FAX entities. */
int supported_compressions;
/*! \brief A bit mask of the currently supported image compression modes for the output
of received page images. */
int supported_output_compressions;
/*! \brief A bit mask of the currently supported bi-level image resolutions. */
int supported_bilevel_resolutions;
/*! \brief A bit mask of the currently supported gray-scale and colour image resolutions. */
......
......@@ -497,6 +497,12 @@
#define T30_DCS_BIT_T38_FAX_MODE 123
/* Bits 124 to 126 specify the T.89 applications profile. */
#define T30_DIS_BIT_T88_CAPABILITY_1 124
#define T30_DCS_BIT_T88_MODE_1 124
#define T30_DIS_BIT_T88_CAPABILITY_2 125
#define T30_DCS_BIT_T88_MODE_2 125
#define T30_DIS_BIT_T88_CAPABILITY_3 126
#define T30_DCS_BIT_T88_MODE_3 126
/* When either bit of 31, 36, 38, 51, 53, 54, 55, 57, 59, 60, 62, 65, 68, 78, 79, 115, 116 and 127 is
set to "1", ECM must be used. If the value of bit field 92 to 94 is non-zero, then ECM must be used.
......
......@@ -66,10 +66,6 @@ typedef struct
{
/*! \brief The FAX modem set for the audio side fo the gateway. */
fax_modems_state_t modems;
/*! \brief CED detector */
modem_connect_tones_rx_state_t connect_rx_ced;
/*! \brief CNG detector */
modem_connect_tones_rx_state_t connect_rx_cng;
} t38_gateway_audio_state_t;
/*!
......
/*
* SpanDSP - a series of DSP components for telephony
*
* private/t43.h - ITU T.43 JBIG for gray and colour FAX image processing
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2011 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#if !defined(_SPANDSP_PRIVATE_T43_H_)
#define _SPANDSP_PRIVATE_T43_H_
/* State of a working instance of the T.43 JBIG for gray and colour FAX encoder */
struct t43_encode_state_s
{
/*! \brief Callback function to read a row of pixels from the image source. */
t4_row_read_handler_t row_read_handler;
/*! \brief Opaque pointer passed to row_read_handler. */
void *row_read_user_data;
struct lab_params_s lab;
struct t85_encode_state_s t85;
int bit_planes[4];
int colour_map_entries;
uint8_t colour_map[3*256];
/*! 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;
/*! \brief Error and flow logging control */
logging_state_t logging;
};
/* State of a working instance of the T.43 JBIG for gray and colour FAX decoder */
struct t43_decode_state_s
{
/*! A callback routine to handle decoded pixel rows */
t4_row_write_handler_t row_write_handler;
/*! An opaque pointer passed to row_write_handler() */
void *row_write_user_data;
struct lab_params_s lab;
struct t85_decode_state_s t85;
int bit_planes[4];
uint8_t bit_plane_mask;
int current_bit_plane;
int plane_ptr;
int colour_map_entries;
uint8_t colour_map[3*256];
int x_resolution;
int y_resolution;
uint8_t *buf;
int ptr;
int row;
/*! \brief Error and flow logging control */
logging_state_t logging;
};
#endif
/*- End of file ------------------------------------------------------------*/
......@@ -94,6 +94,10 @@ struct t4_rx_state_s
/*! \brief Opaque pointer passed to row_write_handler. */
void *row_handler_user_data;
/*! \brief A bit mask of the currently supported image compression modes for writing
to the TIFF file. */
int supported_tiff_compressions;
/*! \brief The number of pages transferred to date. */
int current_page;
......@@ -111,12 +115,24 @@ struct t4_rx_state_s
union
{
t4_t6_decode_state_t t4_t6;
t85_decode_state_t t85;
#if defined(SPANDSP_SUPPORT_T88)
t88_decode_state_t t88;
#endif
t42_decode_state_t t42;
#if defined(SPANDSP_SUPPORT_T43)
t43_decode_state_t t43;
#endif
t85_decode_state_t t85;
#if defined(SPANDSP_SUPPORT_T45)
t45_decode_state_t t45;
#endif
} decoder;
int current_decoder;
uint8_t *pre_encoded_buf;
int pre_encoded_len;
int pre_encoded_ptr;
int pre_encoded_bit;
/* Supporting information, like resolutions, which the backend may want. */
t4_rx_metadata_t metadata;
......
......@@ -146,11 +146,17 @@ struct t4_tx_state_s
union
{
t4_t6_encode_state_t t4_t6;
t85_encode_state_t t85;
#if defined(SPANDSP_SUPPORT_T88)
t88_encode_state_t t88;
#endif
t42_encode_state_t t42;
#if defined(SPANDSP_SUPPORT_T43)
t43_encode_state_t t43;
#endif
t85_encode_state_t t85;
#if defined(SPANDSP_SUPPORT_T45)
t45_encode_state_t t45;
#endif
} encoder;
image_translate_state_t translator;
......@@ -160,6 +166,11 @@ struct t4_tx_state_s
uint8_t *colour_map;
int colour_map_entries;
uint8_t *pre_encoded_buf;
int pre_encoded_len;
int pre_encoded_ptr;
int pre_encoded_bit;
/* Supporting information, like resolutions, which the backend may want. */
t4_tx_metadata_t metadata;
......
......@@ -48,7 +48,6 @@ struct v18_state_s
int baudot_tx_shift;
int tx_signal_on;
uint8_t next_byte;
int byte_no;
fsk_rx_state_t fskrx;
dtmf_rx_state_t dtmfrx;
......
......@@ -439,12 +439,10 @@ SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, int enabled);
/*! Specify the output encoding for TIFF files created during FAX reception.
\brief Specify the output encoding for TIFF files created during FAX reception.
\param s The T.30 context.
\param encoding The coding required. The options are T4_COMPRESSION_T4_1D,
T4_COMPRESSION_T4_2D, T4_COMPRESSION_T6. T6 is usually the
densest option, but support for it is broken in a number of software
packages.
\param supported_compressions Bit field list of the supported compression types, for
output of received page images.
\return 0 if OK, else -1. */
SPAN_DECLARE(int) t30_set_rx_encoding(t30_state_t *s, int encoding);
SPAN_DECLARE(int) t30_set_supported_output_compressions(t30_state_t *s, int supported_compressions);
/*! Specify the minimum scan line time supported by a T.30 context.
\brief Specify minimum scan line time.
......
/*
* SpanDSP - a series of DSP components for telephony
*
* t43.h - ITU T.43 JBIG for grey and colour FAX image processing
*
* Written by Steve Underwood <steveu@coppice.org>
*
* Copyright (C) 2011 Steve Underwood
*
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*! \file */
#if !defined(_SPANDSP_T43_H_)
#define _SPANDSP_T43_H_
/*! \page t43_page T.43 (JBIG for gray and colour FAX) image compression and decompression
\section t43_page_sec_1 What does it do?
\section t43_page_sec_1 How does it work?
*/
/*! State of a working instance of the T.43 encoder */
typedef struct t43_encode_state_s t43_encode_state_t;
/*! State of a working instance of the T.43 decoder */
typedef struct t43_decode_state_s t43_decode_state_t;
#if defined(__cplusplus)
extern "C"
{
#endif
SPAN_DECLARE(const char *) t43_image_type_to_str(int type);
SPAN_DECLARE(void) t43_encode_set_options(t43_encode_state_t *s,
uint32_t l0,
int mx,
int options);
SPAN_DECLARE(int) t43_encode_set_image_width(t43_encode_state_t *s, uint32_t image_width);
SPAN_DECLARE(int) t43_encode_set_image_length(t43_encode_state_t *s, uint32_t length);
SPAN_DECLARE(void) t43_encode_abort(t43_encode_state_t *s);
SPAN_DECLARE(void) t43_encode_comment(t43_encode_state_t *s, const uint8_t comment[], size_t len);
/*! \brief Check if we are at the end of the current document page.
\param s The T.43 context.
\return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
SPAN_DECLARE(int) t43_encode_image_complete(t43_encode_state_t *s);
SPAN_DECLARE(int) t43_encode_get(t43_encode_state_t *s, uint8_t buf[], size_t max_len);
SPAN_DECLARE(uint32_t) t43_encode_get_image_width(t43_encode_state_t *s);
SPAN_DECLARE(uint32_t) t43_encode_get_image_length(t43_encode_state_t *s);
SPAN_DECLARE(int) t43_encode_get_compressed_image_size(t43_encode_state_t *s);
SPAN_DECLARE(int) t43_encode_set_row_read_handler(t43_encode_state_t *s,
t4_row_read_handler_t handler,
void *user_data);
/*! Get the logging context associated with a T.43 encode context.
\brief Get the logging context associated with a T.43 encode context.
\param s The T.43 encode context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t43_encode_get_logging_state(t43_encode_state_t *s);
/*! \brief Restart a T.43 encode context.
\param s The T.43 context.
\param image image_width The image width, in pixels.
\param image image_width The image length, in pixels.
\return 0 for success, otherwise -1. */
SPAN_DECLARE(int) t43_encode_restart(t43_encode_state_t *s, uint32_t image_width, uint32_t image_length);
/*! \brief Prepare to encode an image in T.43 format.
\param s The T.43 context.
\param image_width Image width, in pixels.
\param image_length Image length, in pixels.
\param handler A callback routine to handle encoded image rows.
\param user_data An opaque pointer passed to handler.
\return A pointer to the context, or NULL if there was a problem. */
SPAN_DECLARE(t43_encode_state_t *) t43_encode_init(t43_encode_state_t *s,
uint32_t image_width,
uint32_t image_length,
t4_row_read_handler_t handler,
void *user_data);
/*! \brief Release a T.43 encode context.
\param s The T.43 encode context.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t43_encode_release(t43_encode_state_t *s);
/*! \brief Free a T.43 encode context.
\param s The T.43 encode context.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t43_encode_free(t43_encode_state_t *s);
SPAN_DECLARE(int) t43_create_header(t43_decode_state_t *s, uint8_t data[], size_t len);
SPAN_DECLARE(void) t43_decode_rx_status(t43_decode_state_t *s, int status);
/*! \brief Decode a chunk of T.43 data.
\param s The T.43 context.
\param data The data to be decoded.
\param len The length of the data to be decoded.
\return 0 for OK. */
SPAN_DECLARE(int) t43_decode_put(t43_decode_state_t *s, const uint8_t data[], size_t len);
/*! \brief Set the row handler routine.
\param s The T.43 context.
\param handler A callback routine to handle decoded image rows.
\param user_data An opaque pointer passed to handler.
\return 0 for OK. */
SPAN_DECLARE(int) t43_decode_set_row_write_handler(t43_decode_state_t *s,
t4_row_write_handler_t handler,
void *user_data);
/*! \brief Set the comment handler routine.
\param s The T.43 context.
\param max_comment_len The maximum length of comment to be passed to the handler.
\param handler A callback routine to handle decoded comment.
\param user_data An opaque pointer passed to handler.
\return 0 for OK. */
SPAN_DECLARE(int) t43_decode_set_comment_handler(t43_decode_state_t *s,
uint32_t max_comment_len,
t4_row_write_handler_t handler,
void *user_data);
SPAN_DECLARE(int) t43_decode_set_image_size_constraints(t43_decode_state_t *s,
uint32_t max_xd,
uint32_t max_yd);
/*! \brief Get the width of the image.
\param s The T.43 context.
\return The width of the image, in pixels. */
SPAN_DECLARE(uint32_t) t43_decode_get_image_width(t43_decode_state_t *s);
/*! \brief Get the length of the image.
\param s The T.43 context.
\return The length of the image, in pixels. */
SPAN_DECLARE(uint32_t) t43_decode_get_image_length(t43_decode_state_t *s);
SPAN_DECLARE(int) t43_decode_get_compressed_image_size(t43_decode_state_t *s);
/*! Get the logging context associated with a T.43 decode context.
\brief Get the logging context associated with a T.43 decode context.
\param s The T.43 decode context.
\return A pointer to the logging context */
SPAN_DECLARE(logging_state_t *) t43_decode_get_logging_state(t43_decode_state_t *s);
SPAN_DECLARE(int) t43_decode_restart(t43_decode_state_t *s);
/*! \brief Prepare to decode an image in T.43 format.
\param s The T.43 context.
\param handler A callback routine to handle decoded image rows.
\param user_data An opaque pointer passed to handler.
\return A pointer to the context, or NULL if there was a problem. */
SPAN_DECLARE(t43_decode_state_t *) t43_decode_init(t43_decode_state_t *s,
t4_row_write_handler_t handler,
void *user_data);
/*! \brief Release a T.43 decode context.
\param s The T.43 decode context.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t43_decode_release(t43_decode_state_t *s);
/*! \brief Free a T.43 decode context.
\param s The T.43 decode context.
\return 0 for OK, else -1. */
SPAN_DECLARE(int) t43_decode_free(t43_decode_state_t *s);
#if defined(__cplusplus)
}
#endif
#endif
/*- End of file ------------------------------------------------------------*/
......@@ -67,47 +67,49 @@ typedef enum
/*! T.42 + T.81 + T.30 Annex E colour JPEG coding */
T4_COMPRESSION_T42_T81 = 8,
/*! T.42 + T.81 + T.30 Annex K colour sYCC-JPEG coding */
T4_COMPRESSION_SYCC_T81 = 9
T4_COMPRESSION_SYCC_T81 = 9,
/*! T.88 monochrome JBIG2 compression */
T4_COMPRESSION_T88 = 10
} t4_image_compression_t;
enum
{
/*! No compression */
T30_SUPPORT_COMPRESSION_NONE = 0x01,
T4_SUPPORT_COMPRESSION_NONE = 0x01,
/*! T.1 1D compression */
T30_SUPPORT_COMPRESSION_T4_1D = 0x02,
T4_SUPPORT_COMPRESSION_T4_1D = 0x02,
/*! T.4 2D compression */
T30_SUPPORT_COMPRESSION_T4_2D = 0x04,
T4_SUPPORT_COMPRESSION_T4_2D = 0x04,
/*! T.6 2D compression */
T30_SUPPORT_COMPRESSION_T6 = 0x08,
T4_SUPPORT_COMPRESSION_T6 = 0x08,
/*! T.85 monochrome JBIG compression, with fixed L0 */
T30_SUPPORT_COMPRESSION_T85 = 0x10,
T4_SUPPORT_COMPRESSION_T85 = 0x10,
/*! T.85 monochrome JBIG compression, with variable L0 */
T30_SUPPORT_COMPRESSION_T85_L0 = 0x20,
T4_SUPPORT_COMPRESSION_T85_L0 = 0x20,
/*! T.43 colour JBIG compression */
T30_SUPPORT_COMPRESSION_T43 = 0x40,
T4_SUPPORT_COMPRESSION_T43 = 0x40,
/*! T.45 run length colour compression */
T30_SUPPORT_COMPRESSION_T45 = 0x80,
T4_SUPPORT_COMPRESSION_T45 = 0x80,
/*! T.81 + T.30 Annex E colour JPEG compression */
T30_SUPPORT_COMPRESSION_T42_T81 = 0x100,
T4_SUPPORT_COMPRESSION_T42_T81 = 0x100,
/*! T.81 + T.30 Annex K colour sYCC-JPEG compression */
T30_SUPPORT_COMPRESSION_SYCC_T81 = 0x200,
T4_SUPPORT_COMPRESSION_SYCC_T81 = 0x200,
/*! T.88 monochrome JBIG2 compression */
T30_SUPPORT_COMPRESSION_T88 = 0x400,
T4_SUPPORT_COMPRESSION_T88 = 0x400,
/*! Gray-scale support by multi-level codecs */
T30_SUPPORT_COMPRESSION_GRAYSCALE = 0x1000000,
T4_SUPPORT_COMPRESSION_GRAYSCALE = 0x1000000,
/*! Colour support by multi-level codecs */
T30_SUPPORT_COMPRESSION_COLOUR = 0x2000000,
T4_SUPPORT_COMPRESSION_COLOUR = 0x2000000,
/*! 12 bit mode for gray-scale and colour */
T30_SUPPORT_COMPRESSION_12BIT = 0x4000000,
T4_SUPPORT_COMPRESSION_12BIT = 0x4000000,
/*! Convert a colour image to a gray-scale one */
T30_SUPPORT_COMPRESSION_COLOUR_TO_GRAY = 0x8000000,
T4_SUPPORT_COMPRESSION_COLOUR_TO_GRAY = 0x8000000,
/*! Dither a gray-scale image down a simple bilevel image, with rescaling to fit a FAX page */
T30_SUPPORT_GRAY_TO_BILEVEL = 0x10000000,
/*! Dither a colour image down a simple bilevel image, with rescaling to fit a FAX page */
T30_SUPPORT_COLOUR_TO_BILEVEL = 0x20000000,
/*! Rescale an image (except a bi-level image) to fit a permitted FAX width when necessary */
T30_SUPPORT_COMPRESSION_RESCALING = 0x40000000
T4_SUPPORT_COMPRESSION_RESCALING = 0x40000000
};
/*! Image type */
......@@ -561,9 +563,9 @@ SPAN_DECLARE(logging_state_t *) t4_rx_get_logging_state(t4_rx_state_t *s);
/*! \brief Prepare for reception of a document.
\param s The T.4 context.
\param file The name of the file to be received.
\param output_encoding The output encoding.
\param supported_compressions The compression schemes supported for output to a TIFF file.
\return A pointer to the context, or NULL if there was a problem. */
SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int output_encoding);
SPAN_DECLARE(t4_rx_state_t *) t4_rx_init(t4_rx_state_t *s, const char *file, int supported_compressions);
/*! \brief End reception of a document. Tidy up and close the file.
This should be used to end T.4 reception started with t4_rx_init.
......
差异被折叠。
......@@ -646,19 +646,11 @@ SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, int enabled)
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(int) t30_set_rx_encoding(t30_state_t *s, int encoding)
SPAN_DECLARE(int) t30_set_supported_output_compressions(t30_state_t *s, int supported_compressions)
{
switch (encoding)
{
case T4_COMPRESSION_T4_1D:
case T4_COMPRESSION_T4_2D:
case T4_COMPRESSION_T6:
//case T4_COMPRESSION_T85:
//case T4_COMPRESSION_T85_L0:
s->output_encoding = encoding;
return 0;
}
return -1;
s->supported_output_compressions = supported_compressions;
s->output_encoding = supported_compressions;
return 0;
}
/*- End of function --------------------------------------------------------*/
......@@ -694,14 +686,14 @@ SPAN_DECLARE(int) t30_set_supported_modems(t30_state_t *s, int supported_modems)
SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_compressions)
{
/* Mask out the ones we actually support today. */
supported_compressions &= T30_SUPPORT_COMPRESSION_T4_1D
| T30_SUPPORT_COMPRESSION_T4_2D
| T30_SUPPORT_COMPRESSION_T6
| T30_SUPPORT_COMPRESSION_T85
| T30_SUPPORT_COMPRESSION_T85_L0
//| T30_SUPPORT_COMPRESSION_T81
supported_compressions &= T4_SUPPORT_COMPRESSION_T4_1D
| T4_SUPPORT_COMPRESSION_T4_2D
| T4_SUPPORT_COMPRESSION_T6
| T4_SUPPORT_COMPRESSION_T85
| T4_SUPPORT_COMPRESSION_T85_L0
//| T4_SUPPORT_COMPRESSION_T81
#if defined(SPANDSP_SUPPORT_T43)
| T30_SUPPORT_COMPRESSION_T43
| T4_SUPPORT_COMPRESSION_T43
#endif
| 0;
s->supported_compressions = supported_compressions;
......
差异被折叠。
......@@ -107,6 +107,8 @@ SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding)
return "T.85";
case T4_COMPRESSION_T85_L0:
return "T.85(L0)";
case T4_COMPRESSION_T88:
return "T.88";
case T4_COMPRESSION_T42_T81:
return "T.81";
case T4_COMPRESSION_SYCC_T81:
......
......@@ -104,12 +104,12 @@ static void t4_tx_set_image_length(t4_tx_state_t *s, int image_length);
static const res_table_t x_res_table[] =
{
//{ 100.0f/CM_PER_INCH, T4_X_RESOLUTION_100},
{ 100.0f/CM_PER_INCH, T4_X_RESOLUTION_100},
{ 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4},
//{ 200.0f/CM_PER_INCH, T4_X_RESOLUTION_200},
{ 200.0f/CM_PER_INCH, T4_X_RESOLUTION_200},
{ 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8},
{ 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300},
//{ 400.0f/CM_PER_INCH, T4_X_RESOLUTION_400},
{ 400.0f/CM_PER_INCH, T4_X_RESOLUTION_400},
{ 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16},
{ 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600},
{ 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800},
......@@ -120,12 +120,12 @@ static const res_table_t x_res_table[] =
static const res_table_t y_res_table[] =
{
{ 38.50f, T4_Y_RESOLUTION_STANDARD},
//{ 100.0f/CM_PER_INCH, T4_Y_RESOLUTION_100},
{ 100.0f/CM_PER_INCH, T4_Y_RESOLUTION_100},
{ 77.00f, T4_Y_RESOLUTION_FINE},
//{ 200.0f/CM_PER_INCH, T4_Y_RESOLUTION_200},
{ 200.0f/CM_PER_INCH, T4_Y_RESOLUTION_200},
{ 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300},
{ 154.00f, T4_Y_RESOLUTION_SUPERFINE},
//{ 400.0f/CM_PER_INCH, T4_Y_RESOLUTION_400},
{ 400.0f/CM_PER_INCH, T4_Y_RESOLUTION_400},
{ 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600},
{ 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800},
{1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200},
......@@ -385,7 +385,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
best_y_entry = 0;
s->metadata.y_resolution = y_res_table[best_y_entry].code;
//s->metadata.resolution_code = resolution_map[best_y_entry][best_x_entry];
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);
......
差异被折叠。
......@@ -861,24 +861,15 @@ int main(int argc, char *argv[])
| T4_SUPPORT_RESOLUTION_600_1200
| T4_SUPPORT_RESOLUTION_1200_1200);
t30_set_supported_colour_resolutions(t30_state[i], 0);
//t30_set_rx_encoding(t30_state[i], T4_COMPRESSION_T85);
//t30_set_rx_encoding(t30_state[i], T4_COMPRESSION_T6);
t30_set_ecm_capability(t30_state[i], use_ecm);
if (use_ecm)
{
t30_set_supported_compressions(t30_state[i],
T30_SUPPORT_COMPRESSION_T4_1D
| T30_SUPPORT_COMPRESSION_T4_2D
| T30_SUPPORT_COMPRESSION_T6
//| T30_SUPPORT_COMPRESSION_T81
| T30_SUPPORT_COMPRESSION_T85
| T30_SUPPORT_COMPRESSION_T85_L0);
}
else
{
t30_set_supported_compressions(t30_state[i],
T30_SUPPORT_COMPRESSION_T4_1D
| T30_SUPPORT_COMPRESSION_T4_2D);
}
t30_set_supported_compressions(t30_state[i],
T4_SUPPORT_COMPRESSION_T4_1D
| T4_SUPPORT_COMPRESSION_T4_2D
| T4_SUPPORT_COMPRESSION_T6
//| T4_SUPPORT_COMPRESSION_t42_T81
| T4_SUPPORT_COMPRESSION_T85
| T4_SUPPORT_COMPRESSION_T85_L0);
t30_set_minimum_scan_line_time(t30_state[i], scan_line_time);
if (mode[i] == T38_GATEWAY_FAX)
......@@ -954,6 +945,10 @@ int main(int argc, char *argv[])
logging = fax_get_logging_state(fax_state[i]);
span_log_bump_samples(logging, SAMPLES_PER_CHUNK);
#if 0
/* Mute the signal */
vec_zeroi16(fax_rx_buf[i], SAMPLES_PER_CHUNK);
#endif
fax_rx(fax_state[i], fax_rx_buf[i], SAMPLES_PER_CHUNK);
if (!t30_call_active(t30_state[i]))
{
......
......@@ -106,9 +106,9 @@ static const struct command_response_s fax_send_test_seq[] =
EXCHANGE("AT+FRH=3\r", "\r\nCONNECT\r\n"),
//<DIS frame data>
#if 1
RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\x78\x57\x10\x03"), // For audio FAXing
RESPONSE("\xFF\x13\x80\x00\xEE\xF8\x80\x80\x89\x80\x80\x80\x18\x18\xB9\x10\x03"), // For audio FAXing
#else
RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x91\x80\x80\x80\x18\xE4\xE7\x10\x03"), // For T.38 FAXing
RESPONSE("\xFF\x13\x80\x04\xEE\xF8\x80\x80\x89\x80\x80\x80\x18\x84\x09\x10\x03"), // For T.38 FAXing
#endif
RESPONSE("\r\nOK\r\n"),
//EXCHANGE("AT+FRH=3\r", "\r\nNO CARRIER\r\n"),
......@@ -870,7 +870,7 @@ static int t30_tests(int t38_mode, int use_gui, int log_audio, int test_sending,
if (!done || !sequence_terminated)
{
printf("Tests failed\n");
return 2;
return -1;
}
return 0;
......@@ -934,7 +934,8 @@ int main(int argc, char *argv[])
}
}
t30_tests(t38_mode, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no);
if (t30_tests(t38_mode, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no) < 0)
return 2;
printf("Tests passed\n");
return 0;
}
......
......@@ -440,7 +440,7 @@ int main(int argc, char *argv[])
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30, T30_SUPPORT_COMPRESSION_T4_1D | T30_SUPPORT_COMPRESSION_T4_2D | T30_SUPPORT_COMPRESSION_T6 | T30_SUPPORT_COMPRESSION_T85);
t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6 | T4_SUPPORT_COMPRESSION_T85);
if (pcap_scan_pkts(input_file_name, src_addr, src_port, dest_addr, dest_port, t38_terminal_timing_update, process_packet, NULL))
exit(2);
......@@ -497,7 +497,7 @@ int main(int argc, char *argv[])
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'B');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'B');
t30_set_ecm_capability(t30, use_ecm);
t30_set_supported_compressions(t30, T30_SUPPORT_COMPRESSION_T4_1D | T30_SUPPORT_COMPRESSION_T4_2D | T30_SUPPORT_COMPRESSION_T6);
t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6);
logging = fax_get_logging_state(fax_state);
span_log_set_level(logging, SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
......
......@@ -47,7 +47,6 @@
#include <tif_dir.h>
#endif
//#define IN_FILE_NAME "../test-data/itu/t24/F21_200.TIF"
#define IN_FILE_NAME "../test-data/itu/t24/F21B400.TIF"
#define OUT_FILE_NAME "t42_tests_receive.tif"
......
......@@ -409,7 +409,7 @@ static void fax_prepare(void)
| T4_SUPPORT_RESOLUTION_1200_1200);
t30_set_supported_colour_resolutions(t30, 0);
t30_set_supported_modems(t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17);
t30_set_supported_compressions(t30, T30_SUPPORT_COMPRESSION_T4_1D | T30_SUPPORT_COMPRESSION_T4_2D | T30_SUPPORT_COMPRESSION_T6);
t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6);
t30_set_phase_b_handler(t30, phase_b_handler, (void *) (intptr_t) 'A');
t30_set_phase_d_handler(t30, phase_d_handler, (void *) (intptr_t) 'A');
t30_set_phase_e_handler(t30, phase_e_handler, (void *) (intptr_t) 'A');
......@@ -882,7 +882,7 @@ static int next_step(faxtester_state_t *s)
t30 = fax_get_t30_state(fax);
t30_set_rx_file(t30, output_tiff_file_name, -1);
/* Avoid libtiff 3.8.2 and earlier bug on complex 2D lines. */
t30_set_rx_encoding(t30, T4_COMPRESSION_T4_1D);
t30_set_supported_output_compressions(t30, T4_COMPRESSION_T4_1D);
if (value)
{
sprintf(path, "%s/%s", image_path, (const char *) value);
......@@ -897,7 +897,7 @@ static int next_step(faxtester_state_t *s)
next_tx_file[0] = '\0';
t30 = fax_get_t30_state(fax);
/* Avoid libtiff 3.8.2 and earlier bug on complex 2D lines. */
t30_set_rx_encoding(t30, T4_COMPRESSION_T4_1D);
t30_set_supported_output_compressions(t30, T4_COMPRESSION_T4_1D);
if (value)
{
sprintf(path, "%s/%s", image_path, (const char *) value);
......
......@@ -890,11 +890,11 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
}
if (pvt->use_ecm) {
t30_set_supported_compressions(t30, T30_SUPPORT_COMPRESSION_T4_1D | T30_SUPPORT_COMPRESSION_T4_2D | T30_SUPPORT_COMPRESSION_T6 | T30_SUPPORT_COMPRESSION_T85 | T30_SUPPORT_COMPRESSION_T85_L0);
t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D | T4_SUPPORT_COMPRESSION_T6 | T4_SUPPORT_COMPRESSION_T85 | T4_SUPPORT_COMPRESSION_T85_L0);
t30_set_ecm_capability(t30, TRUE);
switch_channel_set_variable(channel, "fax_ecm_requested", "1");
} else {
t30_set_supported_compressions(t30, T30_SUPPORT_COMPRESSION_T4_1D | T30_SUPPORT_COMPRESSION_T4_2D);
t30_set_supported_compressions(t30, T4_SUPPORT_COMPRESSION_T4_1D | T4_SUPPORT_COMPRESSION_T4_2D);
switch_channel_set_variable(channel, "fax_ecm_requested", "0");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论