Lots of little cosmetic cleanups

This commit is contained in:
Steve Underwood
2013-03-14 21:22:51 +08:00
parent 16289ce9a4
commit d163c6338e
110 changed files with 7259 additions and 762 deletions

View File

@@ -98,9 +98,13 @@
#include <spandsp/v29tx.h> #include <spandsp/v29tx.h>
#include <spandsp/v17rx.h> #include <spandsp/v17rx.h>
#include <spandsp/v17tx.h> #include <spandsp/v17tx.h>
#include <spandsp/v32bis.h>
#include <spandsp/v22bis.h> #include <spandsp/v22bis.h>
#include <spandsp/v27ter_rx.h> #include <spandsp/v27ter_rx.h>
#include <spandsp/v27ter_tx.h> #include <spandsp/v27ter_tx.h>
#if defined(SPANDSP_SUPPORT_V34)
#include <spandsp/v34.h>
#endif
#include <spandsp/v18.h> #include <spandsp/v18.h>
#include <spandsp/timezone.h> #include <spandsp/timezone.h>
#include <spandsp/t4_rx.h> #include <spandsp/t4_rx.h>

View File

@@ -274,7 +274,8 @@ extern "C"
__inline float rintf(float flt) __inline float rintf(float flt)
{ {
_asm _asm
{ fld flt {
fld flt
frndint frndint
} }
} }

View File

@@ -63,7 +63,6 @@ SPAN_DECLARE(void) t81_t82_arith_encode(t81_t82_arith_encode_state_t *s, int cx,
SPAN_DECLARE(void) t81_t82_arith_encode_flush(t81_t82_arith_encode_state_t *s); SPAN_DECLARE(void) t81_t82_arith_encode_flush(t81_t82_arith_encode_state_t *s);
SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_arith_decode_state_t *s); SPAN_DECLARE(t81_t82_arith_decode_state_t *) t81_t82_arith_decode_init(t81_t82_arith_decode_state_t *s);
SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, int reuse_st); SPAN_DECLARE(int) t81_t82_arith_decode_restart(t81_t82_arith_decode_state_t *s, int reuse_st);

View File

@@ -278,7 +278,6 @@ SPAN_DECLARE(int) super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max
tree = s->levels[--s->level]; tree = s->levels[--s->level];
} }
} }
} }
return samples; return samples;
} }

View File

@@ -1105,6 +1105,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message); span_log(logging, SPAN_LOG_FLOW, "%s\n", escape.error_message);
else else
span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n"); span_log(logging, SPAN_LOG_FLOW, "Unspecified libjpeg error.\n");
printf("Error %s.\n", escape.error_message);
if (scan_line_out) if (scan_line_out)
free(scan_line_out); free(scan_line_out);
fclose(in); fclose(in);
@@ -1134,14 +1135,17 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
if (!is_itu_fax(logging, s, decompressor.marker_list)) if (!is_itu_fax(logging, s, decompressor.marker_list))
{ {
span_log(logging, SPAN_LOG_FLOW, "Is not an ITU FAX.\n"); span_log(logging, SPAN_LOG_FLOW, "Is not an ITU FAX.\n");
return FALSE; printf("Is not an ITU FAX 1.\n");
//return FALSE;
} }
/* Copy size, resolution, etc */ /* Copy size, resolution, etc */
*width = decompressor.image_width; *width = decompressor.image_width;
*height = decompressor.image_height; *height = decompressor.image_height;
printf("Is %d x %d\n", decompressor.image_width, decompressor.image_height);
jpeg_start_decompress(&decompressor); jpeg_start_decompress(&decompressor);
printf("Is %d x %d x %d.\n", decompressor.output_width, decompressor.output_height, decompressor.num_components);
if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL) if ((scan_line_in = (JSAMPROW) malloc(decompressor.output_width*decompressor.num_components)) == NULL)
return FALSE; return FALSE;
@@ -1151,6 +1155,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
jpeg_read_scanlines(&decompressor, &scan_line_in, 1); jpeg_read_scanlines(&decompressor, &scan_line_in, 1);
lab_to_srgb(s, scan_line_out, scan_line_in, decompressor.output_width); lab_to_srgb(s, scan_line_out, scan_line_in, decompressor.output_width);
} }
printf("Next %d\n", decompressor.output_scanline);
free(scan_line_in); free(scan_line_in);
jpeg_finish_decompress(&decompressor); jpeg_finish_decompress(&decompressor);
@@ -1159,6 +1164,7 @@ SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s,
*dstlen = pos; *dstlen = pos;
printf("Next2 %d\n", decompressor.output_scanline);
return TRUE; return TRUE;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@@ -75,7 +75,6 @@ static __inline__ int flag_is_changeable_p(uint32_t flag)
" popfl\n" " popfl\n"
: "=&r" (f1), "=&r" (f2) : "=&r" (f1), "=&r" (f2)
: "ir" (flag)); : "ir" (flag));
return ((f1^f2) & flag) != 0; return ((f1^f2) & flag) != 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@@ -23,10 +23,6 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED.
Currently it performs the core compression and decompression functions OK.
However, a number of the bells and whistles in V.42bis are incomplete. */
/*! \file */ /*! \file */
#if defined(HAVE_CONFIG_H) #if defined(HAVE_CONFIG_H)

View File

@@ -83,189 +83,189 @@ struct
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_FINE, T4_Y_RESOLUTION_FINE,
T4_WIDTH_R8_A4, T4_WIDTH_R8_A4,
2200 1100*2
}, },
{ {
"R8_77_B4.tif", "R8_77_B4.tif",
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_FINE, T4_Y_RESOLUTION_FINE,
T4_WIDTH_R8_B4, T4_WIDTH_R8_B4,
2400 1200*2
}, },
{ {
"R8_77_A3.tif", "R8_77_A3.tif",
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_FINE, T4_Y_RESOLUTION_FINE,
T4_WIDTH_R8_A3, T4_WIDTH_R8_A3,
3111 1556*2
}, },
{ {
"R8_154_A4.tif", "R8_154_A4.tif",
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R8_A4, T4_WIDTH_R8_A4,
4400 1100*4
}, },
{ {
"R8_154_B4.tif", "R8_154_B4.tif",
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R8_B4, T4_WIDTH_R8_B4,
4800 1200*4
}, },
{ {
"R8_154_A3.tif", "R8_154_A3.tif",
T4_X_RESOLUTION_R8, T4_X_RESOLUTION_R8,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R8_A3, T4_WIDTH_R8_A3,
6222 1556*4
}, },
{ {
"R300_300_A4.tif", "R300_300_A4.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_300, T4_Y_RESOLUTION_300,
T4_WIDTH_300_A4, T4_WIDTH_300_A4,
4400 1100*3
}, },
{ {
"R300_300_B4.tif", "R300_300_B4.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_300, T4_Y_RESOLUTION_300,
T4_WIDTH_300_B4, T4_WIDTH_300_B4,
4800 1200*3
}, },
{ {
"R300_300_A3.tif", "R300_300_A3.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_300, T4_Y_RESOLUTION_300,
T4_WIDTH_300_A3, T4_WIDTH_300_A3,
6222 1556*3
}, },
{ {
"R300_600_A4.tif", "R300_600_A4.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_300_A4, T4_WIDTH_300_A4,
4400 1100*6
}, },
{ {
"R300_600_B4.tif", "R300_600_B4.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_300_B4, T4_WIDTH_300_B4,
4800 1200*6
}, },
{ {
"R300_600_A3.tif", "R300_600_A3.tif",
T4_X_RESOLUTION_300, T4_X_RESOLUTION_300,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_300_A3, T4_WIDTH_300_A3,
6222 1556*6
}, },
{ {
"R16_154_A4.tif", "R16_154_A4.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R16_A4, T4_WIDTH_R16_A4,
4400 1100*4
}, },
{ {
"R16_154_B4.tif", "R16_154_B4.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R16_B4, T4_WIDTH_R16_B4,
4800 1200*4
}, },
{ {
"R16_154_A3.tif", "R16_154_A3.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_SUPERFINE, T4_Y_RESOLUTION_SUPERFINE,
T4_WIDTH_R16_A3, T4_WIDTH_R16_A3,
6222 1556*4
}, },
{ {
"R16_800_A4.tif", "R16_800_A4.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_800, T4_Y_RESOLUTION_800,
T4_WIDTH_R16_A4, T4_WIDTH_R16_A4,
4400 1100*8
}, },
{ {
"R16_800_B4.tif", "R16_800_B4.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_800, T4_Y_RESOLUTION_800,
T4_WIDTH_R16_B4, T4_WIDTH_R16_B4,
4800 1200*8
}, },
{ {
"R16_800_A3.tif", "R16_800_A3.tif",
T4_X_RESOLUTION_R16, T4_X_RESOLUTION_R16,
T4_Y_RESOLUTION_800, T4_Y_RESOLUTION_800,
T4_WIDTH_R16_A3, T4_WIDTH_R16_A3,
6222 1556*8
}, },
{ {
"R600_600_A4.tif", "R600_600_A4.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_600_A4, T4_WIDTH_600_A4,
4400 1100*6
}, },
{ {
"R600_600_B4.tif", "R600_600_B4.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_600_B4, T4_WIDTH_600_B4,
4800 1200*6
}, },
{ {
"R600_600_A3.tif", "R600_600_A3.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_600, T4_Y_RESOLUTION_600,
T4_WIDTH_600_A3, T4_WIDTH_600_A3,
6222 1556*6
}, },
{ {
"R600_1200_A4.tif", "R600_1200_A4.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_600_A4, T4_WIDTH_600_A4,
4400 1100*12
}, },
{ {
"R600_1200_B4.tif", "R600_1200_B4.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_600_B4, T4_WIDTH_600_B4,
4800 1200*12
}, },
{ {
"R600_1200_A3.tif", "R600_1200_A3.tif",
T4_X_RESOLUTION_600, T4_X_RESOLUTION_600,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_600_A3, T4_WIDTH_600_A3,
6222 1556*12
}, },
{ {
"R1200_1200_A4.tif", "R1200_1200_A4.tif",
T4_X_RESOLUTION_1200, T4_X_RESOLUTION_1200,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_1200_A4, T4_WIDTH_1200_A4,
4400 1100*12
}, },
{ {
"R1200_1200_B4.tif", "R1200_1200_B4.tif",
T4_X_RESOLUTION_1200, T4_X_RESOLUTION_1200,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_1200_B4, T4_WIDTH_1200_B4,
4800 1200*12
}, },
{ {
"R1200_1200_A3.tif", "R1200_1200_A3.tif",
T4_X_RESOLUTION_1200, T4_X_RESOLUTION_1200,
T4_Y_RESOLUTION_1200, T4_Y_RESOLUTION_1200,
T4_WIDTH_1200_A3, T4_WIDTH_1200_A3,
6222 1556*12
}, },
{ {
NULL, NULL,

View File

@@ -236,14 +236,14 @@ int main(int argc, char *argv[])
/* Test 1: Mitel's test 1 isn't really a test. Its a calibration step, /* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
which has no meaning here. */ which has no meaning here. */
printf ("Test 1: Calibration\n"); printf("Test 1: Calibration\n");
printf (" Passed\n"); printf(" Passed\n");
/* Test 2: Decode check /* Test 2: Decode check
This is a sanity check, that all digits are reliably detected This is a sanity check, that all digits are reliably detected
under ideal conditions. Each possible digit is repeated 10 times, under ideal conditions. Each possible digit is repeated 10 times,
with 68ms bursts. The level of each tone is about 6dB down from clip */ with 68ms bursts. The level of each tone is about 6dB down from clip */
printf ("Test 2: Decode check\n"); printf("Test 2: Decode check\n");
my_mf_gen_init(0.0, -3, 0.0, -3, 68, 68); my_mf_gen_init(0.0, -3, 0.0, -3, 68, 68);
s = ALL_POSSIBLE_DIGITS; s = ALL_POSSIBLE_DIGITS;
digit[1] = '\0'; digit[1] = '\0';
@@ -258,14 +258,14 @@ int main(int argc, char *argv[])
actual = bell_mf_rx_get(mf_state, buf, 128); actual = bell_mf_rx_get(mf_state, buf, 128);
if (actual != 1 || buf[0] != digit[0]) if (actual != 1 || buf[0] != digit[0])
{ {
printf (" Sent '%s'\n", digit); printf(" Sent '%s'\n", digit);
printf (" Received '%s' [%d]\n", buf, actual); printf(" Received '%s' [%d]\n", buf, actual);
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
} }
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 3: Recognition bandwidth and channel centre frequency check. /* Test 3: Recognition bandwidth and channel centre frequency check.
Use all digits. Each digit types requires four tests to complete Use all digits. Each digit types requires four tests to complete
@@ -295,7 +295,7 @@ int main(int argc, char *argv[])
The spec calls for +-1.5% +-10Hz of bandwidth. The spec calls for +-1.5% +-10Hz of bandwidth.
*/ */
printf ("Test 3: Recognition bandwidth and channel centre frequency check\n"); printf("Test 3: Recognition bandwidth and channel centre frequency check\n");
s = ALL_POSSIBLE_DIGITS; s = ALL_POSSIBLE_DIGITS;
digit[1] = '\0'; digit[1] = '\0';
j = 0; j = 0;
@@ -320,7 +320,7 @@ int main(int argc, char *argv[])
} }
rrb = (float) (nplus + nminus)/10.0; rrb = (float) (nplus + nminus)/10.0;
rcfo = (float) (nplus - nminus)/10.0; rcfo = (float) (nplus - nminus)/10.0;
printf (" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n", printf(" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
digit[0], digit[0],
rrb, rrb,
rcfo, rcfo,
@@ -329,8 +329,8 @@ int main(int argc, char *argv[])
if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f1) || rrb >= 15.0 + rcfo) if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f1) || rrb >= 15.0 + rcfo)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
for (nplus = 0, i = 1; i <= 60; i++) for (nplus = 0, i = 1; i <= 60; i++)
@@ -351,7 +351,7 @@ int main(int argc, char *argv[])
} }
rrb = (float) (nplus + nminus)/10.0; rrb = (float) (nplus + nminus)/10.0;
rcfo = (float) (nplus - nminus)/10.0; rcfo = (float) (nplus - nminus)/10.0;
printf (" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n", printf(" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
digit[0], digit[0],
rrb, rrb,
rcfo, rcfo,
@@ -359,19 +359,19 @@ int main(int argc, char *argv[])
(float) nplus/10.0); (float) nplus/10.0);
if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f2) || rrb >= 15.0 + rcfo) if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f2) || rrb >= 15.0 + rcfo)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
j++; j++;
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 4: Acceptable amplitude ratio (twist). /* Test 4: Acceptable amplitude ratio (twist).
Twist all digits in both directions, and check the maximum twist Twist all digits in both directions, and check the maximum twist
we can accept. The way this is done is styled after the Mitel DTMF we can accept. The way this is done is styled after the Mitel DTMF
test, and has good and bad points. */ test, and has good and bad points. */
printf ("Test 4: Acceptable amplitude ratio (twist)\n"); printf("Test 4: Acceptable amplitude ratio (twist)\n");
s = ALL_POSSIBLE_DIGITS; s = ALL_POSSIBLE_DIGITS;
digit[1] = '\0'; digit[1] = '\0';
while (*s) while (*s)
@@ -538,12 +538,12 @@ int main(int argc, char *argv[])
if (!callback_ok) if (!callback_ok)
{ {
printf(" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
printf(" Passed\n"); printf(" Passed\n");
duration = time (NULL) - now; duration = time (NULL) - now;
printf ("Tests passed in %ds\n", duration); printf("Tests passed in %ds\n", duration);
return 0; return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@@ -858,6 +858,7 @@ int main(int argc, char *argv[])
| T30_SUPPORT_300_600_RESOLUTION | T30_SUPPORT_300_600_RESOLUTION
| T30_SUPPORT_400_800_RESOLUTION | T30_SUPPORT_400_800_RESOLUTION
| T30_SUPPORT_600_1200_RESOLUTION); | T30_SUPPORT_600_1200_RESOLUTION);
//t30_set_rx_encoding(t30_state[i], T4_COMPRESSION_ITU_T85);
t30_set_ecm_capability(t30_state[i], use_ecm); t30_set_ecm_capability(t30_state[i], use_ecm);
if (use_ecm) if (use_ecm)
{ {

View File

@@ -287,6 +287,9 @@ int pcap_scan_pkts(const char *file,
fprintf(stderr, "Truncated packet - total len = %d, captured len = %d\n", pkthdr->len, pkthdr->caplen); fprintf(stderr, "Truncated packet - total len = %d, captured len = %d\n", pkthdr->len, pkthdr->caplen);
exit(2); exit(2);
} }
#if 0
printf("%d:%d -> %d:%d\n", ntohl(iphdr->saddr), ntohs(udphdr->source), ntohl(iphdr->daddr), ntohs(udphdr->dest));
#endif
body = (const uint8_t *) udphdr; body = (const uint8_t *) udphdr;
body += sizeof(struct udphdr); body += sizeof(struct udphdr);
body_len = pktlen - sizeof(struct udphdr); body_len = pktlen - sizeof(struct udphdr);

View File

@@ -245,15 +245,15 @@ static int test_a_tone_set(int fwd)
/* Test 1: Mitel's test 1 isn't really a test. Its a calibration step, /* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
which has no meaning here. */ which has no meaning here. */
printf ("Test 1: Calibration\n"); printf("Test 1: Calibration\n");
printf (" Passed\n"); printf(" Passed\n");
/* Test 2: Decode check /* Test 2: Decode check
This is a sanity check, that all digits are reliably detected This is a sanity check, that all digits are reliably detected
under ideal conditions. Each possible digit is repeated 10 times, under ideal conditions. Each possible digit is repeated 10 times,
with 68ms bursts. The level of each tone is about 6dB down from clip */ with 68ms bursts. The level of each tone is about 6dB down from clip */
printf ("Test 2: Decode check\n"); printf("Test 2: Decode check\n");
my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd); my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd);
s = r2_mf_tone_codes; s = r2_mf_tone_codes;
while (*s) while (*s)
@@ -267,14 +267,14 @@ static int test_a_tone_set(int fwd)
actual = r2_mf_rx_get(mf_state); actual = r2_mf_rx_get(mf_state);
if (actual != digit) if (actual != digit)
{ {
printf (" Sent '%c'\n", digit); printf(" Sent '%c'\n", digit);
printf (" Received 0x%X\n", actual); printf(" Received 0x%X\n", actual);
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
} }
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 3: Recognition bandwidth and channel centre frequency check. /* Test 3: Recognition bandwidth and channel centre frequency check.
Use all digits. Each digit types requires four tests to complete Use all digits. Each digit types requires four tests to complete
@@ -304,7 +304,7 @@ static int test_a_tone_set(int fwd)
The spec calls for +-4 +-10Hz (ie +-14Hz) of bandwidth. */ The spec calls for +-4 +-10Hz (ie +-14Hz) of bandwidth. */
printf ("Test 3: Recognition bandwidth and channel centre frequency check\n"); printf("Test 3: Recognition bandwidth and channel centre frequency check\n");
s = r2_mf_tone_codes; s = r2_mf_tone_codes;
j = 0; j = 0;
while (*s) while (*s)
@@ -330,7 +330,7 @@ static int test_a_tone_set(int fwd)
} }
rrb = (float) (nplus + nminus)/10.0; rrb = (float) (nplus + nminus)/10.0;
rcfo = (float) (nplus - nminus)/10.0; rcfo = (float) (nplus - nminus)/10.0;
printf (" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n", printf(" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
digit, digit,
rrb, rrb,
rcfo, rcfo,
@@ -339,8 +339,8 @@ static int test_a_tone_set(int fwd)
if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f1) || rrb >= 15.0 + rcfo) if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f1) || rrb >= 15.0 + rcfo)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
for (nplus = 0, i = 1; i <= 60; i++) for (nplus = 0, i = 1; i <= 60; i++)
@@ -363,7 +363,7 @@ static int test_a_tone_set(int fwd)
} }
rrb = (float) (nplus + nminus)/10.0; rrb = (float) (nplus + nminus)/10.0;
rcfo = (float) (nplus - nminus)/10.0; rcfo = (float) (nplus - nminus)/10.0;
printf (" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n", printf(" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
digit, digit,
rrb, rrb,
rcfo, rcfo,
@@ -371,19 +371,19 @@ static int test_a_tone_set(int fwd)
(float) nplus/10.0); (float) nplus/10.0);
if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f2) || rrb >= 15.0 + rcfo) if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f2) || rrb >= 15.0 + rcfo)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
j++; j++;
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 4: Acceptable amplitude ratio (twist). /* Test 4: Acceptable amplitude ratio (twist).
Twist all digits in both directions, and check the maximum twist Twist all digits in both directions, and check the maximum twist
we can accept. The way this is done is styled after the Mitel DTMF we can accept. The way this is done is styled after the Mitel DTMF
test, and has good and bad points. */ test, and has good and bad points. */
printf ("Test 4: Acceptable amplitude ratio (twist)\n"); printf("Test 4: Acceptable amplitude ratio (twist)\n");
s = r2_mf_tone_codes; s = r2_mf_tone_codes;
while (*s) while (*s)
{ {
@@ -398,11 +398,11 @@ static int test_a_tone_set(int fwd)
if (r2_mf_rx_get(mf_state) == digit) if (r2_mf_rx_get(mf_state) == digit)
nplus++; nplus++;
} }
printf (" %c normal twist = %.2fdB\n", digit, (float) nplus/10.0); printf(" %c normal twist = %.2fdB\n", digit, (float) nplus/10.0);
if (nplus < 70) if (nplus < 70)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
for (nminus = 0, i = -50; i >= -250; i--) for (nminus = 0, i = -50; i >= -250; i--)
{ {
@@ -414,21 +414,21 @@ static int test_a_tone_set(int fwd)
if (r2_mf_rx_get(mf_state) == digit) if (r2_mf_rx_get(mf_state) == digit)
nminus++; nminus++;
} }
printf (" %c reverse twist = %.2fdB\n", digit, (float) nminus/10.0); printf(" %c reverse twist = %.2fdB\n", digit, (float) nminus/10.0);
if (nminus < 70) if (nminus < 70)
{ {
printf (" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 5: Dynamic range /* Test 5: Dynamic range
This test sends all possible digits, with gradually increasing This test sends all possible digits, with gradually increasing
amplitude. We determine the span over which we achieve reliable amplitude. We determine the span over which we achieve reliable
detection. */ detection. */
printf ("Test 5: Dynamic range\n"); printf("Test 5: Dynamic range\n");
for (nplus = nminus = -1000, i = -50; i <= 3; i++) for (nplus = nminus = -1000, i = -50; i <= 3; i++)
{ {
s = r2_mf_tone_codes; s = r2_mf_tone_codes;
@@ -458,19 +458,19 @@ static int test_a_tone_set(int fwd)
nminus = i; nminus = i;
} }
} }
printf (" Dynamic range = %ddB to %ddB\n", nplus, nminus - 1); printf(" Dynamic range = %ddB to %ddB\n", nplus, nminus - 1);
if (nplus > -35 || nminus <= -5) if (nplus > -35 || nminus <= -5)
{ {
printf(" Failed\n"); printf(" Failed\n");
exit(2); exit(2);
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 6: Guard time /* Test 6: Guard time
This test sends all possible digits, with a gradually reducing This test sends all possible digits, with a gradually reducing
duration. */ duration. */
printf ("Test 6: Guard time\n"); printf("Test 6: Guard time\n");
for (i = 30; i < 62; i++) for (i = 30; i < 62; i++)
{ {
s = r2_mf_tone_codes; s = r2_mf_tone_codes;
@@ -493,19 +493,19 @@ static int test_a_tone_set(int fwd)
if (j == 500) if (j == 500)
break; break;
} }
printf (" Guard time = %dms\n", i); printf(" Guard time = %dms\n", i);
if (i > 61) if (i > 61)
{ {
printf(" Failed\n"); printf(" Failed\n");
exit(2); exit(2);
} }
printf (" Passed\n"); printf(" Passed\n");
/* Test 7: Acceptable signal to noise ratio /* Test 7: Acceptable signal to noise ratio
We send all possible digits at -6dBm from clip, mixed with AWGN. We send all possible digits at -6dBm from clip, mixed with AWGN.
We gradually reduce the noise until we get clean detection. */ We gradually reduce the noise until we get clean detection. */
printf ("Test 7: Acceptable signal to noise ratio\n"); printf("Test 7: Acceptable signal to noise ratio\n");
my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd); my_mf_gen_init(0.0, -3, 0.0, -3, 68, fwd);
for (i = -3; i > -50; i--) for (i = -3; i > -50; i--)
{ {
@@ -563,7 +563,7 @@ static int test_a_tone_set(int fwd)
if (!callback_ok) if (!callback_ok)
{ {
printf(" Failed\n"); printf(" Failed\n");
exit (2); exit(2);
} }
printf(" Passed\n"); printf(" Passed\n");
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
printf("R2 backward tones\n"); printf("R2 backward tones\n");
test_a_tone_set(FALSE); test_a_tone_set(FALSE);
duration = time(NULL) - now; duration = time(NULL) - now;
printf ("Tests passed in %lds\n", duration); printf("Tests passed in %lds\n", duration);
return 0; return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|| ||
saturated_mul16_32(32767, 32767) != 2147352578 saturated_mul16_32(32767, 32767) != 2147352578
|| ||
saturated_mul16_32(-32768, -32768) != -2147483648) saturated_mul16_32(-32768, -32768) != INT32_MAX)
{ {
printf("Test failed.\n"); printf("Test failed.\n");
exit(2); exit(2);

View File

@@ -7,7 +7,7 @@
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
* Copyright (C) 2005 Steve Underwood * Copyright (C) 2005, 2009, 2012 Steve Underwood
* *
* All rights reserved. * All rights reserved.
* *
@@ -381,6 +381,8 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
int len; int len;
int limit; int limit;
int high_tide; int high_tide;
int len_before_entries;
int previous_len;
/* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
maximum length. */ maximum length. */
@@ -425,16 +427,28 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
entries = s->error_correction_entries; entries = s->error_correction_entries;
else else
entries = s->tx_seq_no; entries = s->tx_seq_no;
len_before_entries = len;
/* The number of entries will always be small, so it is pointless allowing /* The number of entries will always be small, so it is pointless allowing
for the fragmented case here. */ for the fragmented case here. */
if (encode_length(buf, &len, entries) < 0) if (encode_length(buf, &len, entries) < 0)
return -1; return -1;
/* Encode the elements */ /* Encode the elements */
for (i = 0; i < entries; i++) for (m = 0; m < entries; m++)
{ {
j = (entry - i - 1) & UDPTL_BUF_MASK; previous_len = len;
j = (entry - m - 1) & UDPTL_BUF_MASK;
if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0) if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
return -1; return -1;
/* If we have exceeded the far end's max datagram size, don't include this last chunk,
and stop trying to add more. */
if (len > s->far_max_datagram_size)
{
len = previous_len;
if (encode_length(buf, &len_before_entries, m) < 0)
return -1;
break;
}
} }
break; break;
case UDPTL_ERROR_CORRECTION_FEC: case UDPTL_ERROR_CORRECTION_FEC:
@@ -455,9 +469,11 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
buf[len++] = span; buf[len++] = span;
/* The number of entries is defined as a length, but will only ever be a small /* The number of entries is defined as a length, but will only ever be a small
value. Treat it as such. */ value. Treat it as such. */
len_before_entries = len;
buf[len++] = entries; buf[len++] = entries;
for (m = 0; m < entries; m++) for (m = 0; m < entries; m++)
{ {
previous_len = len;
/* Make an XOR'ed entry the maximum length */ /* Make an XOR'ed entry the maximum length */
limit = (entry + m) & UDPTL_BUF_MASK; limit = (entry + m) & UDPTL_BUF_MASK;
high_tide = 0; high_tide = 0;
@@ -479,6 +495,15 @@ int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int
} }
if (encode_open_type(buf, &len, fec, high_tide) < 0) if (encode_open_type(buf, &len, fec, high_tide) < 0)
return -1; return -1;
/* If we have exceeded the far end's max datagram size, don't include this last chunk,
and stop trying to add more. */
if (len > s->far_max_datagram_size)
{
len = previous_len;
buf[len_before_entries] = (uint8_t) m;
break;
}
} }
break; break;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -373,7 +373,6 @@ int main(int argc, char *argv[])
bert_set_report(&endpoint[i].bert_rx, 10000, reporter, &endpoint[i]); bert_set_report(&endpoint[i].bert_rx, 10000, reporter, &endpoint[i]);
} }
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_gui) if (use_gui)
{ {