rs.hpp 849 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _RAR_RS_
  2. #define _RAR_RS_
  3. #define MAXPAR 255 // Maximum parity data size.
  4. #define MAXPOL 512 // Maximum polynomial degree.
  5. class RSCoder
  6. {
  7. private:
  8. void gfInit();
  9. int gfMult(int a,int b);
  10. void pnInit();
  11. void pnMult(int *p1,int *p2,int *r);
  12. int gfExp[MAXPOL]; // Galois field exponents.
  13. int gfLog[MAXPAR+1]; // Galois field logarithms.
  14. int GXPol[MAXPOL*2]; // Generator polynomial g(x).
  15. int ErrorLocs[MAXPAR+1],ErrCount;
  16. int Dnm[MAXPAR+1];
  17. int ParSize; // Parity bytes size and so the number of recovery volumes.
  18. int ELPol[MAXPOL]; // Error locator polynomial.
  19. bool FirstBlockDone;
  20. public:
  21. RSCoder(int ParSize);
  22. void Encode(byte *Data,int DataSize,byte *DestData);
  23. bool Decode(byte *Data,int DataSize,int *EraLoc,int EraSize);
  24. };
  25. #endif