Skip to content

Commit

Permalink
Improvements to T.4 end of image handling, and the related tests.
Browse files Browse the repository at this point in the history
A lot of tiny tidy up edits
  • Loading branch information
coppice-git committed Aug 12, 2012
1 parent 16b9601 commit d0e7b4a
Show file tree
Hide file tree
Showing 80 changed files with 338 additions and 583 deletions.
4 changes: 2 additions & 2 deletions src/ademco_contactid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/at_interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion src/awgn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/bell_r2_mf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down
2 changes: 1 addition & 1 deletion src/bert.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down
6 changes: 3 additions & 3 deletions src/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ 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;
ec->tap_mask = 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));
for (i = 0; i < 4; i++)
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/g711.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/g726.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gsm0610_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down
4 changes: 2 additions & 2 deletions src/gsm0610_long_term.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions src/gsm0610_lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int16_t gsm0610_norm(int32_t x)
if (x < 0)
{
if (x <= -1073741824)
return 0;
return 0;
/*endif*/
x = ~x;
}
Expand Down Expand Up @@ -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;
Expand All @@ -128,7 +128,7 @@ static int16_t gsm_div(int16_t num, int16_t denom)
}
/*endwhile*/

return div;
return div;
}
/*- End of function --------------------------------------------------------*/

Expand Down
2 changes: 1 addition & 1 deletion src/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down
6 changes: 3 additions & 3 deletions src/ima_adpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down Expand Up @@ -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 ------------------------------------------------------------*/
14 changes: 7 additions & 7 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down Expand Up @@ -175,39 +175,39 @@ SPAN_DECLARE(int) span_log_set_level(logging_state_t *s, int level)
{
s->level = level;

return 0;
return 0;
}
/*- End of function --------------------------------------------------------*/

SPAN_DECLARE(int) span_log_set_tag(logging_state_t *s, const char *tag)
{
s->tag = tag;

return 0;
return 0;
}
/*- End of function --------------------------------------------------------*/

SPAN_DECLARE(int) span_log_set_protocol(logging_state_t *s, const char *protocol)
{
s->protocol = protocol;

return 0;
return 0;
}
/*- End of function --------------------------------------------------------*/

SPAN_DECLARE(int) span_log_set_sample_rate(logging_state_t *s, int samples_per_second)
{
s->samples_per_second = samples_per_second;

return 0;
return 0;
}
/*- End of function --------------------------------------------------------*/

SPAN_DECLARE(int) span_log_bump_samples(logging_state_t *s, int samples)
{
s->elapsed_samples += samples;

return 0;
return 0;
}
/*- End of function --------------------------------------------------------*/

Expand Down
12 changes: 6 additions & 6 deletions src/modem_echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,31 +67,31 @@ 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)
{
free(ec->fir_taps16);
free(ec->fir_taps32);
free(ec);
return NULL;
return NULL;
}
return ec;
return ec;
}
/*- End of function --------------------------------------------------------*/

Expand Down Expand Up @@ -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 ------------------------------------------------------------*/
8 changes: 4 additions & 4 deletions src/oki_adpcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 --------------------------------------------------------*/

Expand Down Expand Up @@ -318,7 +318,7 @@ SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s,
/*endfor*/
}
/*endif*/
return samples;
return samples;
}
/*- End of function --------------------------------------------------------*/

Expand Down Expand Up @@ -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 ------------------------------------------------------------*/
16 changes: 2 additions & 14 deletions src/spandsp/t30.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,38 +625,26 @@ 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
\param user_data An opaque pointer, which must point to the T.30 context.
\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.
Expand Down
Loading

0 comments on commit d0e7b4a

Please sign in to comment.