3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef INCLUDED_CODE_METRIC_H
24 #define INCLUDED_CODE_METRIC_H
26 #include <sys/types.h>
32 typedef float pdf_fcn_io_t;
35 virtual ~code_metrics () {};
37 // lookup() returns either a float, or a sign-extended
38 // 'sample_precision'-bit integer value.
40 virtual void lookup (pdf_fcn_io_t sym,
44 virtual void convert (size_t n_syms,
50 class code_metric_ff : public code_metrics
52 typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t);
53 typedef float metric_t, *metric_ptr_t;
57 pdf_fcn_io_t d_max_sample, d_min_sample, d_delta;
58 pdf_fcn_t d_pdf_fcn_0_bit, d_pdf_fcn_1_bit;
59 std::vector<metric_t> d_metric_table_0_bit;
60 std::vector<metric_t> d_metric_table_1_bit;
63 code_metric_ff (pdf_fcn_t pdf_fcn_0_bit,
64 pdf_fcn_t pdf_fcn_1_bit,
66 pdf_fcn_io_t min_sample,
67 pdf_fcn_io_t max_sample);
68 ~code_metric_ff () {};
70 void lookup (pdf_fcn_io_t sym, void* bit_0, void* bit_1);
71 void convert (size_t n_syms, pdf_fcn_io_t* sym, void* bit_0, void* bit_1);
74 class code_metric_fl : public code_metrics
76 typedef float pdf_fcn_io_t;
77 typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t);
78 typedef long metric_t, *metric_ptr_t;
81 char d_sample_precision;
82 size_t d_n_samples, d_sample_mask;
83 pdf_fcn_io_t d_max_sample, d_min_sample, d_delta;
84 pdf_fcn_t d_pdf_fcn_0_bit, d_pdf_fcn_1_bit;
85 std::vector<metric_t> d_metric_table_0_bit;
86 std::vector<metric_t> d_metric_table_1_bit;
89 code_metric_fl (pdf_fcn_t pdf_fcn_0_bit,
90 pdf_fcn_t pdf_fcn_1_bit,
92 pdf_fcn_io_t min_sample,
93 pdf_fcn_io_t max_sample,
94 int sample_precision = 32);
95 ~code_metric_fl () {};
97 void lookup (pdf_fcn_io_t sym, void* bit_0, void* bit_1);
98 void convert (size_t n_syms, pdf_fcn_io_t* sym, void* bit_0, void* bit_1);
101 class code_metric_fs : public code_metrics
103 typedef float pdf_fcn_io_t;
104 typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t);
105 typedef short metric_t, *metric_ptr_t;
108 char d_sample_precision;
109 size_t d_n_samples, d_sample_mask;
110 pdf_fcn_io_t d_max_sample, d_min_sample, d_delta;
111 pdf_fcn_t d_pdf_fcn_0_bit, d_pdf_fcn_1_bit;
112 std::vector<metric_t> d_metric_table_0_bit;
113 std::vector<metric_t> d_metric_table_1_bit;
116 code_metric_fs (pdf_fcn_t pdf_fcn_0_bit,
117 pdf_fcn_t pdf_fcn_1_bit,
119 pdf_fcn_io_t min_sample,
120 pdf_fcn_io_t max_sample,
121 int sample_precision = 16);
122 ~code_metric_fs () {};
124 void lookup (pdf_fcn_io_t sym, void* bit_0, void* bit_1);
125 void convert (size_t n_syms, pdf_fcn_io_t* sym, void* bit_0, void* bit_1);
128 class code_metric_fb : public code_metrics
130 typedef float pdf_fcn_io_t;
131 typedef pdf_fcn_io_t (*pdf_fcn_t) (pdf_fcn_io_t);
132 typedef char metric_t, *metric_ptr_t;
135 char d_sample_precision;
136 size_t d_n_samples, d_sample_mask;
137 pdf_fcn_io_t d_max_sample, d_min_sample, d_delta;
138 pdf_fcn_t d_pdf_fcn_0_bit, d_pdf_fcn_1_bit;
139 std::vector<metric_t> d_metric_table_0_bit;
140 std::vector<metric_t> d_metric_table_1_bit;
143 code_metric_fb (pdf_fcn_t pdf_fcn_0_bit,
144 pdf_fcn_t pdf_fcn_1_bit,
146 pdf_fcn_io_t min_sample,
147 pdf_fcn_io_t max_sample,
148 int sample_precision = 8);
149 ~code_metric_fb () {};
151 void lookup (pdf_fcn_io_t sym, void* bit_0, void* bit_1);
152 void convert (size_t n_syms, pdf_fcn_io_t* sym, void* bit_0, void* bit_1);
155 #endif /* INCLUDED_CODE_METRIC_H */