Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / gr-error-correcting-codes / src / lib / ecc_syms_to_metrics.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2006 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef INCLUDED_SYMS_TO_METRICS_H
24 #define INCLUDED_SYMS_TO_METRICS_H
25
26 #include <gr_block.h>
27 #include <gr_feval.h>
28 #include <vector>
29 #include <libecc/code_metrics.h>
30
31 class ecc_syms_to_metrics;
32 typedef boost::shared_ptr<ecc_syms_to_metrics> ecc_syms_to_metrics_sptr;
33
34 ecc_syms_to_metrics_sptr ecc_make_syms_to_metrics
35 (gr_feval_ff* pdf_fcn_0_bit,
36  gr_feval_ff* pdf_fcn_1_bit,
37  int n_samples,
38  float min_sample,
39  float max_sample,
40  int sample_precision);
41
42 /*!
43  * \brief Convert the input stream(s) of soft (float) symbols to
44  * log-probability metrics of user-specified precision; output is 2
45  * streams per input stream, each stream consisting of the metric for
46  * receiving a 0-bit and 1-bit, respectively, with the lower-numbered
47  * stream being the 0-bit.
48  *
49  * input: stream(s) of float; output: stream(s) of metrics
50  */
51
52 class ecc_syms_to_metrics : public gr_block
53 {
54 protected:
55   friend ecc_syms_to_metrics_sptr
56   ecc_make_syms_to_metrics (gr_feval_ff* pdf_fcn_0_bit,
57                             gr_feval_ff* pdf_fcn_1_bit,
58                             int n_samples,
59                             float min_sample,
60                             float max_sample,
61                             int sample_precision);
62
63 /*
64  * ecc_syms_to_metrics: Convert the input soft (float) symbols into
65  *     log-probabilities (metrics) for use in the convolutional
66  *     decoder.  Samples the provided PDF function in 'n_samples'
67  *     places from 'min_sample' to 'max_sample', takes the log of that
68  *     value, then converts the result into a given precision and
69  *     stores all results in a "handy dandy" lookup table for much
70  *     faster processing.
71  *
72  * pdf_fcn_0_bit: point to a probability distribution function which
73  *     takes a float and returns a float, for the 0-bit probabilities.
74  *
75  * pdf_fcn_1_bit: point to a probability distribution function which
76  *     takes a float and returns a float, for the 1-bit probabilities.
77  *
78  * n_samples: the number of samples between min_sample and max_sample
79  *     to store in the lookup table.  Must be at least 2, but
80  *     otherwise is limited only by the amount of available memory;
81  *     generally, 65536 (1 << 16) is plenty of samples.
82  *
83  * min_sample: the minimum value below which any incoming value is
84  *     "rounded" up.
85  *
86  * max_sample: the maximum value above which any incoming value is
87  *     "rounded" down.
88  *
89  * sample_precision: the precision with which to sample the returned
90  *     value of the PDF function.
91  *  +  Cannot be < 0 or > 32.
92  *  +  "soft float" == 0
93  *  + otherwise, convert to an integer of the given value
94  *
95  * in "work", finds the (linearly) closest sample value for the given
96  *     input and outputs the metric for a 0-bit input on the first
97  *     stream and a 1-bit input on the second stream.
98  *
99  */
100
101   ecc_syms_to_metrics (gr_feval_ff* pdf_fcn_0_bit,
102                        gr_feval_ff* pdf_fcn_1_bit,
103                        int n_samples,
104                        float min_sample,
105                        float max_sample,
106                        int sample_precision);
107
108   size_t d_out_item_size_bytes;
109   code_metrics_table<float>* d_code_metrics_table;
110
111 public:
112   ~ecc_syms_to_metrics() {delete d_code_metrics_table;};
113
114   bool check_topology (int ninputs, int noutputs);
115
116   void forecast (int noutput_items, gr_vector_int &ninput_items_required);
117
118   int general_work (int noutput_items,
119                     gr_vector_int &ninput_items,
120                     gr_vector_const_void_star &input_items,
121                     gr_vector_void_star &output_items);
122 };
123
124 #endif /* INCLUDED_SYMS_TO_METRICS_H */