Various little cleanups in spandsp

This commit is contained in:
Steve Underwood 2015-06-18 21:15:41 +08:00
parent 33c723e839
commit 0eada8dc77
26 changed files with 191 additions and 88 deletions

View File

@ -36,27 +36,7 @@ m4_include(m4/ax_misaligned_access_fails.m4)
m4_include(m4/ax_c99_features.m4) m4_include(m4/ax_c99_features.m4)
m4_include(m4/ax_check_export_capability.m4) m4_include(m4/ax_check_export_capability.m4)
m4_include(m4/ax_check_arm_neon.m4) m4_include(m4/ax_check_arm_neon.m4)
m4_include(m4/ax_func_aligned_alloc.m4)
AC_DEFUN([AC_FUNC_ALIGNED_ALLOC],[
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_CACHE_CHECK([checking for aligned_alloc],
[ac_cv_func_aligned_alloc],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define _ISOC11_SOURCE
#include <stdlib.h>
],
[
aligned_alloc(0,0);
])],
[ac_cv_func_aligned_alloc=yes],
[ac_cv_func_aligned_alloc=no])])
if test "x${ac_cv_func_aligned_alloc}" = "xyes" ; then
AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if you have the aligned_alloc() function.])
fi
CFLAGS="$saved_CFLAGS"
])
AC_CONFIG_SRCDIR([src/tone_generate.c]) AC_CONFIG_SRCDIR([src/tone_generate.c])
AC_CONFIG_AUX_DIR([config]) AC_CONFIG_AUX_DIR([config])
@ -150,9 +130,6 @@ AC_TYPE_SIGNAL
AC_ARG_ENABLE(doc, [ --enable-doc Build the documentation]) AC_ARG_ENABLE(doc, [ --enable-doc Build the documentation])
AC_ARG_ENABLE(tests, [ --enable-tests Build the test programs]) AC_ARG_ENABLE(tests, [ --enable-tests Build the test programs])
AC_ARG_ENABLE(t43, [ --enable-t43 Enable T.43 support])
AC_ARG_ENABLE(v32bis, [ --enable-v32bis Enable V.32bis support])
AC_ARG_ENABLE(v34, [ --enable-v34 Enable V.34 support])
AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support]) AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support])
AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support]) AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support])
AC_ARG_ENABLE(sse2, [ --enable-sse2 Enable SSE2 support]) AC_ARG_ENABLE(sse2, [ --enable-sse2 Enable SSE2 support])
@ -160,12 +137,12 @@ AC_ARG_ENABLE(sse3, [ --enable-sse3 Enable SSE3 support])
AC_ARG_ENABLE(ssse3, [ --enable-ssse3 Enable SSSE3 support]) AC_ARG_ENABLE(ssse3, [ --enable-ssse3 Enable SSSE3 support])
AC_ARG_ENABLE(sse4_1, [ --enable-sse4-1 Enable SSE4.1 support]) AC_ARG_ENABLE(sse4_1, [ --enable-sse4-1 Enable SSE4.1 support])
AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support]) AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support])
AC_ARG_ENABLE(sse4a, [ --enable-sse4a Enable SSE4A support])
AC_ARG_ENABLE(sse5, [ --enable-sse5 Enable SSE5 support])
AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support]) AC_ARG_ENABLE(avx, [ --enable-avx Enable AVX support])
AC_ARG_ENABLE(avx2, [ --enable-avx2 Enable AVX2 support]) AC_ARG_ENABLE(avx2, [ --enable-avx2 Enable AVX2 support])
AC_ARG_ENABLE(neon, [ --enable-neon Enable NEON support]) AC_ARG_ENABLE(neon, [ --enable-neon Enable NEON support])
AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support]) AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
AC_ARG_ENABLE(v32bis, [ --enable-v32bis Enable V.32bis support])
AC_ARG_ENABLE(v34, [ --enable-v34 Enable V.34 support])
# The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp # The following is for MSVC, where we may be using a local copy of libtiff, built alongside spandsp
AC_ARG_ENABLE(builtin_tiff, AC_ARG_ENABLE(builtin_tiff,
@ -195,7 +172,7 @@ fi
AX_C99_FLEXIBLE_ARRAY AX_C99_FLEXIBLE_ARRAY
AC_FUNC_ALIGNED_ALLOC AX_FUNC_ALIGNED_ALLOC
AC_CHECK_FUNCS([memalign]) AC_CHECK_FUNCS([memalign])
AC_CHECK_FUNCS([posix_memalign]) AC_CHECK_FUNCS([posix_memalign])
AC_CHECK_FUNCS([memmove]) AC_CHECK_FUNCS([memmove])
@ -389,12 +366,6 @@ gnu)
if test "$enable_avx" = "yes" ; then if test "$enable_avx" = "yes" ; then
COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS" COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
fi fi
if test "$enable_sse5" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS"
fi
if test "$enable_sse4a" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse4a $COMP_VENDOR_CFLAGS"
fi
if test "$enable_sse4_2" = "yes" ; then if test "$enable_sse4_2" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS" COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
fi fi
@ -456,12 +427,6 @@ intel)
if test "$enable_avx" = "yes" ; then if test "$enable_avx" = "yes" ; then
COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS" COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
fi fi
if test "$enable_sse5" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS"
fi
if test "$enable_sse4a" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse4a $COMP_VENDOR_CFLAGS"
fi
if test "$enable_sse4_2" = "yes" ; then if test "$enable_sse4_2" = "yes" ; then
COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS" COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
fi fi
@ -530,14 +495,6 @@ x86_64-* | i386-* | i686-*)
fi fi
if test "$enable_avx" = "yes" ; then if test "$enable_avx" = "yes" ; then
AC_DEFINE([SPANDSP_USE_AVX], [1], [Use the AVX instruction set (i386 and x86_64 only).]) AC_DEFINE([SPANDSP_USE_AVX], [1], [Use the AVX instruction set (i386 and x86_64 only).])
enable_sse5="yes"
fi
if test "$enable_sse5" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).])
enable_sse4a="yes"
fi
if test "$enable_sse4a" = "yes" ; then
AC_DEFINE([SPANDSP_USE_SSE4A], [1], [Use the SSE4A instruction set (i386 and x86_64 only).])
enable_sse4_2="yes" enable_sse4_2="yes"
fi fi
if test "$enable_sse4_2" = "yes" ; then if test "$enable_sse4_2" = "yes" ; then
@ -640,8 +597,6 @@ AM_CONDITIONAL([COND_SSE3], [test "$enable_sse3" = yes])
AM_CONDITIONAL([COND_SSSE3], [test "$enable_ssse3" = yes]) AM_CONDITIONAL([COND_SSSE3], [test "$enable_ssse3" = yes])
AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes]) AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes])
AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes]) AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes])
AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes])
AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes])
AM_CONDITIONAL([COND_AVX], [test "$enable_avx" = yes]) AM_CONDITIONAL([COND_AVX], [test "$enable_avx" = yes])
AM_CONDITIONAL([COND_AVX2], [test "$enable_avx2" = yes]) AM_CONDITIONAL([COND_AVX2], [test "$enable_avx2" = yes])
AM_CONDITIONAL([COND_NEON], [test "$enable_neon" = yes]) AM_CONDITIONAL([COND_NEON], [test "$enable_neon" = yes])
@ -682,6 +637,7 @@ AC_CONFIG_FILES([Makefile
test-data/etsi/fax/Makefile test-data/etsi/fax/Makefile
test-data/itu/Makefile test-data/itu/Makefile
test-data/itu/fax/Makefile test-data/itu/fax/Makefile
test-data/itu/tiff-fx/Makefile
test-data/local/Makefile test-data/local/Makefile
tests/Makefile tests/Makefile
spandsp.pc spandsp.pc

View File

@ -0,0 +1,25 @@
# AX_FUNC_ALIGNED_ALLOC
# ---------------------
#
# Check for the function aligned_alloc()
#
AC_DEFUN([AX_FUNC_ALIGNED_ALLOC],[
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror"
AC_CACHE_CHECK([checking for aligned_alloc],
[ax_cv_func_aligned_alloc],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
#define _ISOC11_SOURCE
#include <stdlib.h>
],
[
aligned_alloc(0,0);
])],
[ax_cv_func_aligned_alloc=yes],
[ax_cv_func_aligned_alloc=no])])
if test "x${ax_cv_func_aligned_alloc}" = "xyes" ; then
AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if you have the aligned_alloc() function.])
fi
CFLAGS="$saved_CFLAGS"
])# AX_ALIGNED_ALLOC

View File

@ -891,7 +891,6 @@ static void generate_ad_edd(void)
l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2; l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
for (i = 0; i < LINE_FILTER_SIZE; i++) for (i = 0; i < LINE_FILTER_SIZE; i++)
{ {
#if defined(HAVE_FFTW3_H) #if defined(HAVE_FFTW3_H)
impulse_responses[filter_sets][i] = out[l][0]/pw; impulse_responses[filter_sets][i] = out[l][0]/pw;
#else #else

View File

@ -61,7 +61,7 @@ SPAN_DECLARE(void) ifft(complex_t data[], int len);
SPAN_DECLARE(codec_munge_state_t *) codec_munge_init(int codec, int info); SPAN_DECLARE(codec_munge_state_t *) codec_munge_init(int codec, int info);
SPAN_DECLARE(void) codec_munge_free(codec_munge_state_t *s); SPAN_DECLARE(int) codec_munge_free(codec_munge_state_t *s);
SPAN_DECLARE(void) codec_munge(codec_munge_state_t *s, int16_t amp[], int len); SPAN_DECLARE(void) codec_munge(codec_munge_state_t *s, int16_t amp[], int len);

View File

@ -316,9 +316,10 @@ SPAN_DECLARE(codec_munge_state_t *) codec_munge_init(int codec, int info)
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) codec_munge_free(codec_munge_state_t *s) SPAN_DECLARE(int) codec_munge_free(codec_munge_state_t *s)
{ {
free(s); free(s);
return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@ -78,7 +78,7 @@ static span_alloc_t __span_alloc = malloc;
static span_realloc_t __span_realloc = realloc; static span_realloc_t __span_realloc = realloc;
static span_free_t __span_free = free; static span_free_t __span_free = free;
#ifdef _MSC_VER #if defined(_MSC_VER)
#pragma warning(pop) #pragma warning(pop)
#endif #endif

View File

@ -606,6 +606,7 @@ SPAN_DECLARE(logging_state_t *) fax_modems_get_logging_state(fax_modems_state_t
SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s) SPAN_DECLARE(int) fax_modems_restart(fax_modems_state_t *s)
{ {
s->current_tx_type = -1;
return 0; return 0;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -653,7 +654,7 @@ SPAN_DECLARE(fax_modems_state_t *) fax_modems_init(fax_modems_state_t *s,
s->hdlc_accept = hdlc_accept; s->hdlc_accept = hdlc_accept;
s->hdlc_accept_user_data = user_data; s->hdlc_accept_user_data = user_data;
hdlc_rx_init(&s->hdlc_rx, false, false, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s); hdlc_rx_init(&s->hdlc_rx, false, true, HDLC_FRAMING_OK_THRESHOLD, fax_modems_hdlc_accept, s);
hdlc_tx_init(&s->hdlc_tx, false, 2, false, hdlc_tx_underflow, user_data); hdlc_tx_init(&s->hdlc_tx, false, 2, false, hdlc_tx_underflow, user_data);
fax_modems_start_slow_modem(s, FAX_MODEM_V21_RX); fax_modems_start_slow_modem(s, FAX_MODEM_V21_RX);

View File

@ -59,7 +59,7 @@
static void weighting_filter(int16_t x[40], static void weighting_filter(int16_t x[40],
const int16_t *e) // signal [-5..0.39.44] IN) const int16_t *e) // signal [-5..0.39.44] IN)
{ {
#if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) && !defined(__OpenBSD__) #if defined(__GNUC__) && defined(SPANDSP_USE_MMX) && defined(__x86_64__) && !defined(__OpenBSD__)
/* Table 4.4 Coefficients of the weighting filter */ /* Table 4.4 Coefficients of the weighting filter */
/* This must be padded to a multiple of 4 for MMX to work */ /* This must be padded to a multiple of 4 for MMX to work */
static const union static const union

View File

@ -53,6 +53,7 @@ static void report_status_change(hdlc_rx_state_t *s, int status)
s->status_handler(s->status_user_data, status); s->status_handler(s->status_user_data, status);
else if (s->frame_handler) else if (s->frame_handler)
s->frame_handler(s->frame_user_data, NULL, status, true); s->frame_handler(s->frame_user_data, NULL, status, true);
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -80,6 +81,7 @@ static void rx_special_condition(hdlc_rx_state_t *s, int status)
//printf("Eh!\n"); //printf("Eh!\n");
break; break;
} }
/*endswitch*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -97,12 +99,14 @@ static __inline__ void octet_set_and_count(hdlc_rx_state_t *s)
s->octet_count = s->octet_count_report_interval; s->octet_count = s->octet_count_report_interval;
report_status_change(s, SIG_STATUS_OCTET_REPORT); report_status_change(s, SIG_STATUS_OCTET_REPORT);
} }
/*endif*/
} }
else else
{ {
s->octet_counting_mode = true; s->octet_counting_mode = true;
s->octet_count = s->octet_count_report_interval; s->octet_count = s->octet_count_report_interval;
} }
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -110,6 +114,7 @@ static __inline__ void octet_count(hdlc_rx_state_t *s)
{ {
if (s->octet_count_report_interval == 0) if (s->octet_count_report_interval == 0)
return; return;
/*endif*/
/* If we are not in octet counting mode, we start it. /* If we are not in octet counting mode, we start it.
If we are in octet counting mode, we update it. */ If we are in octet counting mode, we update it. */
@ -120,7 +125,9 @@ static __inline__ void octet_count(hdlc_rx_state_t *s)
s->octet_count = s->octet_count_report_interval; s->octet_count = s->octet_count_report_interval;
report_status_change(s, SIG_STATUS_OCTET_REPORT); report_status_change(s, SIG_STATUS_OCTET_REPORT);
} }
/*endif*/
} }
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -138,6 +145,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->flags_seen = 0; s->flags_seen = 0;
else else
s->flags_seen = s->framing_ok_threshold - 1; s->flags_seen = s->framing_ok_threshold - 1;
/*endif*/
/* An abort starts octet counting */ /* An abort starts octet counting */
octet_set_and_count(s); octet_set_and_count(s);
} }
@ -171,8 +179,11 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->len -= s->crc_bytes; s->len -= s->crc_bytes;
if (s->frame_handler) if (s->frame_handler)
s->frame_handler(s->frame_user_data, s->buffer, s->len, false); s->frame_handler(s->frame_user_data, s->buffer, s->len, false);
/*endif*/
} }
/*endif*/
} }
/*endif*/
} }
else else
{ {
@ -185,12 +196,17 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->len -= s->crc_bytes; s->len -= s->crc_bytes;
else else
s->len = 0; s->len = 0;
/*endif*/
if (s->frame_handler) if (s->frame_handler)
s->frame_handler(s->frame_user_data, s->buffer, s->len, false); s->frame_handler(s->frame_user_data, s->buffer, s->len, false);
/*endif*/
} }
/*endif*/
s->rx_length_errors++; s->rx_length_errors++;
} }
/*endif*/
} }
/*endif*/
} }
else else
{ {
@ -210,14 +226,19 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
s->flags_seen = 0; s->flags_seen = 0;
else else
s->flags_seen = s->framing_ok_threshold - 1; s->flags_seen = s->framing_ok_threshold - 1;
/*endif*/
} }
/*endif*/
if (++s->flags_seen >= s->framing_ok_threshold && !s->framing_ok_announced) if (++s->flags_seen >= s->framing_ok_threshold && !s->framing_ok_announced)
{ {
report_status_change(s, SIG_STATUS_FRAMING_OK); report_status_change(s, SIG_STATUS_FRAMING_OK);
s->framing_ok_announced = true; s->framing_ok_announced = true;
} }
/*endif*/
} }
/*endif*/
} }
/*endif*/
s->len = 0; s->len = 0;
s->num_bits = 0; s->num_bits = 0;
} }
@ -235,20 +256,25 @@ static __inline__ void hdlc_rx_put_bit_core(hdlc_rx_state_t *s)
/* Is this a bit to be skipped for destuffing? */ /* Is this a bit to be skipped for destuffing? */
if ((s->raw_bit_stream & 0x4100) == 0) if ((s->raw_bit_stream & 0x4100) == 0)
return; return;
/*endif*/
/* Is this a flag or abort? */ /* Is this a flag or abort? */
if ((s->raw_bit_stream & 0xFE00) == 0x7E00) if ((s->raw_bit_stream & 0xFE00) == 0x7E00)
{ {
rx_flag_or_abort(s); rx_flag_or_abort(s);
return; return;
} }
/*endif*/
} }
/*endif*/
s->num_bits++; s->num_bits++;
if (s->flags_seen < s->framing_ok_threshold) if (s->flags_seen < s->framing_ok_threshold)
{ {
if ((s->num_bits & 0x7) == 0) if ((s->num_bits & 0x7) == 0)
octet_count(s); octet_count(s);
/*endif*/
return; return;
} }
/*endif*/
s->byte_in_progress = (s->byte_in_progress | (s->raw_bit_stream & 0x100)) >> 1; s->byte_in_progress = (s->byte_in_progress | (s->raw_bit_stream & 0x100)) >> 1;
if (s->num_bits == 8) if (s->num_bits == 8)
{ {
@ -266,8 +292,10 @@ static __inline__ void hdlc_rx_put_bit_core(hdlc_rx_state_t *s)
s->flags_seen = s->framing_ok_threshold - 1; s->flags_seen = s->framing_ok_threshold - 1;
octet_set_and_count(s); octet_set_and_count(s);
} }
/*endif*/
s->num_bits = 0; s->num_bits = 0;
} }
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -278,6 +306,7 @@ SPAN_DECLARE_NONSTD(void) hdlc_rx_put_bit(hdlc_rx_state_t *s, int new_bit)
rx_special_condition(s, new_bit); rx_special_condition(s, new_bit);
return; return;
} }
/*endif*/
s->raw_bit_stream = (s->raw_bit_stream << 1) | ((new_bit << 8) & 0x100); s->raw_bit_stream = (s->raw_bit_stream << 1) | ((new_bit << 8) & 0x100);
hdlc_rx_put_bit_core(s); hdlc_rx_put_bit_core(s);
} }
@ -292,12 +321,14 @@ SPAN_DECLARE_NONSTD(void) hdlc_rx_put_byte(hdlc_rx_state_t *s, int new_byte)
rx_special_condition(s, new_byte); rx_special_condition(s, new_byte);
return; return;
} }
/*endif*/
s->raw_bit_stream |= new_byte; s->raw_bit_stream |= new_byte;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
s->raw_bit_stream <<= 1; s->raw_bit_stream <<= 1;
hdlc_rx_put_bit_core(s); hdlc_rx_put_bit_core(s);
} }
/*endfor*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -307,6 +338,7 @@ SPAN_DECLARE_NONSTD(void) hdlc_rx_put(hdlc_rx_state_t *s, const uint8_t buf[], i
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
hdlc_rx_put_byte(s, buf[i]); hdlc_rx_put_byte(s, buf[i]);
/*endfor*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -348,7 +380,9 @@ SPAN_DECLARE(hdlc_rx_state_t *) hdlc_rx_init(hdlc_rx_state_t *s,
{ {
if ((s = (hdlc_rx_state_t *) span_alloc(sizeof(*s))) == NULL) if ((s = (hdlc_rx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL; return NULL;
/*endif*/
} }
/*endif*/
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
s->frame_handler = handler; s->frame_handler = handler;
s->frame_user_data = user_data; s->frame_user_data = user_data;
@ -406,29 +440,36 @@ SPAN_DECLARE(int) hdlc_tx_frame(hdlc_tx_state_t *s, const uint8_t *frame, size_t
s->tx_end = true; s->tx_end = true;
return 0; return 0;
} }
/*endif*/
if (s->len + len > s->max_frame_len) if (s->len + len > s->max_frame_len)
return -1; return -1;
/*endif*/
if (s->progressive) if (s->progressive)
{ {
/* Only lock out if we are in the CRC section. */ /* Only lock out if we are in the CRC section. */
if (s->pos >= HDLC_MAXFRAME_LEN) if (s->pos >= HDLC_MAXFRAME_LEN)
return -1; return -1;
/*endif*/
} }
else else
{ {
/* Lock out if there is anything in the buffer. */ /* Lock out if there is anything in the buffer. */
if (s->len) if (s->len)
return -1; return -1;
/*endif*/
} }
/*endif*/
memcpy(&s->buffer[s->len], frame, len); memcpy(&s->buffer[s->len], frame, len);
if (s->crc_bytes == 2) if (s->crc_bytes == 2)
s->crc = crc_itu16_calc(frame, len, (uint16_t) s->crc); s->crc = crc_itu16_calc(frame, len, (uint16_t) s->crc);
else else
s->crc = crc_itu32_calc(frame, len, s->crc); s->crc = crc_itu32_calc(frame, len, s->crc);
/*endif*/
if (s->progressive) if (s->progressive)
s->len += len; s->len += len;
else else
s->len = len; s->len = len;
/*endif*/
s->tx_end = false; s->tx_end = false;
return 0; return 0;
} }
@ -440,10 +481,12 @@ SPAN_DECLARE(int) hdlc_tx_flags(hdlc_tx_state_t *s, int len)
flag words. */ flag words. */
if (s->pos) if (s->pos)
return -1; return -1;
/*endif*/
if (len < 0) if (len < 0)
s->flag_octets += -len; s->flag_octets += -len;
else else
s->flag_octets = len; s->flag_octets = len;
/*endif*/
s->report_flag_underflow = true; s->report_flag_underflow = true;
s->tx_end = false; s->tx_end = false;
return 0; return 0;
@ -464,6 +507,7 @@ SPAN_DECLARE(int) hdlc_tx_corrupt_frame(hdlc_tx_state_t *s)
{ {
if (s->len <= 0) if (s->len <= 0)
return -1; return -1;
/*endif*/
s->crc ^= 0xFFFF; s->crc ^= 0xFFFF;
s->buffer[HDLC_MAXFRAME_LEN] ^= 0xFF; s->buffer[HDLC_MAXFRAME_LEN] ^= 0xFF;
s->buffer[HDLC_MAXFRAME_LEN + 1] ^= 0xFF; s->buffer[HDLC_MAXFRAME_LEN + 1] ^= 0xFF;
@ -491,15 +535,20 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
and we have been told to report this underflow. */ and we have been told to report this underflow. */
if (s->underflow_handler) if (s->underflow_handler)
s->underflow_handler(s->user_data); s->underflow_handler(s->user_data);
/*endif*/
} }
/*endif*/
} }
/*endif*/
if (s->abort_octets) if (s->abort_octets)
{ {
s->abort_octets = 0; s->abort_octets = 0;
return 0x7F; return 0x7F;
} }
/*endif*/
return s->idle_octet; return s->idle_octet;
} }
/*endif*/
if (s->len) if (s->len)
{ {
if (s->num_bits >= 8) if (s->num_bits >= 8)
@ -507,6 +556,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
s->num_bits -= 8; s->num_bits -= 8;
return (s->octets_in_progress >> s->num_bits) & 0xFF; return (s->octets_in_progress >> s->num_bits) & 0xFF;
} }
/*endif*/
if (s->pos >= s->len) if (s->pos >= s->len)
{ {
if (s->pos == s->len) if (s->pos == s->len)
@ -519,6 +569,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
s->buffer[HDLC_MAXFRAME_LEN + 2] = (uint8_t) (s->crc >> 16); s->buffer[HDLC_MAXFRAME_LEN + 2] = (uint8_t) (s->crc >> 16);
s->buffer[HDLC_MAXFRAME_LEN + 3] = (uint8_t) (s->crc >> 24); s->buffer[HDLC_MAXFRAME_LEN + 3] = (uint8_t) (s->crc >> 24);
} }
/*endif*/
s->pos = HDLC_MAXFRAME_LEN; s->pos = HDLC_MAXFRAME_LEN;
} }
else if (s->pos == (size_t) (HDLC_MAXFRAME_LEN + s->crc_bytes)) else if (s->pos == (size_t) (HDLC_MAXFRAME_LEN + s->crc_bytes))
@ -538,6 +589,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
s->crc = 0xFFFF; s->crc = 0xFFFF;
else else
s->crc = 0xFFFFFFFF; s->crc = 0xFFFFFFFF;
/*endif*/
/* Report the underflow now. If there are timed flags still in progress, loading the /* Report the underflow now. If there are timed flags still in progress, loading the
next frame right now will be harmless. */ next frame right now will be harmless. */
s->report_flag_underflow = false; s->report_flag_underflow = false;
@ -547,9 +599,12 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
in a new frame being sent. */ in a new frame being sent. */
if (s->len == 0 && s->flag_octets < 2) if (s->len == 0 && s->flag_octets < 2)
s->flag_octets = 2; s->flag_octets = 2;
/*endif*/
return txbyte; return txbyte;
} }
/*endif*/
} }
/*endif*/
byte_in_progress = s->buffer[s->pos++]; byte_in_progress = s->buffer[s->pos++];
i = bottom_bit(byte_in_progress | 0x100); i = bottom_bit(byte_in_progress | 0x100);
s->octets_in_progress <<= i; s->octets_in_progress <<= i;
@ -564,7 +619,9 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
s->octets_in_progress <<= 1; s->octets_in_progress <<= 1;
s->num_bits++; s->num_bits++;
} }
/*endif*/
} }
/*endfor*/
/* An input byte will generate between 8 and 10 output bits */ /* An input byte will generate between 8 and 10 output bits */
return (s->octets_in_progress >> s->num_bits) & 0xFF; return (s->octets_in_progress >> s->num_bits) & 0xFF;
} }
@ -574,6 +631,7 @@ SPAN_DECLARE_NONSTD(int) hdlc_tx_get_byte(hdlc_tx_state_t *s)
s->tx_end = false; s->tx_end = false;
return SIG_STATUS_END_OF_DATA; return SIG_STATUS_END_OF_DATA;
} }
/*endif*/
return s->idle_octet; return s->idle_octet;
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -629,6 +687,7 @@ SPAN_DECLARE(int) hdlc_tx_restart(hdlc_tx_state_t *s)
s->crc = 0xFFFF; s->crc = 0xFFFF;
else else
s->crc = 0xFFFFFFFF; s->crc = 0xFFFFFFFF;
/*endif*/
s->byte = 0; s->byte = 0;
s->bits = 0; s->bits = 0;
s->tx_end = false; s->tx_end = false;
@ -647,7 +706,9 @@ SPAN_DECLARE(hdlc_tx_state_t *) hdlc_tx_init(hdlc_tx_state_t *s,
{ {
if ((s = (hdlc_tx_state_t *) span_alloc(sizeof(*s))) == NULL) if ((s = (hdlc_tx_state_t *) span_alloc(sizeof(*s))) == NULL)
return NULL; return NULL;
/*endif*/
} }
/*endif*/
memset(s, 0, sizeof(*s)); memset(s, 0, sizeof(*s));
s->underflow_handler = handler; s->underflow_handler = handler;
s->user_data = user_data; s->user_data = user_data;
@ -662,6 +723,7 @@ SPAN_DECLARE(hdlc_tx_state_t *) hdlc_tx_init(hdlc_tx_state_t *s,
s->crc_bytes = 2; s->crc_bytes = 2;
s->crc = 0xFFFF; s->crc = 0xFFFF;
} }
/*endif*/
s->idle_octet = 0x7E; s->idle_octet = 0x7E;
s->progressive = progressive; s->progressive = progressive;
s->max_frame_len = HDLC_MAXFRAME_LEN; s->max_frame_len = HDLC_MAXFRAME_LEN;

View File

@ -605,30 +605,35 @@ static void dump_trie(void)
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
static void trie_recursive_free(trie_node_t *t) static void trie_recursive_free(trie_node_t *t)
{ {
int i; int i;
if (t)
{ if (t)
if (t->first <= t->last) {
{ if (t->first <= t->last)
for (i = t->first; i <= t->last; i++) {
trie_recursive_free(t->child_list[i]); for (i = t->first; i <= t->last; i++)
} trie_recursive_free(t->child_list[i]);
free(t); /*endfor*/
} }
/*endif*/
free(t);
}
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
static void trie_free(trie_t *s) static void trie_free(trie_t *s)
{ {
if(s) if (s)
{ {
if(s->root) if (s->root)
trie_recursive_free(s->root); trie_recursive_free(s->root);
free(s); /*endif*/
} free(s);
}
/*endif*/
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -639,6 +644,7 @@ int main(int argc, char *argv[])
if ((s = trie_create()) == NULL) if ((s = trie_create()) == NULL)
exit(2); exit(2);
/*endif*/
printf("/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS"); printf("/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS");
printf(" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\n"); printf(" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\n");
@ -646,6 +652,7 @@ int main(int argc, char *argv[])
for (i = 0; wordlist[i]; i++) for (i = 0; wordlist[i]; i++)
trie_add(s, wordlist[i], strlen(wordlist[i])); trie_add(s, wordlist[i], strlen(wordlist[i]));
/*endfor*/
printf("// The trie contains %d entries\n", i); printf("// The trie contains %d entries\n", i);
packed_ptr = 0; packed_ptr = 0;

View File

@ -195,7 +195,7 @@ extern "C"
{ {
return (long int) (x); return (long int) (x);
} }
#elif defined(__ppc__) || defined(__powerpc__) #elif (defined(__ppc__) || defined(__powerpc__)) && !defined(__NO_FPRS__)
static __inline__ long int lfastrint(register double x) static __inline__ long int lfastrint(register double x)
{ {
int res[2]; int res[2];

View File

@ -1460,6 +1460,7 @@ static int t38_terminal_t38_fe_restart(t38_terminal_state_t *t)
s = &t->t38_fe; s = &t->t38_fe;
t38_core_restart(&s->t38); t38_core_restart(&s->t38);
s->current_tx_type = -1;
s->rx_signal_present = false; s->rx_signal_present = false;
s->timed_step = T38_TIMED_STEP_NONE; s->timed_step = T38_TIMED_STEP_NONE;
//s->iaf = T30_IAF_MODE_T37 | T30_IAF_MODE_T38; //s->iaf = T30_IAF_MODE_T37 | T30_IAF_MODE_T38;

View File

@ -90,7 +90,7 @@ typedef struct
} packer_t; } packer_t;
#if defined(SPANDSP_SUPPORT_TIFF_FX) #if defined(SPANDSP_SUPPORT_TIFF_FX)
#if TIFFLIB_VERSION >= 20120615 #if TIFFLIB_VERSION >= 20120922 && defined(HAVE_TIF_DIR_H)
extern TIFFFieldArray tiff_fx_field_array; extern TIFFFieldArray tiff_fx_field_array;
#endif #endif
#endif #endif
@ -615,7 +615,7 @@ static int write_tiff_t43_image(t4_rx_state_t *s)
static int write_tiff_image(t4_rx_state_t *s) static int write_tiff_image(t4_rx_state_t *s)
{ {
t4_rx_tiff_state_t *t; t4_rx_tiff_state_t *t;
#if defined(SPANDSP_SUPPORT_TIFF_FX) #if defined(SPANDSP_SUPPORT_TIFF_FX) && TIFFLIB_VERSION >= 20120922 && defined(HAVE_TIF_DIR_H)
toff_t diroff; toff_t diroff;
#endif #endif
@ -678,6 +678,7 @@ static int write_tiff_image(t4_rx_state_t *s)
the first page in the file */ the first page in the file */
if (s->current_page == 0) if (s->current_page == 0)
{ {
#if TIFFLIB_VERSION >= 20120922 && defined(HAVE_TIF_DIR_H)
if (!TIFFCreateCustomDirectory(t->tiff_file, &tiff_fx_field_array)) if (!TIFFCreateCustomDirectory(t->tiff_file, &tiff_fx_field_array))
{ {
TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, PROFILETYPE_G3_FAX); TIFFSetField(t->tiff_file, TIFFTAG_FAXPROFILE, PROFILETYPE_G3_FAX);
@ -698,6 +699,7 @@ static int write_tiff_image(t4_rx_state_t *s)
if (!TIFFWriteDirectory(t->tiff_file)) if (!TIFFWriteDirectory(t->tiff_file))
span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page); span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page);
} }
#endif
} }
#endif #endif
return 0; return 0;

View File

@ -81,7 +81,7 @@
#include "faxfont.h" #include "faxfont.h"
#if defined(SPANDSP_SUPPORT_TIFF_FX) #if defined(SPANDSP_SUPPORT_TIFF_FX) && defined(HAVE_TIF_DIR_H)
#include <tif_dir.h> #include <tif_dir.h>
#endif #endif
@ -164,7 +164,7 @@ static const TIFFFieldInfo tiff_fx_tiff_field_info[] =
{TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ImageLayer"}, {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, FIELD_CUSTOM, false, false, (char *) "ImageLayer"},
}; };
#if TIFFLIB_VERSION >= 20120615 #if TIFFLIB_VERSION >= 20120922 && defined(HAVE_TIF_DIR_H)
static TIFFField tiff_fx_tiff_fields[] = static TIFFField tiff_fx_tiff_fields[] =
{ {
{ TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "Indexed" }, { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, (char *) "Indexed" },
@ -623,6 +623,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
diroff = 0; diroff = 0;
if (TIFFGetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, &diroff)) if (TIFFGetField(t->tiff_file, TIFFTAG_GLOBALPARAMETERSIFD, &diroff))
{ {
#if TIFFLIB_VERSION >= 20120922 && defined(HAVE_TIF_DIR_H)
if (!TIFFReadCustomDirectory(t->tiff_file, diroff, &tiff_fx_field_array)) if (!TIFFReadCustomDirectory(t->tiff_file, diroff, &tiff_fx_field_array))
{ {
span_log(&s->logging, SPAN_LOG_FLOW, "Global parameter read failed\n"); span_log(&s->logging, SPAN_LOG_FLOW, "Global parameter read failed\n");
@ -648,6 +649,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
if (!TIFFSetDirectory(t->tiff_file, (tdir_t) s->current_page)) if (!TIFFSetDirectory(t->tiff_file, (tdir_t) s->current_page))
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to set directory to page %d\n", s->current_page); span_log(&s->logging, SPAN_LOG_FLOW, "Failed to set directory to page %d\n", s->current_page);
} }
#endif
} }
#endif #endif
return 0; return 0;

View File

@ -643,6 +643,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa
tune_equalizer(s, &z, target); tune_equalizer(s, &z, target);
raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3];
bitstream = decode_baudx(s, nearest); bitstream = decode_baudx(s, nearest);
span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx 0x%x\n", bitstream);
s->rx.training_count++; s->rx.training_count++;
//span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d\n", raw_bits, nearest, bitstream, s->rx.scrambled_ones_to_date, 0, 0, 0, s->rx.training_count); //span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d\n", raw_bits, nearest, bitstream, s->rx.scrambled_ones_to_date, 0, 0, 0, s->rx.training_count);
if (s->negotiated_bit_rate == 1200) if (s->negotiated_bit_rate == 1200)
@ -736,6 +737,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa
track_carrier(s, &z, target); track_carrier(s, &z, target);
tune_equalizer(s, &z, target); tune_equalizer(s, &z, target);
bitstream = decode_baudx(s, nearest); bitstream = decode_baudx(s, nearest);
span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx 0x%x\n", bitstream);
if (++s->rx.training_count > ms_to_symbols(270 + 765)) if (++s->rx.training_count > ms_to_symbols(270 + 765))
{ {
span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n"); span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n");

View File

@ -315,7 +315,7 @@ static int receive_xid(v42_state_t *ss, const uint8_t *frame, int len)
{ {
case PI_HDLC_OPTIONAL_FUNCTIONS: case PI_HDLC_OPTIONAL_FUNCTIONS:
/* TODO: param_val is never used right now. */ /* TODO: param_val is never used right now. */
param_val = pack_value(buf, param_len); //param_val = pack_value(buf, param_len);
break; break;
case PI_TX_INFO_MAXSIZE: case PI_TX_INFO_MAXSIZE:
param_val = pack_value(buf, param_len); param_val = pack_value(buf, param_len);

View File

@ -0,0 +1,39 @@
##
## SpanDSP - a series of DSP components for telephony
##
## Makefile.am - Process this file with automake to produce Makefile.in
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2, as
## as published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
SUBDIRS =
DIST_SUBDIRS =
EXTRA_DIST = c03x_02x.tif \
c03x_02x-bilevel.tif \
f03x_02x.tif \
f05x_02x.tif \
f06x_01x.tif \
j01x_02x.tif \
l02x_02x.tif \
l02x_02x-bilevel.tif \
l04x_02x.tif \
l04x_02x-bilevel.tif \
m02x_04x.tif \
m06x-03x.tif \
m11x_02x.tif
all:
clean:

View File

@ -23,7 +23,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #if defined(HAVE_CONFIG_H)
#include "config.h" #include "config.h"
#endif #endif

View File

@ -23,7 +23,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #if defined(HAVE_CONFIG_H)
#include "config.h" #include "config.h"
#endif #endif

View File

@ -23,7 +23,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #if defined(HAVE_CONFIG_H)
#include "config.h" #include "config.h"
#endif #endif

View File

@ -23,7 +23,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#ifdef HAVE_CONFIG_H #if defined(HAVE_CONFIG_H)
#include "config.h" #include "config.h"
#endif #endif

View File

@ -61,7 +61,7 @@
struct iphdr struct iphdr
{ {
#ifdef _HPUX_LI #if defined(_HPUX_LI)
unsigned int ihl:4; unsigned int ihl:4;
unsigned int version:4; unsigned int version:4;
#else #else

View File

@ -95,7 +95,7 @@ int socket_harness_run(socket_harness_state_t *s)
{ {
//if (s->modem->event) //if (s->modem->event)
// modem_event(s->modem); // modem_event(s->modem);
#ifdef SIMULATE_RING #if defined(SIMULATE_RING)
tmo.tv_sec = 0; tmo.tv_sec = 0;
tmo.tv_usec= 1000000/RING_HZ; tmo.tv_usec= 1000000/RING_HZ;
#else #else
@ -135,7 +135,7 @@ int socket_harness_run(socket_harness_state_t *s)
if (ret == 0) if (ret == 0)
{ {
/* Timeout */ /* Timeout */
#ifdef SIMULATE_RING #if defined(SIMULATE_RING)
if (!modem->modem->started) if (!modem->modem->started)
{ {
rcount++; rcount++;

View File

@ -222,7 +222,7 @@ int write_file(meta_t *meta, int page, const uint8_t buf[])
TIFFSetField(tif, TIFFTAG_MAKE, "soft-switch.org"); TIFFSetField(tif, TIFFTAG_MAKE, "soft-switch.org");
TIFFSetField(tif, TIFFTAG_MODEL, "spandsp"); TIFFSetField(tif, TIFFTAG_MODEL, "spandsp");
TIFFSetField(tif, TIFFTAG_HOSTCOMPUTER, "i7.coppice.org"); TIFFSetField(tif, TIFFTAG_HOSTCOMPUTER, "i7.coppice.org");
#if defined(SPANDSP_SUPPORT_TIFF_FX) && defined(HAVE_TIF_DIR_H) #if defined(SPANDSP_SUPPORT_TIFF_FX)
/* Make space for this to be filled in later */ /* Make space for this to be filled in later */
TIFFSetField(tif, TIFFTAG_GLOBALPARAMETERSIFD, 0); TIFFSetField(tif, TIFFTAG_GLOBALPARAMETERSIFD, 0);
#endif #endif

View File

@ -237,6 +237,12 @@ int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
{ {
if ((stat = decode_length(buf, len, &ptr, &count)) < 0) if ((stat = decode_length(buf, len, &ptr, &count)) < 0)
return -1; return -1;
if ((total_count + count) >= 16)
{
/* There is too much stuff here to be real, and it would overflow the bufs array
if we continue */
return -1;
}
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i]) != 0) if (decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i]) != 0)

View File

@ -8905,13 +8905,13 @@ int main(int argc, char *argv[])
break; break;
} }
} }
argc -= optind;
argv += optind;
if (decode_test_file) if (decode_test_file)
{ {
decode_test_data_file(test_standard, decode_test_file); decode_test_data_file(test_standard, decode_test_file);
exit(0); exit(0);
} }
argc -= optind;
argv += optind;
if (argc > 0) if (argc > 0)
match = argv[0]; match = argv[0];