Lots of little cosmetic cleanups

This commit is contained in:
Steve Underwood committed 2013-03-14 21:22:51 +08:00
1 parent 16289ce9a4
commit d163c6338e
38 files changed
+6890 -393

No files matched your search

+1 -1
View File
@@ -348,7 +348,7 @@ SPAN_DECLARE(int16_t) dds_lookup(uint32_t phase)
step = DDS_STEPS - step; step = DDS_STEPS - step;
amp = sine_table[step]; amp = sine_table[step];
if ((phase & (2*DDS_STEPS))) if ((phase & (2*DDS_STEPS)))
amp = -amp; amp = -amp;
return amp; return amp;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
+5 -5
View File
@@ -55,7 +55,7 @@
#define TRUE (!FALSE) #define TRUE (!FALSE)
#endif #endif
#define MAXPZ 8192 #define MAXPZ 8192
#define SEQ_LEN 8192 #define SEQ_LEN 8192
#define MAX_FFT_LEN SEQ_LEN #define MAX_FFT_LEN SEQ_LEN
@@ -162,10 +162,10 @@ void compute_raised_cosine_filter(double coeffs[],
if (sinc_compensate) if (sinc_compensate)
{ {
for (i = 1; i <= SEQ_LEN/2; i++) for (i = 1; i <= SEQ_LEN/2; i++)
{ {
x = 3.1415926535*(double) i/(double) SEQ_LEN; x = 3.1415926535*(double) i/(double) SEQ_LEN;
vec[i].re *= (x/sin(x)); vec[i].re *= (x/sin(x));
} }
} }
for (i = 0; i <= SEQ_LEN/2; i++) for (i = 0; i <= SEQ_LEN/2; i++)
vec[i].re *= tau; vec[i].re *= tau;
@@ -228,7 +228,7 @@ void truncate_coeffs(double coeffs[], int len, int bits, int hilbert)
fac = pow(2.0, (double) (bits - 1.0)); fac = pow(2.0, (double) (bits - 1.0));
h = (len - 1)/2; h = (len - 1)/2;
max = (hilbert) ? coeffs[h - 1] : coeffs[h]; /* Max coeff */ max = (hilbert) ? coeffs[h - 1] : coeffs[h]; /* Max coeff */
scale = (fac - 1.0)/(fac*max); scale = (fac - 1.0)/(fac*max);
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
+10 -10
View File
@@ -37,42 +37,42 @@ extern "C"
#if !defined(HAVE_SINF) #if !defined(HAVE_SINF)
static __inline__ float sinf(float x) static __inline__ float sinf(float x)
{ {
return (float) sin((double) x); return (float) sin((double) x);
} }
#endif #endif
#if !defined(HAVE_COSF) #if !defined(HAVE_COSF)
static __inline__ float cosf(float x) static __inline__ float cosf(float x)
{ {
return (float) cos((double) x); return (float) cos((double) x);
} }
#endif #endif
#if !defined(HAVE_TANF) #if !defined(HAVE_TANF)
static __inline__ float tanf(float x) static __inline__ float tanf(float x)
{ {
return (float) tan((double) x); return (float) tan((double) x);
} }
#endif #endif
#if !defined(HAVE_ASINF) #if !defined(HAVE_ASINF)
static __inline__ float asinf(float x) static __inline__ float asinf(float x)
{ {
return (float) asin((double) x); return (float) asin((double) x);
} }
#endif #endif
#if !defined(HAVE_ACOSF) #if !defined(HAVE_ACOSF)
static __inline__ float acosf(float x) static __inline__ float acosf(float x)
{ {
return (float) acos((double) x); return (float) acos((double) x);
} }
#endif #endif
#if !defined(HAVE_ATANF) #if !defined(HAVE_ATANF)
static __inline__ float atanf(float x) static __inline__ float atanf(float x)
{ {
return (float) atan((double) x); return (float) atan((double) x);
} }
#endif #endif
@@ -80,7 +80,7 @@ static __inline__ float atanf(float x)
#if !defined(HAVE_ATAN2F) #if !defined(HAVE_ATAN2F)
static __inline__ float atan2f(float y, float x) static __inline__ float atan2f(float y, float x)
{ {
return (float) atan2((double) y, (double) x); return (float) atan2((double) y, (double) x);
} }
#endif #endif
@@ -88,14 +88,14 @@ static __inline__ float atan2f(float y, float x)
#if !defined(HAVE_CEILF) #if !defined(HAVE_CEILF)
static __inline__ float ceilf(float x) static __inline__ float ceilf(float x)
{ {
return (float) ceil((double) x); return (float) ceil((double) x);
} }
#endif #endif
#if !defined(HAVE_FLOORF) #if !defined(HAVE_FLOORF)
static __inline__ float floorf(float x) static __inline__ float floorf(float x)
{ {
return (float) floor((double) x); return (float) floor((double) x);
} }
#endif #endif
@@ -117,7 +117,7 @@ static __inline__ float expf(float x)
#if !defined(HAVE_LOGF) #if !defined(HAVE_LOGF)
static __inline__ float logf(float x) static __inline__ float logf(float x)
{ {
return (float) logf((double) x); return (float) logf((double) x);
} }
#endif #endif
+23 -23
View File
@@ -170,32 +170,32 @@ SPAN_DECLARE(int) gsm0610_pack_wav49(uint8_t c[], const gsm0610_frame_t *s)
uint16_t sr; uint16_t sr;
int i; int i;
sr = 0; sr = 0;
sr = (sr >> 6) | (s->LARc[0] << 10); sr = (sr >> 6) | (s->LARc[0] << 10);
sr = (sr >> 6) | (s->LARc[1] << 10); sr = (sr >> 6) | (s->LARc[1] << 10);
*c++ = (uint8_t) (sr >> 4); *c++ = (uint8_t) (sr >> 4);
sr = (sr >> 5) | (s->LARc[2] << 11); sr = (sr >> 5) | (s->LARc[2] << 11);
*c++ = (uint8_t) (sr >> 7); *c++ = (uint8_t) (sr >> 7);
sr = (sr >> 5) | (s->LARc[3] << 11); sr = (sr >> 5) | (s->LARc[3] << 11);
sr = (sr >> 4) | (s->LARc[4] << 12); sr = (sr >> 4) | (s->LARc[4] << 12);
*c++ = (uint8_t) (sr >> 6); *c++ = (uint8_t) (sr >> 6);
sr = (sr >> 4) | (s->LARc[5] << 12); sr = (sr >> 4) | (s->LARc[5] << 12);
sr = (sr >> 3) | (s->LARc[6] << 13); sr = (sr >> 3) | (s->LARc[6] << 13);
*c++ = (uint8_t) (sr >> 7); *c++ = (uint8_t) (sr >> 7);
sr = (sr >> 3) | (s->LARc[7] << 13); sr = (sr >> 3) | (s->LARc[7] << 13);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
sr = (sr >> 7) | (s->Nc[i] << 9); sr = (sr >> 7) | (s->Nc[i] << 9);
*c++ = (uint8_t) (sr >> 5); *c++ = (uint8_t) (sr >> 5);
sr = (sr >> 2) | (s->bc[i] << 14); sr = (sr >> 2) | (s->bc[i] << 14);
sr = (sr >> 2) | (s->Mc[i] << 14); sr = (sr >> 2) | (s->Mc[i] << 14);
sr = (sr >> 6) | (s->xmaxc[i] << 10); sr = (sr >> 6) | (s->xmaxc[i] << 10);
*c++ = (uint8_t) (sr >> 3); *c++ = (uint8_t) (sr >> 3);
sr = (sr >> 3) | (s->xMc[i][0] << 13); sr = (sr >> 3) | (s->xMc[i][0] << 13);
*c++ = (uint8_t) (sr >> 8); *c++ = (uint8_t) (sr >> 8);
sr = (sr >> 3) | (s->xMc[i][1] << 13); sr = (sr >> 3) | (s->xMc[i][1] << 13);
sr = (sr >> 3) | (s->xMc[i][2] << 13); sr = (sr >> 3) | (s->xMc[i][2] << 13);
sr = (sr >> 3) | (s->xMc[i][3] << 13); sr = (sr >> 3) | (s->xMc[i][3] << 13);
*c++ = (uint8_t) (sr >> 7); *c++ = (uint8_t) (sr >> 7);
sr = (sr >> 3) | (s->xMc[i][4] << 13); sr = (sr >> 3) | (s->xMc[i][4] << 13);
+1 -1
View File
@@ -31,7 +31,7 @@
#define GSM0610_FRAME_LEN 160 #define GSM0610_FRAME_LEN 160
#define GSM0610_MAGIC 0xD #define GSM0610_MAGIC 0xD
#include "spandsp/private/gsm0610.h" #include "spandsp/private/gsm0610.h"
+1 -1
View File
@@ -62,7 +62,7 @@ void lpc10_voicing(lpc10_encode_state_t *st,
int32_t half, int32_t half,
float *minamd, float *minamd,
float *maxamd, float *maxamd,
int32_t *mintau, int32_t *mintau,
float *ivrc, float *ivrc,
int32_t *obound); int32_t *obound);
+2 -2
View File
@@ -180,7 +180,7 @@ SPAN_DECLARE(int16_t) fixed_sin(uint16_t x)
} }
z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6); z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6);
if ((x & 0x8000)) if ((x & 0x8000))
z = -z; z = -z;
return z; return z;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@@ -206,7 +206,7 @@ SPAN_DECLARE(int16_t) fixed_cos(uint16_t x)
} }
z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6); z = fixed_sine_table[step] + ((frac*(fixed_sine_table[step_after] - fixed_sine_table[step])) >> 6);
if ((x & 0x8000)) if ((x & 0x8000))
z = -z; z = -z;
return z; return z;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
+4
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>
+2 -2
View File
@@ -2,8 +2,8 @@
* SpanDSP - a series of DSP components for telephony * SpanDSP - a series of DSP components for telephony
* *
* echo.h - An echo cancellor, suitable for electrical and acoustic * echo.h - An echo cancellor, suitable for electrical and acoustic
* cancellation. This code does not currently comply with * cancellation. This code does not currently comply with
* any relevant standards (e.g. G.164/5/7/8). * any relevant standards (e.g. G.164/5/7/8).
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
+8 -7
View File
@@ -273,16 +273,17 @@ extern "C"
__inline float rintf(float flt) __inline float rintf(float flt)
{ {
_asm _asm
{ fld flt {
frndint fld flt
} frndint
}
} }
__inline double rint(double dbl) __inline double rint(double dbl)
{ {
_asm _asm
{ {
fld dbl fld dbl
frndint frndint
} }
@@ -318,12 +319,12 @@ extern "C"
__inline long int lrint(double x) __inline long int lrint(double x)
{ {
return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) ); return (long int)_mm_cvtsd_si64x( _mm_loadu_pd ((const double*)&x) );
} }
__inline long int lrintf(float x) __inline long int lrintf(float x)
{ {
return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) ); return _mm_cvt_ss2si( _mm_load_ss((const float*)&x) );
} }
__inline long int lfastrint(double x) __inline long int lfastrint(double x)
+5 -5
View File
@@ -197,7 +197,7 @@ static __inline__ int16_t fir16(fir16_state_t *fir, int16_t sample)
y += fir->coeffs[i]*fir->history[i + offset2]; y += fir->coeffs[i]*fir->history[i + offset2];
#endif #endif
if (fir->curr_pos <= 0) if (fir->curr_pos <= 0)
fir->curr_pos = fir->taps; fir->curr_pos = fir->taps;
fir->curr_pos--; fir->curr_pos--;
return (int16_t) (y >> 15); return (int16_t) (y >> 15);
} }
@@ -212,7 +212,7 @@ static __inline__ const int16_t *fir32_create(fir32_state_t *fir,
fir->coeffs = coeffs; fir->coeffs = coeffs;
fir->history = (int16_t *) malloc(taps*sizeof(int16_t)); fir->history = (int16_t *) malloc(taps*sizeof(int16_t));
if (fir->history) if (fir->history)
memset(fir->history, '\0', taps*sizeof(int16_t)); memset(fir->history, '\0', taps*sizeof(int16_t));
return fir->history; return fir->history;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@@ -245,7 +245,7 @@ static __inline__ int16_t fir32(fir32_state_t *fir, int16_t sample)
for ( ; i >= 0; i--) for ( ; i >= 0; i--)
y += fir->coeffs[i]*fir->history[i + offset2]; y += fir->coeffs[i]*fir->history[i + offset2];
if (fir->curr_pos <= 0) if (fir->curr_pos <= 0)
fir->curr_pos = fir->taps; fir->curr_pos = fir->taps;
fir->curr_pos--; fir->curr_pos--;
return (int16_t) (y >> 15); return (int16_t) (y >> 15);
} }
@@ -253,7 +253,7 @@ static __inline__ int16_t fir32(fir32_state_t *fir, int16_t sample)
static __inline__ const float *fir_float_create(fir_float_state_t *fir, static __inline__ const float *fir_float_create(fir_float_state_t *fir,
const float *coeffs, const float *coeffs,
int taps) int taps)
{ {
fir->taps = taps; fir->taps = taps;
fir->curr_pos = taps - 1; fir->curr_pos = taps - 1;
@@ -288,7 +288,7 @@ static __inline__ int16_t fir_float(fir_float_state_t *fir, int16_t sample)
for ( ; i >= 0; i--) for ( ; i >= 0; i--)
y += fir->coeffs[i]*fir->history[i + offset2]; y += fir->coeffs[i]*fir->history[i + offset2];
if (fir->curr_pos <= 0) if (fir->curr_pos <= 0)
fir->curr_pos = fir->taps; fir->curr_pos = fir->taps;
fir->curr_pos--; fir->curr_pos--;
return (int16_t) y; return (int16_t) y;
} }
+1 -1
View File
@@ -2,7 +2,7 @@
* SpanDSP - a series of DSP components for telephony * SpanDSP - a series of DSP components for telephony
* *
* g168models.h - line models for echo cancellation tests against the G.168 * g168models.h - line models for echo cancellation tests against the G.168
* spec. * spec.
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
+1 -1
View File
@@ -2,7 +2,7 @@
* SpanDSP - a series of DSP components for telephony * SpanDSP - a series of DSP components for telephony
* *
* oki_adpcm.h - Conversion routines between linear 16 bit PCM data and * oki_adpcm.h - Conversion routines between linear 16 bit PCM data and
* OKI (Dialogic) ADPCM format. * OKI (Dialogic) ADPCM format.
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
+1 -1
View File
@@ -51,7 +51,7 @@ enum
/* Frame types */ /* Frame types */
#define PLAYOUT_TYPE_CONTROL 0 #define PLAYOUT_TYPE_CONTROL 0
#define PLAYOUT_TYPE_SILENCE 1 #define PLAYOUT_TYPE_SILENCE 1
#define PLAYOUT_TYPE_SPEECH 2 #define PLAYOUT_TYPE_SPEECH 2
typedef int timestamp_t; typedef int timestamp_t;
+2 -2
View File
@@ -2,8 +2,8 @@
* SpanDSP - a series of DSP components for telephony * SpanDSP - a series of DSP components for telephony
* *
* private/echo.h - An echo cancellor, suitable for electrical and acoustic * private/echo.h - An echo cancellor, suitable for electrical and acoustic
* cancellation. This code does not currently comply with * cancellation. This code does not currently comply with
* any relevant standards (e.g. G.164/5/7/8). * any relevant standards (e.g. G.164/5/7/8).
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
+1 -1
View File
@@ -2,7 +2,7 @@
* SpanDSP - a series of DSP components for telephony * SpanDSP - a series of DSP components for telephony
* *
* private/oki_adpcm.h - Conversion routines between linear 16 bit PCM data * private/oki_adpcm.h - Conversion routines between linear 16 bit PCM data
* and OKI (Dialogic) ADPCM format. * and OKI (Dialogic) ADPCM format.
* *
* Written by Steve Underwood <steveu@coppice.org> * Written by Steve Underwood <steveu@coppice.org>
* *
+1 -1
View File
@@ -212,7 +212,7 @@ struct t31_state_s
/*! TRUE if DLE prefix just used */ /*! TRUE if DLE prefix just used */
int dled; int dled;
/*! \brief Samples of silence awaited, as specified in a "wait for silence" command */ /*! \brief Samples of silence awaited, as specified in a "wait for silence" command */
int silence_awaited; int silence_awaited;
/*! \brief The current bit rate for the FAX fast message transfer modem. */ /*! \brief The current bit rate for the FAX fast message transfer modem. */
@@ -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);
-1
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;
} }
+2 -2
View File
@@ -300,7 +300,7 @@ static const nsf_data_t vendor_00[] =
{"\x00\x41", 2, "Swasaki Communication", FALSE, NULL}, {"\x00\x41", 2, "Swasaki Communication", FALSE, NULL},
{"\x00\x45", 2, "Muratec", FALSE, Muratec45}, {"\x00\x45", 2, "Muratec", FALSE, Muratec45},
{"\x00\x46", 2, "Pheonix", FALSE, NULL}, {"\x00\x46", 2, "Pheonix", FALSE, NULL},
{"\x00\x48", 2, "Muratec", FALSE, Muratec48}, /* Not registered */ {"\x00\x48", 2, "Muratec", FALSE, Muratec48}, /* Not registered */
{"\x00\x49", 2, "Japan Electric", FALSE, NULL}, {"\x00\x49", 2, "Japan Electric", FALSE, NULL},
{"\x00\x4D", 2, "Okura Electric", FALSE, NULL}, {"\x00\x4D", 2, "Okura Electric", FALSE, NULL},
{"\x00\x51", 2, "Sanyo", FALSE, Sanyo}, {"\x00\x51", 2, "Sanyo", FALSE, Sanyo},
@@ -502,7 +502,7 @@ static const nsf_data_t vendor_b5[] =
{"\x00\x6E", 2, "Microsoft", FALSE, NULL}, {"\x00\x6E", 2, "Microsoft", FALSE, NULL},
{"\x00\x72", 2, "Speaking Devices", FALSE, NULL}, {"\x00\x72", 2, "Speaking Devices", FALSE, NULL},
{"\x00\x74", 2, "Compaq", FALSE, NULL}, {"\x00\x74", 2, "Compaq", FALSE, NULL},
{"\x00\x76", 2, "Microsoft", FALSE, NULL}, /* uses LSB for country but MSB for manufacturer */ {"\x00\x76", 2, "Microsoft", FALSE, NULL}, /* uses LSB for country but MSB for manufacturer */
{"\x00\x78", 2, "Cylink", FALSE, NULL}, {"\x00\x78", 2, "Cylink", FALSE, NULL},
{"\x00\x7A", 2, "Pitney Bowes", FALSE, NULL}, {"\x00\x7A", 2, "Pitney Bowes", FALSE, NULL},
{"\x00\x7C", 2, "Digiboard", FALSE, NULL}, {"\x00\x7C", 2, "Digiboard", FALSE, NULL},
+7 -1
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 --------------------------------------------------------*/
+2 -2
View File
@@ -541,8 +541,8 @@ static int put_bits(t4_t6_decode_state_t *s, uint32_t bit_string, int quantity)
/* TODO: we really should record that something wasn't right at this point. */ /* TODO: we really should record that something wasn't right at this point. */
s->a0 = old_a0; s->a0 = old_a0;
break; break;
} }
} }
s->run_length += (s->a0 - old_a0); s->run_length += (s->a0 - old_a0);
add_run_to_row(s); add_run_to_row(s);
/* We need to move one step in one direction or the other, to change to the /* We need to move one step in one direction or the other, to change to the
+31 -32
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 --------------------------------------------------------*/
@@ -96,15 +95,15 @@ int has_MMX(void)
/*endif*/ /*endif*/
__asm__ __volatile__( __asm__ __volatile__(
" push %%ebx;\n" " push %%ebx;\n"
" mov $1,%%eax;\n" " mov $1,%%eax;\n"
" cpuid;\n" " cpuid;\n"
" xor %%eax,%%eax;\n" " xor %%eax,%%eax;\n"
" test $0x800000,%%edx;\n" " test $0x800000,%%edx;\n"
" jz 1f;\n" /* no MMX support */ " jz 1f;\n" /* no MMX support */
" inc %%eax;\n" /* MMX support */ " inc %%eax;\n" /* MMX support */
"1:\n" "1:\n"
" pop %%ebx;\n" " pop %%ebx;\n"
: "=a" (result) : "=a" (result)
: :
: "ecx", "edx"); : "ecx", "edx");
return result; return result;
@@ -120,15 +119,15 @@ int has_SIMD(void)
/*endif*/ /*endif*/
__asm__ __volatile__( __asm__ __volatile__(
" push %%ebx;\n" " push %%ebx;\n"
" mov $1,%%eax;\n" " mov $1,%%eax;\n"
" cpuid;\n" " cpuid;\n"
" xor %%eax,%%eax;\n" " xor %%eax,%%eax;\n"
" test $0x02000000,%%edx;\n" " test $0x02000000,%%edx;\n"
" jz 1f;\n" /* no SIMD support */ " jz 1f;\n" /* no SIMD support */
" inc %%eax;\n" /* SIMD support */ " inc %%eax;\n" /* SIMD support */
"1:\n" "1:\n"
" pop %%ebx;\n" " pop %%ebx;\n"
: "=a" (result) : "=a" (result)
: :
: "ecx", "edx"); : "ecx", "edx");
return result; return result;
@@ -144,15 +143,15 @@ int has_SIMD2(void)
/*endif*/ /*endif*/
__asm__ __volatile__( __asm__ __volatile__(
" push %%ebx;\n" " push %%ebx;\n"
" mov $1,%%eax;\n" " mov $1,%%eax;\n"
" cpuid;\n" " cpuid;\n"
" xor %%eax,%%eax;\n" " xor %%eax,%%eax;\n"
" test $0x04000000,%%edx;\n" " test $0x04000000,%%edx;\n"
" jz 1f;\n" /* no SIMD2 support */ " jz 1f;\n" /* no SIMD2 support */
" inc %%eax;\n" /* SIMD2 support */ " inc %%eax;\n" /* SIMD2 support */
"1:\n" "1:\n"
" pop %%ebx;\n" " pop %%ebx;\n"
: "=a" (result) : "=a" (result)
: :
: "ecx", "edx"); : "ecx", "edx");
return result; return result;
@@ -168,20 +167,20 @@ int has_3DNow(void)
/*endif*/ /*endif*/
__asm__ __volatile__( __asm__ __volatile__(
" push %%ebx;\n" " push %%ebx;\n"
" mov $0x80000000,%%eax;\n" " mov $0x80000000,%%eax;\n"
" cpuid;\n" " cpuid;\n"
" xor %%ecx,%%ecx;\n" " xor %%ecx,%%ecx;\n"
" cmp $0x80000000,%%eax;\n" " cmp $0x80000000,%%eax;\n"
" jbe 1f;\n" /* no extended MSR(1), so no 3DNow! */ " jbe 1f;\n" /* no extended MSR(1), so no 3DNow! */
" mov $0x80000001,%%eax;\n" " mov $0x80000001,%%eax;\n"
" cpuid;\n" " cpuid;\n"
" xor %%ecx,%%ecx;\n" " xor %%ecx,%%ecx;\n"
" test $0x80000000,%%edx;\n" " test $0x80000000,%%edx;\n"
" jz 1f;\n" /* no 3DNow! support */ " jz 1f;\n" /* no 3DNow! support */
" inc %%ecx;\n" /* 3DNow! support */ " inc %%ecx;\n" /* 3DNow! support */
"1:\n" "1:\n"
" pop %%ebx;\n" " pop %%ebx;\n"
: "=c" (result) : "=c" (result)
: :
: "eax", "edx"); : "eax", "edx");
return result; return result;
+1 -1
View File
@@ -171,7 +171,7 @@ static complexf_t getbaud(v27ter_tx_state_t *s)
if (s->in_training) if (s->in_training)
{ {
/* Send the training sequence */ /* Send the training sequence */
if (++s->training_step <= V27TER_TRAINING_SEG_5) if (++s->training_step <= V27TER_TRAINING_SEG_5)
{ {
if (s->training_step <= V27TER_TRAINING_SEG_4) if (s->training_step <= V27TER_TRAINING_SEG_4)
-4
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)
@@ -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,
+29 -29
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,17 +320,17 @@ 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,
(float) nminus/10.0, (float) nminus/10.0,
(float) nplus/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) 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,27 +351,27 @@ 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,
(float) nminus/10.0, (float) nminus/10.0,
(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 --------------------------------------------------------*/
+1
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)
{ {
+1 -1
View File
@@ -157,7 +157,7 @@ Algorithm Input Intermediate Output Input Intermediate Output
HN40FA.I HN40FX.O HV40FA.I HV40FX.O HN40FA.I HN40FX.O HV40FA.I HV40FX.O
*/ */
#define G726_ENCODING_NONE 9999 #define G726_ENCODING_NONE 9999
typedef struct typedef struct
{ {
+2 -2
View File
@@ -449,8 +449,8 @@ static int repack_gsm0610_voip_to_wav49(uint8_t c[], const uint8_t d[])
gsm0610_frame_t frame[2]; gsm0610_frame_t frame[2];
int n; int n;
n = gsm0610_unpack_voip(&frame[0], d); n = gsm0610_unpack_voip(&frame[0], d);
gsm0610_unpack_voip(&frame[1], d + n); gsm0610_unpack_voip(&frame[1], d + n);
n = gsm0610_pack_wav49(c, frame); n = gsm0610_pack_wav49(c, frame);
return n; return n;
} }
+3
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);
+43 -43
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,17 +330,17 @@ 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,
(float) nminus/10.0, (float) nminus/10.0,
(float) nplus/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) 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,27 +363,27 @@ 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,
(float) nminus/10.0, (float) nminus/10.0,
(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 --------------------------------------------------------*/
+1 -1
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);
+5 -5
View File
@@ -58,7 +58,7 @@
#define IN_FILE_NAME "super_tone.wav" #define IN_FILE_NAME "super_tone.wav"
#define MITEL_DIR "../test-data/mitel/" #define MITEL_DIR "../test-data/mitel/"
#define BELLCORE_DIR "../test-data/bellcore/" #define BELLCORE_DIR "../test-data/bellcore/"
const char *bellcore_files[] = const char *bellcore_files[] =
{ {
@@ -390,12 +390,12 @@ static int talk_off_tests(super_tone_rx_state_t *super)
x = super_tone_rx(super, amp + sample, frames - sample); x = super_tone_rx(super, amp + sample, frames - sample);
sample += x; sample += x;
} }
} }
if (sf_close_telephony(inhandle)) 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); exit(2);
} }
} }
return 0; return 0;
} }
+52 -52
View File
@@ -70,9 +70,9 @@
typedef enum typedef enum
{ {
MODEM_POLL_READ = (1 << 0), MODEM_POLL_READ = (1 << 0),
MODEM_POLL_WRITE = (1 << 1), MODEM_POLL_WRITE = (1 << 1),
MODEM_POLL_ERROR = (1 << 2) MODEM_POLL_ERROR = (1 << 2)
} modem_poll_t; } modem_poll_t;
g1050_state_t *path_a_to_b; 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) static int at_tx_handler(at_state_t *s, void *user_data, const uint8_t *buf, size_t len)
{ {
#if defined(WIN32) #if defined(WIN32)
DWORD res; DWORD res;
OVERLAPPED o; OVERLAPPED o;
#else #else
int res; int res;
#endif #endif
@@ -155,16 +155,16 @@ printf("\n");
modem = (modem_t *) user_data; modem = (modem_t *) user_data;
#if defined(WIN32) #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. */ /* Initialize the rest of the OVERLAPPED structure to zero. */
o.Internal = 0; o.Internal = 0;
o.InternalHigh = 0; o.InternalHigh = 0;
o.Offset = 0; o.Offset = 0;
o.OffsetHigh = 0; o.OffsetHigh = 0;
assert(o.hEvent); assert(o.hEvent);
if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o)) if (!WriteFile(modem->master, buf, (DWORD) len, &res, &o))
GetOverlappedResult(modem->master, &o, &res, TRUE); GetOverlappedResult(modem->master, &o, &res, TRUE);
CloseHandle(o.hEvent); CloseHandle(o.hEvent);
#else #else
res = write(modem->master, buf, len); res = write(modem->master, buf, len);
#endif #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)); 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; res = 0;
#if !defined(WIN32) #if !defined(WIN32)
if (tcflush(modem->master, TCOFLUSH)) 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]; HANDLE arHandles[2];
ret = MODEM_POLL_ERROR; ret = MODEM_POLL_ERROR;
arHandles[0] = modem->threadAbort; arHandles[0] = modem->threadAbort;
o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); o.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
arHandles[1] = o.hEvent; arHandles[1] = o.hEvent;
@@ -322,7 +322,7 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
} }
else else
{ {
/* IO is pending, wait for it to finish */ /* IO is pending, wait for it to finish */
dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE); dwWait = WaitForMultipleObjects(2, arHandles, FALSE, INFINITE);
if (dwWait == WAIT_OBJECT_0 + 1 && !modem->block_read) if (dwWait == WAIT_OBJECT_0 + 1 && !modem->block_read)
ret = MODEM_POLL_READ; ret = MODEM_POLL_READ;
@@ -341,37 +341,37 @@ static int modem_wait_sock(modem_t *modem, int ms, modem_poll_t flags)
#else #else
static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags) static int modem_wait_sock(int sock, uint32_t ms, modem_poll_t flags)
{ {
struct pollfd pfds[2] = {{0}}; struct pollfd pfds[2] = {{0}};
int s; int s;
int ret; int ret;
pfds[0].fd = sock; pfds[0].fd = sock;
if ((flags & MODEM_POLL_READ)) if ((flags & MODEM_POLL_READ))
pfds[0].events |= POLLIN; pfds[0].events |= POLLIN;
if ((flags & MODEM_POLL_WRITE)) if ((flags & MODEM_POLL_WRITE))
pfds[0].events |= POLLOUT; pfds[0].events |= POLLOUT;
if ((flags & MODEM_POLL_ERROR)) if ((flags & MODEM_POLL_ERROR))
pfds[0].events |= POLLERR; pfds[0].events |= POLLERR;
s = poll(pfds, (modem->block_read) ? 0 : 1, ms); s = poll(pfds, (modem->block_read) ? 0 : 1, ms);
ret = 0; ret = 0;
if (s < 0) if (s < 0)
{ {
ret = s; ret = s;
} }
else if (s > 0) else if (s > 0)
{ {
if ((pfds[0].revents & POLLIN)) if ((pfds[0].revents & POLLIN))
ret |= MODEM_POLL_READ; ret |= MODEM_POLL_READ;
if ((pfds[0].revents & POLLOUT)) if ((pfds[0].revents & POLLOUT))
ret |= MODEM_POLL_WRITE; ret |= MODEM_POLL_WRITE;
if ((pfds[0].revents & POLLERR)) if ((pfds[0].revents & POLLERR))
ret |= MODEM_POLL_ERROR; ret |= MODEM_POLL_ERROR;
} }
return ret; return ret;
} }
/*- End of function --------------------------------------------------------*/ /*- 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; SNDFILE *in_handle;
at_state_t *at_state; at_state_t *at_state;
#if defined(WIN32) #if defined(WIN32)
DWORD read_bytes; DWORD read_bytes;
OVERLAPPED o; OVERLAPPED o;
#endif #endif
/* Test the T.31 modem against the full FAX machine in spandsp */ /* 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 ((ret & MODEM_POLL_READ))
{ {
#if defined(WIN32) #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. */ /* Initialize the rest of the OVERLAPPED structure to zero. */
o.Internal = 0; o.Internal = 0;
o.InternalHigh = 0; o.InternalHigh = 0;
o.Offset = 0; o.Offset = 0;
o.OffsetHigh = 0; o.OffsetHigh = 0;
assert(o.hEvent); assert(o.hEvent);
if (!ReadFile(modem->master, buf, avail, &read_bytes, &o)) if (!ReadFile(modem->master, buf, avail, &read_bytes, &o))
GetOverlappedResult(modem->master, &o, &read_bytes, TRUE); GetOverlappedResult(modem->master, &o, &read_bytes, TRUE);
CloseHandle (o.hEvent); CloseHandle (o.hEvent);
if ((len = read_bytes)) if ((len = read_bytes))
#else #else
if ((len = read(modem[0].master, buf, 1024))) if ((len = read(modem[0].master, buf, 1024)))
#endif #endif
+28 -3
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
-1
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)
{ {