00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00039 #ifndef BLOCKENCODER_H
00040 #define BLOCKENCODER_H
00041 
00042 #include "encoder.h"
00043 
00044 
00045 namespace simthlib{
00046 
00050 class BlockEncoder : public Encoder
00051 {
00052 
00053   public:
00054     BlockEncoder(int deviceID, simth::DeviceSystemIntf* system,
00055          const simth::PropertyList& pl);
00056     virtual ~BlockEncoder() = 0;
00057 
00058 };
00059 
00060   
00061 
00064 class ReedSol_init
00065 {
00066   private:
00067   public:
00068     ReedSol_init();
00069     virtual ~ReedSol_init();
00070 
00071     static const int Q=256;
00072     static const int R=60;
00073 
00074     int *gp,(*mlga)[Q],(*mgp)[ReedSol_init::Q];
00075     int *g,*lgt,*lga,*qua,*inv;
00076     void init(int ,int ,int );
00077     int mult(int, int);
00078   private:
00079     void gf(int);
00080     void mcf(int,int,int  (*mgp)[ReedSol_init::Q]);
00081     void genpol(int, int, int);
00082 
00083 
00084 };
00085 
00088 class ReedSolomonEncoder : public BlockEncoder
00089 {
00090 
00091 
00092   public:
00093     ReedSolomonEncoder(int deviceID, simth::DeviceSystemIntf* system,
00094                const simth::PropertyList& pl,
00095                int bitsPerSymbol, int numCheckSymbol ,int m0_, int input_Length);
00096     virtual ~ReedSolomonEncoder();
00097     virtual void Encode(const simth::BitSeq &bsin, simth::BitSeq* bsout) const;
00098     virtual void updateOutputLengths( );
00099     virtual void updateInputLengths();
00100 
00101     virtual int getDataLength(int codedLength) const;
00102     virtual int getCodeLength(int rawLength) const;
00103 
00104   private:
00105     void invariante() const;
00106     void coder(int*, int, int) const;
00107     size_t inp_length;
00108     size_t out_length;
00109     int q;
00110     int inf_code_length;
00111     int code_length;
00112     int *gp,(*mgp)[ReedSol_init::Q];
00113     int ns;
00114     mutable int temp[ReedSol_init::Q];
00115     int bits_p_sym, r, m0;
00116 };
00117 
00118 inline void ReedSolomonEncoder::invariante() const
00119 {
00120   if(DEBUG) {
00121     if(outputLength(0) != out_length) {
00122       throw std::runtime_error("inline ReedSolomonEncoder:invariante() : error 1");
00123     }
00124   }
00125 }
00126 
00127 
00128 }
00129 
00130 #endif