Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / lib / viterbi / viterbi.h
1 /*
2  * Copyright 2008 Free Software Foundation, Inc.
3  * 
4  * This file is part of GNU Radio
5  * 
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  * 
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 /* The path memory for each state is 32 bits. This is slightly shorter
23  * than we'd like for K=7, especially since we chain back every 8 bits.
24  * But it fits so nicely into a 32-bit machine word...
25  */
26 struct viterbi_state {
27   unsigned long path;   /* Decoded path to this state */
28   long metric;          /* Cumulative metric to this state */
29 };
30
31 int gen_met(int mettab[2][256], /* Metric table */
32             int amp,            /* Signal amplitude */
33             double esn0,        /* Es/N0 ratio in dB */
34             double bias,        /* Metric bias */
35             int scale);         /* Scale factor */
36
37 unsigned char
38 encode(unsigned char *symbols, unsigned char *data,
39        unsigned int nbytes,unsigned char encstate);
40
41 void 
42 viterbi_chunks_init(struct viterbi_state* state);
43
44 void 
45 viterbi_butterfly2(unsigned char *symbols, int mettab[2][256], 
46                    struct viterbi_state *state0, struct viterbi_state *state1);
47
48 unsigned char
49 viterbi_get_output(struct viterbi_state *state, unsigned char *outbuf);