T.85 compression has now been added to the FAX engine in spandsp

This commit is contained in:
Steve Underwood committed 2012-07-15 13:37:39 +08:00
1 parent 232fe67722
commit 4bcdafec68
35 files changed
+4625 -2819

No files matched your search

+26 -44
View File
@@ -61,12 +61,8 @@
#include "spandsp/timezone.h"
#include "spandsp/t4_rx.h"
#include "spandsp/t4_tx.h"
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85)
#include "spandsp/t81_t82_arith_coding.h"
#endif
#if defined(SPANDSP_SUPPORT_T85)
#include "spandsp/t85.h"
#endif
#if defined(SPANDSP_SUPPORT_T42)
#include "spandsp/t42.h"
#endif
@@ -83,12 +79,8 @@
#include "spandsp/private/logging.h"
#include "spandsp/private/timezone.h"
#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85)
#include "spandsp/private/t81_t82_arith_coding.h"
#endif
#if defined(SPANDSP_SUPPORT_T85)
#include "spandsp/private/t85.h"
#endif
#if defined(SPANDSP_SUPPORT_T42)
#include "spandsp/private/t42.h"
#endif
@@ -398,8 +390,9 @@ static const struct
static void queue_phase(t30_state_t *s, int phase);
static void set_phase(t30_state_t *s, int phase);
static void set_state(t30_state_t *s, int state);
static void send_simple_frame(t30_state_t *s, int type);
static void shut_down_hdlc_tx(t30_state_t *s);
static void send_frame(t30_state_t *s, const uint8_t *fr, int frlen);
static void send_simple_frame(t30_state_t *s, int type);
static void send_dcn(t30_state_t *s);
static void repeat_last_command(t30_state_t *s);
static void disconnect(t30_state_t *s);
@@ -834,6 +827,13 @@ static void print_frame(t30_state_t *s, const char *io, const uint8_t *msg, int
}
/*- End of function --------------------------------------------------------*/
static void shut_down_hdlc_tx(t30_state_t *s)
{
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
}
/*- End of function --------------------------------------------------------*/
static void send_frame(t30_state_t *s, const uint8_t *msg, int len)
{
print_frame(s, "Tx: ", msg, len);
@@ -1344,7 +1344,6 @@ static int build_dcs(t30_state_t *s)
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
break;
#endif
#if defined(SPANDSP_SUPPORT_T85)
case T4_COMPRESSION_ITU_T85:
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_MODE);
clr_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
@@ -1355,7 +1354,6 @@ static int build_dcs(t30_state_t *s)
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T85_L0_MODE);
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
break;
#endif
case T4_COMPRESSION_ITU_T6:
set_ctrl_bit(s->dcs_frame, T30_DCS_BIT_T6_MODE);
set_ctrl_bits(s->dcs_frame, T30_MIN_SCAN_0MS, 21);
@@ -1750,9 +1748,7 @@ static int send_dis_or_dtc_sequence(t30_state_t *s, int start)
break;
case 3:
s->step++;
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
break;
default:
return -1;
@@ -1805,9 +1801,7 @@ static int send_dis_or_dtc_sequence(t30_state_t *s, int start)
break;
case 8:
s->step++;
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
break;
default:
return -1;
@@ -1866,9 +1860,7 @@ static int send_dcs_sequence(t30_state_t *s, int start)
break;
case 7:
s->step++;
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
break;
default:
return -1;
@@ -2683,10 +2675,14 @@ static void process_rx_ppr(t30_state_t *s, const uint8_t *msg, int len)
int frame_no;
uint8_t frame[4];
if (len != 3 + 32)
if (len != 3 + 256/8)
{
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for PPR bits - %d\n", len);
/* TODO: probably should send DCN */
span_log(&s->logging, SPAN_LOG_FLOW, "Bad length for PPR bits - %d\n", (len - 3)*8);
/* This frame didn't get corrupted in transit, because its CRC is OK. It was sent bad
and there is little possibility that causing a retransmission will help. It is best
to just give up. */
t30_set_status(s, T30_ERR_TX_ECMPHD);
disconnect(s);
return;
}
/* Check which frames are OK, and mark them as OK. */
@@ -5866,9 +5862,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
case T30_STATE_F_CFR:
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else
@@ -5890,9 +5884,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
case T30_STATE_F_FTT:
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else
@@ -5908,9 +5900,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
case T30_STATE_F_POST_RCP_MCF:
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else
@@ -5962,9 +5952,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
case T30_STATE_IV_CTC:
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else
@@ -5987,9 +5975,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
case T30_STATE_C:
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else
@@ -6047,9 +6033,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
{
if (send_next_ecm_frame(s))
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
}
@@ -6068,9 +6052,7 @@ SPAN_DECLARE(void) t30_front_end_status(void *user_data, int status)
/* This should be the end of a CTR being sent. */
if (s->step == 0)
{
/* Shut down HDLC transmission. */
if (s->send_hdlc_handler)
s->send_hdlc_handler(s->send_hdlc_user_data, NULL, 0);
shut_down_hdlc_tx(s);
s->step++;
}
else