BCH.h
Go to the documentation of this file.
00001 /* ========================================================================
00002 * PROJECT: ARToolKitPlus
00003 * ========================================================================
00004 * This work is based on the original ARToolKit developed by
00005 *   Hirokazu Kato
00006 *   Mark Billinghurst
00007 *   HITLab, University of Washington, Seattle
00008 * http://www.hitl.washington.edu/artoolkit/
00009 *
00010 * Copyright of the derived and new portions of this work
00011 *     (C) 2006 Graz University of Technology
00012 *
00013 * This framework is free software; you can redistribute it and/or modify
00014 * it under the terms of the GNU General Public License as published by
00015 * the Free Software Foundation; either version 2 of the License, or
00016 * (at your option) any later version.
00017 *
00018 * This framework is distributed in the hope that it will be useful,
00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021 * GNU General Public License for more details.
00022 *
00023 * You should have received a copy of the GNU General Public License
00024 * along with this framework; if not, write to the Free Software
00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 *
00027 * For further information please contact 
00028 *   Dieter Schmalstieg
00029 *   <schmalstieg@icg.tu-graz.ac.at>
00030 *   Graz University of Technology, 
00031 *   Institut for Computer Graphics and Vision,
00032 *   Inffeldgasse 16a, 8010 Graz, Austria.
00033 * ========================================================================
00034 ** @author   Thomas Pintaric
00035 *
00036 * $Id: BCH.h 162 2006-04-19 21:28:10Z grabner $
00037 * @file
00038 * ======================================================================== */
00039 
00040 
00041 #ifndef __BCH_CODE__H__
00042 #define __BCH_CODE__H__
00043 
00044 #include <stdio.h>
00045 #include <stdlib.h>
00046 #include <vector>
00047 
00048 
00049 namespace ARToolKitPlus {
00050 
00051 
00052 // --------------------------------------------------------
00053 // WARNING: It is *NOT SAFE* to alter the values below!
00054 
00055         #define BCH_DEFAULT_M       6
00056         #define BCH_DEFAULT_LENGTH 36
00057         #define BCH_DEFAULT_T       4
00058         #define BCH_DEFAULT_K      12
00059 
00060         #define BCH_MAX_M    6
00061         #define BCH_MAX_P    7  // MAX_M+1
00062         #define BCH_MAX_LUT 64  // 2^MAX_M
00063         #define BCH_MAX_SQ   8  // SQRT(MAX_LUT) -- (?)
00064 // -------------------------------------------------------
00065 
00066 // we only use unsigned __int64 under windows.
00067 // have to use unsigned long long othersie...
00068 #if defined(_MSC_VER) || defined(_WIN32_WCE)
00069 typedef unsigned __int64 _64bits;
00070 #else
00071 typedef unsigned long long _64bits;
00072 #endif
00073 
00074 
00075 static bool _isBitSet(_64bits bn, int which_bit);
00076 static void _setBit(_64bits &bn, int which_bit);
00077 /*
00078 static void _clearBit(_64bits &bn, int which_bit);
00079 static void _copyBit(_64bits &dest_n, const int dest_bit, const _64bits src_n, const int src_bit);
00080 static int _countOnes(const _64bits src_n);
00081 */
00082 
00083 static int* toBitPattern(int b[], _64bits n, int n_bits);
00084 static _64bits fromBitPattern(int b[], int n_bits);
00085 
00086 // static void printBitPattern(_64bits n, int n_bits);
00087 
00088 
00089 class BCH
00090 // this class implements a (36, 12, 9) binary BCH encoder/decoder
00091 {
00092         public:
00093                 BCH();
00094 
00095                 void encode(int encoded_bits[BCH_DEFAULT_LENGTH], const _64bits orig_n);
00096                 bool decode(int &err_n, _64bits &orig_n, const int encoded_bits[BCH_DEFAULT_LENGTH]);
00097 
00098                 void encode(_64bits &encoded_n, const _64bits orig_n);
00099                 bool decode(int &err_n, _64bits &orig_n,    const _64bits encoded_n);
00100 
00101 
00102         protected:
00103                 BCH(int _m, int _length, int _t);
00104                 void initialize(int _m, int _length, int _t);
00105                 void generate_gf();
00106                 bool gen_poly(int _t);
00107                 void encode_bch(int *bb, const int *data); // int bb[length - k], data[k]
00108                 int decode_bch(int *recd);
00109 
00110                 int t;
00111                 int             m, n, length, k, d;
00112                 
00113                 std::vector<int> p;
00114                 std::vector<int> alpha_to;
00115                 std::vector<int> index_of;
00116                 std::vector<int> g;
00117 
00118                 std::vector<std::vector<int> > _elp;
00119                 std::vector<int> _d;
00120                 std::vector<int> _l;
00121                 std::vector<int> _u_lu;
00122                 std::vector<int> _s;
00123                 std::vector<int> _root;
00124                 std::vector<int> _loc;
00125                 std::vector<int> _reg;
00126 };
00127 
00128 
00129 }  // namespace ARToolKitPlus
00130 
00131 
00132 #endif // __BCH_CODE__H__


v4r_artoolkitplus
Author(s): Markus Bader
autogenerated on Wed Aug 26 2015 16:41:52