diff --git a/libs/spandsp/src/spandsp/image_translate.h b/libs/spandsp/src/spandsp/image_translate.h index f356f9847c..087ef3f583 100644 --- a/libs/spandsp/src/spandsp/image_translate.h +++ b/libs/spandsp/src/spandsp/image_translate.h @@ -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. diff --git a/libs/spandsp/src/spandsp/private/t4_tx.h b/libs/spandsp/src/spandsp/private/t4_tx.h index e85861f50f..e691758fc5 100644 --- a/libs/spandsp/src/spandsp/private/t4_tx.h +++ b/libs/spandsp/src/spandsp/private/t4_tx.h @@ -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; diff --git a/libs/spandsp/src/spandsp/t30.h b/libs/spandsp/src/spandsp/t30.h index 3b514b48da..2ba1330538 100644 --- a/libs/spandsp/src/spandsp/t30.h +++ b/libs/spandsp/src/spandsp/t30.h @@ -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. */ diff --git a/libs/spandsp/src/spandsp/t43.h b/libs/spandsp/src/spandsp/t43.h index decb92843a..c6718d18ff 100644 --- a/libs/spandsp/src/spandsp/t43.h +++ b/libs/spandsp/src/spandsp/t43.h @@ -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. diff --git a/libs/spandsp/src/spandsp/t4_rx.h b/libs/spandsp/src/spandsp/t4_rx.h index e415cdcb4a..b3f114dc5f 100644 --- a/libs/spandsp/src/spandsp/t4_rx.h +++ b/libs/spandsp/src/spandsp/t4_rx.h @@ -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; diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index 3b1346a6eb..2761d05669 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -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; diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index ef75ae79b8..0891486c11 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -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} }; diff --git a/libs/spandsp/tests/fax_utils.c b/libs/spandsp/tests/fax_utils.c index b6f075da6d..5c94e899ce 100644 --- a/libs/spandsp/tests/fax_utils.c +++ b/libs/spandsp/tests/fax_utils.c @@ -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); diff --git a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c index c4da0db931..560ef04fde 100644 --- a/src/mod/applications/mod_spandsp/mod_spandsp_fax.c +++ b/src/mod/applications/mod_spandsp/mod_spandsp_fax.c @@ -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); }