File indexing completed on 2024-05-12 15:49:08
0001 /* 0002 SPDX-FileCopyrightText: 2017 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef PRISON_REEDSOLOMON_P_H 0008 #define PRISON_REEDSOLOMON_P_H 0009 0010 #include <memory> 0011 0012 namespace Prison 0013 { 0014 class BitVector; 0015 0016 /** Reed Solomon checksum generator. */ 0017 class ReedSolomon 0018 { 0019 public: 0020 enum GF { 0021 GF16 = 0x13, 0022 GF64 = 0x43, 0023 GF256 = 0x12d, 0024 GF1024 = 0x409, 0025 GF4096 = 0x1069, 0026 }; 0027 0028 /** Initialize a Reed Solomon encoder with the Galois Field 0029 * described by the bit pattern of @p polynom, for generating 0030 * @p symbolCount error correction symbols. 0031 */ 0032 explicit ReedSolomon(int polynom, int symbolCount); 0033 ReedSolomon(const ReedSolomon &) = delete; 0034 ~ReedSolomon(); 0035 0036 /** Encode the content of @p input and return the resulting 0037 * code words. 0038 */ 0039 BitVector encode(const BitVector &input) const; 0040 0041 private: 0042 std::unique_ptr<int[]> m_logTable; 0043 std::unique_ptr<int[]> m_antiLogTable; 0044 std::unique_ptr<int[]> m_polynom; 0045 int m_symCount = 0; 0046 int m_symSize = 0; 0047 }; 0048 0049 } 0050 0051 #endif // PRISON_REEDSOLOMON_P_H