From 43e2f86c0f8dbdd415ce5ad3d87ab62f4cef8a45 Mon Sep 17 00:00:00 2001
From: Steve Underwood <steveu@x100e.coppice.org>
Date: Wed, 24 Jul 2013 01:38:07 +0800
Subject: [PATCH] More tweaks to spandsp

---
 libs/spandsp/src/fsk.c                  |  9 +++++++++
 libs/spandsp/src/spandsp/t4_t6_encode.h |  6 ++++++
 libs/spandsp/src/spandsp/v18.h          | 21 +++++++++++----------
 libs/spandsp/src/t4_t6_encode.c         |  6 ++++++
 4 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/libs/spandsp/src/fsk.c b/libs/spandsp/src/fsk.c
index 56f155169e..2c1d326d84 100644
--- a/libs/spandsp/src/fsk.c
+++ b/libs/spandsp/src/fsk.c
@@ -69,6 +69,7 @@ const fsk_spec_t preset_fsk_specs[] =
         300*100
     },
     {
+        /* This is mode 2 of the V.23 spec. Mode 1 (the 600baud mode) is not defined here */
         "V23 ch 1",
         1700 + 400,
         1700 - 400,
@@ -124,6 +125,14 @@ const fsk_spec_t preset_fsk_specs[] =
         -30,
          50*100
     },
+    {
+        "Weitbrecht 47.6",  /* Used for V.18 probing */
+        1600 + 200,
+        1600 - 200,
+        -14,
+        -30,
+         4760
+    },
     {
         "V21 (110bps) ch 1",
         1080 + 100,
diff --git a/libs/spandsp/src/spandsp/t4_t6_encode.h b/libs/spandsp/src/spandsp/t4_t6_encode.h
index a157b444b9..81c6ddb3e4 100644
--- a/libs/spandsp/src/spandsp/t4_t6_encode.h
+++ b/libs/spandsp/src/spandsp/t4_t6_encode.h
@@ -77,6 +77,12 @@ SPAN_DECLARE(int) t4_t6_encode_set_encoding(t4_t6_encode_state_t *s, int encodin
     \return 0 for success, otherwise -1. */
 SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int image_width);
 
+/*! \brief Set the length of the image.
+    \param s The T.4/T.6 context.
+    \param image_length The image length, in pixels.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_t6_encode_set_image_length(t4_t6_encode_state_t *s, int image_length);
+
 /*! \brief Get the width of the image.
     \param s The T.4/T.6 context.
     \return The width of the image, in pixels. */
diff --git a/libs/spandsp/src/spandsp/v18.h b/libs/spandsp/src/spandsp/v18.h
index 970d2a3f22..32814d9c65 100644
--- a/libs/spandsp/src/spandsp/v18.h
+++ b/libs/spandsp/src/spandsp/v18.h
@@ -38,24 +38,25 @@ typedef struct v18_state_s v18_state_t;
 
 enum
 {
-    V18_MODE_NONE = 0,
+    V18_MODE_NONE = 0x0001,
     /* V.18 Annex A - Weitbrecht TDD at 45.45bps (US TTY), half-duplex, 5 bit baudot (USA). */
-    V18_MODE_5BIT_4545 = 1,
+    V18_MODE_5BIT_4545 = 0x0002,
     /* V.18 Annex A - Weitbrecht TDD at 50bps (International TTY), half-duplex, 5 bit baudot (UK, Australia and others). */
-    V18_MODE_5BIT_50 = 2,
+    V18_MODE_5BIT_50 = 0x0004,
     /* V.18 Annex B - DTMF encoding of ASCII (Denmark, Holland and others). */
-    V18_MODE_DTMF = 3,
+    V18_MODE_DTMF = 0x0008,
     /* V.18 Annex C - EDT (European Deaf Telephone) 110bps, V.21, half-duplex, ASCII (Germany, Austria, Switzerland and others). */
-    V18_MODE_EDT = 4,
+    V18_MODE_EDT = 0x0010,
     /* V.18 Annex D - 300bps, Bell 103, duplex, ASCII (USA). */
-    V18_MODE_BELL103 = 5,
+    V18_MODE_BELL103 = 0x0020,
     /* V.18 Annex E - 1200bps Videotex terminals, ASCII (France). */
-    V18_MODE_V23VIDEOTEX = 6,
+    V18_MODE_V23VIDEOTEX = 0x0040,
     /* V.18 Annex F - V.21 text telephone, V.21, duplex, ASCII (Sweden, Norway and Finland). */
-    V18_MODE_V21TEXTPHONE = 7,
+    V18_MODE_V21TEXTPHONE = 0x0080,
     /* V.18 Annex G - V.18 text telephone mode. */
-    V18_MODE_V18TEXTPHONE = 8,
-    V18_MODE_5BIT_476 = 9,
+    V18_MODE_V18TEXTPHONE = 0x0100,
+    /* V.18 Annex A - Used during probing. */
+    V18_MODE_5BIT_476 = 0x0200,
     /* Use repetitive shift characters where character set shifts are used */ 
     V18_MODE_REPETITIVE_SHIFTS_OPTION = 0x1000
 };
diff --git a/libs/spandsp/src/t4_t6_encode.c b/libs/spandsp/src/t4_t6_encode.c
index ddb8b33a06..4ed063e063 100644
--- a/libs/spandsp/src/t4_t6_encode.c
+++ b/libs/spandsp/src/t4_t6_encode.c
@@ -1040,6 +1040,12 @@ SPAN_DECLARE(int) t4_t6_encode_set_image_width(t4_t6_encode_state_t *s, int imag
 }
 /*- End of function --------------------------------------------------------*/
 
+SPAN_DECLARE(int) t4_t6_encode_set_image_length(t4_t6_encode_state_t *s, int image_length)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
 SPAN_DECLARE(uint32_t) t4_t6_encode_get_image_width(t4_t6_encode_state_t *s)
 {
     return s->image_width;