BCH.h
Go to the documentation of this file.
1 /* ========================================================================
2 * PROJECT: ARToolKitPlus
3 * ========================================================================
4 * This work is based on the original ARToolKit developed by
5 * Hirokazu Kato
6 * Mark Billinghurst
7 * HITLab, University of Washington, Seattle
8 * http://www.hitl.washington.edu/artoolkit/
9 *
10 * Copyright of the derived and new portions of this work
11 * (C) 2006 Graz University of Technology
12 *
13 * This framework is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This framework is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this framework; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 * For further information please contact
28 * Dieter Schmalstieg
29 * <schmalstieg@icg.tu-graz.ac.at>
30 * Graz University of Technology,
31 * Institut for Computer Graphics and Vision,
32 * Inffeldgasse 16a, 8010 Graz, Austria.
33 * ========================================================================
34 ** @author Thomas Pintaric
35 *
36 * $Id: BCH.h 162 2006-04-19 21:28:10Z grabner $
37 * @file
38 * ======================================================================== */
39 
40 
41 #ifndef __BCH_CODE__H__
42 #define __BCH_CODE__H__
43 
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <vector>
47 
48 
49 namespace ARToolKitPlus {
50 
51 
52 // --------------------------------------------------------
53 // WARNING: It is *NOT SAFE* to alter the values below!
54 
55  #define BCH_DEFAULT_M 6
56  #define BCH_DEFAULT_LENGTH 36
57  #define BCH_DEFAULT_T 4
58  #define BCH_DEFAULT_K 12
59 
60  #define BCH_MAX_M 6
61  #define BCH_MAX_P 7 // MAX_M+1
62  #define BCH_MAX_LUT 64 // 2^MAX_M
63  #define BCH_MAX_SQ 8 // SQRT(MAX_LUT) -- (?)
64 // -------------------------------------------------------
65 
66 // we only use unsigned __int64 under windows.
67 // have to use unsigned long long othersie...
68 #if defined(_MSC_VER) || defined(_WIN32_WCE)
69 typedef unsigned __int64 _64bits;
70 #else
71 typedef unsigned long long _64bits;
72 #endif
73 
74 
75 static bool _isBitSet(_64bits bn, int which_bit);
76 static void _setBit(_64bits &bn, int which_bit);
77 /*
78 static void _clearBit(_64bits &bn, int which_bit);
79 static void _copyBit(_64bits &dest_n, const int dest_bit, const _64bits src_n, const int src_bit);
80 static int _countOnes(const _64bits src_n);
81 */
82 
83 static int* toBitPattern(int b[], _64bits n, int n_bits);
84 static _64bits fromBitPattern(int b[], int n_bits);
85 
86 // static void printBitPattern(_64bits n, int n_bits);
87 
88 
89 class BCH
90 // this class implements a (36, 12, 9) binary BCH encoder/decoder
91 {
92  public:
93  BCH();
94 
95  void encode(int encoded_bits[BCH_DEFAULT_LENGTH], const _64bits orig_n);
96  bool decode(int &err_n, _64bits &orig_n, const int encoded_bits[BCH_DEFAULT_LENGTH]);
97 
98  void encode(_64bits &encoded_n, const _64bits orig_n);
99  bool decode(int &err_n, _64bits &orig_n, const _64bits encoded_n);
100 
101 
102  protected:
103  BCH(int _m, int _length, int _t);
104  void initialize(int _m, int _length, int _t);
105  void generate_gf();
106  bool gen_poly(int _t);
107  void encode_bch(int *bb, const int *data); // int bb[length - k], data[k]
108  int decode_bch(int *recd);
109 
110  int t;
111  int m, n, length, k, d;
112 
113  std::vector<int> p;
114  std::vector<int> alpha_to;
115  std::vector<int> index_of;
116  std::vector<int> g;
117 
118  std::vector<std::vector<int> > _elp;
119  std::vector<int> _d;
120  std::vector<int> _l;
121  std::vector<int> _u_lu;
122  std::vector<int> _s;
123  std::vector<int> _root;
124  std::vector<int> _loc;
125  std::vector<int> _reg;
126 };
127 
128 
129 } // namespace ARToolKitPlus
130 
131 
132 #endif // __BCH_CODE__H__
std::vector< int > _reg
Definition: BCH.h:125
#define BCH_DEFAULT_LENGTH
Definition: BCH.h:56
unsigned long long _64bits
Definition: BCH.h:71
std::vector< int > alpha_to
Definition: BCH.h:114
bool gen_poly(int _t)
std::vector< int > _loc
Definition: BCH.h:124
std::vector< int > p
Definition: BCH.h:113
int decode_bch(int *recd)
bool decode(int &err_n, _64bits &orig_n, const int encoded_bits[BCH_DEFAULT_LENGTH])
std::vector< std::vector< int > > _elp
Definition: BCH.h:118
This file should only be compiled when using ARToolKitPlus as a DLL.
Definition: ar.h:60
std::vector< int > _l
Definition: BCH.h:120
std::vector< int > index_of
Definition: BCH.h:115
std::vector< int > _root
Definition: BCH.h:123
static bool _isBitSet(_64bits bn, int which_bit)
std::vector< int > g
Definition: BCH.h:116
std::vector< int > _u_lu
Definition: BCH.h:121
void initialize(int _m, int _length, int _t)
std::vector< int > _s
Definition: BCH.h:122
static void _setBit(_64bits &bn, int which_bit)
std::vector< int > _d
Definition: BCH.h:119
void encode_bch(int *bb, const int *data)
static _64bits fromBitPattern(int b[], int n_bits)
void encode(int encoded_bits[BCH_DEFAULT_LENGTH], const _64bits orig_n)
static int * toBitPattern(int b[], _64bits n, int n_bits)


tuw_artoolkitplus
Author(s): Markus Bader
autogenerated on Sun Sep 4 2016 03:24:33