diff --git a/bitman.hh b/bitman.hh index 074841b..ad5335d 100644 --- a/bitman.hh +++ b/bitman.hh @@ -29,12 +29,12 @@ void set_le_bit(uint8_t *buf, int pos, bool val) buf[pos/8] = (~(1<<(pos%8))&buf[pos/8])|(val<<(pos%8)); } -bool get_be_bit(uint8_t *buf, int pos) +bool get_be_bit(const uint8_t *buf, int pos) { return (buf[pos/8]>>(7-pos%8))&1; } -bool get_le_bit(uint8_t *buf, int pos) +bool get_le_bit(const uint8_t *buf, int pos) { return (buf[pos/8]>>(pos%8))&1; } diff --git a/bose_chaudhuri_hocquenghem_decoder.hh b/bose_chaudhuri_hocquenghem_decoder.hh index ece25b6..3e11185 100644 --- a/bose_chaudhuri_hocquenghem_decoder.hh +++ b/bose_chaudhuri_hocquenghem_decoder.hh @@ -23,7 +23,7 @@ public: static const int N = GF::N, K = MSG, NP = N - K; private: ReedSolomonErrorCorrection algorithm; - void update_syndromes(uint8_t *poly, ValueType *syndromes, int begin, int end) + void update_syndromes(const uint8_t *poly, ValueType *syndromes, int begin, int end) { for (int j = begin; j < end; ++j) { ValueType coeff(get_be_bit(poly, j)); @@ -35,7 +35,7 @@ private: } } public: - int compute_syndromes(uint8_t *data, uint8_t *parity, ValueType *syndromes, int data_len = K) + int compute_syndromes(const uint8_t *data, const uint8_t *parity, ValueType *syndromes, int data_len = K) { assert(0 < data_len && data_len <= K); // $syndromes_i = code(pe^{FCR+i})$ @@ -49,7 +49,7 @@ public: nonzero += !!syndromes[i]; return nonzero; } - int compute_syndromes(uint8_t *data, uint8_t *parity, value_type *syndromes, int data_len = K) + int compute_syndromes(const uint8_t *data, const uint8_t *parity, value_type *syndromes, int data_len = K) { return compute_syndromes(data, parity, reinterpret_cast(syndromes), data_len); } @@ -110,7 +110,7 @@ public: static const int N = GF::N, K = MSG, NP = N - K; private: ReedSolomonErrorCorrection algorithm; - void update_syndromes(ValueType *poly, ValueType *syndromes, int begin, int end) + void update_syndromes(const ValueType *poly, ValueType *syndromes, int begin, int end) { for (int j = begin; j < end; ++j) { ValueType coeff(poly[j]); @@ -122,7 +122,7 @@ private: } } public: - int compute_syndromes(ValueType *data, ValueType *parity, ValueType *syndromes, int data_len = K) + int compute_syndromes(const ValueType *data, const ValueType *parity, ValueType *syndromes, int data_len = K) { assert(0 < data_len && data_len <= K); // $syndromes_i = code(pe^{FCR+i})$ diff --git a/bose_chaudhuri_hocquenghem_encoder.hh b/bose_chaudhuri_hocquenghem_encoder.hh index 2424066..d561e7b 100644 --- a/bose_chaudhuri_hocquenghem_encoder.hh +++ b/bose_chaudhuri_hocquenghem_encoder.hh @@ -59,7 +59,7 @@ public: set_be_bit(generator, i, get_be_bit(generator, i+1)); set_be_bit(generator, NP, 0); } - void operator()(uint8_t *data, uint8_t *parity, int data_len = K) + void operator()(const uint8_t *data, uint8_t *parity, int data_len = K) { assert(0 < data_len && data_len <= K); // $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$ @@ -129,7 +129,7 @@ public: std::cerr << std::endl; } } - void operator()(ValueType *data, ValueType *parity, int data_len = K) + void operator()(const ValueType *data, ValueType *parity, int data_len = K) { assert(0 < data_len && data_len <= K); // $code = data * x^{NP} + (data * x^{NP}) \mod{generator}$ diff --git a/ldpc_encoder.hh b/ldpc_encoder.hh index 1de86e9..73e549d 100644 --- a/ldpc_encoder.hh +++ b/ldpc_encoder.hh @@ -55,7 +55,7 @@ public: } } } - void operator()(int8_t *data, int8_t *parity) + void operator()(const int8_t *data, int8_t *parity) { int8_t tmp = 1; for (int j = 0; j < M; ++j) { diff --git a/reed_solomon_decoder.hh b/reed_solomon_decoder.hh index d469a28..aa99e43 100644 --- a/reed_solomon_decoder.hh +++ b/reed_solomon_decoder.hh @@ -22,7 +22,7 @@ public: static const int N = GF::N, K = N - NR, NP = NR; private: ReedSolomonErrorCorrection algorithm; - void update_syndromes(ValueType *poly, ValueType *syndromes, int begin, int end) + void update_syndromes(const ValueType *poly, ValueType *syndromes, int begin, int end) { for (int j = begin; j < end; ++j) { ValueType coeff(poly[j]); @@ -34,7 +34,7 @@ private: } } public: - int compute_syndromes(ValueType *data, ValueType *parity, ValueType *syndromes, int data_len = K) + int compute_syndromes(const ValueType *data, const ValueType *parity, ValueType *syndromes, int data_len = K) { assert(0 < data_len && data_len <= K); // $syndromes_i = code(pe^{FCR+i})$ @@ -92,9 +92,9 @@ public: { return (*this)(reinterpret_cast(data), reinterpret_cast(parity), reinterpret_cast(erasures), erasures_count, data_len); } - int compute_syndromes(value_type *data, value_type *parity, value_type *syndromes, int data_len = K) + int compute_syndromes(const value_type *data, const value_type *parity, value_type *syndromes, int data_len = K) { - return compute_syndromes(reinterpret_cast(data), reinterpret_cast(parity), reinterpret_cast(syndromes), data_len); + return compute_syndromes(reinterpret_cast(data), reinterpret_cast(parity), reinterpret_cast(syndromes), data_len); } }; diff --git a/reed_solomon_encoder.hh b/reed_solomon_encoder.hh index 6de493d..3c813fa 100644 --- a/reed_solomon_encoder.hh +++ b/reed_solomon_encoder.hh @@ -51,7 +51,7 @@ public: for (int i = 0; i <= NR; ++i) generator[i] = index(tmp[i]); } - void operator()(ValueType *data, ValueType *parity, int data_len = K) + void operator()(const ValueType *data, ValueType *parity, int data_len = K) { assert(0 < data_len && data_len <= K); // $code = data * x^{NR} + (data * x^{NR}) \mod{generator}$ @@ -71,9 +71,9 @@ public: } } } - void operator()(value_type *data, value_type *parity, int data_len = K) + void operator()(const value_type *data, value_type *parity, int data_len = K) { - (*this)(reinterpret_cast(data), reinterpret_cast(parity), data_len); + (*this)(reinterpret_cast(data), reinterpret_cast(parity), data_len); } }; diff --git a/reed_solomon_error_correction.hh b/reed_solomon_error_correction.hh index 9283b28..cee462d 100644 --- a/reed_solomon_error_correction.hh +++ b/reed_solomon_error_correction.hh @@ -15,7 +15,7 @@ struct Chien { typedef typename GF::ValueType ValueType; typedef typename GF::IndexType IndexType; - static int search(ValueType *locator, int locator_degree, IndexType *locations) + static int search(const ValueType *locator, int locator_degree, IndexType *locations) { ValueType tmp[locator_degree+1]; for (int i = 0; i <= locator_degree; ++i) @@ -65,7 +65,7 @@ struct LocationFinder typedef typename GF::ValueType ValueType; typedef typename GF::IndexType IndexType; ArtinSchreier imap; - int operator()(ValueType *locator, int locator_degree, IndexType *locations) + int operator()(const ValueType *locator, int locator_degree, IndexType *locations) { if (locator_degree == 1) { locations[0] = (index(locator[0]) / index(locator[1])) / IndexType(1); @@ -91,7 +91,7 @@ struct Forney { typedef typename GF::ValueType ValueType; typedef typename GF::IndexType IndexType; - static int compute_evaluator(ValueType *syndromes, ValueType *locator, int locator_degree, ValueType *evaluator) + static int compute_evaluator(const ValueType *syndromes, const ValueType *locator, int locator_degree, ValueType *evaluator) { // $evaluator = (syndromes * locator) \bmod{x^{NR}}$ int tmp = std::min(locator_degree, NR-1); @@ -105,7 +105,7 @@ struct Forney } return degree; } - static void compute_magnitudes(ValueType *locator, IndexType *locations, int count, ValueType *evaluator, int evaluator_degree, ValueType *magnitudes) + static void compute_magnitudes(const ValueType *locator, const IndexType *locations, int count, const ValueType *evaluator, int evaluator_degree, ValueType *magnitudes) { // $magnitude = root^{FCR-1} * \frac{evaluator(root)}{locator'(root)}$ for (int i = 0; i < count; ++i) { @@ -134,7 +134,7 @@ struct Forney magnitudes[i] = value(magnitude); } } - static int algorithm(ValueType *syndromes, ValueType *locator, IndexType *locations, int count, ValueType *evaluator, ValueType *magnitudes) + static int algorithm(const ValueType *syndromes, const ValueType *locator, const IndexType *locations, int count, ValueType *evaluator, ValueType *magnitudes) { int evaluator_degree = compute_evaluator(syndromes, locator, count, evaluator); compute_magnitudes(locator, locations, count, evaluator, evaluator_degree, magnitudes); @@ -147,7 +147,7 @@ struct BerlekampMassey { typedef typename GF::ValueType ValueType; typedef typename GF::IndexType IndexType; - static int algorithm(ValueType *s, ValueType *C, int count = 0) + static int algorithm(const ValueType *s, ValueType *C, int count = 0) { ValueType B[NR+1]; for (int i = 0; i <= NR; ++i) @@ -189,7 +189,7 @@ struct ReedSolomonErrorCorrection typedef typename GF::ValueType ValueType; typedef typename GF::IndexType IndexType; RS::LocationFinder search; - int operator()(ValueType *syndromes, IndexType *locations, ValueType *magnitudes, IndexType *erasures = 0, int erasures_count = 0) + int operator()(const ValueType *syndromes, IndexType *locations, ValueType *magnitudes, const IndexType *erasures = 0, int erasures_count = 0) { assert(0 <= erasures_count && erasures_count <= NR); ValueType locator[NR+1];