Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rs16.hpp « unrar « thirdparty « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b67a7ca86ec5bc111b897aa7f5bfc28c44eca625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _RAR_RS16_
#define _RAR_RS16_

class RSCoder16
{
  private:
    static const uint gfSize=65535;   // Galois field size.
    void gfInit();                    // Galois field inititalization.
    inline uint gfAdd(uint a,uint b); // Addition in Galois field. 
    inline uint gfMul(uint a,uint b); // Multiplication in Galois field. 
    inline uint gfInv(uint a);        // Inverse element in Galois field.
    uint *gfExp;                      // Galois field exponents.
    uint *gfLog;                      // Galois field logarithms.

    void MakeEncoderMatrix();
    void MakeDecoderMatrix();
    void InvertDecoderMatrix();

#ifdef USE_SSE
    bool SSE_UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
#endif

    bool Decoding;    // If we are decoding or encoding data.
    uint ND;          // Number of data units.
    uint NR;          // Number of Reed-Solomon code units.
    uint NE;          // Number of erasures.
    bool *ValidFlags; // Validity flags for data and ECC units.
    uint *MX;         // Cauchy based coding or decoding matrix.

    uint *DataLog; // Buffer to store data logarithms for UpdateECC.
    size_t DataLogSize;

  public:
    RSCoder16();
    ~RSCoder16();

    bool Init(uint DataCount, uint RecCount, bool *ValidityFlags);
#if 0 // We use only UpdateECC now.
    void Process(const uint *Data, uint *Out);
#endif
    void UpdateECC(uint DataNum, uint ECCNum, const byte *Data, byte *ECC, size_t BlockSize);
};

#endif