]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Improvements to T.4 end of image handling, and the related tests.
authorSteve Underwood <steveu@coppice.org>
Sun, 12 Aug 2012 14:11:06 +0000 (22:11 +0800)
committerSteve Underwood <steveu@coppice.org>
Sun, 12 Aug 2012 14:11:06 +0000 (22:11 +0800)
A lot of tiny tidy up edits

80 files changed:
libs/spandsp/src/ademco_contactid.c
libs/spandsp/src/at_interpreter.c
libs/spandsp/src/awgn.c
libs/spandsp/src/bell_r2_mf.c
libs/spandsp/src/bert.c
libs/spandsp/src/echo.c
libs/spandsp/src/g711.c
libs/spandsp/src/g726.c
libs/spandsp/src/gsm0610_encode.c
libs/spandsp/src/gsm0610_long_term.c
libs/spandsp/src/gsm0610_lpc.c
libs/spandsp/src/hdlc.c
libs/spandsp/src/ima_adpcm.c
libs/spandsp/src/logging.c
libs/spandsp/src/modem_echo.c
libs/spandsp/src/oki_adpcm.c
libs/spandsp/src/spandsp/t30.h
libs/spandsp/src/spandsp/t42.h
libs/spandsp/src/spandsp/t4_rx.h
libs/spandsp/src/spandsp/t4_t6_decode.h
libs/spandsp/src/spandsp/t4_t6_encode.h
libs/spandsp/src/spandsp/t4_tx.h
libs/spandsp/src/spandsp/t85.h
libs/spandsp/src/super_tone_rx.c
libs/spandsp/src/super_tone_tx.c
libs/spandsp/src/t30.c
libs/spandsp/src/t31.c
libs/spandsp/src/t38_terminal.c
libs/spandsp/src/t42.c
libs/spandsp/src/t4_rx.c
libs/spandsp/src/t4_t6_decode.c
libs/spandsp/src/t4_t6_encode.c
libs/spandsp/src/t4_tx.c
libs/spandsp/src/t85_decode.c
libs/spandsp/src/t85_encode.c
libs/spandsp/src/testcpuid.c
libs/spandsp/src/time_scale.c
libs/spandsp/src/tone_generate.c
libs/spandsp/tests/async_tests.c
libs/spandsp/tests/at_interpreter_tests.c
libs/spandsp/tests/awgn_tests.c
libs/spandsp/tests/bell_mf_tx_tests.c
libs/spandsp/tests/bert_tests.c
libs/spandsp/tests/crc_tests.c
libs/spandsp/tests/dc_restore_tests.c
libs/spandsp/tests/dds_tests.c
libs/spandsp/tests/dtmf_tx_tests.c
libs/spandsp/tests/echo_tests.c
libs/spandsp/tests/fax_decode.c
libs/spandsp/tests/fax_tests.c
libs/spandsp/tests/fsk_tests.c
libs/spandsp/tests/g168_tests.c
libs/spandsp/tests/hdlc_tests.c
libs/spandsp/tests/make_g168_css.c
libs/spandsp/tests/modem_connect_tones_tests.c
libs/spandsp/tests/modem_echo_tests.c
libs/spandsp/tests/noise_tests.c
libs/spandsp/tests/r2_mf_tx_tests.c
libs/spandsp/tests/regression_tests.sh
libs/spandsp/tests/saturated_tests.c
libs/spandsp/tests/schedule_tests.c
libs/spandsp/tests/sig_tone_tests.c
libs/spandsp/tests/super_tone_rx_tests.c
libs/spandsp/tests/super_tone_tx_tests.c
libs/spandsp/tests/swept_tone_tests.c
libs/spandsp/tests/t31_tests.c
libs/spandsp/tests/t35_tests.c
libs/spandsp/tests/t38_core_tests.c
libs/spandsp/tests/t38_non_ecm_buffer_tests.c
libs/spandsp/tests/t42_tests.c
libs/spandsp/tests/t4_t6_tests.c
libs/spandsp/tests/t4_tests.c
libs/spandsp/tests/t85_tests.c
libs/spandsp/tests/tone_detect_tests.c
libs/spandsp/tests/tone_generate_tests.c
libs/spandsp/tests/tsb85_tests.c
libs/spandsp/tests/v17_tests.c
libs/spandsp/tests/v22bis_tests.c
libs/spandsp/tests/v29_tests.c
libs/spandsp/tests/v42_tests.c

index 1ba11f47636d5a82061a69402aa60b6b172c973b..39ce670bde13fe9072061e1ed126851574653e53 100644 (file)
@@ -683,7 +683,7 @@ SPAN_DECLARE(ademco_contactid_receiver_state_t *) ademco_contactid_receiver_init
     if (s == NULL)
     {
         if ((s = (ademco_contactid_receiver_state_t *) malloc(sizeof (*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     memset(s, 0, sizeof(*s));
     span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
@@ -1020,7 +1020,7 @@ SPAN_DECLARE(ademco_contactid_sender_state_t *) ademco_contactid_sender_init(ade
     if (s == NULL)
     {
         if ((s = (ademco_contactid_sender_state_t *) malloc(sizeof (*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     memset(s, 0, sizeof(*s));
     span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
index ba29e55469cc7d20ac591e78e2a2d157c5091fdc..9342cfc58d760e7b9e33ee518f4188f28d06bfd3 100644 (file)
@@ -434,13 +434,13 @@ static int match_element(const char **variant, const char *variants)
         if (len == (int) strlen(*variant)  &&  memcmp(*variant, s, len) == 0)
         {
             *variant += len;
-            return  i;
+            return i;
         }
         s += len;
         if (*s == ',')
             s++;
     }
-    return  -1;
+    return -1;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -804,7 +804,7 @@ static int process_class1_cmd(at_state_t *s, const char **t)
     if (val < 0)
     {
         /* It was just a query */
-        return  TRUE;
+        return TRUE;
     }
     /* All class 1 FAX commands are supposed to give an ERROR response, if the phone
        is on-hook. */
index e97dd6be0bdfe34af71e3153ac3698cf9e0def7c..b432901bb2d02c8dc589e4098af83e2de4c431e0 100644 (file)
@@ -101,7 +101,7 @@ SPAN_DECLARE(awgn_state_t *) awgn_init_dbov(awgn_state_t *s, int idum, float lev
     if (s == NULL)
     {
         if ((s = (awgn_state_t *) malloc(sizeof(*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     if (idum < 0)
         idum = -idum;
index 1487a821f5a9ca05943f7397ceb8a8aef19e83a1..d22b4c05f28dd1984de3d656e477bc0d68b76dfc 100644 (file)
@@ -621,7 +621,7 @@ SPAN_DECLARE(size_t) bell_mf_rx_get(bell_mf_rx_state_t *s, char *buf, int max)
         s->current_digits -= max;
     }
     buf[max] = '\0';
-    return  max;
+    return max;
 }
 /*- End of function --------------------------------------------------------*/
 
index c697b39a7a94930a83038823e0a55fbfc7407250..4ba0c335f7a7efe1edb619e6bb310527f813f284 100644 (file)
@@ -491,7 +491,7 @@ SPAN_DECLARE(bert_state_t *) bert_init(bert_state_t *s, int limit, int pattern,
     span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
     span_log_set_protocol(&s->logging, "BERT");
 
-    return  s;
+    return s;
 }
 /*- End of function --------------------------------------------------------*/
 
index 13a685d316e77e4a13174f9b9e0e060dfc43b0d1..0b1aaac2aa2b125a4818732037944405ac0201c3 100644 (file)
@@ -245,7 +245,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode)
     int j;
 
     if ((ec = (echo_can_state_t *) malloc(sizeof(*ec))) == NULL)
-        return  NULL;
+        return NULL;
     memset(ec, 0, sizeof(*ec));
     ec->taps = len;
     ec->curr_pos = ec->taps - 1;
@@ -253,7 +253,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode)
     if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL)
     {
         free(ec);
-        return  NULL;
+        return NULL;
     }
     memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t));
     for (i = 0;  i < 4;  i++)
@@ -264,7 +264,7 @@ SPAN_DECLARE(echo_can_state_t *) echo_can_init(int len, int adaption_mode)
                 free(ec->fir_taps16[j]);
             free(ec->fir_taps32);
             free(ec);
-            return  NULL;
+            return NULL;
         }
         memset(ec->fir_taps16[i], 0, ec->taps*sizeof(int16_t));
     }
index 17403d8f92a3868d22c8708538756c142153915c..173bd2ae5370eab50a4ce3e54b5074423cbc5910 100644 (file)
@@ -172,7 +172,7 @@ SPAN_DECLARE(g711_state_t *) g711_init(g711_state_t *s, int mode)
     if (s == NULL)
     {
         if ((s = (g711_state_t *) malloc(sizeof(*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     s->mode = mode;
     return s;
index 2bf1236d80ad74756266cac2a7aba50006fa6ffe..1f2fb2ffd3fb873b928e361e6f4fe21df32f0dee 100644 (file)
@@ -1004,7 +1004,7 @@ SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_co
     if (s == NULL)
     {
         if ((s = (g726_state_t *) malloc(sizeof(*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     s->yl = 34816;
     s->yu = 544;
index 10a27540df96072d31613e367b5a511addfe9eec..c49ed1e93b9406a342ac04bcca8c755a7445aad2 100644 (file)
@@ -116,7 +116,7 @@ SPAN_DECLARE(gsm0610_state_t *) gsm0610_init(gsm0610_state_t *s, int packing)
     if (s == NULL)
     {
         if ((s = (gsm0610_state_t *) malloc(sizeof (*s))) == NULL)
-            return  NULL;
+            return NULL;
         /*endif*/
     }
     /*endif*/
index d2578325261cbfc58556fbe5cf7e62761db8a662..32d4ab39b7189208012836ea35e25ec25891b601 100644 (file)
@@ -321,10 +321,10 @@ static int16_t evaluate_ltp_parameters(int16_t d[40],
 
     /* Normalization of L_max and L_power */
     if (L_max <= 0)
-        return  0;
+        return 0;
     /*endif*/
     if (L_max >= L_power)
-        return  3;
+        return 3;
     /*endif*/
     temp = gsm0610_norm(L_power);
 
index 4b2c553d87250867ece75bdd9b4454353e130d40..aa1ab08e8625655f4b0c9819b0f010ab19353011 100644 (file)
@@ -78,7 +78,7 @@ int16_t gsm0610_norm(int32_t x)
     if (x < 0)
     {
         if (x <= -1073741824)
-            return  0;
+            return 0;
         /*endif*/
         x = ~x;
     }
@@ -108,7 +108,7 @@ static int16_t gsm_div(int16_t num, int16_t denom)
 
     assert(num >= 0  &&  denom >= num);
     if (num == 0)
-        return  0;
+        return 0;
     /*endif*/
     num32 = num;
     denom32 = denom;
@@ -128,7 +128,7 @@ static int16_t gsm_div(int16_t num, int16_t denom)
     }
     /*endwhile*/
 
-    return  div;
+    return div;
 }
 /*- End of function --------------------------------------------------------*/
 
index d08ab1a05e4644ca95df7b59056b17e0493371d8..951b44eb7cd2967a066d6a64352b86c6657e7cdf 100644 (file)
@@ -558,7 +558,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_bit(hdlc_tx_state_t *s)
     }
     s->bits--;
     txbit = (s->byte >> s->bits) & 0x01;
-    return  txbit;
+    return txbit;
 }
 /*- End of function --------------------------------------------------------*/
 
index 299d0d113774c7713b40d35820be8596ef02ebd3..6c4cc1637038cd1f765b296942ad11aa9c175499 100644 (file)
@@ -283,13 +283,13 @@ SPAN_DECLARE(ima_adpcm_state_t *) ima_adpcm_init(ima_adpcm_state_t *s,
     if (s == NULL)
     {
         if ((s = (ima_adpcm_state_t *) malloc(sizeof(*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     /*endif*/
     memset(s, 0, sizeof(*s));
     s->variant = variant;
     s->chunk_size = chunk_size;
-    return  s;
+    return s;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -503,7 +503,7 @@ SPAN_DECLARE(int) ima_adpcm_encode(ima_adpcm_state_t *s,
         break;
     }
     /*endswitch*/
-    return  bytes;
+    return bytes;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 589a746106f28c8c5f0e7e98a3ca5b5099d0b7b3..3f9aa58f17e7b7636f30ba5e514d5472482d8dee 100644 (file)
@@ -144,10 +144,10 @@ SPAN_DECLARE(int) span_log(logging_state_t *s, int level, const char *format, ..
             __span_message(s->user_data, level, msg);
         /*endif*/
         va_end(arg_ptr);
-        return  1;
+        return 1;
     }
     /*endif*/
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -175,7 +175,7 @@ SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level)
 {
     s->level = level;
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -183,7 +183,7 @@ SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag)
 {
     s->tag = tag;
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -191,7 +191,7 @@ SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol
 {
     s->protocol = protocol;
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -199,7 +199,7 @@ SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_s
 {
     s->samples_per_second = samples_per_second;
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -207,7 +207,7 @@ SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples)
 {
     s->elapsed_samples += samples;
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
index e4203e15e5a3086ea77aa31b0857c3a9b8100ed1..14257c7eb7f7ccad4b43e1b0d4165c2e74b192f7 100644 (file)
@@ -67,21 +67,21 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len)
     modem_echo_can_state_t *ec;
 
     if ((ec = (modem_echo_can_state_t *) malloc(sizeof(*ec))) == NULL)
-        return  NULL;
+        return NULL;
     memset(ec, 0, sizeof(*ec));
     ec->taps = len;
     ec->curr_pos = ec->taps - 1;
     if ((ec->fir_taps32 = (int32_t *) malloc(ec->taps*sizeof(int32_t))) == NULL)
     {
         free(ec);
-        return  NULL;
+        return NULL;
     }
     memset(ec->fir_taps32, 0, ec->taps*sizeof(int32_t));
     if ((ec->fir_taps16 = (int16_t *) malloc(ec->taps*sizeof(int16_t))) == NULL)
     {
         free(ec->fir_taps32);
         free(ec);
-        return  NULL;
+        return NULL;
     }
     memset(ec->fir_taps16, 0, ec->taps*sizeof(int16_t));
     if (fir16_create(&ec->fir_state, ec->fir_taps16, ec->taps) == NULL)
@@ -89,9 +89,9 @@ SPAN_DECLARE(modem_echo_can_state_t *) modem_echo_can_init(int len)
         free(ec->fir_taps16);
         free(ec->fir_taps32);
         free(ec);
-        return  NULL;
+        return NULL;
     }
-    return  ec;
+    return ec;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -170,7 +170,7 @@ SPAN_DECLARE(int16_t) modem_echo_can_update(modem_echo_can_state_t *ec, int16_t
     if (ec->curr_pos <= 0)
         ec->curr_pos = ec->taps;
     ec->curr_pos--;
-    return  (int16_t) clean_rx;
+    return (int16_t) clean_rx;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 09aea00a27ed05cbbb032eaca603ea373b2d5d31..f3fd6d9f95464599e309a530ac119e51a18ebd2a 100644 (file)
@@ -247,12 +247,12 @@ SPAN_DECLARE(oki_adpcm_state_t *) oki_adpcm_init(oki_adpcm_state_t *s, int bit_r
     if (s == NULL)
     {
         if ((s = (oki_adpcm_state_t *) malloc(sizeof(*s))) == NULL)
-            return  NULL;
+            return NULL;
     }
     memset(s, 0, sizeof(*s));
     s->bit_rate = bit_rate;
     
-    return  s;
+    return s;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -318,7 +318,7 @@ SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s,
         /*endfor*/
     }
     /*endif*/
-    return  samples;
+    return samples;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -379,7 +379,7 @@ SPAN_DECLARE(int) oki_adpcm_encode(oki_adpcm_state_t *s,
         /*endfor*/
     }
     /*endif*/
-    return  bytes;
+    return bytes;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index ee842afea87e1cc0a03bc03dc9cdba1c4882dc6f..a954be1c364e727bede43001fefb0ed34a7a4e77 100644 (file)
@@ -625,19 +625,13 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status);
     \return The next bit to transmit. */
 SPAN_DECLARE_NONSTD(int) t30_non_ecm_get_bit(void *user_data);
 
-/*! Get a byte of received non-ECM image data.
-    \brief Get a byte of received non-ECM image data.
-    \param user_data An opaque pointer, which must point to the T.30 context.
-    \return The next byte to transmit. */
-SPAN_DECLARE(int) t30_non_ecm_get_byte(void *user_data);
-
 /*! Get a chunk of received non-ECM image data.
     \brief Get a bit of received non-ECM image data.
     \param user_data An opaque pointer, which must point to the T.30 context.
     \param buf The buffer to contain the data.
     \param max_len The maximum length of the chunk.
     \return The actual length of the chunk. */
-SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_len);
+SPAN_DECLARE(int) t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len);
 
 /*! Process a bit of received non-ECM image data.
     \brief Process a bit of received non-ECM image data
@@ -645,18 +639,12 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_
     \param bit The received bit. */
 SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit);
 
-/*! Process a byte of received non-ECM image data.
-    \brief Process a byte of received non-ECM image data
-    \param user_data An opaque pointer, which must point to the T.30 context.
-    \param byte The received byte. */
-SPAN_DECLARE(void) t30_non_ecm_put_byte(void *user_data, int byte);
-
 /*! Process a chunk of received non-ECM image data.
     \brief Process a chunk of received non-ECM image data
     \param user_data An opaque pointer, which must point to the T.30 context.
     \param buf The buffer containing the received data.
     \param len The length of the data in buf. */
-SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len);
+SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len);
 
 /*! Process a received HDLC frame.
     \brief Process a received HDLC frame.
index a1441c0406457e1138f6274aa5a00086e7db92fc..e439d1682d0b0ccb8813b3e986c0dadc57d401d0 100644 (file)
@@ -84,11 +84,9 @@ SPAN_DECLARE(void) t42_encode_comment(t42_encode_state_t *s, const uint8_t comme
 /*! \brief Check if we are at the end of the current document page.
     \param s The T.42 context.
     \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
-SPAN_DECLARE(int) t42_encode_check_if_complete(t42_encode_state_t *s);
+SPAN_DECLARE(int) t42_encode_image_complete(t42_encode_state_t *s);
 
-SPAN_DECLARE(int) t42_encode_get_byte(t42_encode_state_t *s);
-
-SPAN_DECLARE(int) t42_encode_get_chunk(t42_encode_state_t *s, uint8_t buf[], int max_len);
+SPAN_DECLARE(int) t42_encode_get(t42_encode_state_t *s, uint8_t buf[], size_t max_len);
 
 SPAN_DECLARE(uint32_t) t42_encode_get_image_width(t42_encode_state_t *s);
 
@@ -114,11 +112,7 @@ SPAN_DECLARE(int) t42_encode_free(t42_encode_state_t *s);
 
 SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status);
 
-SPAN_DECLARE(int) t42_decode_put_byte(t42_decode_state_t *s, int byte);
-
-SPAN_DECLARE(int) t42_decode_put_chunk(t42_decode_state_t *s,
-                                       const uint8_t data[],
-                                       size_t len);
+SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], size_t len);
 
 SPAN_DECLARE(int) t42_decode_set_row_write_handler(t42_decode_state_t *s,
                                                    t4_row_write_handler_t handler,
index 0d372485932393f6313fcc9fe1ddd9c8e2793a60..e77c47bfe29e6671331aca9c4df16fa5d2a1a2ae 100644 (file)
@@ -271,18 +271,12 @@ SPAN_DECLARE(int) t4_rx_start_page(t4_rx_state_t *s);
     \return TRUE when the bit ends the document page, otherwise FALSE. */
 SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit);
 
-/*! \brief Put a byte of the current document page.
-    \param s The T.4 context.
-    \param byte The data byte.
-    \return TRUE when the byte ends the document page, otherwise FALSE. */
-SPAN_DECLARE(int) t4_rx_put_byte(t4_rx_state_t *s, uint8_t byte);
-
 /*! \brief Put a byte of the current document page.
     \param s The T.4 context.
     \param buf The buffer containing the chunk.
     \param len The length of the chunk.
     \return TRUE when the byte ends the document page, otherwise FALSE. */
-SPAN_DECLARE(int) t4_rx_put_chunk(t4_rx_state_t *s, const uint8_t buf[], int len);
+SPAN_DECLARE(int) t4_rx_put(t4_rx_state_t *s, const uint8_t buf[], size_t len);
 
 /*! \brief Complete the reception of a page.
     \param s The T.4 receive context.
index f84293b9b3862ef0e3a91a08ac2120272f940d9a..fd101d3b8f0bb25fff19007161cda20ded4b195e 100644 (file)
@@ -51,18 +51,12 @@ extern "C" {
     \return TRUE when the bit ends the document page, otherwise FALSE. */
 SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit);
 
-/*! \brief Put a byte of the current document page.
-    \param s The T.4/T.6 context.
-    \param byte The data byte.
-    \return TRUE when the byte ends the document page, otherwise FALSE. */
-SPAN_DECLARE(int) t4_t6_decode_put_byte(t4_t6_decode_state_t *s, int byte);
-
 /*! \brief Put a byte of the current document page.
     \param s The T.4/T.6 context.
     \param buf The buffer containing the chunk.
     \param len The length of the chunk.
-    \return TRUE when the byte ends the document page, otherwise FALSE. */
-SPAN_DECLARE(int) t4_t6_decode_put_chunk(t4_t6_decode_state_t *s, const uint8_t buf[], int len);
+    \return T4_DECODE_MORE_DATA when the image is still in progress. T4_DECODE_OK when the image is complete. */
+SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len);
 
 /*! \brief Set the row write handler for a T.4/T.6 decode context.
     \param s The T.4/T.6 context.
index 6e30cb71f684f32818d9d2a2ac12dd14a73e9889..4d64c8cf9731abfdb14d52e323989746b4396630 100644 (file)
@@ -38,8 +38,8 @@ extern "C" {
            moving forward in the buffer. The document will be padded for the
            current minimum scan line time.
     \param s The T.4/T.6 context.
-    \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */
-SPAN_DECLARE(int) t4_t6_encode_check_bit(t4_t6_encode_state_t *s);
+    \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
+SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s);
 
 /*! \brief Get the next bit of the current image. The image will
            be padded for the current minimum scan line time. 
@@ -47,14 +47,6 @@ SPAN_DECLARE(int) t4_t6_encode_check_bit(t4_t6_encode_state_t *s);
     \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */
 SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s);
 
-/*! \brief Get the next byte of the current document page. The document will
-           be padded for the current minimum scan line time.
-    \param s The T.4/T.6 context.
-    \return The next byte. For the last byte of data, bit 8 is
-            set. In this case, one or more bits of the byte may be padded with
-            zeros, to complete the byte. */
-SPAN_DECLARE(int) t4_t6_encode_get_byte(t4_t6_encode_state_t *s);
-
 /*! \brief Get the next chunk of the current document page. The document will
            be padded for the current minimum scan line time.
     \param s The T.4/T.6 context.
@@ -62,7 +54,7 @@ SPAN_DECLARE(int) t4_t6_encode_get_byte(t4_t6_encode_state_t *s);
     \param max_len The maximum length of the chunk.
     \return The actual length of the chunk. If this is less than max_len it 
             indicates that the end of the document has been reached. */
-SPAN_DECLARE(int) t4_t6_encode_get_chunk(t4_t6_encode_state_t *s, uint8_t buf[], int max_len);
+SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len);
 
 /*! \brief Set the row read handler for a T.4/T.6 encode context.
     \param s The T.4/T.6 context.
index 5ed4940b5bf3571f7bd73463fbccb7dda7a669f2..7c100793c14da23c0b54c1aba634b341e87898f1 100644 (file)
@@ -253,8 +253,8 @@ SPAN_DECLARE(int) t4_tx_end_page(t4_tx_state_t *s);
            moving forward in the buffer. The document will be padded for the
            current minimum scan line time.
     \param s The T.4 context.
-    \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */
-SPAN_DECLARE(int) t4_tx_check_if_complete(t4_tx_state_t *s);
+    \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
+SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s);
 
 /*! \brief Get the next bit of the current document page. The document will
            be padded for the current minimum scan line time.
@@ -262,14 +262,6 @@ SPAN_DECLARE(int) t4_tx_check_if_complete(t4_tx_state_t *s);
     \return The next bit (i.e. 0 or 1). SIG_STATUS_END_OF_DATA for no more data. */
 SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s);
 
-/*! \brief Get the next byte of the current document page. The document will
-           be padded for the current minimum scan line time.
-    \param s The T.4 context.
-    \return The next byte. For the last byte of data, bit 8 is
-            set. In this case, one or more bits of the byte may be padded with
-            zeros, to complete the byte. */
-SPAN_DECLARE(int) t4_tx_get_byte(t4_tx_state_t *s);
-
 /*! \brief Get the next chunk of the current document page. The document will
            be padded for the current minimum scan line time.
     \param s The T.4 context.
@@ -277,7 +269,7 @@ SPAN_DECLARE(int) t4_tx_get_byte(t4_tx_state_t *s);
     \param max_len The maximum length of the chunk.
     \return The actual length of the chunk. If this is less than max_len it 
             indicates that the end of the document has been reached. */
-SPAN_DECLARE(int) t4_tx_get_chunk(t4_tx_state_t *s, uint8_t buf[], int max_len);
+SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len);
 
 /*! \brief End the transmission of a document. Tidy up and close the file.
            This should be used to end T.4 transmission started with t4_tx_init.
index 269ba7c6c55cc24f15e732c75da59c3f0091cf68..d599626eedb79f17806217524d6938b893a7fee5 100644 (file)
@@ -67,14 +67,7 @@ extern "C"
 /*! \brief Check if we are at the end of the current document page.
     \param s The T.85 context.
     \return 0 for more data to come. SIG_STATUS_END_OF_DATA for no more data. */
-SPAN_DECLARE(int) t85_encode_check_if_complete(t85_encode_state_t *s);
-
-/*! \brief Get the next byte of the current document page.
-    \param s The T.85 context.
-    \return The next byte. For the last byte of data, bit 8 is
-            set. In this case, one or more bits of the byte may be padded with
-            zeros, to complete the byte. */
-SPAN_DECLARE(int) t85_encode_get_byte(t85_encode_state_t *s);
+SPAN_DECLARE(int) t85_encode_image_complete(t85_encode_state_t *s);
 
 /*! \brief Get the next chunk of the current document page. The document will
            be padded for the current minimum scan line time.
@@ -83,7 +76,7 @@ SPAN_DECLARE(int) t85_encode_get_byte(t85_encode_state_t *s);
     \param max_len The maximum length of the chunk.
     \return The actual length of the chunk. If this is less than max_len it 
             indicates that the end of the document has been reached. */
-SPAN_DECLARE(int) t85_encode_get_chunk(t85_encode_state_t *s, uint8_t buf[], int max_len);
+SPAN_DECLARE(int) t85_encode_get(t85_encode_state_t *s, uint8_t buf[], size_t max_len);
 
 /*! \brief Set the row read handler for a T.85 encode context.
     \param s The T.85 context.
@@ -251,20 +244,12 @@ SPAN_DECLARE(int) t85_decode_set_image_size_constraints(t85_decode_state_t *s,
     \param status The type of status change which occured. */
 SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status);
 
-/*! \brief Decode a byte of T.85 data.
-    \param s The T.85 context.
-    \param byte The data to be decoded.
-    \return 0 for OK. */
-SPAN_DECLARE(int) t85_decode_put_byte(t85_decode_state_t *s, int byte);
-
 /*! \brief Decode a chunk of T.85 data.
     \param s The T.85 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) t85_decode_put_chunk(t85_decode_state_t *s,
-                                       const uint8_t data[],
-                                       size_t len);
+SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], size_t len);
 
 #if defined(__cplusplus)
 }
index 97b9655ea769ca9a5b10544dc00579347f7cef61..e46faa814885f3663eb1cee1035570ce84a89119 100644 (file)
@@ -161,19 +161,19 @@ static int test_cadence(super_tone_rx_segment_t *pattern,
             steps = -steps;
             j = (rotation + steps - 2)%steps;
             if (pattern[j].f1 != test[8].f1  ||  pattern[j].f2 != test[8].f2)
-                return  0;
+                return 0;
             if (pattern[j].min_duration > test[8].min_duration*SUPER_TONE_BINS
                 ||
                 pattern[j].max_duration < test[8].min_duration*SUPER_TONE_BINS)
             {
-                return  0;
+                return 0;
             }
         }
         j = (rotation + steps - 1)%steps;
         if (pattern[j].f1 != test[9].f1  ||  pattern[j].f2 != test[9].f2)
-            return  0;
+            return 0;
         if (pattern[j].max_duration < test[9].min_duration*SUPER_TONE_BINS)
-            return  0;
+            return 0;
     }
     else
     {
@@ -182,16 +182,16 @@ static int test_cadence(super_tone_rx_segment_t *pattern,
         {
             j = i + 10 - steps;
             if (pattern[i].f1 != test[j].f1  ||  pattern[i].f2 != test[j].f2)
-                return  0;
+                return 0;
             if (pattern[i].min_duration > test[j].min_duration*SUPER_TONE_BINS
                 ||
                 pattern[i].max_duration < test[j].min_duration*SUPER_TONE_BINS)
             {
-                return  0;
+                return 0;
             }
         }
     }
-    return  1;
+    return 1;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -288,7 +288,7 @@ SPAN_DECLARE(super_tone_rx_state_t *) super_tone_rx_init(super_tone_rx_state_t *
 #endif
     for (i = 0;  i < desc->monitored_frequencies;  i++)
         goertzel_init(&s->state[i], &s->desc->desc[i]);
-    return  s;
+    return s;
 }
 /*- End of function --------------------------------------------------------*/
 
index 7725858f5de4fb48f8952325affd222a6beacf0b..b43f20628eae117d298e7f321ff85d88c02dc991 100644 (file)
@@ -170,7 +170,7 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max
     super_tone_tx_step_t *tree;
 
     if (s->level < 0  ||  s->level > 3)
-        return  0;
+        return 0;
     samples = 0;
     tree = s->levels[s->level];
     while (tree  &&  samples < max_samples)
@@ -280,7 +280,7 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max
         }
         
     }
-    return  samples;
+    return samples;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 5109c9f0fae33f908c55ed13d49857e8abcdd500..e22f60b01ffee2866dcd59639065fab3fcfb7c8d 100644 (file)
@@ -729,7 +729,7 @@ static int get_partial_ecm_page(t30_state_t *s)
         /* These frames contain a frame sequence number within the partial page (one octet) followed
            by some image data. */
         s->ecm_data[i][3] = (uint8_t) i;
-        if ((len = t4_tx_get_chunk(&s->t4.tx, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame)
+        if ((len = t4_tx_get(&s->t4.tx, &s->ecm_data[i][4], s->octets_per_ecm_frame)) < s->octets_per_ecm_frame)
         {
             /* The image is not big enough to fill the entire buffer */
             /* We need to pad to a full frame, as most receivers expect that. */
@@ -748,7 +748,7 @@ static int get_partial_ecm_page(t30_state_t *s)
     /* We filled the entire buffer */
     s->ecm_frames = 256;
     span_log(&s->logging, SPAN_LOG_FLOW, "Partial page buffer full (%d per frame)\n", s->octets_per_ecm_frame);
-    s->ecm_at_page_end = (t4_tx_check_if_complete(&s->t4.tx) == SIG_STATUS_END_OF_DATA);
+    s->ecm_at_page_end = (t4_tx_image_complete(&s->t4.tx) == SIG_STATUS_END_OF_DATA);
     return 256;
 }
 /*- End of function --------------------------------------------------------*/
@@ -2636,7 +2636,7 @@ static int process_rx_pps(t30_state_t *s, const uint8_t *msg, int len)
         span_log(&s->logging, SPAN_LOG_FLOW, "Partial page OK - committing block %d, %d frames\n", s->ecm_block, s->ecm_frames);
         for (i = 0;  i < s->ecm_frames;  i++)
         {
-            if (t4_rx_put_chunk(&s->t4.rx, s->ecm_data[i], s->ecm_len[i]))
+            if (t4_rx_put(&s->t4.rx, s->ecm_data[i], s->ecm_len[i]))
             {
                 /* This is the end of the document */
                 break;
@@ -5473,7 +5473,7 @@ SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit)
         break;
     case T30_STATE_F_DOC_NON_ECM:
         /* Document transfer */
-        if (t4_rx_put_bit(&s->t4.rx, bit))
+        if (t4_rx_put_bit(&s->t4.rx, bit) == T4_DECODE_OK)
         {
             /* That is the end of the document */
             set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
@@ -5485,48 +5485,7 @@ SPAN_DECLARE_NONSTD(void) t30_non_ecm_put_bit(void *user_data, int bit)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(void) t30_non_ecm_put_byte(void *user_data, int byte)
-{
-    t30_state_t *s;
-
-    if (byte < 0)
-    {
-        t30_non_ecm_rx_status(user_data, byte);
-        return;
-    }
-    s = (t30_state_t *) user_data;
-    switch (s->state)
-    {
-    case T30_STATE_F_TCF:
-        /* Trainability test */
-        /* This makes counting zeros fast, but approximate. That really doesn't matter */
-        s->tcf_test_bits += 8;
-        if (byte)
-        {
-            if (s->tcf_current_zeros > s->tcf_most_zeros)
-                s->tcf_most_zeros = s->tcf_current_zeros;
-            s->tcf_current_zeros = 0;
-        }
-        else
-        {
-            s->tcf_current_zeros += 8;
-        }
-        break;
-    case T30_STATE_F_DOC_NON_ECM:
-        /* Document transfer */
-        if (t4_rx_put_byte(&s->t4.rx, (uint8_t) byte))
-        {
-            /* That is the end of the document */
-            set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
-            queue_phase(s, T30_PHASE_D_RX);
-            timer_t2_start(s);
-        }
-        break;
-    }
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len)
+SPAN_DECLARE(void) t30_non_ecm_put(void *user_data, const uint8_t buf[], int len)
 {
     t30_state_t *s;
     int i;
@@ -5554,7 +5513,7 @@ SPAN_DECLARE(void) t30_non_ecm_put_chunk(void *user_data, const uint8_t buf[], i
         break;
     case T30_STATE_F_DOC_NON_ECM:
         /* Document transfer */
-        if (t4_rx_put_chunk(&s->t4.rx, buf, len))
+        if (t4_rx_put(&s->t4.rx, buf, len))
         {
             /* That is the end of the document */
             set_state(s, T30_STATE_F_POST_DOC_NON_ECM);
@@ -5601,42 +5560,7 @@ SPAN_DECLARE_NONSTD(int) t30_non_ecm_get_bit(void *user_data)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t30_non_ecm_get_byte(void *user_data)
-{
-    int byte;
-    t30_state_t *s;
-
-    s = (t30_state_t *) user_data;
-    switch (s->state)
-    {
-    case T30_STATE_D_TCF:
-        /* Trainability test. */
-        byte = 0;
-        if ((s->tcf_test_bits -= 8) < 0)
-        {
-            /* Finished sending training test. */
-            byte = 0x100;
-        }
-        break;
-    case T30_STATE_I:
-        /* Transferring real data. */
-        byte = t4_tx_get_byte(&s->t4.tx);
-        break;
-    case T30_STATE_D_POST_TCF:
-    case T30_STATE_II_Q:
-        /* We should be padding out a block of samples if we are here */
-        byte = 0;
-        break;
-    default:
-        span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_byte in bad state %d\n", s->state);
-        byte = 0x100;
-        break;
-    }
-    return byte;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_len)
+SPAN_DECLARE(int) t30_non_ecm_get(void *user_data, uint8_t buf[], int max_len)
 {
     int len;
     t30_state_t *s;
@@ -5655,7 +5579,7 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_
         break;
     case T30_STATE_I:
         /* Transferring real data. */
-        len = t4_tx_get_chunk(&s->t4.tx, buf, max_len);
+        len = t4_tx_get(&s->t4.tx, buf, max_len);
         break;
     case T30_STATE_D_POST_TCF:
     case T30_STATE_II_Q:
@@ -5663,7 +5587,7 @@ SPAN_DECLARE(int) t30_non_ecm_get_chunk(void *user_data, uint8_t buf[], int max_
         len = 0;
         break;
     default:
-        span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get_chunk in bad state %d\n", s->state);
+        span_log(&s->logging, SPAN_LOG_WARNING, "t30_non_ecm_get in bad state %d\n", s->state);
         len = -1;
         break;
     }
index a1af29d577bb6df4d732b7915d9a70c5998862a7..163de33c103ed7762a5b3a6643e8f496bc0dc3c6 100644 (file)
@@ -198,8 +198,8 @@ static int v29_v21_rx_fillin(void *user_data, int len);
 static int silence_rx(void *user_data, const int16_t amp[], int len);
 static int cng_rx(void *user_data, const int16_t amp[], int len);
 static void non_ecm_put_bit(void *user_data, int bit);
-static void non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len);
-static int non_ecm_get_chunk(void *user_data, uint8_t buf[], int len);
+static void non_ecm_put(void *user_data, const uint8_t buf[], int len);
+static int non_ecm_get(void *user_data, uint8_t buf[], int len);
 static void non_ecm_rx_status(void *user_data, int status);
 static void hdlc_rx_status(void *user_data, int status);
 
@@ -600,7 +600,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
         if (len > 0)
         {
             bit_reverse(buf2, buf, len);
-            non_ecm_put_chunk(s, buf, len);
+            non_ecm_put(s, buf, len);
         }
         fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
         break;
@@ -618,7 +618,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
                     s->at_state.rx_signal_present = TRUE;
                 }
                 bit_reverse(buf2, buf, len);
-                non_ecm_put_chunk(s, buf, len);
+                non_ecm_put(s, buf, len);
             }
             /* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send HDLC signal end where
                            they should send non-ECM signal end. It is possible they also do the opposite.
@@ -747,7 +747,7 @@ static int stream_non_ecm(t31_state_t *s)
                However, I think the early versions of T.38 said the signal end message should not
                contain data. Hopefully, following the current spec will not cause compatibility
                issues. */
-            len = non_ecm_get_chunk(s, buf, fe->octets_per_data_packet);
+            len = non_ecm_get(s, buf, fe->octets_per_data_packet);
             if (len > 0)
                 bit_reverse(buf, buf, len);
             if (len < fe->octets_per_data_packet)
@@ -1257,7 +1257,7 @@ static void non_ecm_put_bit(void *user_data, int bit)
 }
 /*- End of function --------------------------------------------------------*/
 
-static void non_ecm_put_chunk(void *user_data, const uint8_t buf[], int len)
+static void non_ecm_put(void *user_data, const uint8_t buf[], int len)
 {
     t31_state_t *s;
     int i;
@@ -1335,7 +1335,7 @@ static int non_ecm_get_bit(void *user_data)
 }
 /*- End of function --------------------------------------------------------*/
 
-static int non_ecm_get_chunk(void *user_data, uint8_t buf[], int len)
+static int non_ecm_get(void *user_data, uint8_t buf[], int len)
 {
     t31_state_t *s;
     int i;
index d947d139062b09a9ca82323eac5f395271262e02..3a300ced9e471f3d18b2b87d65444fcf98ccc603 100644 (file)
@@ -553,7 +553,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
         if (len > 0)
         {
             bit_reverse(buf2, buf, len);
-            t30_non_ecm_put_chunk(&s->t30, buf2, len);
+            t30_non_ecm_put(&s->t30, buf2, len);
         }
         /*endif*/
         fe->timeout_rx_samples = fe->samples + ms_to_samples(MID_RX_TIMEOUT);
@@ -573,7 +573,7 @@ static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type,
                 }
                 /*endif*/
                 bit_reverse(buf2, buf, len);
-                t30_non_ecm_put_chunk(&s->t30, buf2, len);
+                t30_non_ecm_put(&s->t30, buf2, len);
             }
             /*endif*/
             /* WORKAROUND: At least some Mediatrix boxes have a bug, where they can send HDLC signal end where
@@ -741,7 +741,7 @@ static int stream_non_ecm(t38_terminal_state_t *s)
                However, I think the early versions of T.38 said the signal end message should not
                contain data. Hopefully, following the current spec will not cause compatibility
                issues. */
-            len = t30_non_ecm_get_chunk(&s->t30, buf, fe->octets_per_data_packet);
+            len = t30_non_ecm_get(&s->t30, buf, fe->octets_per_data_packet);
             if (len < 0)
                 return -1;
             /*endif*/
index fd3dfcfb1a801ca4fef75ddb67c3626c3b61fcb2..0a099c3f7c8f9f534f99b9a975623111037cad32 100644 (file)
@@ -1195,19 +1195,13 @@ SPAN_DECLARE(void) t42_encode_comment(t42_encode_state_t *s, const uint8_t comme
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t42_encode_check_if_complete(t42_encode_state_t *s)
+SPAN_DECLARE(int) t42_encode_image_complete(t42_encode_state_t *s)
 {
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t42_encode_get_byte(t42_encode_state_t *s)
-{
-    return 0;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t42_encode_get_chunk(t42_encode_state_t *s, uint8_t buf[], int max_len)
+SPAN_DECLARE(int) t42_encode_get(t42_encode_state_t *s, uint8_t buf[], size_t max_len)
 {
     return 0;
 }
@@ -1292,15 +1286,7 @@ SPAN_DECLARE(void) t42_decode_rx_status(t42_decode_state_t *s, int status)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t42_decode_put_byte(t42_decode_state_t *s, int byte)
-{
-    return 0;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t42_decode_put_chunk(t42_decode_state_t *s,
-                                       const uint8_t data[],
-                                       size_t len)
+SPAN_DECLARE(int) t42_decode_put(t42_decode_state_t *s, const uint8_t data[], size_t len)
 {
     uint8_t *buf;
 
index c152d3187166bfd0d60f77edc07ea09da06ac57c..b9533c0e1ccbce78af937dcb45a0307b43a7126c 100644 (file)
@@ -344,35 +344,13 @@ static void tiff_rx_release(t4_rx_state_t *s)
 
 SPAN_DECLARE(int) t4_rx_put_bit(t4_rx_state_t *s, int bit)
 {
+    /* We only put bit by bit for T.4-1D and T.4-2D */
     s->line_image_size += 1;
     return t4_t6_decode_put_bit(&s->decoder.t4_t6, bit);
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_rx_put_byte(t4_rx_state_t *s, uint8_t byte)
-{
-    s->line_image_size += 8;
-    switch (s->line_encoding)
-    {
-    case T4_COMPRESSION_ITU_T4_1D:
-    case T4_COMPRESSION_ITU_T4_2D:
-    case T4_COMPRESSION_ITU_T6:
-        return t4_t6_decode_put_byte(&s->decoder.t4_t6, byte);
-    case T4_COMPRESSION_ITU_T42:
-        return t42_decode_put_byte(&s->decoder.t42, byte);
-#if defined(SPANDSP_SUPPORT_T43)
-    case T4_COMPRESSION_ITU_T43:
-        return t43_decode_put_byte(&s->decoder.t43, byte);
-#endif
-    case T4_COMPRESSION_ITU_T85:
-    case T4_COMPRESSION_ITU_T85_L0:
-        return t85_decode_put_byte(&s->decoder.t85, byte);
-    }
-    return T4_DECODE_OK;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t4_rx_put_chunk(t4_rx_state_t *s, const uint8_t buf[], int len)
+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)
@@ -380,16 +358,16 @@ SPAN_DECLARE(int) t4_rx_put_chunk(t4_rx_state_t *s, const uint8_t buf[], int len
     case T4_COMPRESSION_ITU_T4_1D:
     case T4_COMPRESSION_ITU_T4_2D:
     case T4_COMPRESSION_ITU_T6:
-        return t4_t6_decode_put_chunk(&s->decoder.t4_t6, buf, len);
+        return t4_t6_decode_put(&s->decoder.t4_t6, buf, len);
     case T4_COMPRESSION_ITU_T42:
-        return t42_decode_put_chunk(&s->decoder.t42, buf, len);
+        return t42_decode_put(&s->decoder.t42, buf, len);
 #if defined(SPANDSP_SUPPORT_T43)
     case T4_COMPRESSION_ITU_T43:
-        return t43_decode_put_chunk(&s->decoder.t43, buf, len);
+        return t43_decode_put(&s->decoder.t43, buf, len);
 #endif
     case T4_COMPRESSION_ITU_T85:
     case T4_COMPRESSION_ITU_T85_L0:
-        return t85_decode_put_chunk(&s->decoder.t85, buf, len);
+        return t85_decode_put(&s->decoder.t85, buf, len);
     }
     return T4_DECODE_OK;
 }
@@ -646,22 +624,22 @@ SPAN_DECLARE(int) t4_rx_end_page(t4_rx_state_t *s)
     case T4_COMPRESSION_ITU_T4_1D:
     case T4_COMPRESSION_ITU_T4_2D:
     case T4_COMPRESSION_ITU_T6:
-        t4_t6_decode_put_byte(&s->decoder.t4_t6, SIG_STATUS_END_OF_DATA);
+        t4_t6_decode_put(&s->decoder.t4_t6, NULL, 0);
         length = t4_t6_decode_get_image_length(&s->decoder.t4_t6);
         break;
     case T4_COMPRESSION_ITU_T42:
-        t42_decode_put_byte(&s->decoder.t42, SIG_STATUS_END_OF_DATA);
+        t42_decode_put(&s->decoder.t42, NULL, 0);
         length = t42_decode_get_image_length(&s->decoder.t42);
         break;
 #if defined(SPANDSP_SUPPORT_T43)
     case T4_COMPRESSION_ITU_T43:
-        t43_decode_put_byte(&s->decoder.t43, SIG_STATUS_END_OF_DATA);
+        t43_decode_put(&s->decoder.t43, NULL, 0);
         length = t43_decode_get_image_length(&s->decoder.t43);
         break;
 #endif
     case T4_COMPRESSION_ITU_T85:
     case T4_COMPRESSION_ITU_T85_L0:
-        t85_decode_put_byte(&s->decoder.t85, SIG_STATUS_END_OF_DATA);
+        t85_decode_put(&s->decoder.t85, NULL, 0);
         length = t85_decode_get_image_length(&s->decoder.t85);
         break;
     }
index ac528a6a891e9cf3687ffa7b779d576ab67f5a92..f866c98caeb5f4ede31b0172cb003c286f0c796f 100644 (file)
@@ -700,26 +700,7 @@ static void t4_t6_decode_rx_status(t4_t6_decode_state_t *s, int status)
         break;
     case SIG_STATUS_CARRIER_DOWN:
     case SIG_STATUS_END_OF_DATA:
-        /* Finalise the image */
-        if (s->consecutive_eols != EOLS_TO_END_ANY_RX_PAGE)
-        {
-            /* Push enough zeros (13) through the decoder to flush out any remaining codes */
-            put_bits(s, 0, 8);
-            put_bits(s, 0, 5);
-        }
-        if (s->curr_bad_row_run)
-        {
-            if (s->curr_bad_row_run > s->longest_bad_row_run)
-                s->longest_bad_row_run = s->curr_bad_row_run;
-            s->curr_bad_row_run = 0;
-        }
-        /* Don't worry about the return value here. We are finishing anyway. */
-        if (s->row_write_handler)
-            s->row_write_handler(s->row_write_user_data, NULL, 0);
-        s->rx_bits = 0;
-        s->rx_skip_bits = 0;
-        s->rx_bitstream = 0;
-        s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
+        t4_t6_decode_put(s, NULL, 0);
         break;
     default:
         span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status);
@@ -736,27 +717,42 @@ SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit)
         return TRUE;
     }
     s->compressed_image_size++;
-    return put_bits(s, bit & 1, 1);
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t4_t6_decode_put_byte(t4_t6_decode_state_t *s, int byte)
-{
-    if (byte < 0)
-    {
-        t4_t6_decode_rx_status(s, byte);
-        return TRUE;
-    }
-    s->compressed_image_size += 8;
-    return put_bits(s, byte & 0xFF, 8);
+    if (put_bits(s, bit & 1, 1))
+        return T4_DECODE_OK;
+    return T4_DECODE_MORE_DATA;
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_t6_decode_put_chunk(t4_t6_decode_state_t *s, const uint8_t buf[], int len)
+SPAN_DECLARE(int) t4_t6_decode_put(t4_t6_decode_state_t *s, const uint8_t buf[], size_t len)
 {
     int i;
     uint8_t byte;
 
+    if (len == 0)
+    {
+        /* Finalise the image */
+        if (s->consecutive_eols != EOLS_TO_END_ANY_RX_PAGE)
+        {
+            /* Push enough zeros (13) through the decoder to flush out any remaining codes */
+            put_bits(s, 0, 8);
+            put_bits(s, 0, 5);
+        }
+        if (s->curr_bad_row_run)
+        {
+            if (s->curr_bad_row_run > s->longest_bad_row_run)
+                s->longest_bad_row_run = s->curr_bad_row_run;
+            s->curr_bad_row_run = 0;
+        }
+        /* Don't worry about the return value here. We are finishing anyway. */
+        if (s->row_write_handler)
+            s->row_write_handler(s->row_write_user_data, NULL, 0);
+        s->rx_bits = 0;
+        s->rx_skip_bits = 0;
+        s->rx_bitstream = 0;
+        s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
+        return T4_DECODE_OK;
+    }
+
     for (i = 0;  i < len;  i++)
     {
         s->compressed_image_size += 8;
index c8c0c2f5bb44d303756aa76da9d18e14f5388f0e..845c11352772c8d2ac1549d0522826ffcf415805 100644 (file)
@@ -918,14 +918,14 @@ static int get_next_row(t4_t6_encode_state_t *s)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_t6_encode_check_bit(t4_t6_encode_state_t *s)
+SPAN_DECLARE(int) t4_t6_encode_image_complete(t4_t6_encode_state_t *s)
 {
     if (s->bitstream_optr >= s->bitstream_iptr)
     {
         if (get_next_row(s) < 0)
             return SIG_STATUS_END_OF_DATA;
     }
-    return (s->bitstream[s->bitstream_optr] >> (7 - s->bit_pos)) & 1;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -933,8 +933,12 @@ SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s)
 {
     int bit;
 
-    if ((bit = t4_t6_encode_check_bit(s)) < 0)
-        return bit;
+    if (s->bitstream_optr >= s->bitstream_iptr)
+    {
+        if (get_next_row(s) < 0)
+            return SIG_STATUS_END_OF_DATA;
+    }
+    bit = (s->bitstream[s->bitstream_optr] >> (7 - s->bit_pos)) & 1;
     if (--s->bit_pos < 0)
     {
         s->bitstream_optr++;
@@ -944,18 +948,7 @@ SPAN_DECLARE(int) t4_t6_encode_get_bit(t4_t6_encode_state_t *s)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_t6_encode_get_byte(t4_t6_encode_state_t *s)
-{
-    if (s->bitstream_optr >= s->bitstream_iptr)
-    {
-        if (get_next_row(s) < 0)
-            return 0x100;
-    }
-    return s->bitstream[s->bitstream_optr++];
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t4_t6_encode_get_chunk(t4_t6_encode_state_t *s, uint8_t buf[], int max_len)
+SPAN_DECLARE(int) t4_t6_encode_get(t4_t6_encode_state_t *s, uint8_t buf[], int max_len)
 {
     int len;
     int n;
index 89f10664e443db5b637c4bcdddc9f102905f208a..0611c3313b76ae5938cb56e85802611da76b34d5 100644 (file)
@@ -900,23 +900,23 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_tx_check_if_complete(t4_tx_state_t *s)
+SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s)
 {
     switch (s->line_encoding)
     {
     case T4_COMPRESSION_ITU_T4_1D:
     case T4_COMPRESSION_ITU_T4_2D:
     case T4_COMPRESSION_ITU_T6:
-        return t4_t6_encode_check_bit(&s->encoder.t4_t6);
+        return t4_t6_encode_image_complete(&s->encoder.t4_t6);
     case T4_COMPRESSION_ITU_T42:
-        return t42_encode_check_if_complete(&s->encoder.t42);
+        return t42_encode_image_complete(&s->encoder.t42);
 #if defined(SPANDSP_SUPPORT_T43)
     case T4_COMPRESSION_ITU_T43:
-        return t43_encode_check_if_complete(&s->encoder.t43);
+        return t43_encode_image_complete(&s->encoder.t43);
 #endif
     case T4_COMPRESSION_ITU_T85:
     case T4_COMPRESSION_ITU_T85_L0:
-        return t85_encode_check_if_complete(&s->encoder.t85);
+        return t85_encode_image_complete(&s->encoder.t85);
     }
     return SIG_STATUS_END_OF_DATA;
 }
@@ -924,49 +924,28 @@ SPAN_DECLARE(int) t4_tx_check_if_complete(t4_tx_state_t *s)
 
 SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s)
 {
+    /* We only get bit by bit for T.4 1D and T.4 2-D. */
     return t4_t6_encode_get_bit(&s->encoder.t4_t6);
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t4_tx_get_byte(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)
     {
     case T4_COMPRESSION_ITU_T4_1D:
     case T4_COMPRESSION_ITU_T4_2D:
     case T4_COMPRESSION_ITU_T6:
-        return t4_t6_encode_get_byte(&s->encoder.t4_t6);
+        return t4_t6_encode_get(&s->encoder.t4_t6, buf, max_len);
     case T4_COMPRESSION_ITU_T42:
-        return t42_encode_get_byte(&s->encoder.t42);
+        return t42_encode_get(&s->encoder.t42, buf, max_len);
 #if defined(SPANDSP_SUPPORT_T43)
     case T4_COMPRESSION_ITU_T43:
-        return t43_encode_get_byte(&s->encoder.t43);
+        return t43_encode_get(&s->encoder.t43, buf, max_len);
 #endif
     case T4_COMPRESSION_ITU_T85:
     case T4_COMPRESSION_ITU_T85_L0:
-        return t85_encode_get_byte(&s->encoder.t85);
-    }
-    return SIG_STATUS_END_OF_DATA;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t4_tx_get_chunk(t4_tx_state_t *s, uint8_t buf[], int max_len)
-{
-    switch (s->line_encoding)
-    {
-    case T4_COMPRESSION_ITU_T4_1D:
-    case T4_COMPRESSION_ITU_T4_2D:
-    case T4_COMPRESSION_ITU_T6:
-        return t4_t6_encode_get_chunk(&s->encoder.t4_t6, buf, max_len);
-    case T4_COMPRESSION_ITU_T42:
-        return t42_encode_get_chunk(&s->encoder.t42, buf, max_len);
-#if defined(SPANDSP_SUPPORT_T43)
-    case T4_COMPRESSION_ITU_T43:
-        return t43_encode_get_chunk(&s->encoder.t43, buf, max_len);
-#endif
-    case T4_COMPRESSION_ITU_T85:
-    case T4_COMPRESSION_ITU_T85_L0:
-        return t85_encode_get_chunk(&s->encoder.t85, buf, max_len);
+        return t85_encode_get(&s->encoder.t85, buf, max_len);
     }
     return 0;
 }
index 2cdee513f7b719552ef31f09e44e37eb37a5d438..fc32cccb0fe36e4758cadc65fb4a7ee80858a84e 100644 (file)
@@ -351,8 +351,7 @@ SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status)
     case SIG_STATUS_CARRIER_DOWN:
     case SIG_STATUS_END_OF_DATA:
         /* Finalise the image */
-        s->end_of_data = 1;
-        t85_decode_put_chunk(s, NULL, 0);
+        t85_decode_put(s, NULL, 0);
         break;
     default:
         span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status);
@@ -361,23 +360,7 @@ SPAN_DECLARE(void) t85_decode_rx_status(t85_decode_state_t *s, int status)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t85_decode_put_byte(t85_decode_state_t *s, int byte)
-{
-    uint8_t data[1];
-
-    if (byte < 0)
-    {
-        t85_decode_rx_status(s, byte);
-        return (s->y >= s->yd)  ?  T4_DECODE_OK  :  T4_DECODE_MORE_DATA;
-    }
-    data[0] = byte;
-    return t85_decode_put_chunk(s, data, 1);
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t85_decode_put_chunk(t85_decode_state_t *s,
-                                       const uint8_t data[],
-                                       size_t len)
+SPAN_DECLARE(int) t85_decode_put(t85_decode_state_t *s, const uint8_t data[], size_t len)
 {
     int ret;
     uint32_t y;
@@ -388,6 +371,14 @@ SPAN_DECLARE(int) t85_decode_put_chunk(t85_decode_state_t *s,
     size_t cnt;
     int i;
 
+    if (len == 0)
+    {
+        if (s->y >= s->yd)
+            return T4_DECODE_OK;
+        /* This is the end of image condition */
+        s->end_of_data = 1;
+    }
+
     s->compressed_image_size += len;
     cnt = 0;
 
index c82609c19fae62175a81b9336f51e27f47915fc3..062f7b685bd51db1161a8b95843a1ea815a85809 100644 (file)
@@ -581,7 +581,7 @@ SPAN_DECLARE(void) t85_encode_comment(t85_encode_state_t *s, const uint8_t comme
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t85_encode_check_if_complete(t85_encode_state_t *s)
+SPAN_DECLARE(int) t85_encode_image_complete(t85_encode_state_t *s)
 {
     if (s->y >= s->yd)
         return SIG_STATUS_END_OF_DATA;
@@ -589,22 +589,7 @@ SPAN_DECLARE(int) t85_encode_check_if_complete(t85_encode_state_t *s)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(int) t85_encode_get_byte(t85_encode_state_t *s)
-{
-    if (s->bitstream_optr >= s->bitstream_iptr)
-    {
-        do
-        {
-            if (get_next_row(s) < 0)
-                return 0x100;
-        }
-        while (s->bitstream_iptr == 0);
-    }
-    return s->bitstream[s->bitstream_optr++];
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) t85_encode_get_chunk(t85_encode_state_t *s, uint8_t buf[], int max_len)
+SPAN_DECLARE(int) t85_encode_get(t85_encode_state_t *s, uint8_t buf[], size_t max_len)
 {
     int len;
     int n;
index 2344c59079b20a52598465dc5edfd1edb00dcb44..248f7b8d1cbe75ea40048c18f18e31151131a409 100644 (file)
@@ -92,7 +92,7 @@ int has_MMX(void)
     int result;
 
     if (!have_cpuid_p())
-        return  0;
+        return 0;
     /*endif*/
     __asm__ __volatile__ (
         " push  %%ebx;\n"
@@ -107,7 +107,7 @@ int has_MMX(void)
        : "=a" (result)
         : 
         : "ecx", "edx");
-    return  result;
+    return result;
 }
 /*- End of function --------------------------------------------------------*/
         
@@ -116,7 +116,7 @@ int has_SIMD(void)
     int result;
 
     if (!have_cpuid_p())
-        return  0;
+        return 0;
     /*endif*/
     __asm__ __volatile__ (
         " push  %%ebx;\n"
@@ -131,7 +131,7 @@ int has_SIMD(void)
        : "=a" (result)
         : 
         : "ecx", "edx");
-    return  result;
+    return result;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -140,7 +140,7 @@ int has_SIMD2(void)
     int result;
 
     if (!have_cpuid_p())
-        return  0;
+        return 0;
     /*endif*/
     __asm__ __volatile__ (
         " push  %%ebx;\n"
@@ -155,7 +155,7 @@ int has_SIMD2(void)
        : "=a" (result)
         : 
         : "ecx", "edx");
-    return  result;
+    return result;
 }
 /*- End of function --------------------------------------------------------*/
         
@@ -164,7 +164,7 @@ int has_3DNow(void)
     int result;
 
     if (!have_cpuid_p())
-        return  0;
+        return 0;
     /*endif*/
     __asm__ __volatile__ (
         " push  %%ebx;\n"
@@ -184,7 +184,7 @@ int has_3DNow(void)
        : "=c" (result)
         : 
         : "eax", "edx");
-    return  result;
+    return result;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
     printf("SIMD2 is %x\n", result);
     result = has_3DNow();
     printf("3DNow is %x\n", result);
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 #endif
index 3a85cae71c24314cbcf7c0c6399b75364a86456c..605e1c5fb5075bfe49c14647b62cf65ab00bfd74 100644 (file)
@@ -133,7 +133,7 @@ SPAN_DECLARE(time_scale_state_t *) time_scale_init(time_scale_state_t *s, int sa
     if (s == NULL)
     {
         if ((s = (time_scale_state_t *) malloc(sizeof (*s))) == NULL)
-            return  NULL;
+            return NULL;
         /*endif*/
         alloced = TRUE;
     }
index 437865b3d3b48d6831c3c9588c02db3ed7d55b42..841e1860cf2151a8a1c869543f66bfe566872d88 100644 (file)
@@ -131,7 +131,7 @@ SPAN_DECLARE_NONSTD(int) tone_gen(tone_gen_state_t *s, int16_t amp[], int max_sa
     int i;
 
     if (s->current_section < 0)
-        return  0;
+        return 0;
 
     for (samples = 0;  samples < max_samples;  )
     {
index 98f3211e5898a25164dd5797c5b8beeec459df70..64639ecee4bc685c1ba1fe217bd5a68ed75f4a8e 100644 (file)
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
     }
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 84cb4b4f92be9387aedf9e430cf71f1a9639312c..c69724876fbc2f3a55dadb7e5aca4c8252db81eb 100644 (file)
@@ -563,7 +563,7 @@ int main(int argc, char *argv[])
         exit(2);
     }
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 556e01664fcff86f95474e1b5b9674d3665747ef..9f4b8891cc0727ca2b95a14e40085c1af61c7582 100644 (file)
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
     }
     
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index c5b5867155892a31c0090b25f79229a598b9a1f4..4e577d9c4e14f255266ce325844e5d61af4dc922 100644 (file)
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
         exit (2);
     }
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index fce1eec16ff9c709077d8f6fba01b5d16201f4cd..05fd6c10a857e0887215c5ef901d4cfc9d38867c 100644 (file)
@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
     }
     
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 2227d28805199b328b401cef16ff1735d14a3075..a2d77ec3c4fa0317679a4b439e17b94cb2b71bdd 100644 (file)
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
         }
     }
     printf("Test passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index e18e16f1aafa70457c162ed7a0d509bc87490ed8..a85638a23379f29aa3fa03bec64879b0beba41cc 100644 (file)
@@ -89,7 +89,7 @@ int main (int argc, char *argv[])
         exit(2);
     }
     printf("Test passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 8bd7713195619b258f79435bd26fbe1de0130642..27095b6108f4fd6580ea60b95d130c289fe28630 100644 (file)
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
     }
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 43c8522c3141d6c1e18647e4272d8f9c56ddc287..c108f38ed57652018d121bb6298c591572dd3559 100644 (file)
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
         exit(2);
     }
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 2bf0d68799cd034e16a63604f0788ba5fe3f0f43..4a94112df123ddfaafbfd1efcc8f5777da87c3ed 100644 (file)
@@ -254,7 +254,7 @@ static level_measurement_device_t *level_measurement_device_create(int type)
     dev->factor = expf(-1.0f/((float) SAMPLE_RATE*0.035f));
     dev->power = 0;
     dev->type = type;
-    return  dev;
+    return dev;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -1720,7 +1720,7 @@ int main(int argc, char *argv[])
 #endif
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 4ad1410587c041ba4168ea423c060d025f69b6d6..722f40681fd79e41ffc7ff4f294b3644127fb8da 100644 (file)
@@ -316,7 +316,7 @@ static void t4_end(void)
         for (i = 0;  i < 256;  i++)
         {
             if (ecm_len[i] > 0)
-                t4_rx_put_chunk(&t4_rx_state, ecm_data[i], ecm_len[i]);
+                t4_rx_put(&t4_rx_state, ecm_data[i], ecm_len[i]);
             fprintf(stderr, "%d", (ecm_len[i] <= 0)  ?  0  :  1);
         }
         fprintf(stderr, "\n");
@@ -560,7 +560,7 @@ int main(int argc, char *argv[])
         fprintf(stderr, "    Cannot close audio file '%s'\n", filename);
         exit(2);
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 4584a0da35e09813ab1766928a4d7372e52ced3d..28bf52b9a3118c4a360964f3def8b5b777d09630 100644 (file)
@@ -1138,7 +1138,7 @@ int main(int argc, char *argv[])
         exit(2);
     }
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 297322c09e8afd93af6c726ee8b31345ef766d50..fa1da0df6f44c2c595c9d3997ced01f3f71556fa 100644 (file)
@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index aaa233ba910c7e6d2a371bd8a1e2be7dfdd27122..b1b8e776f47bdfd0339f68e83d2dbb424ae07607 100644 (file)
@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
         printf("%d\n", css_c3[i]);
     signal_free(&local_css);
     signal_free(&far_css);
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index bf7a63995dba58c2d3bfea0156af0a938e39ffc2..a4a35dcf3c964f0d608ec895af2c7145c31be7c7 100644 (file)
@@ -862,7 +862,7 @@ int main(int argc, char *argv[])
         decode_bitstream(in_file_name);
     else
         hdlc_tests();
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 850eb7e223cebafeb6406d54e7e0469daa16e3ce..ba0138e63e6efbc28d6c889afe67b042f9bfd3c2 100644 (file)
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
     }
 
     fftw_destroy_plan(p);
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index dc5147a9a833eeb34a6d50000aaf9f3ec3449520..bf60efe5f8bc2789bd8f63a59e8eb29453c3e7a4 100644 (file)
@@ -1752,7 +1752,7 @@ int main(int argc, char *argv[])
         printf("    File gave %d hits.\n", hits);
     }
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 07ffa0e7ed61e33128139e17d7ad02ccb73f0b74..6b986d79da25234657850156b966bd7540f5f59a 100644 (file)
@@ -246,7 +246,7 @@ static int16_t channel_model(int16_t local, int16_t far)
     /* This mixed echo and far end signal will have been through an A-law munging when it came back into
        the digital network. */
     rx = codec_munger(rx);
-    return  rx;
+    return rx;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -392,7 +392,7 @@ int main(int argc, char *argv[])
 #endif
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 8f9b6e573773f62b485977148ccdbddc8cc028aa..8ccd55f6d2d8be4183760137943ccafd78558cd3 100644 (file)
@@ -230,7 +230,7 @@ int main (int argc, char *argv[])
     }
     
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 172b92f156015e496151c5208e1b2a308b02453b..b47f1fc46de0cf6cc431920096adf15cddcea4fd 100644 (file)
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
         exit (2);
     }
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 173e38ad3645cbe05c03f2da87ac0df17d8dd3f4..3019e200cf423435f55e26e8c438572ae7f8b8c4 100755 (executable)
@@ -260,14 +260,14 @@ then
 fi
 echo ima_adpcm_tests completed OK
 
-./image_translate_tests >$STDOUT_DEST 2>$STDERR_DEST
-RETVAL=$?
-if [ $RETVAL != 0 ]
-then
-    echo image_translate_tests failed!
-    exit $RETVAL
-fi
-echo image_translate_tests completed OK
+#./image_translate_tests >$STDOUT_DEST 2>$STDERR_DEST
+#RETVAL=$?
+#if [ $RETVAL != 0 ]
+#then
+#    echo image_translate_tests failed!
+#    exit $RETVAL
+#fi
+#echo image_translate_tests completed OK
 
 ./logging_tests >$STDOUT_DEST 2>$STDERR_DEST
 RETVAL=$?
@@ -499,7 +499,23 @@ fi
 echo t38_non_ecm_buffer_tests completed OK
 
 rm -f t4_tests_receive.tif
-./t4_tests >$STDOUT_DEST 2>$STDERR_DEST
+./t4_tests -b 0 >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+    echo t4_tests failed!
+    exit $RETVAL
+fi
+rm -f t4_tests_receive.tif
+./t4_tests -b 1 >$STDOUT_DEST 2>$STDERR_DEST
+RETVAL=$?
+if [ $RETVAL != 0 ]
+then
+    echo t4_tests failed!
+    exit $RETVAL
+fi
+rm -f t4_tests_receive.tif
+./t4_tests -b 10 >$STDOUT_DEST 2>$STDERR_DEST
 RETVAL=$?
 if [ $RETVAL != 0 ]
 then
index de2a40bcc28166f83d417ae53e89210f1d83dd5a..419020cd1b9afdf9f2e5b30363e7b3109f35230d 100644 (file)
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])
         exit(2);
     }
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index a9fa4661990e12c2e0282db809e83eaeb022a449..f1b19bc946fa71b9034c0c068d8d2d4b2a36fad5 100644 (file)
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
     span_schedule_release(&sched);
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 7f1311a92a327f934d88fd4a888d2754fa75787c..b967fecabd92d964d967f233b7cef3f50e555349 100644 (file)
@@ -656,7 +656,7 @@ int main(int argc, char *argv[])
     /*endfor*/
     
     printf("Tests completed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index b9b673855d9c8d8b962c24e6f31edd673c9e46ef..4e37a9961d85850e9eba64a69035025aac9b29dc 100644 (file)
@@ -198,7 +198,7 @@ static int parse_tone(super_tone_rx_descriptor_t *desc, int tone_id, super_tone_
         cur = cur->next;
     }
     /*endwhile*/
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
index 2fabbbd7c9e41a044e186adde7b0241b8e24ef24..51b6eeaeb7ce89601ad89d66275e2aaadf524ab3 100644 (file)
@@ -177,7 +177,7 @@ static int parse_tone(super_tone_tx_step_t **tree, xmlDocPtr doc, xmlNsPtr ns, x
         cur = cur->next;
     }
     /*endwhile*/
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
index c806701afaf7493ec92115f64a8af3b6bdff57b3..9ff6bc462febcd85486a90dc75bb934654f2becb 100644 (file)
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
     }
 
     printf("Tests passed.\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 7f5e7c00a8a628f06a47ed885b29549d92b2b5ce..a5a12931677bb1d6b5235bb9f6e2cb4dd3249a87 100644 (file)
@@ -934,7 +934,7 @@ int main(int argc, char *argv[])
 
     t30_tests(t38_mode, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no);
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index d5edaf4f5082552e8eb92f6416472ac29413db63..78ab3a1ca44fdc7958047b57fcbbf961951eea13 100644 (file)
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
     printf("Decoded as %s %s %s\n", (country)  ?  country  :  "???", (vendor)  ?  vendor  :  "???", (model)  ?  model  :  "???");
 
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index efd103dcb3d972a3146f2fff91dc504fde27804b..b765e9805e4a797d3873c9916fad1f960cd6b2ab 100644 (file)
@@ -728,7 +728,7 @@ int main(int argc, char *argv[])
         exit(2);
     }
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 1794cf6e6d2156f5a16ea985a75ab663ea19c1f7..5248259b999af188495a244a4be88d43cf2f5c58 100644 (file)
@@ -699,7 +699,7 @@ int main(int argc, char *argv[])
     t38_non_ecm_buffer_report_output_status(&buffer, &logging);
 
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index b00dac0707b9e466efcfe197a56d18a6c19a8257..f1b3630f362846d58a2b2810a8151b18d15486be 100644 (file)
@@ -287,9 +287,9 @@ int main(int argc, char *argv[])
                 printf("0x%02x\n", data[i]);
             t85_decode_init(&t85_dec, t85_row_write_handler, NULL);
             t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL);
-            result = t85_decode_put_chunk(&t85_dec, data, total_len);
+            result = t85_decode_put(&t85_dec, data, total_len);
             if (result == T4_DECODE_MORE_DATA)
-                result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
+                result = t85_decode_put(&t85_dec, NULL, 0);
             len = t85_decode_get_compressed_image_size(&t85_dec);
             printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
             t85_decode_release(&t85_dec);
@@ -331,7 +331,7 @@ int main(int argc, char *argv[])
             t85_dec.min_bit_planes = 1;
             t85_dec.max_bit_planes = 8;
             data5_ptr = 0;
-            result = t85_decode_put_chunk(&t85_dec, data, total_len);
+            result = t85_decode_put(&t85_dec, data, total_len);
             len = t85_decode_get_compressed_image_size(&t85_dec);
             printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
 
@@ -343,14 +343,14 @@ int main(int argc, char *argv[])
                 t85_decode_new_plane(&t85_dec);
                 data5_ptr = 0;
                 t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL);
-                result = t85_decode_put_chunk(&t85_dec, data, total_len);
+                result = t85_decode_put(&t85_dec, data, total_len);
                 len = t85_decode_get_compressed_image_size(&t85_dec);
                 printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
             }
             if (result == T4_DECODE_MORE_DATA)
             {
                 printf("More\n");
-                result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
+                result = t85_decode_put(&t85_dec, NULL, 0);
             }
             len = t85_decode_get_compressed_image_size(&t85_dec);
             printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
index 52eef26c199f59564d79c359ba2b83b983ac3e09..6df56303c1d22777f3df62b464f7e0ebe954e36e 100644 (file)
@@ -394,27 +394,10 @@ int main(int argc, char *argv[])
                     end_of_page = t4_t6_decode_put_bit(&receive_state, bit & 1);
             }
             break;
-        case 1:
-            do
-            {
-                bit = t4_t6_encode_get_byte(&send_state);
-                if ((bit & 0x100))
-                {
-                    if (++end_marks > 50)
-                    {
-                        printf("Receiver missed the end of page mark\n");
-                        tests_failed++;
-                        break;
-                    }
-                }
-                end_of_page = t4_t6_decode_put_byte(&receive_state, bit & 0xFF);
-            }
-            while (!end_of_page);
-            break;
         default:
             do
             {
-                len = t4_t6_encode_get_chunk(&send_state, chunk_buf, block_size);
+                len = t4_t6_encode_get(&send_state, chunk_buf, block_size);
                 if (len == 0)
                 {
                     if (++end_marks > 50)
@@ -426,7 +409,7 @@ int main(int argc, char *argv[])
                     chunk_buf[0] = 0xFF;
                     len = 1;
                 }
-                end_of_page = t4_t6_decode_put_chunk(&receive_state, chunk_buf, len);
+                end_of_page = t4_t6_decode_put(&receive_state, chunk_buf, len);
             }
             while (!end_of_page);
             break;
index b47530068d0c565c5d6599bc063e8c03b7c7437b..b53c8f65be2527f6ea2703dcba6ee266d15cf130 100644 (file)
@@ -263,7 +263,7 @@ static int detect_page_end(int bit, int page_ended)
         if (!page_ended)
         {
             /* We might need to push a few bits to get the receiver to report the
-                end of page condition (at least with T.6). */
+               end of page condition (at least with T.6). */
             if (++end_marks > 50)
             {
                 printf("Receiver missed the end of page mark\n");
@@ -316,6 +316,7 @@ int main(int argc, char *argv[])
     const char *page_header_tz;
     tz_t tz;
     int opt;
+    int len;
     int i;
     int bit_error_rate;
     int dump_as_xxx;
@@ -424,7 +425,7 @@ int main(int argc, char *argv[])
     memset(&send_state, 0, sizeof(send_state));
     memset(&receive_state, 0, sizeof(receive_state));
 
-    end_of_page = FALSE;
+    end_of_page = T4_DECODE_MORE_DATA;
     if (decode_file_name)
     {
         if (compression < 0)
@@ -454,9 +455,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[18 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit;
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (sscanf(buf, "HDLC:  %x", &pkt_no) == 1)
             {
@@ -465,9 +466,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[19 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit;
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (sscanf(buf, "%*d:%*d:%*d.%*d T.38 Rx %d: IFP %x %x", &pkt_no, (unsigned int *) &bit, (unsigned int *) &bit) == 3)
             {
@@ -479,10 +480,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[47 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    bit = bit_reverse8(bit);
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit_reverse8(bit);
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (strlen(buf) > 2  &&  sscanf(buf, "T.30 Rx:  %x %x", (unsigned int *) &bit, (unsigned int *) &bit) == 2)
             {
@@ -494,10 +494,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[22 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    bit = bit_reverse8(bit);
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit_reverse8(bit);
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (sscanf(buf, "%04x  %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
             {
@@ -505,10 +504,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[6 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    bit = bit_reverse8(bit);
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit_reverse8(bit);
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (sscanf(buf, "%08x  %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
             {
@@ -516,10 +514,9 @@ int main(int argc, char *argv[])
                 {
                     if (sscanf(&buf[10 + 3*i], "%x", (unsigned int *) &bit) != 1)
                         break;
-                    bit = bit_reverse8(bit);
-                    if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
-                        break;
+                    block[i] = bit_reverse8(bit);
                 }
+                end_of_page = t4_rx_put(&receive_state, block, i);
             }
             else if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1)
             {
@@ -575,7 +572,7 @@ int main(int argc, char *argv[])
             if (compression_step >= 0)
             {
                 compression = compression_sequence[compression_step++];
-                if (compression < 0)
+                if (compression < 0  ||  (block_size == 0  &&  compression_step >= 3))
                     break;
             }
             t4_tx_set_tx_encoding(&send_state, compression);
@@ -587,64 +584,66 @@ int main(int argc, char *argv[])
                 break;
             if (t4_rx_start_page(&receive_state))
                 break;
+            detect_page_end(-1000000, compression);
+            page_ended = FALSE;
             switch (block_size)
             {
             case 0:
-                do
+                while ((bit = t4_tx_get_bit(&send_state)) >= 0)
                 {
-                    bit = t4_tx_get_bit(&send_state);
-                    if (bit == SIG_STATUS_END_OF_DATA)
+                    /* Monitor whether the EOLs are there in the correct amount */
+                    if ((res = detect_page_end(bit, page_ended)))
                     {
-                        if (++end_marks > 50)
-                        {
-                            printf("Receiver missed the end of page mark\n");
-                            tests_failed++;
-                            break;
-                        }
+                        printf("Incorrect EOLs - %d\n", res);
+                        tests_failed += (res - 1);
+                        break;
                     }
-                    end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
-                }
-                while (!end_of_page);
-                break;
-            case 1:
-                do
-                {
-                    bit = t4_tx_get_byte(&send_state);
-                    if ((bit & 0x100))
+                    if (bit >= 0)
                     {
-                        if (++end_marks > 50)
+                        if (bit_error_rate)
                         {
-                            printf("Receiver missed the end of page mark\n");
-                            tests_failed++;
-                            break;
+                            if ((rand() % bit_error_rate) == 0)
+                                bit ^= 1;
                         }
+                        end_of_page = t4_rx_put_bit(&receive_state, bit);
                     }
-                    end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
                 }
-                while (!end_of_page);
-                if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
+                while (end_of_page != T4_DECODE_OK)
                 {
-                    printf("Page ended, but source is not reporting end of data\n");
-                    tests_failed++;
+                    end_of_page = t4_rx_put_bit(&receive_state, 0);
+                    if (++end_marks > 50)
+                    {
+                        printf("Receiver missed the end of page mark\n");
+                        tests_failed++;
+                        break;
+                    }
                 }
+                /* Now throw junk at the receive context, to ensure stuff occuring
+                   after the end of page condition has no bad effect. */
+                for (i = 0;  i < 1000;  i++)
+                    t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
                 break;
             default:
+                /* Some decoders require a few extra bits before the recognise the end
+                   of an image, so be prepared to offer it a few. */
                 do
                 {
-                    bit = t4_tx_get_chunk(&send_state, block, block_size);
-                    if (bit > 0)
-                        end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
-                    if (bit < block_size)
+                    len = t4_tx_get(&send_state, block, block_size);
+                    if (len > 0)
+                        end_of_page = t4_rx_put(&receive_state, block, len);
+                }
+                while (len > 0);
+                while (end_of_page != T4_DECODE_OK)
+                {
+                    block[0] = 0;
+                    end_of_page = t4_rx_put(&receive_state, block, 1);
+                    if (++end_marks > 5)
                     {
-                        if (++end_marks > 50)
-                        {
-                            printf("Receiver missed the end of page mark\n");
-                            tests_failed++;
-                            break;
-                        }
+                        printf("Receiver missed the end of page mark\n");
+                        tests_failed++;
+                        break;
                     }
                 }
-                while (!end_of_page);
                 break;
             }
             display_page_stats(&receive_state);
@@ -711,7 +710,7 @@ int main(int argc, char *argv[])
                 if (compression_step >= 0)
                 {
                     compression = compression_sequence[compression_step++];
-                    if (compression < 0)
+                    if (compression < 0  ||  (block_size == 0  &&  compression_step >= 3))
                     {
                         compression_step = 0;
                         compression = compression_sequence[compression_step++];
@@ -732,72 +731,58 @@ int main(int argc, char *argv[])
             switch (block_size)
             {
             case 0:
-                for (;;)
+                while ((bit = t4_tx_get_bit(&send_state)) >= 0)
                 {
-                    bit = t4_tx_get_bit(&send_state);
                     /* Monitor whether the EOLs are there in the correct amount */
                     if ((res = detect_page_end(bit, page_ended)))
                     {
+                        printf("Incorrect EOLs - %d\n", res);
                         tests_failed += (res - 1);
                         break;
                     }
-                    if (!page_ended)
+                    if (bit_error_rate)
                     {
-                        if (bit_error_rate)
-                        {
-                            if ((rand() % bit_error_rate) == 0)
-                                bit ^= 1;
-                        }
-                        if (t4_rx_put_bit(&receive_state, bit & 1))
-                            page_ended = TRUE;
+                        if ((rand() % bit_error_rate) == 0)
+                            bit ^= 1;
+                    }
+                    end_of_page = t4_rx_put_bit(&receive_state, bit);
+                }
+                while (end_of_page != T4_DECODE_OK)
+                {
+                    end_of_page = t4_rx_put_bit(&receive_state, 0);
+                    if (++end_marks > 50)
+                    {
+                        printf("Receiver missed the end of page mark\n");
+                        tests_failed++;
+                        break;
                     }
                 }
                 /* Now throw junk at the receive context, to ensure stuff occuring
                    after the end of page condition has no bad effect. */
                 for (i = 0;  i < 1000;  i++)
-                {
                     t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
-                }
                 break;
-            case 1:
+            default:
                 do
                 {
-                    bit = t4_tx_get_byte(&send_state);
-                    if ((bit & 0x100))
-                    {
-                        if (++end_marks > 50)
-                        {
-                            printf("Receiver missed the end of page mark\n");
-                            tests_failed++;
-                            break;
-                        }
-                    }
-                    end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
-                }
-                while (!end_of_page);
-                if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
-                {
-                    printf("Page ended, but source is not reporting end of data\n");
-                    tests_failed++;
+                    len = t4_tx_get(&send_state, block, block_size);
+                    if (len > 0)
+                        end_of_page = t4_rx_put(&receive_state, block, len);
                 }
-                break;
-            default:
-                do
+                while (len > 0);
+                /* Some decoders require a few extra bits before the recognise the end
+                   of an image, so be prepared to offer it a few. */
+                while (end_of_page != T4_DECODE_OK)
                 {
-                    bit = t4_tx_get_chunk(&send_state, block, block_size);
-                    if (bit > 0)
-                        end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
-                    if (bit < block_size)
+                    block[0] = 0;
+                    end_of_page = t4_rx_put(&receive_state, block, 1);
+                    if (++end_marks > 5)
                     {
-                        if (++end_marks > 50)
-                        {
-                            printf("Receiver missed the end of page mark\n");
-                            tests_failed++;
-                            break;
-                        }
+                        printf("Receiver missed the end of page mark\n");
+                        tests_failed++;
+                        break;
                     }
                 }
-                while (!end_of_page);
                 break;
             }
             if (dump_as_xxx)
index 3e60507c1a9f00f22e36f4b59916b7939566bd8e..8820028aa68d550b32adc070f0fecfa36d7905b2 100644 (file)
@@ -229,7 +229,7 @@ static int test_cycle(const char *test_id,
     
     testbuf_len = 0;
     max_len = 100;
-    while ((len = t85_encode_get_chunk(&t85_enc, &testbuf[testbuf_len], max_len)) > 0)
+    while ((len = t85_encode_get(&t85_enc, &testbuf[testbuf_len], max_len)) > 0)
     {
         testbuf_len += len;
         max_len = 100;
@@ -261,9 +261,9 @@ static int test_cycle(const char *test_id,
     if (comment  &&  comment[0] != 'X')
         t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL);
     write_row = 0;
-    result = t85_decode_put_chunk(&t85_dec, testbuf, testbuf_len);
+    result = t85_decode_put(&t85_dec, testbuf, testbuf_len);
     if (result == T4_DECODE_MORE_DATA)
-        result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
+        result = t85_decode_put(&t85_dec, NULL, 0);
     cnt_a = t85_encode_get_compressed_image_size(&t85_enc);
     cnt_b = t85_decode_get_compressed_image_size(&t85_dec);
     if (cnt_a != cnt_b  ||  cnt_a != testbuf_len*8  ||  result != T4_DECODE_OK)
@@ -300,7 +300,7 @@ static int test_cycle(const char *test_id,
     result = T4_DECODE_MORE_DATA;
     for (l = 0;  l < testbuf_len;  l++)
     {
-        result = t85_decode_put_chunk(&t85_dec, &testbuf[l], 1);
+        result = t85_decode_put(&t85_dec, &testbuf[l], 1);
         if (result != T4_DECODE_MORE_DATA)
         {
             l++;
@@ -308,7 +308,7 @@ static int test_cycle(const char *test_id,
         }
     }
     if (result == T4_DECODE_MORE_DATA)
-        result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
+        result = t85_decode_put(&t85_dec, NULL, 0);
     if (l != testbuf_len  ||  result != T4_DECODE_OK)
     {
         printf("Decode result %d\n", result);
index 9375f157a2059a856ceed845aad6ca55138686a0..d6dea2740c479cad947728c4058da751f9b216be 100644 (file)
@@ -127,7 +127,7 @@ static int periodogram_tests(void)
             }
         }
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
     if (periodogram_tests())
         exit(2);
     printf("Tests passed\n");
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index f61753da377948bc81cabd659f7ca63dab1e50dc..2ece5a737792351d8eaaa58ccaa42f430a64660b 100644 (file)
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
         exit (2);
     }
 
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index 7899047cd3cdd051408703beeb1629478c6f5009..300b8b6e62fce553340268c4458eb612c7482223 100644 (file)
@@ -989,7 +989,7 @@ static int next_step(faxtester_state_t *s)
                 printf("Test failed\n");
                 exit(2);
             }
-            len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
+            len = t4_tx_get(&t4_tx_state, image, sizeof(image));
             if (bad_rows)
             {
                 span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
@@ -1030,7 +1030,7 @@ static int next_step(faxtester_state_t *s)
                 exit(2);
             }
             /*endif*/
-            len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
+            len = t4_tx_get(&t4_tx_state, image, sizeof(image));
             if (bad_rows)
             {
                 span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
index 39b5a4a3191bb700e8475afacd94cd8c420c86d0..f366ab10eb9eb79823c9a80b4e8c905ac9be9c18 100644 (file)
@@ -600,7 +600,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index f9604554d094fe43c421e6d54e67b53d37df63fe..dd3564cdcb63f33ea6949363b058ab154ebb4f8e 100644 (file)
@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index c7335b08ec30b82bb04dfbd7fabf63ab9dd316c3..6bab0d9a14d67615d27df4325e2e41755d5f229b 100644 (file)
@@ -585,7 +585,7 @@ int main(int argc, char *argv[])
             exit(2);
         }
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
index c485fd17bb8efbd99eb3d62eed46ca51a76db19d..2607d5a53fbaab9dd4c3d9c31fd78bf43ca3edab 100644 (file)
@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
             bit ^= 1;
         v42_rx_bit(&caller, bit);
     }
-    return  0;
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/