mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-30 10:15:52 +00:00
More tweaks towards colour FAXing
This commit is contained in:
parent
0b6c53217a
commit
3b595efc60
@ -74,6 +74,8 @@ SPAN_DECLARE(int) image_translate_get_output_length(image_translate_state_t *s);
|
||||
\return 0 for success, else -1. */
|
||||
SPAN_DECLARE(int) image_translate_set_row_read_handler(image_translate_state_t *s, t4_row_read_handler_t row_read_handler, void *row_read_user_data);
|
||||
|
||||
SPAN_DECLARE(int) image_translate_restart(image_translate_state_t *s, int input_length);
|
||||
|
||||
/*! \brief Initialise an image translation context for rescaling and squashing a gray scale
|
||||
or colour image to a bi-level FAX type image.
|
||||
\param s The image translation context.
|
||||
|
@ -163,6 +163,10 @@ struct t4_tx_state_s
|
||||
} encoder;
|
||||
|
||||
image_translate_state_t translator;
|
||||
uint8_t *pack_buf;
|
||||
int pack_ptr;
|
||||
int pack_row;
|
||||
int pack_bit_mask;
|
||||
|
||||
int apply_lab;
|
||||
lab_params_t lab_params;
|
||||
|
@ -479,7 +479,7 @@ typedef struct
|
||||
/*! \brief The size of the image, in bytes */
|
||||
int image_size;
|
||||
/*! \brief The type of compression used between the FAX machines */
|
||||
int encoding;
|
||||
int compression;
|
||||
/*! \brief The number of bad pixel rows in the most recent page. */
|
||||
int bad_rows;
|
||||
/*! \brief The largest number of bad pixel rows in a block in the most recent page. */
|
||||
|
@ -41,6 +41,17 @@ 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;
|
||||
|
||||
enum
|
||||
{
|
||||
T43_IMAGE_TYPE_RGB_BILEVEL = 0,
|
||||
T43_IMAGE_TYPE_CMY_BILEVEL = 1,
|
||||
T43_IMAGE_TYPE_CMYK_BILEVEL = 2,
|
||||
T43_IMAGE_TYPE_8BIT_COLOUR_PALETTE = 16,
|
||||
T43_IMAGE_TYPE_12BIT_COLOUR_PALETTE = 17,
|
||||
T43_IMAGE_TYPE_GRAY = 32,
|
||||
T43_IMAGE_TYPE_COLOUR = 48
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
@ -59,6 +70,8 @@ SPAN_DECLARE(int) t43_encode_set_image_length(t43_encode_state_t *s, uint32_t le
|
||||
|
||||
SPAN_DECLARE(void) t43_encode_abort(t43_encode_state_t *s);
|
||||
|
||||
SPAN_DECLARE(int) t43_encode_set_image_type(t43_encode_state_t *s, int image_type);
|
||||
|
||||
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.
|
||||
@ -114,8 +127,6 @@ SPAN_DECLARE(int) t43_encode_release(t43_encode_state_t *s);
|
||||
\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.
|
||||
|
@ -139,14 +139,13 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
T4_X_RESOLUTION_100 = 3937,
|
||||
T4_X_RESOLUTION_R4 = 4016,
|
||||
T4_X_RESOLUTION_R4 = 4020,
|
||||
T4_X_RESOLUTION_200 = 7874,
|
||||
T4_X_RESOLUTION_R8 = 8031,
|
||||
T4_X_RESOLUTION_R8 = 8040,
|
||||
T4_X_RESOLUTION_300 = 11811,
|
||||
T4_X_RESOLUTION_400 = 15748,
|
||||
T4_X_RESOLUTION_R16 = 16063,
|
||||
T4_X_RESOLUTION_R16 = 16080,
|
||||
T4_X_RESOLUTION_600 = 23622,
|
||||
T4_X_RESOLUTION_800 = 31496,
|
||||
T4_X_RESOLUTION_1200 = 47244
|
||||
} t4_image_x_resolution_t;
|
||||
|
||||
|
@ -6704,7 +6704,7 @@ SPAN_DECLARE(void) t30_get_transfer_statistics(t30_state_t *s, t30_stats_t *t)
|
||||
t->width = stats.width;
|
||||
t->length = stats.length;
|
||||
|
||||
t->encoding = stats.encoding;
|
||||
t->compression = stats.encoding;
|
||||
t->image_size = stats.line_image_size;
|
||||
t->current_status = s->current_status;
|
||||
t->rtn_events = s->rtn_events;
|
||||
|
@ -112,7 +112,6 @@ static const res_table_t x_res_table[] =
|
||||
{ 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},
|
||||
{1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200},
|
||||
{ -1.00f, -1}
|
||||
};
|
||||
|
@ -103,7 +103,7 @@ void fax_log_page_transfer_statistics(t30_state_t *s, const char *tag)
|
||||
printf("%s: Pages in the file %d\n", tag, t.pages_in_file);
|
||||
printf("%s: Bad rows %d, longest bad row run %d\n", tag, t.bad_rows, t.longest_bad_row_run);
|
||||
printf("%s: Bad ECM frames %d\n", tag, t.error_correcting_mode_retries);
|
||||
printf("%s: Compression type %s (%d)\n", tag, t4_encoding_to_str(t.encoding), t.encoding);
|
||||
printf("%s: Compression type %s (%d)\n", tag, t4_encoding_to_str(t.compression), t.compression);
|
||||
printf("%s: Compressed image size %d bytes\n", tag, t.image_size);
|
||||
printf("%s: Image type %s (%s in the file)\n", tag, t4_image_type_to_str(t.type), t4_image_type_to_str(t.image_type));
|
||||
printf("%s: Image size %d pels x %d pels (%d pels x %d pels in the file)\n", tag, t.width, t.length, t.image_width, t.image_length);
|
||||
|
@ -427,12 +427,12 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
|
||||
switch_channel_set_variable(channel, "fax_longest_bad_row_run", fax_longest_bad_row_run);
|
||||
}
|
||||
|
||||
fax_encoding = switch_core_session_sprintf(session, "%d", t30_stats.encoding);
|
||||
fax_encoding = switch_core_session_sprintf(session, "%d", t30_stats.compression);
|
||||
if (fax_encoding) {
|
||||
switch_channel_set_variable(channel, "fax_encoding", fax_encoding);
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, "fax_encoding_name", t4_encoding_to_str(t30_stats.encoding));
|
||||
switch_channel_set_variable(channel, "fax_encoding_name", t4_encoding_to_str(t30_stats.compression));
|
||||
|
||||
fax_document_transferred_pages = switch_core_session_sprintf(session, "%d", (pvt->app_mode == FUNCTION_TX) ? t30_stats.pages_tx : t30_stats.pages_rx);
|
||||
if (fax_document_transferred_pages) {
|
||||
@ -445,7 +445,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image type = %s (%s in the file)\n", t4_image_type_to_str(t30_stats.type), t4_image_type_to_str(t30_stats.image_type));
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image size = %d x %d pixels (%d x %d pixels in the file)\n", t30_stats.width, t30_stats.length, t30_stats.image_width, t30_stats.image_length);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image resolution = %d/m x %d/m (%d/m x %d/m in the file)\n", t30_stats.x_resolution, t30_stats.y_resolution, t30_stats.image_x_resolution, t30_stats.image_y_resolution);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compression = %s (%d)\n", t4_encoding_to_str(t30_stats.encoding), t30_stats.encoding);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compression = %s (%d)\n", t4_encoding_to_str(t30_stats.compression), t30_stats.compression);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Compressed image size = %d bytes\n", t30_stats.image_size);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Bad rows = %d\n", t30_stats.bad_rows);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Longest bad row run = %d\n", t30_stats.longest_bad_row_run);
|
||||
@ -466,7 +466,7 @@ static int phase_d_handler(t30_state_t *s, void *user_data, int msg)
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-bad-rows", fax_bad_rows);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-longest-bad-row-run", fax_longest_bad_row_run);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding", fax_encoding);
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding-name", t4_encoding_to_str(t30_stats.encoding));
|
||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "fax-encoding-name", t4_encoding_to_str(t30_stats.compression));
|
||||
switch_event_fire(&event);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user