提交 dfce47f2 authored 作者: Steve Underwood's avatar Steve Underwood

Relaxed the constraints for declaring a clean end of call on FAX receive. If we

get an EOP, we no longer worry whether the final stages tidy up. This helps
tolerate the increasing number of VoIP calls which hang up before the audio has
flushed down the line.

A few little cleanups.
上级 8f0b7e69
......@@ -212,6 +212,9 @@ struct t30_state_s
/*! \brief TRUE once the far end FAX entity has been detected. */
int far_end_detected;
/*! \brief TRUE once the end of procedure condition has been detected. */
int end_of_procedure_detected;
/*! \brief TRUE if a local T.30 interrupt is pending. */
int local_interrupt_pending;
......
......@@ -88,6 +88,16 @@ typedef int (*span_tx_handler_t)(void *s, int16_t amp[], int max_len);
#define FP_Q_2_14(x) ((int16_t) (16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_1_15(x) ((int16_t) (32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_9_7_32(x) ((int32_t) (128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_8_8_32(x) ((int32_t) (256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_7_9_32(x) ((int32_t) (512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_6_10_32(x) ((int32_t) (1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_5_11_32(x) ((int32_t) (2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_4_12_32(x) ((int32_t) (4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_3_13_32(x) ((int32_t) (8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_2_14_32(x) ((int32_t) (16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_1_15_32(x) ((int32_t) (32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_9_23(x) ((int32_t) (65536.0*128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_8_24(x) ((int32_t) (65536.0*256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
#define FP_Q_7_25(x) ((int32_t) (65536.0*512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
......
差异被折叠。
......@@ -661,7 +661,7 @@ static int make_header(t4_tx_state_t *s)
if ((s->header_text = malloc(132 + 1)) == NULL)
return -1;
}
/* This is very English oriented, but then most FAX machines are. Some
/* This is very English oriented, but then most FAX machines are, too. Some
measure of i18n in the time and date, and even the header_info string, is
entirely possible, although the font area would need some serious work to
properly deal with East Asian script. There is no spec for what the header
......@@ -733,26 +733,21 @@ static int header_row_read_handler(void *user_data, uint8_t buf[], size_t len)
return len;
}
}
switch (s->tiff.image_type)
row = s->header_row/repeats;
pos = 0;
for (t = s->header_text; *t && pos <= len - 2; t++)
{
case T4_IMAGE_TYPE_BILEVEL:
row = s->header_row/repeats;
pos = 0;
for (t = s->header_text; *t && pos <= len - 2; t++)
{
pattern = header_font[(uint8_t) *t][row];
buf[pos++] = (uint8_t) (pattern >> 8);
buf[pos++] = (uint8_t) (pattern & 0xFF);
}
while (pos < len)
buf[pos++] = 0;
s->header_row++;
if (s->header_row >= 16*repeats)
{
/* End of header. Change to normal image row data. */
set_row_read_handler(s, s->row_handler, s->row_handler_user_data);
}
break;
pattern = header_font[(uint8_t) *t][row];
buf[pos++] = (uint8_t) (pattern >> 8);
buf[pos++] = (uint8_t) (pattern & 0xFF);
}
while (pos < len)
buf[pos++] = 0;
s->header_row++;
if (s->header_row >= 16*repeats)
{
/* End of header. Change to normal image row data. */
set_row_read_handler(s, s->row_handler, s->row_handler_user_data);
}
return len;
}
......@@ -1113,7 +1108,7 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s)
break;
}
/* If there is a page header, create that first */
if (s->header_info && s->header_info[0] && make_header(s) == 0)
if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL && s->header_info && s->header_info[0] && make_header(s) == 0)
{
s->header_row = 0;
set_row_read_handler(s, header_row_read_handler, (void *) s);
......
......@@ -106,6 +106,7 @@ int image_width = 1728;
int octets_per_ecm_frame = 256;
int error_correcting_mode = FALSE;
int current_fallback = 0;
int end_of_page_detected = FALSE;
static void decode_20digit_msg(const uint8_t *pkt, int len)
{
......@@ -232,8 +233,6 @@ static int check_rx_dcs(const uint8_t *msg, int len)
if ((current_fallback = find_fallback_entry(dcs_frame[4] & (DISBIT6 | DISBIT5 | DISBIT4 | DISBIT3))) < 0)
printf("Remote asked for a modem standard we do not support\n");
error_correcting_mode = ((dcs_frame[6] & DISBIT3) != 0);
//v17_rx_restart(&v17, fallback_sequence[fallback_entry].bit_rate, FALSE);
return 0;
}
/*- End of function --------------------------------------------------------*/
......@@ -298,6 +297,7 @@ static void t4_begin(void)
t4_rx_start_page(&t4_rx_state);
t4_up = TRUE;
end_of_page_detected = FALSE;
for (i = 0; i < 256; i++)
ecm_len[i] = -1;
......@@ -381,7 +381,9 @@ static void v17_put_bit(void *user_data, int bit)
if (t4_rx_put_bit(&t4_rx_state, bit))
{
t4_end();
fprintf(stderr, "End of page detected\n");
if (!end_of_page_detected)
fprintf(stderr, "End of page detected\n");
end_of_page_detected = TRUE;
}
}
//printf("V.17 Rx bit %d - %d\n", rx_bits++, bit);
......@@ -417,7 +419,9 @@ static void v29_put_bit(void *user_data, int bit)
if (t4_rx_put_bit(&t4_rx_state, bit))
{
t4_end();
fprintf(stderr, "End of page detected\n");
if (!end_of_page_detected)
fprintf(stderr, "End of page detected\n");
end_of_page_detected = TRUE;
}
}
//printf("V.29 Rx bit %d - %d\n", rx_bits++, bit);
......@@ -453,7 +457,9 @@ static void v27ter_put_bit(void *user_data, int bit)
if (t4_rx_put_bit(&t4_rx_state, bit))
{
t4_end();
fprintf(stderr, "End of page detected\n");
if (!end_of_page_detected)
fprintf(stderr, "End of page detected\n");
end_of_page_detected = TRUE;
}
}
//printf("V.27ter Rx bit %d - %d\n", rx_bits++, bit);
......
......@@ -216,7 +216,7 @@ int line_model_monitor_line_spectrum_update(const int16_t amp[], int len)
#endif
}
s->in_ptr = 0;
#if defined(HAVE_FFTW3_H)
#if defined(HAVE_FFTW3_H)
fftw_execute(s->p);
#else
fftw_one(s->p, s->in, s->out);
......@@ -227,7 +227,7 @@ int line_model_monitor_line_spectrum_update(const int16_t amp[], int len)
for (i = 0; i < 512; i++)
{
s->spec_re_plot[2*i] = i*4000.0/512.0;
#if defined(HAVE_FFTW3_H)
#if defined(HAVE_FFTW3_H)
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i][0]*s->out[i][0] + s->out[i][1]*s->out[i][1])/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
#else
s->spec_re_plot[2*i + 1] = 10.0*log10((s->out[i].re*s->out[i].re + s->out[i].im*s->out[i].im)/(256.0*32768*256.0*32768) + 1.0e-10) + 3.14;
......@@ -395,7 +395,7 @@ int start_line_model_monitor(int len)
s->w->end();
s->w->show();
#if defined(HAVE_FFTW3_H)
#if defined(HAVE_FFTW3_H)
s->p = fftw_plan_dft_1d(1024, s->in, s->out, FFTW_BACKWARD, FFTW_ESTIMATE);
for (i = 0; i < 1024; i++)
{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论