]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
More tweaks towards colour FAXing
authorSteve Underwood <steveu@coppice.org>
Wed, 29 May 2013 01:53:56 +0000 (09:53 +0800)
committerSteve Underwood <steveu@coppice.org>
Wed, 29 May 2013 01:53:56 +0000 (09:53 +0800)
libs/spandsp/src/spandsp/image_translate.h
libs/spandsp/src/spandsp/private/t4_tx.h
libs/spandsp/src/spandsp/t30.h
libs/spandsp/src/spandsp/t43.h
libs/spandsp/src/spandsp/t4_rx.h
libs/spandsp/src/t30.c
libs/spandsp/src/t4_tx.c
libs/spandsp/tests/fax_utils.c
src/mod/applications/mod_spandsp/mod_spandsp_fax.c

index f356f9847c0381d4586811eefe8ce9310191d596..087ef3f583232db8eb0a0ef1f2ba16bc9573562e 100644 (file)
@@ -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.
index e85861f50ff542998f7d87c719e7dfd24a817e16..e691758fc5c16e6e6c9bfb61285727e507533265 100644 (file)
@@ -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;
index 3b514b48da02081b35f22567b9f8b0bdece754ad..2ba1330538aae966aca817e9a832ab3b9e773446 100644 (file)
@@ -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. */
index decb92843af3ede76db50fa33817fdcf15f88c5d..c6718d18ff37addfcd7028e3ca8f24ca737fc781 100644 (file)
@@ -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.
index e415cdcb4a20b0764cbd3a372f4ba34b03d2a903..b3f114dc5fcf2fec20b29251b2516173c42b70af 100644 (file)
@@ -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;
 
index 3b1346a6eb6681cd97b9e5bb0aebce9690c5fba6..2761d0566919fc23fb68eb1e561672c303077e15 100644 (file)
@@ -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;
index ef75ae79b80229e8b51a1e7b4c5501f6b3e15ef6..0891486c11d02d54ebc4e72640e653ac48f09e09 100644 (file)
@@ -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}
 };
index b6f075da6d45886008c182978df3d10405fa36db..5c94e899ce2c87c433428415c273600d9c5640c8 100644 (file)
@@ -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);
index c4da0db9318b8df60a3d0c9fabf6966e283f53cf..560ef04fdeb08ae85405c0b4bd2ebe11efb531cf 100644 (file)
@@ -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);
        }