Improvements to T.4 end of image handling, and the related tests.

A lot of tiny tidy up edits
This commit is contained in:
Steve Underwood
2012-08-12 22:11:06 +08:00
parent e69a5a3037
commit 5f12c3dc1c
80 changed files with 340 additions and 585 deletions

View File

@@ -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++)
{