rs16.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _RAR_RS16_
  2. #define _RAR_RS16_
  3. class RSCoder16
  4. {
  5. private:
  6. static const uint gfSize=65535; // Galois field size.
  7. void gfInit(); // Galois field inititalization.
  8. inline uint gfAdd(uint a,uint b); // Addition in Galois field.
  9. inline uint gfMul(uint a,uint b); // Multiplication in Galois field.
  10. inline uint gfInv(uint a); // Inverse element in Galois field.
  11. uint *gfExp; // Galois field exponents.
  12. uint *gfLog; // Galois field logarithms.
  13. void MakeEncoderMatrix();
  14. void MakeDecoderMatrix();
  15. void InvertDecoderMatrix();
  16. #ifdef USE_SSE
  17. bool SSE_UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
  18. #endif
  19. bool Decoding; // If we are decoding or encoding data.
  20. uint ND; // Number of data units.
  21. uint NR; // Number of Reed-Solomon code units.
  22. uint NE; // Number of erasures.
  23. bool *ValidFlags; // Validity flags for data and ECC units.
  24. uint *MX; // Cauchy based coding or decoding matrix.
  25. uint *DataLog; // Buffer to store data logarithms for UpdateECC.
  26. size_t DataLogSize;
  27. public:
  28. RSCoder16();
  29. ~RSCoder16();
  30. bool Init(uint DataCount, uint RecCount, bool *ValidityFlags);
  31. #if 0 // We use only UpdateECC now.
  32. void Process(const uint *Data, uint *Out);
  33. #endif
  34. void UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
  35. };
  36. #endif