mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-16 22:38:38 +00:00
Lots of little cosmetic cleanups
This commit is contained in:
1 parent
16289ce9a4
commit
d163c6338e
110 files changed
+7259
-762
No files matched your search
@@ -240,7 +240,7 @@ static int end_to_end_tests(void)
|
||||
samples = ademco_contactid_receiver_tx(receiver, amp, SAMPLES_PER_CHUNK);
|
||||
for (j = samples; j < SAMPLES_PER_CHUNK; j++)
|
||||
amp[j] = 0;
|
||||
|
||||
|
||||
/* We add AWGN and codec impairments to the signal, to stress the tone detector. */
|
||||
codec_munge(munge, amp, SAMPLES_PER_CHUNK);
|
||||
for (j = 0; j < SAMPLES_PER_CHUNK; j++)
|
||||
|
||||
@@ -233,7 +233,7 @@ static void put_adsi_msg(void *user_data, const uint8_t *msg, int len)
|
||||
int field_len;
|
||||
int message_type;
|
||||
uint8_t body[256];
|
||||
|
||||
|
||||
printf("Good message received (%d bytes)\n", len);
|
||||
good_message_received = TRUE;
|
||||
for (i = 0; i < len; i++)
|
||||
@@ -784,7 +784,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
outhandle = NULL;
|
||||
|
||||
|
||||
tdd_character_set_tests();
|
||||
|
||||
if (decode_test_file)
|
||||
|
||||
@@ -60,7 +60,7 @@ int v14_test_async_tx_get_bit(void *user_data)
|
||||
async_tx_state_t *s;
|
||||
int bit;
|
||||
static int destuff = 0;
|
||||
|
||||
|
||||
/* Special routine to test V.14 rate adaption, by randomly skipping
|
||||
stop bits. */
|
||||
s = (async_tx_state_t *) user_data;
|
||||
@@ -110,7 +110,7 @@ int v14_test_async_tx_get_bit(void *user_data)
|
||||
static int test_get_async_byte(void *user_data)
|
||||
{
|
||||
int byte;
|
||||
|
||||
|
||||
byte = tx_async_chars & 0xFF;
|
||||
tx_async_chars++;
|
||||
return byte;
|
||||
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
printf("Test failed.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
printf("Test with async 7E1\n");
|
||||
async_tx_init(&tx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_get_async_byte, NULL);
|
||||
async_rx_init(&rx_async, 7, ASYNC_PARITY_EVEN, 1, FALSE, test_put_async_byte, NULL);
|
||||
|
||||
@@ -244,7 +244,7 @@ static const struct command_response_s general_test_seq[] =
|
||||
{"AT+FIT=?\r", "\r\n+FIT:(0-255),(0-1)\r\n\r\nOK\r\n"}, /* T.31 8.5.4 - DTE inactivity timeout */
|
||||
{"AT+FIT?\r", "\r\n+FIT:0,0\r\n\r\nOK\r\n"},
|
||||
{"AT+FLO=?\r", "\r\n+FLO:(0-2)\r\n\r\nOK\r\n"}, /* T.31 says to implement something similar to +IFC */
|
||||
{"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"},
|
||||
{"AT+FLO?\r", "\r\n+FLO:2\r\n\r\nOK\r\n"},
|
||||
{"AT+FMI?\r", "\r\n" MANUFACTURER "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMI */
|
||||
{"AT+FMM?\r", "\r\n" PACKAGE "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMM */
|
||||
{"AT+FMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* T.31 says to duplicate +GMR */
|
||||
@@ -279,7 +279,7 @@ static const struct command_response_s general_test_seq[] =
|
||||
{"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"}, /* V.250 6.2.14 - Select sync transmit clock source */
|
||||
{"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"}, /* V.250 6.2.16 - Select data set ready option */
|
||||
{"AT+IFC=?\r", "\r\n+IFC:(0-2),(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.2.12 - DTE-DCE local flow control */
|
||||
{"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"},
|
||||
{"AT+IFC?\r", "\r\n+IFC:2,2\r\n\r\nOK\r\n"},
|
||||
{"AT+ILRR\r", "\r\nOK\r\n"}, /* V.250 6.2.13 - DTE-DCE local rate reporting */
|
||||
{"AT+ILSD=?\r", "\r\n+ILSD:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.2.15 - Select long space disconnect option */
|
||||
{"AT+ILSD?\r", "\r\n+ILSD:0\r\n\r\nOK\r\n"},
|
||||
@@ -459,13 +459,13 @@ static int at_send_hdlc(at_state_t *s, uint8_t *t, int len)
|
||||
static int general_test(at_state_t *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; general_test_seq[i].command[0]; i++)
|
||||
{
|
||||
response_buf_ptr = 0;
|
||||
response_buf[0] = '\0';
|
||||
command_response_test_step = i;
|
||||
at_send(s, general_test_seq[i].command);
|
||||
at_send(s, general_test_seq[i].command);
|
||||
if (strcmp(general_test_seq[command_response_test_step].response, response_buf) != 0)
|
||||
{
|
||||
printf("Incorrect response\n");
|
||||
@@ -544,7 +544,7 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz
|
||||
putchar(buf[i]);
|
||||
}
|
||||
response_buf[response_buf_ptr] = '\0';
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -552,7 +552,7 @@ static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, siz
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
at_state_t *at_state;
|
||||
|
||||
|
||||
if ((at_state = at_init(NULL, at_tx_handler, NULL, modem_call_control, NULL)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot start the AT interpreter\n");
|
||||
|
||||
@@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
/* Now send it out for graphing. */
|
||||
printf("%6d %.7f %.7f\n", i - 32768, x, p);
|
||||
}
|
||||
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
which has no meaning here. */
|
||||
printf ("Test 1: Calibration\n");
|
||||
printf (" Passed\n");
|
||||
printf("Test 1: Calibration\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 2: Decode check
|
||||
This is a sanity check, that all digits are reliably detected
|
||||
under ideal conditions. Each possible digit is repeated 10 times,
|
||||
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);
|
||||
s = ALL_POSSIBLE_DIGITS;
|
||||
digit[1] = '\0';
|
||||
@@ -258,14 +258,14 @@ int main(int argc, char *argv[])
|
||||
actual = bell_mf_rx_get(mf_state, buf, 128);
|
||||
if (actual != 1 || buf[0] != digit[0])
|
||||
{
|
||||
printf (" Sent '%s'\n", digit);
|
||||
printf (" Received '%s' [%d]\n", buf, actual);
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Sent '%s'\n", digit);
|
||||
printf(" Received '%s' [%d]\n", buf, actual);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 3: Recognition bandwidth and channel centre frequency check.
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
digit[1] = '\0';
|
||||
j = 0;
|
||||
@@ -320,17 +320,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
rrb = (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",
|
||||
digit[0],
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
printf(" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
|
||||
digit[0],
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
|
||||
if (rrb < 3.0 + rcfo + (2.0*100.0*10.0/bell_mf_tones[j].f1) || rrb >= 15.0 + rcfo)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
for (nplus = 0, i = 1; i <= 60; i++)
|
||||
@@ -351,27 +351,27 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
rrb = (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",
|
||||
digit[0],
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
printf(" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
|
||||
digit[0],
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/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)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 4: Acceptable amplitude ratio (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
|
||||
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;
|
||||
digit[1] = '\0';
|
||||
while (*s)
|
||||
@@ -538,12 +538,12 @@ int main(int argc, char *argv[])
|
||||
if (!callback_ok)
|
||||
{
|
||||
printf(" Failed\n");
|
||||
exit (2);
|
||||
exit(2);
|
||||
}
|
||||
printf(" Passed\n");
|
||||
|
||||
duration = time (NULL) - now;
|
||||
printf ("Tests passed in %ds\n", duration);
|
||||
printf("Tests passed in %ds\n", duration);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
awgn_state_t *noise_source;
|
||||
|
||||
@@ -47,12 +47,12 @@
|
||||
|
||||
The DTMF detection test suite performs similar tests to the Mitel test tape,
|
||||
traditionally used for testing DTMF receivers. Mitel seem to have discontinued
|
||||
this product, but all it not lost.
|
||||
this product, but all it not lost.
|
||||
|
||||
The first side of the Mitel tape consists of a number of tone and tone+noise
|
||||
based tests. The test suite synthesizes equivalent test data. Being digitally
|
||||
generated, this data is rather more predictable than the test data on the nasty
|
||||
old stretchy cassette tapes which Mitel sold.
|
||||
old stretchy cassette tapes which Mitel sold.
|
||||
|
||||
The second side of the Mitel tape contains fragments of real speech from real
|
||||
phone calls captured from the North American telephone network. These are
|
||||
@@ -62,14 +62,14 @@ copies of this seem to be unobtainable. However, Bellcore produce a much more
|
||||
aggressive set of three cassette tapes. All six side (about 30 minutes each) are
|
||||
filled with much tougher fragments of real speech from the North American
|
||||
telephone network. If you can do well in this test, nobody cares about your
|
||||
results against the Mitel test tape.
|
||||
results against the Mitel test tape.
|
||||
|
||||
A fresh set of tapes was purchased for these tests, and digitised, producing 6
|
||||
wave files of 16 bit signed PCM data, sampled at 8kHz. They were transcribed
|
||||
using a speed adjustable cassette player. The test tone at the start of the
|
||||
tapes is pretty accurate, and the new tapes should not have had much opportunity
|
||||
to stretch. It is believed these transcriptions are about as good as the source
|
||||
material permits.
|
||||
material permits.
|
||||
|
||||
PLEASE NOTE
|
||||
|
||||
@@ -79,7 +79,7 @@ you also have no right to use this data. The original tapes are the copyright
|
||||
material of BellCore, and they charge over US$200 for a set. I doubt they sell
|
||||
enough copies to consider this much of a business. However, it is their data,
|
||||
and it is their right to do as they wish with it. Currently I see no indication
|
||||
they wish to give it away for free.
|
||||
they wish to give it away for free.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -460,7 +460,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 4: Acceptable amplitude ratio (twist).
|
||||
Use only the diagonal pairs of tones (digits 1, 5, 9 and D).
|
||||
Use only the diagonal pairs of tones (digits 1, 5, 9 and D).
|
||||
There are eight sections to the test. Each section contains 200
|
||||
pulses with a 50ms duration for each pulse. Initially the amplitude
|
||||
of both tones is 6dB down from clip. The two sections to test one
|
||||
@@ -477,7 +477,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
|
||||
The Acceptable Amplitude Ratio in dB is equal to the number of
|
||||
responses registered in (a) or (b), divided by 10.
|
||||
|
||||
|
||||
TODO: This is supposed to work in 1/10dB steps, but here I used 1dB
|
||||
steps, as the current tone generator has its amplitude set in
|
||||
1dB steps.
|
||||
@@ -527,7 +527,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
clip. The amplitude of each is gradually attenuated by -35dB at a
|
||||
rate of 1dB per pulse. The Dynamic Range in dB is equal to the
|
||||
number of responses from the receiver during the test.
|
||||
|
||||
|
||||
Well not really, but that is the Mitel test. Lets sweep a bit further,
|
||||
and see what the real range is */
|
||||
printf("Test 5: Dynamic range\n");
|
||||
@@ -555,7 +555,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
are transmitted at an amplitude of -6dB from clip per frequency.
|
||||
Pulse duration starts at 49ms and is gradually reduced to 10ms.
|
||||
Guard time in ms is equal to (500 - number of responses)/10.
|
||||
|
||||
|
||||
That is the Mitel test, and we will follow it. Its totally bogus,
|
||||
though. Just what the heck is a pass or fail here? */
|
||||
|
||||
@@ -580,7 +580,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
level is -24dBV, the second -18dBV and the third -12dBV.. The
|
||||
acceptable signal to noise ratio is the lowest ratio of signal
|
||||
to noise in the test where the receiver responds to all 1000 pulses.
|
||||
|
||||
|
||||
Well, that is the Mitel test, but it doesn't tell you what the
|
||||
decoder can really do. Lets do a more comprehensive test */
|
||||
|
||||
@@ -597,7 +597,7 @@ static void mitel_cm7291_side_1_tests(void)
|
||||
// TODO: Clip
|
||||
for (sample = 0; sample < len; sample++)
|
||||
amp[sample] = saturate(amp[sample] + awgn(&noise_source));
|
||||
|
||||
|
||||
codec_munge(munge, amp, len);
|
||||
dtmf_rx(dtmf_state, amp, len);
|
||||
|
||||
@@ -735,10 +735,10 @@ static void dial_tone_tolerance_tests(void)
|
||||
printf(" Acceptable signal to dial tone ratio is %ddB\n", -15 - j);
|
||||
if ((use_dialtone_filter && (-15 - j) > -12)
|
||||
||
|
||||
(!use_dialtone_filter && (-15 - j) > 10))
|
||||
(!use_dialtone_filter && (-15 - j) > 10))
|
||||
{
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
exit(2);
|
||||
}
|
||||
printf(" Passed\n");
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ typedef struct
|
||||
fir_float_state_t *fir;
|
||||
float history[35*8];
|
||||
int pos;
|
||||
float factor;
|
||||
float factor;
|
||||
float power;
|
||||
float peak;
|
||||
} level_measurement_device_t;
|
||||
@@ -361,7 +361,7 @@ static void print_results(void)
|
||||
{
|
||||
if (!quiet)
|
||||
printf("test model ERL time Max Rin Max Rout Max Sgen Max Sin Max Sout\n");
|
||||
printf("%-4s %-1d %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n",
|
||||
printf("%-4s %-1d %-5.1f%6.2fs%9.2f%9.2f%9.2f%9.2f%9.2f\n",
|
||||
test_name,
|
||||
chan_model.model_no,
|
||||
20.0f*log10f(-chan_model.erl + 1.0e-10f),
|
||||
@@ -404,7 +404,7 @@ static int channel_model_create(channel_model_state_t *chan, int model, float er
|
||||
sizeof(line_model_d8_coeffs)/sizeof(line_model_d8_coeffs[0]),
|
||||
sizeof(line_model_d9_coeffs)/sizeof(line_model_d9_coeffs[0])
|
||||
};
|
||||
static const float ki[] =
|
||||
static const float ki[] =
|
||||
{
|
||||
3.05e-5f,
|
||||
LINE_MODEL_D2_GAIN,
|
||||
@@ -488,13 +488,13 @@ static void write_log_files(int16_t rout, int16_t sin)
|
||||
fprintf(fdump,
|
||||
" %d %d %d %d %d %d %d %d %d %d\n",
|
||||
ctx->clean_nlp,
|
||||
ctx->Ltx,
|
||||
ctx->Ltx,
|
||||
ctx->Lrx,
|
||||
ctx->Lclean,
|
||||
ctx->Lclean,
|
||||
(ctx->nonupdate_dwell > 0),
|
||||
ctx->adapt,
|
||||
ctx->Lclean_bg,
|
||||
ctx->Pstates,
|
||||
ctx->Pstates,
|
||||
ctx->Lbgn_upper,
|
||||
ctx->Lbgn);
|
||||
#endif
|
||||
@@ -616,7 +616,7 @@ static void run_test(echo_can_state_t *ctx, int16_t (*tx_source)(void), int16_t
|
||||
|
||||
static void print_test_title(const char *title)
|
||||
{
|
||||
if (quiet == FALSE)
|
||||
if (quiet == FALSE)
|
||||
printf(title);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -653,7 +653,7 @@ static int perform_test_sanity(void)
|
||||
echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION | ECHO_CAN_USE_NLP | ECHO_CAN_USE_CNG);
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
|
||||
|
||||
|
||||
for (i = 0; i < SAMPLE_RATE*10; i++)
|
||||
{
|
||||
tx = local_css_signal();
|
||||
@@ -715,7 +715,7 @@ static int perform_test_sanity(void)
|
||||
//result_sound[result_cur++] = (ctx->narrowband_score)*5; // ? SAMPLE_RATE : -SAMPLE_RATE;
|
||||
//result_sound[result_cur++] = ctx->tap_rotate_counter*10;
|
||||
////result_sound[result_cur++] = ctx->vad;
|
||||
|
||||
|
||||
put_residue(clean - far_tx);
|
||||
if (result_cur >= RESULT_CHANNELS*SAMPLE_RATE)
|
||||
{
|
||||
@@ -812,7 +812,7 @@ static int perform_test_2b(void)
|
||||
echo_can_flush(ctx);
|
||||
echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
|
||||
signal_restart(&local_css, 0.0f);
|
||||
|
||||
|
||||
/* Test 2B (a) - Convergence test with NLP disabled */
|
||||
|
||||
/* Converge the canceller */
|
||||
@@ -863,17 +863,17 @@ static int perform_test_2ca(void)
|
||||
print_test_title("Performing test 2C(a) - Convergence with background noise present\n");
|
||||
ctx = echo_can_init(TEST_EC_TAPS, 0);
|
||||
awgn_init_dbm0(&far_noise_source, 7162534, -50.0f);
|
||||
|
||||
|
||||
echo_can_flush(ctx);
|
||||
echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
|
||||
|
||||
|
||||
/* Converge a canceller */
|
||||
signal_restart(&local_css, 0.0f);
|
||||
run_test(ctx, silence, silence, 200);
|
||||
|
||||
|
||||
awgn_init_dbm0(&far_noise_source, 7162534, -40.0f);
|
||||
run_test(ctx, local_css_signal, far_hoth_noise_signal, 5000);
|
||||
|
||||
|
||||
/* Now freeze adaption, and measure the echo. */
|
||||
echo_can_adaption_mode(ctx, 0);
|
||||
level_measurements_reset_peaks();
|
||||
@@ -901,18 +901,18 @@ static int perform_test_3a(void)
|
||||
|
||||
echo_can_flush(ctx);
|
||||
echo_can_adaption_mode(ctx, ECHO_CAN_USE_ADAPTION);
|
||||
|
||||
|
||||
run_test(ctx, silence, silence, 200);
|
||||
signal_restart(&local_css, 0.0f);
|
||||
signal_restart(&far_css, -20.0f);
|
||||
|
||||
/* Apply double talk, with a weak far end signal */
|
||||
run_test(ctx, local_css_signal, far_css_signal, 5000);
|
||||
|
||||
|
||||
/* Now freeze adaption. */
|
||||
echo_can_adaption_mode(ctx, 0);
|
||||
run_test(ctx, local_css_signal, silence, 500);
|
||||
|
||||
|
||||
/* Now measure the echo */
|
||||
level_measurements_reset_peaks();
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
@@ -943,20 +943,20 @@ static int perform_test_3ba(void)
|
||||
run_test(ctx, silence, silence, 200);
|
||||
signal_restart(&local_css, 0.0f);
|
||||
signal_restart(&far_css, 0.0f);
|
||||
|
||||
|
||||
/* Converge the canceller */
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
|
||||
|
||||
/* Apply double talk */
|
||||
run_test(ctx, local_css_signal, far_css_signal, 5000);
|
||||
|
||||
|
||||
/* Now freeze adaption. */
|
||||
echo_can_adaption_mode(ctx, 0);
|
||||
run_test(ctx, local_css_signal, far_css_signal, 1000);
|
||||
|
||||
|
||||
/* Turn off the double talk. */
|
||||
run_test(ctx, local_css_signal, silence, 500);
|
||||
|
||||
|
||||
/* Now measure the echo */
|
||||
level_measurements_reset_peaks();
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
@@ -983,20 +983,20 @@ static int perform_test_3bb(void)
|
||||
run_test(ctx, silence, silence, 200);
|
||||
signal_restart(&local_css, 0.0f);
|
||||
signal_restart(&far_css, -15.0f);
|
||||
|
||||
|
||||
/* Converge the canceller */
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
|
||||
|
||||
/* Apply double talk */
|
||||
run_test(ctx, local_css_signal, far_css_signal, 5000);
|
||||
|
||||
|
||||
/* Now freeze adaption. */
|
||||
echo_can_adaption_mode(ctx, 0);
|
||||
run_test(ctx, local_css_signal, silence, 1000);
|
||||
|
||||
|
||||
/* Turn off the double talk. */
|
||||
run_test(ctx, local_css_signal, silence, 500);
|
||||
|
||||
|
||||
/* Now measure the echo */
|
||||
level_measurements_reset_peaks();
|
||||
run_test(ctx, local_css_signal, silence, 5000);
|
||||
@@ -1082,7 +1082,7 @@ static int perform_test_4(void)
|
||||
static int perform_test_5(void)
|
||||
{
|
||||
echo_can_state_t *ctx;
|
||||
|
||||
|
||||
/* Test 5 - Infinite return loss convergence test */
|
||||
print_test_title("Performing test 5 - Infinite return loss convergence test\n");
|
||||
ctx = echo_can_init(TEST_EC_TAPS, 0);
|
||||
@@ -1261,8 +1261,8 @@ static int perform_test_9(void)
|
||||
|
||||
echo_can_flush(ctx);
|
||||
echo_can_adaption_mode(ctx,
|
||||
ECHO_CAN_USE_ADAPTION
|
||||
| ECHO_CAN_USE_NLP
|
||||
ECHO_CAN_USE_ADAPTION
|
||||
| ECHO_CAN_USE_NLP
|
||||
| ECHO_CAN_USE_CNG);
|
||||
|
||||
/* Test 9 part 1 - matching */
|
||||
@@ -1492,7 +1492,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
if (two_channel_file)
|
||||
{
|
||||
txfile = sf_open_telephony_read(argv[0], 1);
|
||||
rxfile = sf_open_telephony_read(argv[1], 1);
|
||||
rxfile = sf_open_telephony_read(argv[1], 1);
|
||||
ecfile = sf_open_telephony_write(argv[2], 1);
|
||||
}
|
||||
else
|
||||
@@ -1524,7 +1524,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
exit(2);
|
||||
}
|
||||
if ((nrx = sf_readf_short(rxfile, &sin, 1)) < 0)
|
||||
{
|
||||
{
|
||||
fprintf(stderr, " Error reading rx sound file\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ static void print_frame(const char *io, const uint8_t *fr, int frlen)
|
||||
const char *country;
|
||||
const char *vendor;
|
||||
const char *model;
|
||||
|
||||
|
||||
fprintf(stderr, "%s %s:", io, t30_frametype(fr[2]));
|
||||
for (i = 2; i < frlen; i++)
|
||||
fprintf(stderr, " %02x", fr[i]);
|
||||
@@ -545,7 +545,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "Failed to init\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK);
|
||||
|
||||
@@ -102,7 +102,7 @@ static void hdlc_underflow_handler(void *user_data)
|
||||
uint8_t buf[400];
|
||||
|
||||
s = (faxtester_state_t *) user_data;
|
||||
|
||||
|
||||
if (s->image_buffer)
|
||||
{
|
||||
/* We are sending an ECM image */
|
||||
@@ -172,7 +172,7 @@ static void tone_detected(void *user_data, int tone, int level, int delay)
|
||||
SPAN_LOG_FLOW,
|
||||
"Tone was on for %fs\n",
|
||||
(float) (s->timer - s->tone_on_time)/SAMPLE_RATE + 0.55);
|
||||
}
|
||||
}
|
||||
s->tone_state = tone;
|
||||
if (tone == MODEM_CONNECT_TONES_NONE)
|
||||
front_end_step_complete(s);
|
||||
@@ -336,7 +336,7 @@ int faxtester_rx(faxtester_state_t *s, int16_t *amp, int len)
|
||||
int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
|
||||
{
|
||||
int len;
|
||||
|
||||
|
||||
len = 0;
|
||||
if (s->transmit)
|
||||
{
|
||||
@@ -350,7 +350,7 @@ int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
|
||||
{
|
||||
/* Pad to the requested length with silence */
|
||||
memset(amp + len, 0, (max_len - len)*sizeof(int16_t));
|
||||
len = max_len;
|
||||
len = max_len;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ int faxtester_tx(faxtester_state_t *s, int16_t *amp, int max_len)
|
||||
{
|
||||
/* Pad to the requested length with silence */
|
||||
memset(amp, 0, max_len*sizeof(int16_t));
|
||||
len = max_len;
|
||||
len = max_len;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
|
||||
@@ -343,7 +343,7 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
int i;
|
||||
t30_stats_t t;
|
||||
char tag[20];
|
||||
|
||||
|
||||
i = (int) (intptr_t) user_data;
|
||||
snprintf(tag, sizeof(tag), "%c: Phase E", i + 'A');
|
||||
printf("%c: Phase E handler - (%d) %s\n", i + 'A', result, t30_completion_code_to_str(result));
|
||||
@@ -363,7 +363,7 @@ static void real_time_frame_handler(t30_state_t *s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
i = (intptr_t) user_data;
|
||||
printf("%c: Real time frame handler - %s, %s, length = %d\n",
|
||||
i + 'A',
|
||||
@@ -376,7 +376,7 @@ static void real_time_frame_handler(t30_state_t *s,
|
||||
static int document_handler(t30_state_t *s, void *user_data, int event)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
i = (intptr_t) user_data;
|
||||
printf("%c: Document handler - event %d\n", i + 'A', event);
|
||||
return FALSE;
|
||||
@@ -400,7 +400,7 @@ static void real_time_gateway_frame_handler(t38_gateway_state_t *s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
i = (intptr_t) user_data;
|
||||
printf("%c: Real time gateway frame handler - %s, %s, length = %d\n",
|
||||
i + 'A',
|
||||
@@ -674,7 +674,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
memset(silence, 0, sizeof(silence));
|
||||
|
||||
|
||||
srand48(0x1234567);
|
||||
/* Set up the nodes */
|
||||
input_wave_handle = NULL;
|
||||
@@ -858,6 +858,7 @@ int main(int argc, char *argv[])
|
||||
| T30_SUPPORT_300_600_RESOLUTION
|
||||
| T30_SUPPORT_400_800_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);
|
||||
if (use_ecm)
|
||||
{
|
||||
@@ -1096,7 +1097,7 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Check how many pages should have been transferred */
|
||||
expected_pages = get_tiff_total_pages(input_tiff_file_name);
|
||||
if (end_page >= 0 && expected_pages > end_page + 1)
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
void fax_log_tx_parameters(t30_state_t *s, const char *tag)
|
||||
{
|
||||
const char *u;
|
||||
|
||||
|
||||
if ((u = t30_get_tx_ident(s)))
|
||||
printf("%s: Local ident '%s'\n", tag, u);
|
||||
if ((u = t30_get_tx_sub_address(s)))
|
||||
|
||||
@@ -174,7 +174,7 @@ int main(int argc, char *argv[])
|
||||
int16_t out_amp[2*BLOCK_LEN];
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int outframes;
|
||||
int i;
|
||||
int j;
|
||||
int samples;
|
||||
@@ -350,14 +350,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
off_at = i;
|
||||
printf("Carrier on at %d, off at %d\n", on_at, off_at);
|
||||
if (on_at < -29 || on_at > -26
|
||||
if (on_at < -29 || on_at > -26
|
||||
||
|
||||
off_at < -35 || off_at > -31)
|
||||
{
|
||||
printf("Tests failed.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
printf("Test with BERT\n");
|
||||
test_bps = preset_fsk_specs[modem_under_test_1].baud_rate;
|
||||
if (modem_under_test_1 >= 0)
|
||||
@@ -426,7 +426,7 @@ int main(int argc, char *argv[])
|
||||
out_amp[2*i + 1] = answerer_model_amp[i];
|
||||
for ( ; i < BLOCK_LEN; i++)
|
||||
out_amp[2*i + 1] = 0;
|
||||
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = sf_writef_short(outhandle, out_amp, BLOCK_LEN);
|
||||
@@ -468,7 +468,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Put a little silence between the chunks in the file. */
|
||||
memset(out_amp, 0, sizeof(out_amp));
|
||||
if (log_audio)
|
||||
|
||||
@@ -173,7 +173,7 @@ static void compliance_tests(int log_audio)
|
||||
printf("Tests failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
printf("Cyclic conversion repeatability tests.\n");
|
||||
/* Find what happens to every possible linear value after a round trip. */
|
||||
for (i = 0; i < 65536; i++)
|
||||
@@ -200,7 +200,7 @@ static void compliance_tests(int log_audio)
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Reference power level tests.\n");
|
||||
power_meter_init(&power_meter, 7);
|
||||
|
||||
@@ -274,7 +274,7 @@ static void compliance_tests(int log_audio)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enc_state = g711_init(NULL, G711_ALAW);
|
||||
transcode = g711_init(NULL, G711_ALAW);
|
||||
dec_state = g711_init(NULL, G711_ULAW);
|
||||
|
||||
@@ -136,7 +136,7 @@ static const char *decode_test_files[] =
|
||||
TESTDATA_DIR "T3L3.RC2",
|
||||
TESTDATA_DIR "T3L3.RC3",
|
||||
TESTDATA_DIR "T3H3.RC0",
|
||||
|
||||
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -197,13 +197,13 @@ static int get_test_vector(const char *file, uint16_t buf[], int max_len)
|
||||
int octets;
|
||||
int i;
|
||||
FILE *infile;
|
||||
|
||||
|
||||
if ((infile = fopen(file, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open '%s'\n", file);
|
||||
exit(2);
|
||||
}
|
||||
octets = 0;
|
||||
octets = 0;
|
||||
while ((i = get_vector(infile, buf + octets)) > 0)
|
||||
octets += i;
|
||||
fclose(infile);
|
||||
@@ -232,7 +232,7 @@ static void itu_compliance_tests(void)
|
||||
for (file = 0; encode_test_files[file]; file += 2)
|
||||
{
|
||||
printf("Testing %s -> %s\n", encode_test_files[file], encode_test_files[file + 1]);
|
||||
|
||||
|
||||
/* Get the input data */
|
||||
len_data = get_test_vector(encode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN);
|
||||
|
||||
@@ -322,7 +322,7 @@ static void itu_compliance_tests(void)
|
||||
len = j - i;
|
||||
for (k = 0; k < len; k++)
|
||||
compressed[k] = itu_data[k + i] >> ((mode == 3) ? 10 : (mode == 2) ? 9 : 8);
|
||||
|
||||
|
||||
dec_state = g722_decode_init(NULL, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0);
|
||||
dec_state->itu_test_mode = TRUE;
|
||||
len2 = g722_decode(dec_state, decompressed, compressed, len);
|
||||
|
||||
@@ -157,7 +157,7 @@ Algorithm Input Intermediate Output Input Intermediate Output
|
||||
HN40FA.I HN40FX.O HV40FA.I HV40FX.O
|
||||
*/
|
||||
|
||||
#define G726_ENCODING_NONE 9999
|
||||
#define G726_ENCODING_NONE 9999
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -1043,13 +1043,13 @@ static int get_test_vector(const char *file, uint8_t buf[], int max_len)
|
||||
int i;
|
||||
int sum;
|
||||
FILE *infile;
|
||||
|
||||
|
||||
if ((infile = fopen(file, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open '%s'\n", file);
|
||||
exit(2);
|
||||
}
|
||||
octets = 0;
|
||||
octets = 0;
|
||||
while ((i = get_vector(infile, buf + octets)) > 0)
|
||||
octets += i;
|
||||
fclose(infile);
|
||||
@@ -1253,7 +1253,7 @@ int main(int argc, char *argv[])
|
||||
printf("ADPCM packing is %d\n", packing);
|
||||
g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing);
|
||||
g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing);
|
||||
|
||||
|
||||
while ((frames = sf_readf_short(inhandle, amp, 159)))
|
||||
{
|
||||
adpcm = g726_encode(&enc_state, adpcmdata, amp, frames);
|
||||
|
||||
@@ -92,7 +92,7 @@ copied to etsitests/gsm0610/unpacked so the files are arranged in the following
|
||||
./fr_sync_A:
|
||||
Seqsync_A.inp
|
||||
Sync000_A.cod --to-- Sync159_A.cod
|
||||
|
||||
|
||||
./fr_sync_L:
|
||||
Bitsync.inp
|
||||
Seqsync.inp
|
||||
@@ -153,7 +153,7 @@ static int get_test_vector(int full, int disk, const char *name)
|
||||
int in;
|
||||
int len;
|
||||
int i;
|
||||
|
||||
|
||||
if (full)
|
||||
{
|
||||
sprintf(buf, "%s%c/%s.inp", TESTDATA_DIR, 'L', name);
|
||||
@@ -189,7 +189,7 @@ static int get_test_vector(int full, int disk, const char *name)
|
||||
{
|
||||
vector_len = len;
|
||||
}
|
||||
|
||||
|
||||
sprintf(buf, "%s%c/%s.cod", TESTDATA_DIR, 'L', name);
|
||||
if ((in = open(buf, O_RDONLY)) < 0)
|
||||
{
|
||||
@@ -221,9 +221,9 @@ static int get_law_test_vector(int full, int law, const char *name)
|
||||
int len;
|
||||
int i;
|
||||
int law_uc;
|
||||
|
||||
|
||||
law_uc = toupper(law);
|
||||
|
||||
|
||||
if (full)
|
||||
{
|
||||
sprintf(buf, "%s%c/%s-%c.inp", TESTDATA_DIR, law_uc, name, law_uc);
|
||||
@@ -286,7 +286,7 @@ static int get_law_test_vector(int full, int law, const char *name)
|
||||
len /= sizeof(int16_t);
|
||||
for (i = 0; i < len; i++)
|
||||
decoder_code_vector[i] = code_vector_buf[i];
|
||||
|
||||
|
||||
return len;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -368,7 +368,7 @@ static int perform_law_test(int full, int law, const char *name)
|
||||
printf("Performing A-law test '%s'\n", name);
|
||||
else
|
||||
printf("Performing u-law test '%s'\n", name);
|
||||
|
||||
|
||||
get_law_test_vector(full, law, name);
|
||||
|
||||
if (full)
|
||||
@@ -448,9 +448,9 @@ static int repack_gsm0610_voip_to_wav49(uint8_t c[], const uint8_t d[])
|
||||
{
|
||||
gsm0610_frame_t frame[2];
|
||||
int n;
|
||||
|
||||
n = gsm0610_unpack_voip(&frame[0], d);
|
||||
gsm0610_unpack_voip(&frame[1], d + n);
|
||||
|
||||
n = gsm0610_unpack_voip(&frame[0], d);
|
||||
gsm0610_unpack_voip(&frame[1], d + n);
|
||||
n = gsm0610_pack_wav49(c, frame);
|
||||
return n;
|
||||
}
|
||||
@@ -479,7 +479,7 @@ static int perform_pack_unpack_test(void)
|
||||
printf("Performing packing/unpacking tests (not part of the ETSI conformance tests).\n");
|
||||
/* Try trans-packing a lot of random data looking for before/after mismatch. */
|
||||
for (j = 0; j < 1000; j++)
|
||||
{
|
||||
{
|
||||
for (i = 0; i < 65; i++)
|
||||
a[i] = rand();
|
||||
repack_gsm0610_wav49_to_voip(b, a);
|
||||
@@ -583,13 +583,13 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
if ((gsm0610_enc_state = gsm0610_init(NULL, packing)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create encoder\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
if ((gsm0610_dec_state = gsm0610_init(NULL, packing)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create decoder\n");
|
||||
@@ -602,7 +602,7 @@ int main(int argc, char *argv[])
|
||||
gsm0610_decode(gsm0610_dec_state, post_amp, gsm0610_data, bytes);
|
||||
sf_writef_short(outhandle, post_amp, frames);
|
||||
}
|
||||
|
||||
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
|
||||
@@ -818,7 +818,7 @@ static void decode_bitstream(const char *in_file_name)
|
||||
int num;
|
||||
hdlc_rx_state_t rx;
|
||||
FILE *in;
|
||||
|
||||
|
||||
if ((in = fopen(in_file_name, "r")) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Failed to open '%s'\n", in_file_name);
|
||||
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, " Cannot create encoder\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
if ((ima_dec_state = ima_adpcm_init(NULL, variant, enc_chunk_size)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create decoder\n");
|
||||
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
printf("Tests failed.\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ static int test_dithered_50_by_50(int row, int width, uint8_t buf[])
|
||||
" 46: @ @ @ @ @ @ @@ @ @ @@ @@ @@ @@@@@ @ @@ @@@@@@@@@@",
|
||||
" 47: @ @ @ @ @ @@ @ @ @@@@ @@@@ @@@@@ @@@@@@@@@@@ @@@@@",
|
||||
" 48: @ @ @ @@ @ @@ @@ @ @@ @ @@@ @ @@@@@ @@@@@@@@@@@@@",
|
||||
" 49: @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@@@"
|
||||
" 49: @ @ @ @ @ @@ @@ @@ @@ @@@@ @@@@@@@ @@@@@@ @@@@@@@@"
|
||||
};
|
||||
int i;
|
||||
int match;
|
||||
|
||||
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
|
||||
pk = peak(noise_sound, 8192);
|
||||
ms = rms(noise_sound, 8192);
|
||||
printf("Filtered noise level = %.2fdB, crest factor = %.2fdB\n", rms_to_dbm0(ms), rms_to_db(pk/ms));
|
||||
|
||||
|
||||
for (i = 0; i < 8192; i++)
|
||||
silence_sound[i] = 0.0;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ static int preamble_get_bit(void *user_data)
|
||||
{
|
||||
static int bit_no = 0;
|
||||
int bit;
|
||||
|
||||
|
||||
/* Generate a section of HDLC flag octet preamble. Then generate some random
|
||||
bits, which should not look like preamble. */
|
||||
if (++preamble_count < 255)
|
||||
|
||||
@@ -27,12 +27,12 @@
|
||||
\section modem_echo_can_tests_page_sec_1 What does it do?
|
||||
Currently the echo cancellation tests only provide simple exercising of the
|
||||
cancellor in the way it might be used for line echo cancellation. The test code
|
||||
is in echotests.c.
|
||||
is in echotests.c.
|
||||
|
||||
The goal is to test the echo cancellor again the G.16X specs. Clearly, that also
|
||||
means the goal for the cancellor itself is to comply with those specs. Right
|
||||
now, the only aspect of these tests implemented is the line impulse response
|
||||
models in g168tests.c.
|
||||
models in g168tests.c.
|
||||
|
||||
\section modem_echo_can_tests_page_sec_2 How does it work?
|
||||
The current test consists of feeding an audio file of real speech to the echo
|
||||
@@ -42,7 +42,7 @@ real speech is also used to simulate a signal received form the far end of the
|
||||
line. This is gated so it is only placed for one second every 10 seconds,
|
||||
simulating the double talk condition. The resulting echo cancelled signal can
|
||||
either be store in a file for further analysis, or played back as the data is
|
||||
processed.
|
||||
processed.
|
||||
|
||||
A number of modified versions of this test have been performed. The signal level
|
||||
of the two speech sources has been varied. Several simple models of the
|
||||
@@ -53,7 +53,7 @@ is very loud (with earlier versions, well, ....:) ). The lack of saturating
|
||||
arithmetic in general purpose CPUs is a huge disadvantage here, as software
|
||||
saturation logic would cause a major slow down. Floating point would be good,
|
||||
but is not usable in the Linux kernel. Anyway, the bottom line seems to be the
|
||||
current design is genuinely useful, if imperfect.
|
||||
current design is genuinely useful, if imperfect.
|
||||
|
||||
\section modem_echo_can_tests_page_sec_2 How do I use it?
|
||||
|
||||
@@ -69,7 +69,7 @@ echo_tests.c is commented out with a \#if. If this is enabled, detailed
|
||||
information about the results of the echo cancellation will be written to
|
||||
stdout. By saving this into a file, Grace (recommended), GnuPlot, or some other
|
||||
plotting package may be used to graphically display the functioning of the
|
||||
cancellor.
|
||||
cancellor.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -266,7 +266,7 @@ int main(int argc, char *argv[])
|
||||
#if defined(ENABLE_GUI)
|
||||
int16_t amp[2];
|
||||
#endif
|
||||
|
||||
|
||||
line_model_no = 0;
|
||||
use_gui = FALSE;
|
||||
for (i = 1; i < argc; i++)
|
||||
@@ -305,7 +305,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
power_meter_init(&power_before, 5);
|
||||
power_meter_init(&power_after, 5);
|
||||
|
||||
|
||||
/* Measure the echo power before adaption */
|
||||
modem_echo_can_adaption_mode(ctx, FALSE);
|
||||
for (i = 0; i < 8000*5; i++)
|
||||
@@ -319,7 +319,7 @@ int main(int argc, char *argv[])
|
||||
unadapted_output_power = power_meter_current_dbm0(&power_before);
|
||||
unadapted_echo_power = power_meter_current_dbm0(&power_after);
|
||||
printf("Pre-adaption: output power %10.5fdBm0, echo power %10.5fdBm0\n", unadapted_output_power, unadapted_echo_power);
|
||||
|
||||
|
||||
/* Converge the canceller */
|
||||
signal_restart(&local_css);
|
||||
modem_echo_can_adaption_mode(ctx, TRUE);
|
||||
@@ -364,7 +364,7 @@ int main(int argc, char *argv[])
|
||||
adapted_output_power = power_meter_current_dbm0(&power_before);
|
||||
adapted_echo_power = power_meter_current_dbm0(&power_after);
|
||||
printf("Post-adaption: output power %10.5fdBm0, echo power %10.5fdBm0\n", adapted_output_power, adapted_echo_power);
|
||||
|
||||
|
||||
if (fabsf(adapted_output_power - unadapted_output_power) > 0.1f
|
||||
||
|
||||
adapted_echo_power > unadapted_echo_power - 30.0f)
|
||||
|
||||
@@ -202,7 +202,7 @@ int main (int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
quality = 7;
|
||||
printf("Generating Hoth noise at -15dBOv to file\n");
|
||||
level = -15;
|
||||
@@ -224,7 +224,7 @@ int main (int argc, char *argv[])
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ struct iphdr
|
||||
uint32_t daddr;
|
||||
/*The options start here. */
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/* We define our own structures for Ethernet Header and IPv6 Header as they are not available on CYGWIN.
|
||||
@@ -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);
|
||||
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 += sizeof(struct udphdr);
|
||||
body_len = pktlen - sizeof(struct udphdr);
|
||||
|
||||
@@ -260,7 +260,7 @@ static void static_buffer_tests(void)
|
||||
fr,
|
||||
type,
|
||||
len,
|
||||
next_scheduled_send,
|
||||
next_scheduled_send,
|
||||
next_actual_receive);
|
||||
switch (ret)
|
||||
{
|
||||
|
||||
@@ -101,7 +101,7 @@ static int power_surge_detector_tests(void)
|
||||
if (prev_signal_present != signal_present)
|
||||
{
|
||||
signal_power = power_surge_detector_current_dbm0(sig);
|
||||
if (signal_present)
|
||||
if (signal_present)
|
||||
{
|
||||
if (ok == 0 && i >= 0 && i < 25)
|
||||
ok = 1;
|
||||
@@ -120,7 +120,7 @@ static int power_surge_detector_tests(void)
|
||||
if (extremes[3] < i)
|
||||
extremes[3] = i;
|
||||
printf("Off at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
|
||||
}
|
||||
}
|
||||
prev_signal_present = signal_present;
|
||||
}
|
||||
amp_out[2*i] = amp[i];
|
||||
|
||||
@@ -546,7 +546,7 @@ static void functional_message_tests(void)
|
||||
uint8_t buf[MSG_LEN];
|
||||
int i;
|
||||
int len;
|
||||
|
||||
|
||||
total_in = 0;
|
||||
total_out = 0;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ static void my_mf_gen_init(float low_fudge,
|
||||
{
|
||||
const mf_digit_tones_t *tone;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < 15; i++)
|
||||
{
|
||||
if (fwd)
|
||||
@@ -190,7 +190,7 @@ 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]);
|
||||
@@ -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,
|
||||
which has no meaning here. */
|
||||
|
||||
printf ("Test 1: Calibration\n");
|
||||
printf (" Passed\n");
|
||||
printf("Test 1: Calibration\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 2: Decode check
|
||||
This is a sanity check, that all digits are reliably detected
|
||||
under ideal conditions. Each possible digit is repeated 10 times,
|
||||
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);
|
||||
s = r2_mf_tone_codes;
|
||||
while (*s)
|
||||
@@ -267,14 +267,14 @@ static int test_a_tone_set(int fwd)
|
||||
actual = r2_mf_rx_get(mf_state);
|
||||
if (actual != digit)
|
||||
{
|
||||
printf (" Sent '%c'\n", digit);
|
||||
printf (" Received 0x%X\n", actual);
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Sent '%c'\n", digit);
|
||||
printf(" Received 0x%X\n", actual);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 3: Recognition bandwidth and channel centre frequency check.
|
||||
Use all digits. Each digit types requires four tests to complete
|
||||
@@ -297,14 +297,14 @@ static int test_a_tone_set(int fwd)
|
||||
RRB% = (N+ + N-)/10
|
||||
Receiver Center Frequency Offset (RCFO) is calculated as follows:
|
||||
RCFO% = X + (N+ - N-)/20
|
||||
|
||||
|
||||
Note that this test doesn't test what it says it is testing at all,
|
||||
and the results are quite inaccurate, if not a downright lie! However,
|
||||
it follows the Mitel procedure, so how can it be bad? :)
|
||||
|
||||
|
||||
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;
|
||||
j = 0;
|
||||
while (*s)
|
||||
@@ -330,17 +330,17 @@ static int test_a_tone_set(int fwd)
|
||||
}
|
||||
rrb = (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",
|
||||
digit,
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
printf(" %c (low) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
|
||||
digit,
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
|
||||
if (rrb < rcfo + (2.0*100.0*14.0/r2_mf_fwd_tones[j].f1) || rrb >= 15.0 + rcfo)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
for (nplus = 0, i = 1; i <= 60; i++)
|
||||
@@ -363,27 +363,27 @@ static int test_a_tone_set(int fwd)
|
||||
}
|
||||
rrb = (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",
|
||||
digit,
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/10.0,
|
||||
(float) nplus/10.0);
|
||||
printf(" %c (high) rrb = %5.2f%%, rcfo = %5.2f%%, max -ve = %5.2f, max +ve = %5.2f\n",
|
||||
digit,
|
||||
rrb,
|
||||
rcfo,
|
||||
(float) nminus/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)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 4: Acceptable amplitude ratio (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
|
||||
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;
|
||||
while (*s)
|
||||
{
|
||||
@@ -398,11 +398,11 @@ static int test_a_tone_set(int fwd)
|
||||
if (r2_mf_rx_get(mf_state) == digit)
|
||||
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)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
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)
|
||||
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)
|
||||
{
|
||||
printf (" Failed\n");
|
||||
exit (2);
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* 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
|
||||
detection. */
|
||||
|
||||
printf ("Test 5: Dynamic range\n");
|
||||
|
||||
printf("Test 5: Dynamic range\n");
|
||||
for (nplus = nminus = -1000, i = -50; i <= 3; i++)
|
||||
{
|
||||
s = r2_mf_tone_codes;
|
||||
@@ -458,19 +458,19 @@ static int test_a_tone_set(int fwd)
|
||||
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)
|
||||
{
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* 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. */
|
||||
|
||||
printf ("Test 6: Guard time\n");
|
||||
printf("Test 6: Guard time\n");
|
||||
for (i = 30; i < 62; i++)
|
||||
{
|
||||
s = r2_mf_tone_codes;
|
||||
@@ -493,19 +493,19 @@ static int test_a_tone_set(int fwd)
|
||||
if (j == 500)
|
||||
break;
|
||||
}
|
||||
printf (" Guard time = %dms\n", i);
|
||||
printf(" Guard time = %dms\n", i);
|
||||
if (i > 61)
|
||||
{
|
||||
printf(" Failed\n");
|
||||
exit(2);
|
||||
}
|
||||
printf (" Passed\n");
|
||||
printf(" Passed\n");
|
||||
|
||||
/* Test 7: Acceptable signal to noise ratio
|
||||
We send all possible digits at -6dBm from clip, mixed with AWGN.
|
||||
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);
|
||||
for (i = -3; i > -50; i--)
|
||||
{
|
||||
@@ -563,7 +563,7 @@ static int test_a_tone_set(int fwd)
|
||||
if (!callback_ok)
|
||||
{
|
||||
printf(" Failed\n");
|
||||
exit (2);
|
||||
exit(2);
|
||||
}
|
||||
printf(" Passed\n");
|
||||
|
||||
@@ -571,7 +571,7 @@ static int test_a_tone_set(int fwd)
|
||||
meaningless for R2 MF. However the decoder's tolerance of
|
||||
out of band noise is significant. */
|
||||
/* TODO: add a OOB tolerance test. */
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
|
||||
printf("R2 backward tones\n");
|
||||
test_a_tone_set(FALSE);
|
||||
duration = time(NULL) - now;
|
||||
printf ("Tests passed in %lds\n", duration);
|
||||
printf("Tests passed in %lds\n", duration);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -183,7 +183,7 @@ int main(int argc, char *argv[])
|
||||
if ((len = rfc2198_sim_put(s, put_pkt, put_pkt_len, i, (double) i*0.001*PACKET_INTERVAL)) > 0)
|
||||
packets_really_put++;
|
||||
packets_put++;
|
||||
#if 0
|
||||
#if 0
|
||||
if (i == 5)
|
||||
rfc2198_sim_queue_dump(s);
|
||||
#endif
|
||||
|
||||
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
|
||||
||
|
||||
saturated_mul16_32(32767, 32767) != 2147352578
|
||||
||
|
||||
saturated_mul16_32(-32768, -32768) != -2147483648)
|
||||
saturated_mul16_32(-32768, -32768) != INT32_MAX)
|
||||
{
|
||||
printf("Test failed.\n");
|
||||
exit(2);
|
||||
|
||||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||
when1 = span_schedule_time(&sched) + 500000;
|
||||
when2 = span_schedule_time(&sched) + 550000;
|
||||
//span_schedule_del(&sched, id);
|
||||
|
||||
|
||||
for (i = 0; i < 100000000; i += 20000)
|
||||
span_schedule_update(&sched, 20000);
|
||||
when = span_schedule_time(&sched);
|
||||
|
||||
@@ -88,12 +88,12 @@ static int use_gui = FALSE;
|
||||
static void plot_frequency_response(void)
|
||||
{
|
||||
FILE *gnucmd;
|
||||
|
||||
|
||||
if ((gnucmd = popen("gnuplot", "w")) == NULL)
|
||||
{
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
fprintf(gnucmd, "set autoscale\n");
|
||||
fprintf(gnucmd, "unset log\n");
|
||||
fprintf(gnucmd, "unset label\n");
|
||||
@@ -175,7 +175,7 @@ static void tx_handler(void *user_data, int what, int level, int duration)
|
||||
#endif
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
||||
s = (sig_tone_tx_state_t *) user_data;
|
||||
tx_handler_callbacks++;
|
||||
//printf("What - %d, duration - %d\n", what, duration);
|
||||
@@ -268,7 +268,7 @@ static void map_frequency_response(sig_tone_rx_state_t *s, template_t template[]
|
||||
double gain;
|
||||
int template_entry;
|
||||
FILE *file;
|
||||
|
||||
|
||||
/* Things like noise don't highlight the frequency response of the high Q notch
|
||||
very well. We use a slowly swept frequency to check it. */
|
||||
printf("Frequency response test\n");
|
||||
@@ -650,7 +650,7 @@ int main(int argc, char *argv[])
|
||||
sequence_tests(&tx_state, &rx_state, munge);
|
||||
}
|
||||
/*endfor*/
|
||||
|
||||
|
||||
printf("Tests completed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
#define IN_FILE_NAME "super_tone.wav"
|
||||
|
||||
#define MITEL_DIR "../test-data/mitel/"
|
||||
#define BELLCORE_DIR "../test-data/bellcore/"
|
||||
#define BELLCORE_DIR "../test-data/bellcore/"
|
||||
|
||||
const char *bellcore_files[] =
|
||||
{
|
||||
@@ -270,7 +270,7 @@ static void get_tone_set(super_tone_rx_descriptor_t *desc, const char *tone_file
|
||||
xmlValidCtxt valid;
|
||||
#endif
|
||||
xmlChar *x;
|
||||
|
||||
|
||||
ns = NULL;
|
||||
xmlKeepBlanksDefault(0);
|
||||
xmlCleanupParser();
|
||||
@@ -334,7 +334,7 @@ static void get_tone_set(super_tone_rx_descriptor_t *desc, const char *tone_file
|
||||
static void super_tone_rx_fill_descriptor(super_tone_rx_descriptor_t *desc)
|
||||
{
|
||||
int tone_id;
|
||||
|
||||
|
||||
tone_id = super_tone_rx_add_tone(desc);
|
||||
super_tone_rx_add_element(desc, tone_id, 400, 0, 700, 0);
|
||||
tone_names[tone_id] = "XXX";
|
||||
@@ -390,12 +390,12 @@ static int talk_off_tests(super_tone_rx_state_t *super)
|
||||
x = super_tone_rx(super, amp + sample, frames - sample);
|
||||
sample += x;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sf_close_telephony(inhandle))
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ static void get_tone_set(const char *tone_file, const char *set_id)
|
||||
#endif
|
||||
xmlChar *x;
|
||||
|
||||
ns = NULL;
|
||||
ns = NULL;
|
||||
xmlKeepBlanksDefault(0);
|
||||
xmlCleanupParser();
|
||||
doc = xmlParseFile(tone_file);
|
||||
|
||||
@@ -70,9 +70,9 @@
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODEM_POLL_READ = (1 << 0),
|
||||
MODEM_POLL_WRITE = (1 << 1),
|
||||
MODEM_POLL_ERROR = (1 << 2)
|
||||
MODEM_POLL_READ = (1 << 0),
|
||||
MODEM_POLL_WRITE = (1 << 1),
|
||||
MODEM_POLL_ERROR = (1 << 2)
|
||||
} modem_poll_t;
|
||||
|
||||
g1050_state_t *path_a_to_b;
|
||||
@@ -139,8 +139,8 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
|
||||
static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len)
|
||||
{
|
||||
#if defined(WIN32)
|
||||
DWORD res;
|
||||
OVERLAPPED o;
|
||||
DWORD res;
|
||||
OVERLAPPED o;
|
||||
#else
|
||||
int res;
|
||||
#endif
|
||||
@@ -155,16 +155,16 @@ printf("\n");
|
||||
|
||||
modem = (modem_t *) user_data;
|
||||
#if defined(WIN32)
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
/* Initialize the rest of the OVERLAPPED structure to zero. */
|
||||
o.Internal = 0;
|
||||
o.InternalHigh = 0;
|
||||
o.Offset = 0;
|
||||
o.OffsetHigh = 0;
|
||||
assert(o.hEvent);
|
||||
if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
|
||||
GetOverlappedResult(modem->master, &o, &res, TRUE);
|
||||
CloseHandle(o.hEvent);
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
/* Initialize the rest of the OVERLAPPED structure to zero. */
|
||||
o.Internal = 0;
|
||||
o.InternalHigh = 0;
|
||||
o.Offset = 0;
|
||||
o.OffsetHigh = 0;
|
||||
assert(o.hEvent);
|
||||
if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
|
||||
GetOverlappedResult(modem->master, &o, &res, TRUE);
|
||||
CloseHandle(o.hEvent);
|
||||
#else
|
||||
res = write(modem->master, buf, len);
|
||||
#endif
|
||||
@@ -172,7 +172,7 @@ printf("\n");
|
||||
{
|
||||
printf("Failed to write the whole buffer to the device. %d bytes of %d written: %s\n", res, (int) len, strerror(errno));
|
||||
|
||||
if (res == -1)
|
||||
if (res == -1)
|
||||
res = 0;
|
||||
#if !defined(WIN32)
|
||||
if (tcflush(modem->master, TCOFLUSH))
|
||||
@@ -300,7 +300,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
|
||||
HANDLE arHandles[2];
|
||||
|
||||
ret = MODEM_POLL_ERROR;
|
||||
arHandles[0] = modem->threadAbort;
|
||||
arHandles[0] = modem->threadAbort;
|
||||
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
arHandles[1] = o.hEvent;
|
||||
@@ -322,7 +322,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* IO is pending, wait for it to finish */
|
||||
/* IO is pending, wait for it to finish */
|
||||
dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE);
|
||||
if (dwWait == WAIT_OBJECT_0 + 1 && !modem->block_read)
|
||||
ret = MODEM_POLL_READ;
|
||||
@@ -341,37 +341,37 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
|
||||
#else
|
||||
static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
|
||||
{
|
||||
struct pollfd pfds[2] = {{0}};
|
||||
int s;
|
||||
struct pollfd pfds[2] = {{0}};
|
||||
int s;
|
||||
int ret;
|
||||
|
||||
pfds[0].fd = sock;
|
||||
pfds[0].fd = sock;
|
||||
|
||||
if ((flags & MODEM_POLL_READ))
|
||||
pfds[0].events |= POLLIN;
|
||||
if ((flags & MODEM_POLL_WRITE))
|
||||
pfds[0].events |= POLLOUT;
|
||||
if ((flags & MODEM_POLL_ERROR))
|
||||
pfds[0].events |= POLLERR;
|
||||
if ((flags & MODEM_POLL_READ))
|
||||
pfds[0].events |= POLLIN;
|
||||
if ((flags & MODEM_POLL_WRITE))
|
||||
pfds[0].events |= POLLOUT;
|
||||
if ((flags & MODEM_POLL_ERROR))
|
||||
pfds[0].events |= POLLERR;
|
||||
|
||||
s = poll(pfds, (modem->block_read) ? 0 : 1, ms);
|
||||
s = poll(pfds, (modem->block_read) ? 0 : 1, ms);
|
||||
|
||||
ret = 0;
|
||||
if (s < 0)
|
||||
if (s < 0)
|
||||
{
|
||||
ret = s;
|
||||
}
|
||||
ret = s;
|
||||
}
|
||||
else if (s > 0)
|
||||
{
|
||||
if ((pfds[0].revents & POLLIN))
|
||||
ret |= MODEM_POLL_READ;
|
||||
if ((pfds[0].revents & POLLOUT))
|
||||
ret |= MODEM_POLL_WRITE;
|
||||
if ((pfds[0].revents & POLLERR))
|
||||
ret |= MODEM_POLL_ERROR;
|
||||
}
|
||||
if ((pfds[0].revents & POLLIN))
|
||||
ret |= MODEM_POLL_READ;
|
||||
if ((pfds[0].revents & POLLOUT))
|
||||
ret |= MODEM_POLL_WRITE;
|
||||
if ((pfds[0].revents & POLLERR))
|
||||
ret |= MODEM_POLL_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -407,8 +407,8 @@ static int t30_tests(int t38_mode, int use_ecm, int use_gui, int log_audio, int
|
||||
SNDFILE *in_handle;
|
||||
at_state_t *at_state;
|
||||
#if defined(WIN32)
|
||||
DWORD read_bytes;
|
||||
OVERLAPPED o;
|
||||
DWORD read_bytes;
|
||||
OVERLAPPED o;
|
||||
#endif
|
||||
|
||||
/* Test the T.31 modem against the full FAX machine in spandsp */
|
||||
@@ -606,18 +606,18 @@ printf("ZZZ\n");
|
||||
if ((ret & MODEM_POLL_READ))
|
||||
{
|
||||
#if defined(WIN32)
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
|
||||
/* Initialize the rest of the OVERLAPPED structure to zero. */
|
||||
o.Internal = 0;
|
||||
o.InternalHigh = 0;
|
||||
o.Offset = 0;
|
||||
o.OffsetHigh = 0;
|
||||
assert(o.hEvent);
|
||||
if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
|
||||
GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
|
||||
CloseHandle (o.hEvent);
|
||||
if ((len = read_bytes))
|
||||
/* Initialize the rest of the OVERLAPPED structure to zero. */
|
||||
o.Internal = 0;
|
||||
o.InternalHigh = 0;
|
||||
o.Offset = 0;
|
||||
o.OffsetHigh = 0;
|
||||
assert(o.hEvent);
|
||||
if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
|
||||
GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
|
||||
CloseHandle (o.hEvent);
|
||||
if ((len = read_bytes))
|
||||
#else
|
||||
if ((len = read(modem[0].master, buf, 1024)))
|
||||
#endif
|
||||
|
||||
@@ -219,7 +219,7 @@ static int test_cycle(const char *test_id,
|
||||
down the image, will only succeed if a new chunk is started afterwards. */
|
||||
if (comment)
|
||||
t85_encode_comment(t85_enc, comment, strlen((const char *) comment) + 1);
|
||||
|
||||
|
||||
testbuf_len = 0;
|
||||
max_len = 100;
|
||||
while ((len = t85_encode_get(t85_enc, &testbuf[testbuf_len], max_len)) > 0)
|
||||
@@ -321,7 +321,7 @@ static int test_cycle(const char *test_id,
|
||||
free(decoded_image);
|
||||
t85_decode_release(t85_dec);
|
||||
printf("Test passed\n");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
|
||||
/* Try a different tone pair */
|
||||
tone_gen_descriptor_init(&tone_desc,
|
||||
350,
|
||||
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
|
||||
/* Try an AM modulated tone at maximum modulation level (100%) */
|
||||
tone_gen_descriptor_init(&tone_desc,
|
||||
425,
|
||||
@@ -233,7 +233,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
|
||||
if (sf_close_telephony(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Written by Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
* Copyright (C) 2005 Steve Underwood
|
||||
* Copyright (C) 2005, 2009, 2012 Steve Underwood
|
||||
*
|
||||
* 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 limit;
|
||||
int high_tide;
|
||||
int len_before_entries;
|
||||
int previous_len;
|
||||
|
||||
/* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
|
||||
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;
|
||||
else
|
||||
entries = s->tx_seq_no;
|
||||
len_before_entries = len;
|
||||
/* The number of entries will always be small, so it is pointless allowing
|
||||
for the fragmented case here. */
|
||||
if (encode_length(buf, &len, entries) < 0)
|
||||
return -1;
|
||||
/* 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)
|
||||
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;
|
||||
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;
|
||||
/* The number of entries is defined as a length, but will only ever be a small
|
||||
value. Treat it as such. */
|
||||
len_before_entries = len;
|
||||
buf[len++] = entries;
|
||||
for (m = 0; m < entries; m++)
|
||||
{
|
||||
previous_len = len;
|
||||
/* Make an XOR'ed entry the maximum length */
|
||||
limit = (entry + m) & UDPTL_BUF_MASK;
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
+6586
-121
File diff suppressed because it is too large.
Load diff
@@ -373,7 +373,6 @@ int main(int argc, char *argv[])
|
||||
bert_set_report(&endpoint[i].bert_rx, 10000, reporter, &endpoint[i]);
|
||||
}
|
||||
|
||||
|
||||
#if defined(ENABLE_GUI)
|
||||
if (use_gui)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user