]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Various little cleanups in spandsp
authorSteve Underwood <steveu@coppice.org>
Thu, 18 Jun 2015 13:15:41 +0000 (21:15 +0800)
committerSteve Underwood <steveu@coppice.org>
Thu, 18 Jun 2015 13:15:41 +0000 (21:15 +0800)
26 files changed:
libs/spandsp/configure.ac
libs/spandsp/m4/ax_func_aligned_alloc.m4 [new file with mode: 0644]
libs/spandsp/spandsp-sim/make_line_models.c
libs/spandsp/spandsp-sim/spandsp/test_utils.h
libs/spandsp/spandsp-sim/test_utils.c
libs/spandsp/src/alloc.c
libs/spandsp/src/fax_modems.c
libs/spandsp/src/gsm0610_rpe.c
libs/spandsp/src/hdlc.c
libs/spandsp/src/make_at_dictionary.c
libs/spandsp/src/spandsp/fast_convert.h
libs/spandsp/src/t38_terminal.c
libs/spandsp/src/t4_rx.c
libs/spandsp/src/t4_tx.c
libs/spandsp/src/v22bis_rx.c
libs/spandsp/src/v42.c
libs/spandsp/test-data/itu/tiff-fx/Makefile.am [new file with mode: 0644]
libs/spandsp/tests/echo_monitor.cpp
libs/spandsp/tests/line_model_monitor.cpp
libs/spandsp/tests/media_monitor.cpp
libs/spandsp/tests/modem_monitor.cpp
libs/spandsp/tests/pcap_parse.c
libs/spandsp/tests/socket_harness.c
libs/spandsp/tests/t43_tests.c
libs/spandsp/tests/udptl.c
libs/spandsp/tests/v18_tests.c

index 43265fb2a2b7349844994d3207a80b5529eee784..fa0c1c0607b423ed59f449c6b9bc43d2890b3bf2 100644 (file)
@@ -36,27 +36,7 @@ m4_include(m4/ax_misaligned_access_fails.m4)
 m4_include(m4/ax_c99_features.m4)
 m4_include(m4/ax_check_export_capability.m4)
 m4_include(m4/ax_check_arm_neon.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"
-])
+m4_include(m4/ax_func_aligned_alloc.m4)
 
 AC_CONFIG_SRCDIR([src/tone_generate.c])
 AC_CONFIG_AUX_DIR([config])
@@ -150,9 +130,6 @@ AC_TYPE_SIGNAL
 
 AC_ARG_ENABLE(doc,          [  --enable-doc         Build the documentation])
 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(sse,          [  --enable-sse         Enable SSE 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(sse4_1,       [  --enable-sse4-1      Enable SSE4.1 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(avx2,         [  --enable-avx2        Enable AVX2 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(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
 AC_ARG_ENABLE(builtin_tiff,
@@ -195,7 +172,7 @@ fi
 
 AX_C99_FLEXIBLE_ARRAY
 
-AC_FUNC_ALIGNED_ALLOC
+AX_FUNC_ALIGNED_ALLOC
 AC_CHECK_FUNCS([memalign])
 AC_CHECK_FUNCS([posix_memalign])
 AC_CHECK_FUNCS([memmove])
@@ -389,12 +366,6 @@ gnu)
     if test "$enable_avx" = "yes" ; then
         COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
     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
         COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
     fi
@@ -456,12 +427,6 @@ intel)
     if test "$enable_avx" = "yes" ; then
         COMP_VENDOR_CFLAGS="-mavx $COMP_VENDOR_CFLAGS"
     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
         COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
     fi
@@ -530,14 +495,6 @@ x86_64-* | i386-* | i686-*)
     fi
     if test "$enable_avx" = "yes" ; then
         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"
     fi
     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_SSE4_1], [test "$enable_sse4_1" = 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_AVX2], [test "$enable_avx2" = yes])
 AM_CONDITIONAL([COND_NEON], [test "$enable_neon" = yes])
@@ -682,6 +637,7 @@ AC_CONFIG_FILES([Makefile
                  test-data/etsi/fax/Makefile
                  test-data/itu/Makefile
                  test-data/itu/fax/Makefile
+                 test-data/itu/tiff-fx/Makefile
                  test-data/local/Makefile
                  tests/Makefile
                  spandsp.pc
diff --git a/libs/spandsp/m4/ax_func_aligned_alloc.m4 b/libs/spandsp/m4/ax_func_aligned_alloc.m4
new file mode 100644 (file)
index 0000000..1a236e1
--- /dev/null
@@ -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
index 8c5e1f2b5b162ad884eb4884b9fe74a4760cc831..cac9d75cc1d0d9c71e7fdd0bd68c0a5ec19ef1bb 100644 (file)
@@ -891,7 +891,6 @@ static void generate_ad_edd(void)
             l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
             for (i = 0;  i < LINE_FILTER_SIZE;  i++)
             {
-
 #if defined(HAVE_FFTW3_H)
                 impulse_responses[filter_sets][i] = out[l][0]/pw;
 #else
index 407b800048b721ff3e1dd6f972514ac84650549f..9a7214976ee1eb5cc69c9ebf1dd97091122b0b47 100644 (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(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);
 
index 69394702c0040f4ddd173464b60b5e9eca201045..21f019ec915941e566b24935cad0afdbc6285c90 100644 (file)
@@ -316,9 +316,10 @@ SPAN_DECLARE(codec_munge_state_t *) codec_munge_init(int codec, int info)
 }
 /*- 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);
+    return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
index 3785293ea2276d70041226da312ec63e6177c44d..a885a3d57f7264b6663a4477264c1b8093cef4c2 100644 (file)
@@ -78,7 +78,7 @@ static span_alloc_t __span_alloc = malloc;
 static span_realloc_t __span_realloc = realloc;
 static span_free_t __span_free = free;
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER)
 #pragma warning(pop)
 #endif
 
index 4602854a6f64c5cb6dce28fd62d67100b4be4701..78d5b198d0e4c9fb25431ce144faac5507d94ec2 100644 (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)
 {
+    s->current_tx_type = -1;
     return 0;
 }
 /*- 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_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);
 
     fax_modems_start_slow_modem(s, FAX_MODEM_V21_RX);
index 509880a5c7ae52deccd4fd49113c4d1c54a6d7ae..bf27c6550bb3242d442ee1f5d8791d23571f32a4 100644 (file)
@@ -59,7 +59,7 @@
 static void weighting_filter(int16_t x[40],
                              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 */
     /* This must be padded to a multiple of 4 for MMX to work */
     static const union
index 8891c071f80dcc6e2bce75e5f35554dfe3872e45..c3de12d01e92c8a982b9957406096494e7f6213b 100644 (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);
     else if (s->frame_handler)
         s->frame_handler(s->frame_user_data, NULL, status, true);
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -80,6 +81,7 @@ static void rx_special_condition(hdlc_rx_state_t *s, int status)
         //printf("Eh!\n");
         break;
     }
+    /*endswitch*/
 }
 /*- 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;
             report_status_change(s, SIG_STATUS_OCTET_REPORT);
         }
+        /*endif*/
     }
     else
     {
         s->octet_counting_mode = true;
         s->octet_count = s->octet_count_report_interval;
     }
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -110,6 +114,7 @@ static __inline__ void octet_count(hdlc_rx_state_t *s)
 {
     if (s->octet_count_report_interval == 0)
         return;
+    /*endif*/
 
     /* If we are not in octet counting mode, we start 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;
             report_status_change(s, SIG_STATUS_OCTET_REPORT);
         }
+        /*endif*/
     }
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -138,6 +145,7 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
             s->flags_seen = 0;
         else
             s->flags_seen = s->framing_ok_threshold - 1;
+        /*endif*/
         /* An abort starts octet counting */
         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;
                             if (s->frame_handler)
                                 s->frame_handler(s->frame_user_data, s->buffer, s->len, false);
+                            /*endif*/
                         }
+                        /*endif*/
                     }
+                    /*endif*/
                 }
                 else
                 {
@@ -185,12 +196,17 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
                             s->len -= s->crc_bytes;
                         else
                             s->len = 0;
+                        /*endif*/
                         if (s->frame_handler)
                             s->frame_handler(s->frame_user_data, s->buffer, s->len, false);
+                        /*endif*/
                     }
+                    /*endif*/
                     s->rx_length_errors++;
                 }
+                /*endif*/
             }
+            /*endif*/
         }
         else
         {
@@ -210,14 +226,19 @@ static void rx_flag_or_abort(hdlc_rx_state_t *s)
                     s->flags_seen = 0;
                 else
                     s->flags_seen = s->framing_ok_threshold - 1;
+                /*endif*/
             }
+            /*endif*/
             if (++s->flags_seen >= s->framing_ok_threshold  &&  !s->framing_ok_announced)
             {
                 report_status_change(s, SIG_STATUS_FRAMING_OK);
                 s->framing_ok_announced = true;
             }
+            /*endif*/
         }
+        /*endif*/
     }
+    /*endif*/
     s->len = 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? */
         if ((s->raw_bit_stream & 0x4100) == 0)
             return;
+        /*endif*/
         /* Is this a flag or abort? */
         if ((s->raw_bit_stream & 0xFE00) == 0x7E00)
         {
             rx_flag_or_abort(s);
             return;
         }
+        /*endif*/
     }
+    /*endif*/
     s->num_bits++;
     if (s->flags_seen < s->framing_ok_threshold)
     {
         if ((s->num_bits & 0x7) == 0)
             octet_count(s);
+        /*endif*/
         return;
     }
+    /*endif*/
     s->byte_in_progress = (s->byte_in_progress | (s->raw_bit_stream & 0x100)) >> 1;
     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;
             octet_set_and_count(s);
         }
+        /*endif*/
         s->num_bits = 0;
     }
+    /*endif*/
 }
 /*- 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);
         return;
     }
+    /*endif*/
     s->raw_bit_stream = (s->raw_bit_stream << 1) | ((new_bit << 8) & 0x100);
     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);
         return;
     }
+    /*endif*/
     s->raw_bit_stream |= new_byte;
     for (i = 0;  i < 8;  i++)
     {
         s->raw_bit_stream <<= 1;
         hdlc_rx_put_bit_core(s);
     }
+    /*endfor*/
 }
 /*- 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++)
         hdlc_rx_put_byte(s, buf[i]);
+    /*endfor*/
 }
 /*- 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)
             return NULL;
+        /*endif*/
     }
+    /*endif*/
     memset(s, 0, sizeof(*s));
     s->frame_handler = handler;
     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;
         return 0;
     }
+    /*endif*/
     if (s->len + len > s->max_frame_len)
         return -1;
+    /*endif*/
     if (s->progressive)
     {
         /* Only lock out if we are in the CRC section. */
         if (s->pos >= HDLC_MAXFRAME_LEN)
             return -1;
+        /*endif*/
     }
     else
     {
         /* Lock out if there is anything in the buffer. */
         if (s->len)
             return -1;
+        /*endif*/
     }
+    /*endif*/
     memcpy(&s->buffer[s->len], frame, len);
     if (s->crc_bytes == 2)
         s->crc = crc_itu16_calc(frame, len, (uint16_t) s->crc);
     else
         s->crc = crc_itu32_calc(frame, len, s->crc);
+    /*endif*/
     if (s->progressive)
         s->len += len;
     else
         s->len = len;
+    /*endif*/
     s->tx_end = false;
     return 0;
 }
@@ -440,10 +481,12 @@ SPAN_DECLARE(int) hdlc_tx_flags(hdlc_tx_state_t *s, int len)
        flag words. */
     if (s->pos)
         return -1;
+    /*endif*/
     if (len < 0)
         s->flag_octets += -len;
     else
         s->flag_octets = len;
+    /*endif*/
     s->report_flag_underflow = true;
     s->tx_end = false;
     return 0;
@@ -464,6 +507,7 @@ SPAN_DECLARE(int) hdlc_tx_corrupt_frame(hdlc_tx_state_t *s)
 {
     if (s->len <= 0)
         return -1;
+    /*endif*/
     s->crc ^= 0xFFFF;
     s->buffer[HDLC_MAXFRAME_LEN] ^= 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. */
                 if (s->underflow_handler)
                     s->underflow_handler(s->user_data);
+                /*endif*/
             }
+            /*endif*/
         }
+        /*endif*/
         if (s->abort_octets)
         {
             s->abort_octets = 0;
             return 0x7F;
         }
+        /*endif*/
         return s->idle_octet;
     }
+    /*endif*/
     if (s->len)
     {
         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;
             return (s->octets_in_progress >> s->num_bits) & 0xFF;
         }
+        /*endif*/
         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 + 3] = (uint8_t) (s->crc >> 24);
                 }
+                /*endif*/
                 s->pos = HDLC_MAXFRAME_LEN;
             }
             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;
                 else
                     s->crc = 0xFFFFFFFF;
+                /*endif*/
                 /* Report the underflow now. If there are timed flags still in progress, loading the
                    next frame right now will be harmless. */
                 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. */
                 if (s->len == 0  &&  s->flag_octets < 2)
                     s->flag_octets = 2;
+                /*endif*/
                 return txbyte;
             }
+            /*endif*/
         }
+        /*endif*/
         byte_in_progress = s->buffer[s->pos++];
         i = bottom_bit(byte_in_progress | 0x100);
         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->num_bits++;
             }
+            /*endif*/
         }
+        /*endfor*/
         /* An input byte will generate between 8 and 10 output bits */
         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;
         return SIG_STATUS_END_OF_DATA;
     }
+    /*endif*/
     return s->idle_octet;
 }
 /*- End of function --------------------------------------------------------*/
@@ -629,6 +687,7 @@ SPAN_DECLARE(int) hdlc_tx_restart(hdlc_tx_state_t *s)
         s->crc = 0xFFFF;
     else
         s->crc = 0xFFFFFFFF;
+    /*endif*/
     s->byte = 0;
     s->bits = 0;
     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)
             return NULL;
+        /*endif*/
     }
+    /*endif*/
     memset(s, 0, sizeof(*s));
     s->underflow_handler = handler;
     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 = 0xFFFF;
     }
+    /*endif*/
     s->idle_octet = 0x7E;
     s->progressive = progressive;
     s->max_frame_len = HDLC_MAXFRAME_LEN;
index a34dd6f3a3fe09fc592994f7ef0b7460424ddb6c..974f1b22ab970f23e3a1f5812dfde085ab201384 100644 (file)
@@ -605,30 +605,35 @@ static void dump_trie(void)
 }
 /*- End of function --------------------------------------------------------*/
 
-
 static void trie_recursive_free(trie_node_t *t)
 {
-       int i;
-       if (t)
-       {
-               if (t->first <= t->last)
-               {
-                       for (i = t->first;  i <= t->last;  i++)
-                               trie_recursive_free(t->child_list[i]);
-               }
-               free(t);
-       }
+    int i;
+
+    if (t)
+    {
+        if (t->first <= t->last)
+        {
+            for (i = t->first;  i <= t->last;  i++)
+                trie_recursive_free(t->child_list[i]);
+            /*endfor*/
+        }
+        /*endif*/
+        free(t);
+    }
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
 static void trie_free(trie_t *s)
 {
-       if(s)
-       {
-               if(s->root)
-                       trie_recursive_free(s->root);
-               free(s);
-       }
+    if (s)
+    {
+        if (s->root)
+            trie_recursive_free(s->root);
+        /*endif*/
+        free(s);
+    }
+    /*endif*/
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -639,6 +644,7 @@ int main(int argc, char *argv[])
 
     if ((s = trie_create()) == NULL)
         exit(2);
+    /*endif*/
 
     printf("/* THIS FILE WAS AUTOMATICALLY GENERATED - ANY MODIFICATIONS MADE TO THIS");
     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++)
         trie_add(s, wordlist[i], strlen(wordlist[i]));
+    /*endfor*/
     printf("// The trie contains %d entries\n", i);
 
     packed_ptr = 0;
index 8f79b110d4aaed1b9b7c5a164b2d5e3308135fb8..a1d8c026af483158e4b818a5234fec912c2d43b2 100644 (file)
@@ -195,7 +195,7 @@ extern "C"
     {
         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)
     {
         int res[2];
index cbdd1f50bfd8d249206a7f33343472ee19e7c942..6532aacb9af050205efa2b7572399f0b7c714323 100644 (file)
@@ -1460,6 +1460,7 @@ static int t38_terminal_t38_fe_restart(t38_terminal_state_t *t)
     s = &t->t38_fe;
     t38_core_restart(&s->t38);
 
+    s->current_tx_type = -1;
     s->rx_signal_present = false;
     s->timed_step = T38_TIMED_STEP_NONE;
     //s->iaf = T30_IAF_MODE_T37 | T30_IAF_MODE_T38;
index df10c8f7c960b43e766af702f7d4b336284a8030..56bb1ac7cd4ad4dba330e36d65bc5f127423774e 100644 (file)
@@ -90,7 +90,7 @@ typedef struct
 } packer_t;
 
 #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;
 #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)
 {
     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;
 #endif
 
@@ -678,6 +678,7 @@ static int write_tiff_image(t4_rx_state_t *s)
        the first page in the file */
     if (s->current_page == 0)
     {
+#if TIFFLIB_VERSION >= 20120922  &&  defined(HAVE_TIF_DIR_H)
         if (!TIFFCreateCustomDirectory(t->tiff_file, &tiff_fx_field_array))
         {
             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))
                 span_log(&s->logging, SPAN_LOG_WARNING, "%s: Failed to write directory for page %d.\n", t->file, s->current_page);
         }
+#endif
     }
 #endif
     return 0;
index c273326fdb542a34b8b901a1eba33534af4e80c3..b10131cf9782d0b08dfb5b25019ae90ac992dd8c 100644 (file)
@@ -81,7 +81,7 @@
 
 #include "faxfont.h"
 
-#if defined(SPANDSP_SUPPORT_TIFF_FX)
+#if defined(SPANDSP_SUPPORT_TIFF_FX)  &&  defined(HAVE_TIF_DIR_H)
 #include <tif_dir.h>
 #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"},
 };
 
-#if TIFFLIB_VERSION >= 20120615
+#if TIFFLIB_VERSION >= 20120922  &&  defined(HAVE_TIF_DIR_H)
 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" },
@@ -623,6 +623,7 @@ static int get_tiff_directory_info(t4_tx_state_t *s)
     diroff = 0;
     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))
         {
             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))
                 span_log(&s->logging, SPAN_LOG_FLOW, "Failed to set directory to page %d\n", s->current_page);
         }
+#endif
     }
 #endif
     return 0;
index 102b9a2eb7ee64723ab6edbb0f9d844078905e81..af922882a64d6efb9c49cc09344b895da92cee6a 100644 (file)
@@ -643,6 +643,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa
         tune_equalizer(s, &z, target);
         raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3];
         bitstream = decode_baudx(s, nearest);
+        span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx 0x%x\n", bitstream);
         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)
@@ -736,6 +737,7 @@ static __inline__ void process_half_baud(v22bis_state_t *s, const complexf_t *sa
         track_carrier(s, &z, target);
         tune_equalizer(s, &z, target);
         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))
         {
             span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n");
index 806f7aa21239fec1d49f2114c38ec62bf999aec7..44e6bd01d92bfce44cc3ad43b6156ade0ad081e4 100644 (file)
@@ -315,7 +315,7 @@ static int receive_xid(v42_state_t *ss, const uint8_t *frame, int len)
                 {
                 case PI_HDLC_OPTIONAL_FUNCTIONS:
                     /* TODO: param_val is never used right now. */
-                    param_val = pack_value(buf, param_len);
+                    //param_val = pack_value(buf, param_len);
                     break;
                 case PI_TX_INFO_MAXSIZE:
                     param_val = pack_value(buf, param_len);
diff --git a/libs/spandsp/test-data/itu/tiff-fx/Makefile.am b/libs/spandsp/test-data/itu/tiff-fx/Makefile.am
new file mode 100644 (file)
index 0000000..97413d8
--- /dev/null
@@ -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:
index 690bc5da8c03027c2593dd3d894103785d8e7c0e..ecea0f6b7bf6146d22d14e4eee6becdcd0eb9fb2 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
 
index a517c62e5b5b5121300e7513868899302c74868b..0d3059359d020efeffa91b3e801f4048c017a125 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
 
index ffdfc75a263b627f25815912da110e3c7bea5c9a..be983e64f83e619e76a9c7de86fc73021d7cdc46 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
 
index 0c3c8ce8ab80c2463fa27214d5da74dfa3e3fc2d..5ec46b63e0e668154c46eefb4e7151e3deef2740 100644 (file)
@@ -23,7 +23,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#ifdef HAVE_CONFIG_H
+#if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
 
index d9c68700294235bcf82759415082bec2857d86bf..bc3805af2affccbf7e54a7a941145bf32a7d0873 100644 (file)
@@ -61,7 +61,7 @@
 
 struct iphdr
 {
-#ifdef _HPUX_LI
+#if defined(_HPUX_LI)
     unsigned int ihl:4;
     unsigned int version:4;
 #else
index 71b22b90b0ed0d0a19d762a7b01d324a46f83452..f946f4a8a7a2ec58e6db521884028bd788e10503 100644 (file)
@@ -95,7 +95,7 @@ int socket_harness_run(socket_harness_state_t *s)
     {
         //if (s->modem->event)
         //    modem_event(s->modem);
-#ifdef SIMULATE_RING
+#if defined(SIMULATE_RING)
         tmo.tv_sec = 0;
         tmo.tv_usec= 1000000/RING_HZ;
 #else
@@ -135,7 +135,7 @@ int socket_harness_run(socket_harness_state_t *s)
         if (ret == 0)
         {
             /* Timeout */
-#ifdef SIMULATE_RING
+#if defined(SIMULATE_RING)
             if (!modem->modem->started)
             {
                 rcount++;
index dff6bc1978e9fde05aad5bdedf50b4cb2055d9af..0896f8e6b3e58e6976f725cb32fdfa8347c12782 100644 (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_MODEL, "spandsp");
     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 */
     TIFFSetField(tif, TIFFTAG_GLOBALPARAMETERSIFD, 0);
 #endif
index f4bb05d2ebb7d0d09ed5a6393542cab264d924b3..e44fa023faaf3c769e15067db861770a316b2457 100644 (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)
                 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++)
             {
                 if (decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i]) != 0)
index 948ffef50187ba2e6b4bba09cebeb24bc7442b1f..a767eac2632544153c0aedf7c822b34d11fb8878 100644 (file)
@@ -8905,13 +8905,13 @@ int main(int argc, char *argv[])
             break;
         }
     }
+    argc -= optind;
+    argv += optind;
     if (decode_test_file)
     {
         decode_test_data_file(test_standard, decode_test_file);
         exit(0);
     }
-    argc -= optind;
-    argv += optind;
     if (argc > 0)
         match = argv[0];