summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/viterbi
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/viterbi')
-rw-r--r--gnuradio-core/src/lib/viterbi/CMakeLists.txt63
-rw-r--r--gnuradio-core/src/lib/viterbi/Makefile.am2
-rw-r--r--gnuradio-core/src/lib/viterbi/metrics.c3
-rw-r--r--gnuradio-core/src/lib/viterbi/viterbi.h14
4 files changed, 77 insertions, 5 deletions
diff --git a/gnuradio-core/src/lib/viterbi/CMakeLists.txt b/gnuradio-core/src/lib/viterbi/CMakeLists.txt
new file mode 100644
index 000000000..add5c77e8
--- /dev/null
+++ b/gnuradio-core/src/lib/viterbi/CMakeLists.txt
@@ -0,0 +1,63 @@
+# Copyright 2010-2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio 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
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+# This file included, use CMake directory variables
+########################################################################
+
+set(viterbi_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/metrics.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/tab.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.c
+)
+
+########################################################################
+# define missing erf function with C linkage (hack for metrics.c)
+########################################################################
+if(MSVC)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc "
+#include <boost/math/special_functions/erf.hpp>
+extern \"C\" double erf(double x){
+ return boost::math::erf(x);
+}
+")
+list(APPEND viterbi_sources ${CMAKE_CURRENT_BINARY_DIR}/boost_math_erf.cc)
+endif(MSVC)
+
+########################################################################
+# Append gnuradio-core library sources
+########################################################################
+list(APPEND gnuradio_core_sources ${viterbi_sources})
+
+########################################################################
+# Install runtime headers
+########################################################################
+install(
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/viterbi.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio
+ COMPONENT "core_devel"
+)
+
+########################################################################
+# Create some text executables (not registered tests)
+# Its not much to build so the sources are just re-listed,
+# rather than create a new library just for these two apps.
+########################################################################
+#ADD_EXECUTABLE(viterbi_encode ${CMAKE_CURRENT_SOURCE_DIR}/encode.cc ${viterbi_sources})
+#ADD_EXECUTABLE(viterbi_decode ${CMAKE_CURRENT_SOURCE_DIR}/decode.cc ${viterbi_sources})
diff --git a/gnuradio-core/src/lib/viterbi/Makefile.am b/gnuradio-core/src/lib/viterbi/Makefile.am
index 8384c52f0..1b86a86f8 100644
--- a/gnuradio-core/src/lib/viterbi/Makefile.am
+++ b/gnuradio-core/src/lib/viterbi/Makefile.am
@@ -21,6 +21,8 @@ include $(top_srcdir)/Makefile.common
LIBS = -lm
+AM_CPPFLAGS = -I$(top_srcdir)/gnuradio-core/src/lib/general
+
noinst_LTLIBRARIES = libviterbi.la
libviterbi_la_SOURCES = \
diff --git a/gnuradio-core/src/lib/viterbi/metrics.c b/gnuradio-core/src/lib/viterbi/metrics.c
index 9f958cab7..77c6a63c8 100644
--- a/gnuradio-core/src/lib/viterbi/metrics.c
+++ b/gnuradio-core/src/lib/viterbi/metrics.c
@@ -42,6 +42,9 @@
#include <stdlib.h>
#include <math.h>
+//declare erf in case it was missing in math.h and provided for by the build system
+extern double erf(double x);
+
/* Normal function integrated from -Inf to x. Range: 0-1 */
#define normal(x) (0.5 + 0.5*erf((x)/M_SQRT2))
diff --git a/gnuradio-core/src/lib/viterbi/viterbi.h b/gnuradio-core/src/lib/viterbi/viterbi.h
index 155b0d93a..5bb8b357a 100644
--- a/gnuradio-core/src/lib/viterbi/viterbi.h
+++ b/gnuradio-core/src/lib/viterbi/viterbi.h
@@ -23,27 +23,31 @@
* than we'd like for K=7, especially since we chain back every 8 bits.
* But it fits so nicely into a 32-bit machine word...
*/
-struct viterbi_state {
+
+#include <gr_core_api.h>
+
+struct GR_CORE_API viterbi_state {
unsigned long path; /* Decoded path to this state */
long metric; /* Cumulative metric to this state */
};
+GR_CORE_API
int gen_met(int mettab[2][256], /* Metric table */
int amp, /* Signal amplitude */
double esn0, /* Es/N0 ratio in dB */
double bias, /* Metric bias */
int scale); /* Scale factor */
-unsigned char
+GR_CORE_API unsigned char
encode(unsigned char *symbols, unsigned char *data,
unsigned int nbytes,unsigned char encstate);
-void
+GR_CORE_API void
viterbi_chunks_init(struct viterbi_state* state);
-void
+ GR_CORE_API void
viterbi_butterfly2(unsigned char *symbols, int mettab[2][256],
struct viterbi_state *state0, struct viterbi_state *state1);
-unsigned char
+GR_CORE_API unsigned char
viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf);