Tweaks and feature additions to some of the spandsp tests.
This commit is contained in:
parent
3f8585f636
commit
6b1dccc3b2
|
@ -175,7 +175,7 @@ awgn_tests_SOURCES = awgn_tests.c
|
|||
awgn_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
|
||||
bell_mf_rx_tests_SOURCES = bell_mf_rx_tests.c
|
||||
bell_mf_rx_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
bell_mf_rx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
bell_mf_tx_tests_SOURCES = bell_mf_tx_tests.c
|
||||
bell_mf_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
@ -301,7 +301,7 @@ queue_tests_SOURCES = queue_tests.c
|
|||
queue_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
|
||||
r2_mf_rx_tests_SOURCES = r2_mf_rx_tests.c
|
||||
r2_mf_rx_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
r2_mf_rx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
r2_mf_tx_tests_SOURCES = r2_mf_tx_tests.c
|
||||
r2_mf_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
|
|
@ -45,12 +45,14 @@ a fair test of performance in a real PSTN channel.
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
/* Basic Bell MF specs:
|
||||
*
|
||||
|
@ -75,6 +77,8 @@ a fair test of performance in a real PSTN channel.
|
|||
#define MF_PAUSE (68*8)
|
||||
#define MF_CYCLE (MF_DURATION + MF_PAUSE)
|
||||
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
/*!
|
||||
MF tone descriptor for tests.
|
||||
*/
|
||||
|
@ -115,6 +119,10 @@ static char bell_mf_tone_codes[] = "1234567890CA*B#";
|
|||
bool callback_ok;
|
||||
int callback_roll;
|
||||
|
||||
codec_munge_state_t *munge = NULL;
|
||||
|
||||
char *decode_test_file = NULL;
|
||||
|
||||
static void my_mf_gen_init(float low_fudge,
|
||||
int low_level,
|
||||
float high_fudge,
|
||||
|
@ -164,19 +172,6 @@ static int my_mf_generate(int16_t amp[], const char *digits)
|
|||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void codec_munge(int16_t amp[], int len)
|
||||
{
|
||||
int i;
|
||||
uint8_t alaw;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
alaw = linear_to_alaw (amp[i]);
|
||||
amp[i] = alaw_to_linear (alaw);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
#define ALL_POSSIBLE_DIGITS "1234567890CA*B#"
|
||||
|
||||
static void digit_delivery(void *data, const char *digits, int len)
|
||||
|
@ -212,9 +207,8 @@ static void digit_delivery(void *data, const char *digits, int len)
|
|||
|
||||
static int16_t amp[1000000];
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static int test_tone_set(void)
|
||||
{
|
||||
int duration;
|
||||
int i;
|
||||
int j;
|
||||
int len;
|
||||
|
@ -227,11 +221,9 @@ int main(int argc, char *argv[])
|
|||
int nminus;
|
||||
float rrb;
|
||||
float rcfo;
|
||||
time_t now;
|
||||
bell_mf_rx_state_t *mf_state;
|
||||
awgn_state_t noise_source;
|
||||
|
||||
time(&now);
|
||||
mf_state = bell_mf_rx_init(NULL, NULL, NULL);
|
||||
|
||||
/* Test 1: Mitel's test 1 isn't really a test. Its a calibration step,
|
||||
|
@ -253,7 +245,7 @@ int main(int argc, char *argv[])
|
|||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
actual = bell_mf_rx_get(mf_state, buf, 128);
|
||||
if (actual != 1 || buf[0] != digit[0])
|
||||
|
@ -306,7 +298,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, 68);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nplus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -314,7 +306,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, 68);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nminus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -337,7 +329,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, 68);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nplus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -345,7 +337,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, 68);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nminus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -382,7 +374,7 @@ int main(int argc, char *argv[])
|
|||
my_mf_gen_init(0.0, -5, 0.0, i/10, 68, 68);
|
||||
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nplus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -397,7 +389,7 @@ int main(int argc, char *argv[])
|
|||
my_mf_gen_init(0.0, i/10, 0.0, -5, 68, 68);
|
||||
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
nminus += bell_mf_rx_get(mf_state, buf, 128);
|
||||
}
|
||||
|
@ -423,7 +415,7 @@ int main(int argc, char *argv[])
|
|||
for (j = 0; j < 100; j++)
|
||||
{
|
||||
len = my_mf_generate(amp, ALL_POSSIBLE_DIGITS);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
if (bell_mf_rx_get(mf_state, buf, 128) != 15)
|
||||
break;
|
||||
|
@ -464,7 +456,7 @@ int main(int argc, char *argv[])
|
|||
for (j = 0; j < 500; j++)
|
||||
{
|
||||
len = my_mf_generate(amp, ALL_POSSIBLE_DIGITS);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
if (bell_mf_rx_get(mf_state, buf, 128) != 15)
|
||||
break;
|
||||
|
@ -496,7 +488,7 @@ int main(int argc, char *argv[])
|
|||
len = my_mf_generate(amp, ALL_POSSIBLE_DIGITS);
|
||||
for (sample = 0; sample < len; sample++)
|
||||
amp[sample] = sat_add16(amp[sample], awgn(&noise_source));
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
bell_mf_rx(mf_state, amp, len);
|
||||
if (bell_mf_rx_get(mf_state, buf, 128) != 15)
|
||||
break;
|
||||
|
@ -543,9 +535,82 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
bell_mf_rx_free(mf_state);
|
||||
printf(" Passed\n");
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
duration = time (NULL) - now;
|
||||
printf("Tests passed in %ds\n", duration);
|
||||
static void digit_delivery_decode(void *data, const char *digits, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (data != (void *) 0x12345678)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
printf("Digit '%c'\n", digits[i]);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void decode_test(const char *test_file)
|
||||
{
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
SNDFILE *inhandle;
|
||||
bell_mf_rx_state_t *mf_state;
|
||||
int samples;
|
||||
|
||||
mf_state = bell_mf_rx_init(NULL, digit_delivery_decode, (void *) 0x12345678);
|
||||
|
||||
/* We will decode the audio from a file. */
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) > 0)
|
||||
{
|
||||
codec_munge(munge, amp, samples);
|
||||
bell_mf_rx(mf_state, amp, samples);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
time_t now;
|
||||
time_t duration;
|
||||
decode_test_file = NULL;
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
decode_test_file = optarg;
|
||||
break;
|
||||
default:
|
||||
//usage();
|
||||
exit(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
munge = codec_munge_init(MUNGE_CODEC_ULAW, 0);
|
||||
if (decode_test_file)
|
||||
{
|
||||
decode_test(decode_test_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = time(NULL);
|
||||
test_tone_set();
|
||||
duration = time (NULL) - now;
|
||||
printf("Tests passed in %lds\n", duration);
|
||||
}
|
||||
codec_munge_free(munge);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
|
|
@ -150,7 +150,7 @@ static void terminal_callback(void *user_data, const uint8_t msg[], int len)
|
|||
printf("0x%x ", msg[i]);
|
||||
}
|
||||
printf("\n");
|
||||
at_interpreter(&s->at_state, msg, len);
|
||||
at_interpreter(&s->at_state, (const char *) msg, len);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ int pseudo_terminal_create(modem_t *modem)
|
|||
modem->stty = ttyname(modem->slave);
|
||||
#else
|
||||
#if defined(WIN32)
|
||||
modem->slot = 4 + next_id++; /* need work here we start at COM4 for now*/
|
||||
modem->slot = 4 + next_id++; /* Need work here. We start at COM4 for now */
|
||||
snprintf(modem->devlink, sizeof(modem->devlink), "COM%d", modem->slot);
|
||||
|
||||
modem->master = CreateFile(modem->devlink,
|
||||
|
|
|
@ -45,12 +45,14 @@ a fair test of performance in a real PSTN channel.
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
/* R2 tone generation specs.
|
||||
* Power: -11.5dBm +- 1dB
|
||||
|
@ -80,6 +82,8 @@ a fair test of performance in a real PSTN channel.
|
|||
#define MF_PAUSE (68*8)
|
||||
#define MF_CYCLE (MF_DURATION + MF_PAUSE)
|
||||
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
/*!
|
||||
MF tone generator descriptor for tests.
|
||||
*/
|
||||
|
@ -140,6 +144,10 @@ static char r2_mf_tone_codes[] = "1234567890BCDEF";
|
|||
int callback_ok;
|
||||
int callback_roll;
|
||||
|
||||
codec_munge_state_t *munge = NULL;
|
||||
|
||||
char *decode_test_file = NULL;
|
||||
|
||||
static void my_mf_gen_init(float low_fudge,
|
||||
int low_level,
|
||||
float high_fudge,
|
||||
|
@ -187,19 +195,6 @@ static int my_mf_generate(int16_t amp[], char digit)
|
|||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void codec_munge(int16_t amp[], int len)
|
||||
{
|
||||
int i;
|
||||
uint8_t alaw;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
alaw = linear_to_alaw (amp[i]);
|
||||
amp[i] = alaw_to_linear (alaw);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void digit_delivery(void *data, int digit, int level, int delay)
|
||||
{
|
||||
char ch;
|
||||
|
@ -263,7 +258,7 @@ static int test_a_tone_set(int fwd)
|
|||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge (amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
actual = r2_mf_rx_get(mf_state);
|
||||
if (actual != digit)
|
||||
|
@ -315,7 +310,7 @@ static int test_a_tone_set(int fwd)
|
|||
{
|
||||
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, fwd);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nplus++;
|
||||
|
@ -324,7 +319,7 @@ static int test_a_tone_set(int fwd)
|
|||
{
|
||||
my_mf_gen_init((float) i/1000.0, -17, 0.0, -17, 68, fwd);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nminus++;
|
||||
|
@ -348,7 +343,7 @@ static int test_a_tone_set(int fwd)
|
|||
{
|
||||
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, fwd);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nplus++;
|
||||
|
@ -357,7 +352,7 @@ static int test_a_tone_set(int fwd)
|
|||
{
|
||||
my_mf_gen_init(0.0, -17, (float) i/1000.0, -17, 68, fwd);
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nminus++;
|
||||
|
@ -394,7 +389,7 @@ static int test_a_tone_set(int fwd)
|
|||
my_mf_gen_init(0.0, -5, 0.0, i/10, 68, fwd);
|
||||
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge (amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nplus++;
|
||||
|
@ -410,7 +405,7 @@ static int test_a_tone_set(int fwd)
|
|||
my_mf_gen_init(0.0, i/10, 0.0, -5, 68, fwd);
|
||||
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
nminus++;
|
||||
|
@ -440,7 +435,7 @@ static int test_a_tone_set(int fwd)
|
|||
for (j = 0; j < 100; j++)
|
||||
{
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) != digit)
|
||||
break;
|
||||
|
@ -483,7 +478,7 @@ static int test_a_tone_set(int fwd)
|
|||
for (j = 0; j < 500; j++)
|
||||
{
|
||||
len = my_mf_generate(amp, digit);
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) != digit)
|
||||
break;
|
||||
|
@ -520,7 +515,7 @@ static int test_a_tone_set(int fwd)
|
|||
len = my_mf_generate(amp, digit);
|
||||
for (sample = 0; sample < len; sample++)
|
||||
amp[sample] = sat_add16(amp[sample], awgn(noise_source));
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
if (r2_mf_rx_get(mf_state) != digit)
|
||||
break;
|
||||
|
@ -553,13 +548,13 @@ static int test_a_tone_set(int fwd)
|
|||
len = my_mf_generate(amp, digit);
|
||||
for (sample = 0; sample < len; sample++)
|
||||
amp[sample] = sat_add16(amp[sample], awgn(noise_source));
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
len = 160;
|
||||
memset(amp, '\0', len*sizeof(int16_t));
|
||||
for (sample = 0; sample < len; sample++)
|
||||
amp[sample] = sat_add16(amp[sample], awgn(noise_source));
|
||||
codec_munge(amp, len);
|
||||
codec_munge(munge, amp, len);
|
||||
r2_mf_rx(mf_state, amp, len);
|
||||
}
|
||||
awgn_free(noise_source);
|
||||
|
@ -581,18 +576,91 @@ static int test_a_tone_set(int fwd)
|
|||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void digit_delivery_fwd(void *data, int digit, int level, int delay)
|
||||
{
|
||||
if (data != (void *) 0x12345678)
|
||||
{
|
||||
callback_ok = false;
|
||||
return;
|
||||
}
|
||||
printf("FWD '%c' %d %d\n", (digit == 0) ? '-' : digit, level, delay);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void digit_delivery_bwd(void *data, int digit, int level, int delay)
|
||||
{
|
||||
if (data != (void *) 0x12345678)
|
||||
{
|
||||
callback_ok = false;
|
||||
return;
|
||||
}
|
||||
printf("BWD '%c' %d %d\n", (digit == 0) ? '-' : digit, level, delay);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void decode_test(const char *test_file)
|
||||
{
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
SNDFILE *inhandle;
|
||||
r2_mf_rx_state_t *mf_fwd_state;
|
||||
r2_mf_rx_state_t *mf_bwd_state;
|
||||
int samples;
|
||||
|
||||
mf_fwd_state = r2_mf_rx_init(NULL, true, digit_delivery_fwd, (void *) 0x12345678);
|
||||
mf_bwd_state = r2_mf_rx_init(NULL, false, digit_delivery_bwd, (void *) 0x12345678);
|
||||
|
||||
/* We will decode the audio from a file. */
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) > 0)
|
||||
{
|
||||
codec_munge(munge, amp, samples);
|
||||
r2_mf_rx(mf_fwd_state, amp, samples);
|
||||
r2_mf_rx(mf_bwd_state, amp, samples);
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
time_t now;
|
||||
time_t duration;
|
||||
decode_test_file = NULL;
|
||||
int opt;
|
||||
|
||||
now = time(NULL);
|
||||
printf("R2 forward tones\n");
|
||||
test_a_tone_set(true);
|
||||
printf("R2 backward tones\n");
|
||||
test_a_tone_set(false);
|
||||
duration = time(NULL) - now;
|
||||
printf("Tests passed in %lds\n", duration);
|
||||
while ((opt = getopt(argc, argv, "d:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
decode_test_file = optarg;
|
||||
break;
|
||||
default:
|
||||
//usage();
|
||||
exit(2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
munge = codec_munge_init(MUNGE_CODEC_ALAW, 0);
|
||||
if (decode_test_file)
|
||||
{
|
||||
decode_test(decode_test_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = time(NULL);
|
||||
printf("R2 forward tones\n");
|
||||
test_a_tone_set(true);
|
||||
printf("R2 backward tones\n");
|
||||
test_a_tone_set(false);
|
||||
duration = time(NULL) - now;
|
||||
printf("Tests passed in %lds\n", duration);
|
||||
}
|
||||
codec_munge_free(munge);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
|
|
@ -210,6 +210,8 @@ int main(int argc, char *argv[])
|
|||
int end_marks;
|
||||
int res;
|
||||
int compression;
|
||||
int x_resolution;
|
||||
int y_resolution;
|
||||
int compression_step;
|
||||
int min_row_bits;
|
||||
int block_size;
|
||||
|
@ -224,6 +226,7 @@ int main(int argc, char *argv[])
|
|||
int i;
|
||||
int bit_error_rate;
|
||||
int tests_failed;
|
||||
int match_pos;
|
||||
bool restart_pages;
|
||||
bool add_page_headers;
|
||||
bool overlay_page_headers;
|
||||
|
@ -236,6 +239,8 @@ int main(int argc, char *argv[])
|
|||
tests_failed = 0;
|
||||
compression = -1;
|
||||
compression_step = 0;
|
||||
x_resolution = -1;
|
||||
y_resolution = -1;
|
||||
add_page_headers = false;
|
||||
overlay_page_headers = false;
|
||||
restart_pages = false;
|
||||
|
@ -248,7 +253,7 @@ int main(int argc, char *argv[])
|
|||
block_size = 1;
|
||||
bit_error_rate = 0;
|
||||
dump_as_xxx = false;
|
||||
while ((opt = getopt(argc, argv, "b:c:d:ehHri:m:t:x")) != -1)
|
||||
while ((opt = getopt(argc, argv, "b:c:d:ehHrR:i:m:t:x")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
|
@ -328,6 +333,20 @@ int main(int argc, char *argv[])
|
|||
case 'r':
|
||||
restart_pages = true;
|
||||
break;
|
||||
case 'R':
|
||||
if (strcmp(optarg, "standard") == 0)
|
||||
{
|
||||
y_resolution = T4_Y_RESOLUTION_STANDARD;
|
||||
}
|
||||
else if (strcmp(optarg, "fine") == 0)
|
||||
{
|
||||
y_resolution = T4_Y_RESOLUTION_FINE;
|
||||
}
|
||||
else if (strcmp(optarg, "superfine") == 0)
|
||||
{
|
||||
y_resolution = T4_Y_RESOLUTION_SUPERFINE;
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
in_file_name = optarg;
|
||||
break;
|
||||
|
@ -352,6 +371,10 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
if (compression < 0)
|
||||
compression = T4_COMPRESSION_T4_1D;
|
||||
if (x_resolution < 0)
|
||||
x_resolution = T4_X_RESOLUTION_R8;
|
||||
if (y_resolution < 0)
|
||||
y_resolution = T4_Y_RESOLUTION_STANDARD;
|
||||
/* Receive end puts TIFF to a new file. We assume the receive width here. */
|
||||
if ((receive_state = t4_rx_init(NULL, OUT_FILE_NAME, T4_COMPRESSION_T4_2D)) == NULL)
|
||||
{
|
||||
|
@ -360,9 +383,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
span_log_set_level(t4_rx_get_logging_state(receive_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_FLOW);
|
||||
t4_rx_set_rx_encoding(receive_state, compression);
|
||||
t4_rx_set_x_resolution(receive_state, T4_X_RESOLUTION_R8);
|
||||
//t4_rx_set_y_resolution(receive_state, T4_Y_RESOLUTION_FINE);
|
||||
t4_rx_set_y_resolution(receive_state, T4_Y_RESOLUTION_STANDARD);
|
||||
t4_rx_set_x_resolution(receive_state, x_resolution);
|
||||
t4_rx_set_y_resolution(receive_state, y_resolution);
|
||||
t4_rx_set_image_width(receive_state, XSIZE);
|
||||
|
||||
t4_rx_start_page(receive_state);
|
||||
|
@ -392,7 +414,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
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)
|
||||
else if (sscanf(buf, "%*d:%*d:%*d.%*d T.38 Rx %d: IFP %x %x %x %x %x %n", &pkt_no, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, (unsigned int *) &bit, &match_pos) == 6)
|
||||
{
|
||||
/* Useful for breaking up T.38 non-ECM logs */
|
||||
if (pkt_no != last_pkt_no + 1)
|
||||
|
@ -400,7 +422,7 @@ int main(int argc, char *argv[])
|
|||
last_pkt_no = pkt_no;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
if (sscanf(&buf[47 + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
if (sscanf(&buf[match_pos + 3*i], "%x", (unsigned int *) &bit) != 1)
|
||||
break;
|
||||
block[i] = bit_reverse8(bit);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue