22
22
* along with this program; if not, write to the Free Software
23
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
* $Id: t4_tests.c,v 1.34 2006/11/23 15:48:09 steveu Exp $
25
* $Id: t4_tests.c,v 1.36 2007/03/27 13:04:01 steveu Exp $
75
75
int add_page_headers;
80
82
const char *in_file_name;
83
84
decode_test = FALSE;
85
86
add_page_headers = FALSE;
86
87
restart_pages = FALSE;
87
88
in_file_name = IN_FILE_NAME;
91
for (i = 1; i < argc; i++)
93
if (strcmp(argv[i], "-b") == 0)
95
block_size = atoi(argv[++i]);
96
if (block_size > 1024)
91
100
if (strcmp(argv[i], "-d") == 0)
92
102
decode_test = TRUE;
93
else if (strcmp(argv[i], "-1") == 0)
105
if (strcmp(argv[i], "-1") == 0)
94
107
compression = T4_COMPRESSION_ITU_T4_1D;
95
else if (strcmp(argv[i], "-2") == 0)
110
if (strcmp(argv[i], "-2") == 0)
96
112
compression = T4_COMPRESSION_ITU_T4_2D;
97
else if (strcmp(argv[i], "-6") == 0)
115
if (strcmp(argv[i], "-6") == 0)
98
117
compression = T4_COMPRESSION_ITU_T6;
99
else if (strcmp(argv[i], "-h") == 0)
120
if (strcmp(argv[i], "-h") == 0)
100
122
add_page_headers = TRUE;
101
else if (strcmp(argv[i], "-r") == 0)
125
if (strcmp(argv[i], "-r") == 0)
102
127
restart_pages = TRUE;
103
else if (strcmp(argv[i], "-i") == 0)
130
if (strcmp(argv[i], "-i") == 0)
104
132
in_file_name = argv[++i];
105
else if (strcmp(argv[i], "-m") == 0)
135
if (strcmp(argv[i], "-m") == 0)
106
137
min_row_bits = atoi(argv[++i]);
109
141
/* Create a send and a receive end */
110
142
memset(&send_state, 0, sizeof(send_state));
111
143
memset(&receive_state, 0, sizeof(receive_state));
115
148
if (compression < 0)
231
264
t4_rx_start_page(&receive_state);
234
bit = t4_tx_get_bit(&send_state);
269
bit = t4_tx_get_bit(&send_state);
239
next_hit = rand() & 0x3FF;
240
while (next_hit < 20);
274
next_hit = rand() & 0x3FF;
275
while (next_hit < 20);
244
if (bit == PUTBIT_END_OF_DATA)
246
/* T.6 data does not contain an image termination sequence.
247
T.4 1D and 2D do, and should locate that sequence. */
248
if (compression == T4_COMPRESSION_ITU_T6)
250
if (++end_marks > 50)
252
printf("Receiver missed the end of page mark\n");
256
end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
258
while (!end_of_page);
279
if (bit == PUTBIT_END_OF_DATA)
281
/* T.6 data does not contain an image termination sequence.
282
T.4 1D and 2D do, and should locate that sequence. */
283
if (compression == T4_COMPRESSION_ITU_T6)
285
if (++end_marks > 50)
287
printf("Receiver missed the end of page mark\n");
291
end_of_page = t4_rx_put_bit(&receive_state, bit & 1);
293
while (!end_of_page);
295
else if (block_size == 1)
299
bit = t4_tx_get_byte(&send_state);
302
/* T.6 data does not contain an image termination sequence.
303
T.4 1D and 2D do, and should locate that sequence. */
304
if (compression == T4_COMPRESSION_ITU_T6)
306
if (++end_marks > 50)
308
printf("Receiver missed the end of page mark\n");
312
end_of_page = t4_rx_put_byte(&receive_state, bit & 0xFF);
314
while (!end_of_page);
320
bit = t4_tx_get_chunk(&send_state, block, block_size);
322
end_of_page = t4_rx_put_chunk(&receive_state, block, bit);
323
if (bit < block_size)
325
/* T.6 data does not contain an image termination sequence.
326
T.4 1D and 2D do, and should locate that sequence. */
327
if (compression == T4_COMPRESSION_ITU_T6)
329
if (++end_marks > 50)
331
printf("Receiver missed the end of page mark\n");
336
while (!end_of_page);
259
338
t4_get_transfer_statistics(&receive_state, &stats);
260
339
printf("Pages = %d\n", stats.pages_transferred);
261
340
printf("Image size = %d x %d\n", stats.width, stats.length);