--- a/gr-fec/include/gnuradio/fec/viterbi.h 2015-12-16 20:39:46 +++ b/gr-fec/include/gnuradio/fec/viterbi.h 2018-08-10 12:33:59 @@ -24,6 +24,13 @@ * But it fits so nicely into a 32-bit machine word... */ +#ifndef INCLUDED_VITERBI_H +#define INCLUDED_VITERBI_H + +#ifdef __cplusplus +extern "C" { +#endif + #include struct viterbi_state { @@ -51,3 +58,10 @@ FEC_API unsigned char viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf); + +#ifdef __cplusplus +}; +#endif + +#endif /* INCLUDED_VITERBI_H */ + --- a/gr-fec/lib/viterbi/decode.cc 2015-12-16 20:39:46 +++ b/gr-fec/lib/viterbi/decode.cc 2018-08-10 14:05:31 @@ -49,14 +49,21 @@ float RATE=0.5; float ebn0 = 12.0; float esn0 = RATE*pow(10.0, ebn0/10); + gen_met(mettab, amp, esn0, 0.0, 4); // Initialize decoder state struct viterbi_state state0[64]; struct viterbi_state state1[64]; unsigned char viterbi_in[16]; + viterbi_chunks_init(state0); +#ifdef _WIN32 + setmode (fileno(stdin), O_BINARY); + setmode (fileno(stdout), O_BINARY); +#endif + while (!feof(stdin)) { unsigned int n = fread(syms, 1, MAXENCSIZE, stdin); unsigned char *out = data; --- a/gr-fec/lib/viterbi/encode.cc 2015-12-16 20:39:46 +++ b/gr-fec/lib/viterbi/encode.cc 2018-08-10 14:05:55 @@ -44,6 +44,11 @@ unsigned char data[MAXCHUNKSIZE]; unsigned char syms[MAXENCSIZE]; +#ifdef _WIN32 + setmode (fileno(stdin), O_BINARY); + setmode (fileno(stdout), O_BINARY); +#endif + while (!feof(stdin)) { unsigned int n = fread(data, 1, MAXCHUNKSIZE, stdin); encoder_state = encode(syms, data, n, encoder_state); --- a/gr-fec/lib/viterbi/metrics.c 2015-12-16 20:39:46 +++ b/gr-fec/lib/viterbi/metrics.c 2018-08-10 09:57:03 @@ -30,6 +30,8 @@ * */ +#include + #ifdef HAVE_CONFIG_H #include #endif @@ -42,8 +44,10 @@ #include #include -//declare erf in case it was missing in math.h and provided for by the build system -extern double erf(double x); +#ifndef HAVE_ERF + //declare erf in case it was missing in math.h and provided for by the build system + extern double erf(double x); +#endif /* Normal function integrated from -Inf to x. Range: 0-1 */ #define normal(x) (0.5 + 0.5*erf((x)/M_SQRT2)) @@ -54,7 +58,7 @@ /* Generate log-likelihood metrics for 8-bit soft quantized channel * assuming AWGN and BPSK */ -void +int gen_met(int mettab[2][256], /* Metric table, [sent sym][rx symbol] */ int amp, /* Signal amplitude, units */ double esn0, /* Es/N0 ratio in dB */ @@ -123,4 +127,5 @@ #endif } } + return (0); }