mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 14:58:34 +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
08eb4d72d5
commit
790c4d6eaa
80 files changed
+340
-585
No files matched your search
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -563,7 +563,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
exit (2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
printf("Test passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -89,7 +89,7 @@ int main (int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Test passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -216,7 +216,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -254,7 +254,7 @@ static level_measurement_device_t *level_measurement_device_create(int type)
|
||||
dev->factor = expf(-1.0f/((float) SAMPLE_RATE*0.035f));
|
||||
dev->power = 0;
|
||||
dev->type = type;
|
||||
return dev;
|
||||
return dev;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -1720,7 +1720,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -316,7 +316,7 @@ static void t4_end(void)
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (ecm_len[i] > 0)
|
||||
t4_rx_put_chunk(&t4_rx_state, ecm_data[i], ecm_len[i]);
|
||||
t4_rx_put(&t4_rx_state, ecm_data[i], ecm_len[i]);
|
||||
fprintf(stderr, "%d", (ecm_len[i] <= 0) ? 0 : 1);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
@@ -560,7 +560,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", filename);
|
||||
exit(2);
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -1138,7 +1138,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
|
||||
printf("%d\n", css_c3[i]);
|
||||
signal_free(&local_css);
|
||||
signal_free(&far_css);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -862,7 +862,7 @@ int main(int argc, char *argv[])
|
||||
decode_bitstream(in_file_name);
|
||||
else
|
||||
hdlc_tests();
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
fftw_destroy_plan(p);
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -1752,7 +1752,7 @@ int main(int argc, char *argv[])
|
||||
printf(" File gave %d hits.\n", hits);
|
||||
}
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -246,7 +246,7 @@ static int16_t channel_model(int16_t local, int16_t far)
|
||||
/* This mixed echo and far end signal will have been through an A-law munging when it came back into
|
||||
the digital network. */
|
||||
rx = codec_munger(rx);
|
||||
return rx;
|
||||
return rx;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -392,7 +392,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -230,7 +230,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
||||
exit (2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -260,14 +260,14 @@ then
|
||||
fi
|
||||
echo ima_adpcm_tests completed OK
|
||||
|
||||
./image_translate_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo image_translate_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
echo image_translate_tests completed OK
|
||||
#./image_translate_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||
#RETVAL=$?
|
||||
#if [ $RETVAL != 0 ]
|
||||
#then
|
||||
# echo image_translate_tests failed!
|
||||
# exit $RETVAL
|
||||
#fi
|
||||
#echo image_translate_tests completed OK
|
||||
|
||||
./logging_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
@@ -499,7 +499,23 @@ fi
|
||||
echo t38_non_ecm_buffer_tests completed OK
|
||||
|
||||
rm -f t4_tests_receive.tif
|
||||
./t4_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./t4_tests -b 0 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo t4_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
rm -f t4_tests_receive.tif
|
||||
./t4_tests -b 1 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo t4_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
rm -f t4_tests_receive.tif
|
||||
./t4_tests -b 10 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
|
||||
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
span_schedule_release(&sched);
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -656,7 +656,7 @@ int main(int argc, char *argv[])
|
||||
/*endfor*/
|
||||
|
||||
printf("Tests completed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -198,7 +198,7 @@ static int parse_tone(super_tone_rx_descriptor_t *desc, int tone_id, super_tone_
|
||||
cur = cur->next;
|
||||
}
|
||||
/*endwhile*/
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -177,7 +177,7 @@ static int parse_tone(super_tone_tx_step_t **tree, xmlDocPtr doc, xmlNsPtr ns, x
|
||||
cur = cur->next;
|
||||
}
|
||||
/*endwhile*/
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -934,7 +934,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
t30_tests(t38_mode, use_gui, log_audio, test_sending, g1050_model_no, g1050_speed_pattern_no);
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
|
||||
printf("Decoded as %s %s %s\n", (country) ? country : "???", (vendor) ? vendor : "???", (model) ? model : "???");
|
||||
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -728,7 +728,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -699,7 +699,7 @@ int main(int argc, char *argv[])
|
||||
t38_non_ecm_buffer_report_output_status(&buffer, &logging);
|
||||
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -287,9 +287,9 @@ int main(int argc, char *argv[])
|
||||
printf("0x%02x\n", data[i]);
|
||||
t85_decode_init(&t85_dec, t85_row_write_handler, NULL);
|
||||
t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL);
|
||||
result = t85_decode_put_chunk(&t85_dec, data, total_len);
|
||||
result = t85_decode_put(&t85_dec, data, total_len);
|
||||
if (result == T4_DECODE_MORE_DATA)
|
||||
result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
|
||||
result = t85_decode_put(&t85_dec, NULL, 0);
|
||||
len = t85_decode_get_compressed_image_size(&t85_dec);
|
||||
printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
|
||||
t85_decode_release(&t85_dec);
|
||||
@@ -331,7 +331,7 @@ int main(int argc, char *argv[])
|
||||
t85_dec.min_bit_planes = 1;
|
||||
t85_dec.max_bit_planes = 8;
|
||||
data5_ptr = 0;
|
||||
result = t85_decode_put_chunk(&t85_dec, data, total_len);
|
||||
result = t85_decode_put(&t85_dec, data, total_len);
|
||||
len = t85_decode_get_compressed_image_size(&t85_dec);
|
||||
printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
|
||||
|
||||
@@ -343,14 +343,14 @@ int main(int argc, char *argv[])
|
||||
t85_decode_new_plane(&t85_dec);
|
||||
data5_ptr = 0;
|
||||
t85_decode_set_comment_handler(&t85_dec, 1000, t85_comment_handler, NULL);
|
||||
result = t85_decode_put_chunk(&t85_dec, data, total_len);
|
||||
result = t85_decode_put(&t85_dec, data, total_len);
|
||||
len = t85_decode_get_compressed_image_size(&t85_dec);
|
||||
printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
|
||||
}
|
||||
if (result == T4_DECODE_MORE_DATA)
|
||||
{
|
||||
printf("More\n");
|
||||
result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
|
||||
result = t85_decode_put(&t85_dec, NULL, 0);
|
||||
}
|
||||
len = t85_decode_get_compressed_image_size(&t85_dec);
|
||||
printf("Compressed image is %d bytes, %d rows\n", len/8, write_row);
|
||||
|
||||
@@ -394,27 +394,10 @@ int main(int argc, char *argv[])
|
||||
end_of_page = t4_t6_decode_put_bit(&receive_state, bit & 1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
do
|
||||
{
|
||||
bit = t4_t6_encode_get_byte(&send_state);
|
||||
if ((bit & 0x100))
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
end_of_page = t4_t6_decode_put_byte(&receive_state, bit & 0xFF);
|
||||
}
|
||||
while (!end_of_page);
|
||||
break;
|
||||
default:
|
||||
do
|
||||
{
|
||||
len = t4_t6_encode_get_chunk(&send_state, chunk_buf, block_size);
|
||||
len = t4_t6_encode_get(&send_state, chunk_buf, block_size);
|
||||
if (len == 0)
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
@@ -426,7 +409,7 @@ int main(int argc, char *argv[])
|
||||
chunk_buf[0] = 0xFF;
|
||||
len = 1;
|
||||
}
|
||||
end_of_page = t4_t6_decode_put_chunk(&receive_state, chunk_buf, len);
|
||||
end_of_page = t4_t6_decode_put(&receive_state, chunk_buf, len);
|
||||
}
|
||||
while (!end_of_page);
|
||||
break;
|
||||
|
||||
+88
-103
@@ -263,7 +263,7 @@ static int detect_page_end(int bit, int page_ended)
|
||||
if (!page_ended)
|
||||
{
|
||||
/* We might need to push a few bits to get the receiver to report the
|
||||
end of page condition (at least with T.6). */
|
||||
end of page condition (at least with T.6). */
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
@@ -316,6 +316,7 @@ int main(int argc, char *argv[])
|
||||
const char *page_header_tz;
|
||||
tz_t tz;
|
||||
int opt;
|
||||
int len;
|
||||
int i;
|
||||
int bit_error_rate;
|
||||
int dump_as_xxx;
|
||||
@@ -424,7 +425,7 @@ int main(int argc, char *argv[])
|
||||
memset(&send_state, 0, sizeof(send_state));
|
||||
memset(&receive_state, 0, sizeof(receive_state));
|
||||
|
||||
end_of_page = FALSE;
|
||||
end_of_page = T4_DECODE_MORE_DATA;
|
||||
if (decode_file_name)
|
||||
{
|
||||
if (compression < 0)
|
||||
@@ -454,9 +455,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[18 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit;
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (sscanf(buf, "HDLC: %x", &pkt_no) == 1)
|
||||
{
|
||||
@@ -465,9 +466,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[19 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit;
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (sscanf(buf, "%*d:%*d:%*d.%*d T.38 Rx %d: IFP %x %x", &pkt_no, (unsigned int *) &bit, (unsigned int *) &bit) == 3)
|
||||
{
|
||||
@@ -479,10 +480,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[47 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
bit = bit_reverse8(bit);
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit_reverse8(bit);
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (strlen(buf) > 2 && sscanf(buf, "T.30 Rx: %x %x", (unsigned int *) &bit, (unsigned int *) &bit) == 2)
|
||||
{
|
||||
@@ -494,10 +494,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[22 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
bit = bit_reverse8(bit);
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit_reverse8(bit);
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (sscanf(buf, "%04x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
|
||||
{
|
||||
@@ -505,10 +504,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[6 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
bit = bit_reverse8(bit);
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit_reverse8(bit);
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (sscanf(buf, "%08x %02x %02x %02x", (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit) == 4)
|
||||
{
|
||||
@@ -516,10 +514,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (sscanf(&buf[10 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
bit = bit_reverse8(bit);
|
||||
if ((end_of_page = t4_rx_put_byte(&receive_state, bit)))
|
||||
break;
|
||||
block[i] = bit_reverse8(bit);
|
||||
}
|
||||
end_of_page = t4_rx_put(&receive_state, block, i);
|
||||
}
|
||||
else if (sscanf(buf, "Rx bit %*d - %d", &bit) == 1)
|
||||
{
|
||||
@@ -575,7 +572,7 @@ int main(int argc, char *argv[])
|
||||
if (compression_step >= 0)
|
||||
{
|
||||
compression = compression_sequence[compression_step++];
|
||||
if (compression < 0)
|
||||
if (compression < 0 || (block_size == 0 && compression_step >= 3))
|
||||
break;
|
||||
}
|
||||
t4_tx_set_tx_encoding(&send_state, compression);
|
||||
@@ -587,64 +584,66 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
if (t4_rx_start_page(&receive_state))
|
||||
break;
|
||||
detect_page_end(-1000000, compression);
|
||||
page_ended = FALSE;
|
||||
switch (block_size)
|
||||
{
|
||||
case 0:
|
||||
do
|
||||
while ((bit = t4_tx_get_bit(&send_state)) >= 0)
|
||||
{
|
||||
bit = t4_tx_get_bit(&send_state);
|
||||
if (bit == SIG_STATUS_END_OF_DATA)
|
||||
/* Monitor whether the EOLs are there in the correct amount */
|
||||
if ((res = detect_page_end(bit, page_ended)))
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
printf("Incorrect EOLs - %d\n", res);
|
||||
tests_failed += (res - 1);
|
||||
break;
|
||||
}
|
||||
end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
|
||||
}
|
||||
while (!end_of_page);
|
||||
break;
|
||||
case 1:
|
||||
do
|
||||
{
|
||||
bit = t4_tx_get_byte(&send_state);
|
||||
if ((bit & 0x100))
|
||||
if (bit >= 0)
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
if (bit_error_rate)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
if ((rand() % bit_error_rate) == 0)
|
||||
bit ^= 1;
|
||||
}
|
||||
end_of_page = t4_rx_put_bit(&receive_state, bit);
|
||||
}
|
||||
end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
|
||||
}
|
||||
while (!end_of_page);
|
||||
if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
|
||||
while (end_of_page != T4_DECODE_OK)
|
||||
{
|
||||
printf("Page ended, but source is not reporting end of data\n");
|
||||
tests_failed++;
|
||||
end_of_page = t4_rx_put_bit(&receive_state, 0);
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Now throw junk at the receive context, to ensure stuff occuring
|
||||
after the end of page condition has no bad effect. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
|
||||
break;
|
||||
default:
|
||||
/* Some decoders require a few extra bits before the recognise the end
|
||||
of an image, so be prepared to offer it a few. */
|
||||
do
|
||||
{
|
||||
bit = t4_tx_get_chunk(&send_state, block, block_size);
|
||||
if (bit > 0)
|
||||
end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
|
||||
if (bit < block_size)
|
||||
len = t4_tx_get(&send_state, block, block_size);
|
||||
if (len > 0)
|
||||
end_of_page = t4_rx_put(&receive_state, block, len);
|
||||
}
|
||||
while (len > 0);
|
||||
while (end_of_page != T4_DECODE_OK)
|
||||
{
|
||||
block[0] = 0;
|
||||
end_of_page = t4_rx_put(&receive_state, block, 1);
|
||||
if (++end_marks > 5)
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (!end_of_page);
|
||||
break;
|
||||
}
|
||||
display_page_stats(&receive_state);
|
||||
@@ -711,7 +710,7 @@ int main(int argc, char *argv[])
|
||||
if (compression_step >= 0)
|
||||
{
|
||||
compression = compression_sequence[compression_step++];
|
||||
if (compression < 0)
|
||||
if (compression < 0 || (block_size == 0 && compression_step >= 3))
|
||||
{
|
||||
compression_step = 0;
|
||||
compression = compression_sequence[compression_step++];
|
||||
@@ -732,72 +731,58 @@ int main(int argc, char *argv[])
|
||||
switch (block_size)
|
||||
{
|
||||
case 0:
|
||||
for (;;)
|
||||
while ((bit = t4_tx_get_bit(&send_state)) >= 0)
|
||||
{
|
||||
bit = t4_tx_get_bit(&send_state);
|
||||
/* Monitor whether the EOLs are there in the correct amount */
|
||||
if ((res = detect_page_end(bit, page_ended)))
|
||||
{
|
||||
printf("Incorrect EOLs - %d\n", res);
|
||||
tests_failed += (res - 1);
|
||||
break;
|
||||
}
|
||||
if (!page_ended)
|
||||
if (bit_error_rate)
|
||||
{
|
||||
if (bit_error_rate)
|
||||
{
|
||||
if ((rand() % bit_error_rate) == 0)
|
||||
bit ^= 1;
|
||||
}
|
||||
if (t4_rx_put_bit(&receive_state, bit & 1))
|
||||
page_ended = TRUE;
|
||||
if ((rand() % bit_error_rate) == 0)
|
||||
bit ^= 1;
|
||||
}
|
||||
end_of_page = t4_rx_put_bit(&receive_state, bit);
|
||||
}
|
||||
while (end_of_page != T4_DECODE_OK)
|
||||
{
|
||||
end_of_page = t4_rx_put_bit(&receive_state, 0);
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Now throw junk at the receive context, to ensure stuff occuring
|
||||
after the end of page condition has no bad effect. */
|
||||
for (i = 0; i < 1000; i++)
|
||||
{
|
||||
t4_rx_put_bit(&receive_state, (rand() >> 10) & 1);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
do
|
||||
{
|
||||
bit = t4_tx_get_byte(&send_state);
|
||||
if ((bit & 0x100))
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
|
||||
}
|
||||
while (!end_of_page);
|
||||
if ((t4_tx_get_byte(&send_state) & 0x100) == 0)
|
||||
{
|
||||
printf("Page ended, but source is not reporting end of data\n");
|
||||
tests_failed++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
do
|
||||
{
|
||||
bit = t4_tx_get_chunk(&send_state, block, block_size);
|
||||
if (bit > 0)
|
||||
end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
|
||||
if (bit < block_size)
|
||||
len = t4_tx_get(&send_state, block, block_size);
|
||||
if (len > 0)
|
||||
end_of_page = t4_rx_put(&receive_state, block, len);
|
||||
}
|
||||
while (len > 0);
|
||||
/* Some decoders require a few extra bits before the recognise the end
|
||||
of an image, so be prepared to offer it a few. */
|
||||
while (end_of_page != T4_DECODE_OK)
|
||||
{
|
||||
block[0] = 0;
|
||||
end_of_page = t4_rx_put(&receive_state, block, 1);
|
||||
if (++end_marks > 5)
|
||||
{
|
||||
if (++end_marks > 50)
|
||||
{
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
printf("Receiver missed the end of page mark\n");
|
||||
tests_failed++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (!end_of_page);
|
||||
break;
|
||||
}
|
||||
if (dump_as_xxx)
|
||||
|
||||
@@ -229,7 +229,7 @@ static int test_cycle(const char *test_id,
|
||||
|
||||
testbuf_len = 0;
|
||||
max_len = 100;
|
||||
while ((len = t85_encode_get_chunk(&t85_enc, &testbuf[testbuf_len], max_len)) > 0)
|
||||
while ((len = t85_encode_get(&t85_enc, &testbuf[testbuf_len], max_len)) > 0)
|
||||
{
|
||||
testbuf_len += len;
|
||||
max_len = 100;
|
||||
@@ -261,9 +261,9 @@ static int test_cycle(const char *test_id,
|
||||
if (comment && comment[0] != 'X')
|
||||
t85_decode_set_comment_handler(&t85_dec, 1000, comment_handler, NULL);
|
||||
write_row = 0;
|
||||
result = t85_decode_put_chunk(&t85_dec, testbuf, testbuf_len);
|
||||
result = t85_decode_put(&t85_dec, testbuf, testbuf_len);
|
||||
if (result == T4_DECODE_MORE_DATA)
|
||||
result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
|
||||
result = t85_decode_put(&t85_dec, NULL, 0);
|
||||
cnt_a = t85_encode_get_compressed_image_size(&t85_enc);
|
||||
cnt_b = t85_decode_get_compressed_image_size(&t85_dec);
|
||||
if (cnt_a != cnt_b || cnt_a != testbuf_len*8 || result != T4_DECODE_OK)
|
||||
@@ -300,7 +300,7 @@ static int test_cycle(const char *test_id,
|
||||
result = T4_DECODE_MORE_DATA;
|
||||
for (l = 0; l < testbuf_len; l++)
|
||||
{
|
||||
result = t85_decode_put_chunk(&t85_dec, &testbuf[l], 1);
|
||||
result = t85_decode_put(&t85_dec, &testbuf[l], 1);
|
||||
if (result != T4_DECODE_MORE_DATA)
|
||||
{
|
||||
l++;
|
||||
@@ -308,7 +308,7 @@ static int test_cycle(const char *test_id,
|
||||
}
|
||||
}
|
||||
if (result == T4_DECODE_MORE_DATA)
|
||||
result = t85_decode_put_byte(&t85_dec, SIG_STATUS_END_OF_DATA);
|
||||
result = t85_decode_put(&t85_dec, NULL, 0);
|
||||
if (l != testbuf_len || result != T4_DECODE_OK)
|
||||
{
|
||||
printf("Decode result %d\n", result);
|
||||
|
||||
@@ -127,7 +127,7 @@ static int periodogram_tests(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
if (periodogram_tests())
|
||||
exit(2);
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
exit (2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -989,7 +989,7 @@ static int next_step(faxtester_state_t *s)
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
|
||||
len = t4_tx_get(&t4_tx_state, image, sizeof(image));
|
||||
if (bad_rows)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
|
||||
@@ -1030,7 +1030,7 @@ static int next_step(faxtester_state_t *s)
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
len = t4_tx_get_chunk(&t4_tx_state, image, sizeof(image));
|
||||
len = t4_tx_get(&t4_tx_state, image, sizeof(image));
|
||||
if (bad_rows)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n");
|
||||
|
||||
@@ -600,7 +600,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -476,7 +476,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -585,7 +585,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -192,7 +192,7 @@ int main(int argc, char *argv[])
|
||||
bit ^= 1;
|
||||
v42_rx_bit(&caller, bit);
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
Reference in new issue
Block a user