Write no-op copy routines.
authorbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 6 Mar 2014 23:44:11 +0000 (23:44 +0000)
committerbruceperens <bruceperens@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 6 Mar 2014 23:44:11 +0000 (23:44 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1409 01035d8c-6547-0410-b346-abe4f91aad63

freedv-server/source/big_main.cpp
freedv-server/source/codec_noop.cpp
freedv-server/source/modem_noop.cpp

index 7123ed3d6a3861f0682f0f380943f6b9cf009481..94c71a6216795cef4794ad65d971ada545eb1cb2 100644 (file)
@@ -38,6 +38,7 @@ static void help(const char * name)
     "\nWhere options are these flags:\n\n"
     "--codec or -c\t\tSelect the voice codec.\n"
     "--drivers or -d\t\tPrint a list of the available device drivers.\n"
+    "--framer or -f\t\tSelect the communications protocol framer.\n"
     "--gui or -g\t\tSelect the graphical user interface.\n"
     "--help or -h\t\tPrint this message.\n"
     "--interface or -i\tSelect the user-interface (graphical or otherwise).\n"
index da8f9b3147de09b68f92c7972134385b030601b7..891b039e736601bbd63ca2240a8e91f50b32e3d7 100644 (file)
@@ -1,6 +1,7 @@
 /// The No-Op Codec, for testing and plain SSB voice.
 
 #include "drivers.h"
+#include <string.h>
 
 namespace FreeDV {
   /// Codec "no-op", just copies its input to its output. For plain SSB voice, and for testing.
@@ -76,19 +77,23 @@ namespace FreeDV {
   std::size_t
   CodecNoOp::decode16(const std::uint8_t * i, std::int16_t * o, std::size_t * data_length, std::size_t sample_length)
   {
-    return sample_length;
+    const std::size_t length = std::min(*data_length / 2, sample_length);
+    memcpy(o, i, length * 2);
+    *data_length = length * 2;
+    return length;
   }
 
   std::size_t
   CodecNoOp::encode16(const std::int16_t * i, std::uint8_t * o, std::size_t length)
   {
+    memcpy(o, i, length);
     return length;
   }
 
   int const
   CodecNoOp::frame_duration() const
   {
-    return 0;
+    return 1;
   }
 
   std::size_t const
index 7a898755634c4578e6748c37c9b3bd3ee9cb6914..93745ee403ddd28ed27f43a8c8013a51aaff426f 100644 (file)
@@ -1,6 +1,7 @@
 /// The no-op modem, for plain SSB voice and testing.
 
 #include "drivers.h"
+#include <string.h>
 
 namespace FreeDV {
   /// Modem "no-op", just copies its input to its output.
@@ -82,13 +83,19 @@ namespace FreeDV {
    std::size_t * sample_length,
    std::size_t data_length)
   {
-    return data_length;
+    const std::size_t length = std::min(data_length / 2, *sample_length);
+    memcpy(o, i, length * 2);
+    *sample_length = length * 2;
+    return length;
   }
 
   std::size_t
   ModemNoOp::modulate16(const std::uint8_t * i, std::int16_t * o, std::size_t length)
   {
-    return length;
+    length = length - (length % 2);
+
+    memcpy(o, i, length);
+    return length / 2;
   }
 
   int const