mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-08 12:34:53 +00:00
Improvements to T.4 end of image handling, and the related tests.
A lot of tiny tidy up edits
This commit is contained in:
1 parent
e69a5a3037
commit
5f12c3dc1c
80 files changed
+340
-585
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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 ------------------------------------------------------------*/
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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 ------------------------------------------------------------*/
|
||||
@@ -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 ------------------------------------------------------------*/
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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 ------------------------------------------------------------*/
|
||||
+9
-85
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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*/
|
||||
|
||||
+3
-17
@@ -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;
|
||||
|
||||
|
||||
+10
-32
@@ -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;
|
||||
}
|
||||
|
||||
@@ -700,6 +700,36 @@ 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:
|
||||
t4_t6_decode_put(s, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit)
|
||||
{
|
||||
if (bit < 0)
|
||||
{
|
||||
t4_t6_decode_rx_status(s, bit);
|
||||
return TRUE;
|
||||
}
|
||||
s->compressed_image_size++;
|
||||
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(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)
|
||||
{
|
||||
@@ -720,42 +750,8 @@ static void t4_t6_decode_rx_status(t4_t6_decode_state_t *s, int status)
|
||||
s->rx_skip_bits = 0;
|
||||
s->rx_bitstream = 0;
|
||||
s->consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
|
||||
break;
|
||||
default:
|
||||
span_log(&s->logging, SPAN_LOG_WARNING, "Unexpected rx status - %d!\n", status);
|
||||
break;
|
||||
return T4_DECODE_OK;
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(int) t4_t6_decode_put_bit(t4_t6_decode_state_t *s, int bit)
|
||||
{
|
||||
if (bit < 0)
|
||||
{
|
||||
t4_t6_decode_rx_status(s, 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);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
SPAN_DECLARE(int) t4_t6_decode_put_chunk(t4_t6_decode_state_t *s, const uint8_t buf[], int len)
|
||||
{
|
||||
int i;
|
||||
uint8_t byte;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
+11
-32
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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; )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user