Skip to content

Commit

Permalink
Merge pull request #8 from j123b567/feature/fix-typos
Browse files Browse the repository at this point in the history
Fix typos
  • Loading branch information
mersinvald authored Mar 8, 2022
2 parents 5d80f75 + f3938f1 commit edc9b1c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Reed Solomon BCH encoder and decoder library
## Overview

This RS implementation was designed for embedded purposes, so all the memory allocations performed on the stack.<br>
If somebody want to reimplement memory management with heap usege, pull requests are welcome
If somebody wants to reimplement memory management with heap usage, pull requests are welcome

## Getting the source

Expand Down
16 changes: 8 additions & 8 deletions include/gf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,37 @@ const uint8_t log[256] = {


/* ################################
* # OPERATIONS OVER GALUA FIELDS #
* # OPERATIONS OVER GALOIS FIELDS #
* ################################ */

/* @brief Addition in Galua Fields
/* @brief Addition in Galois Fields
* @param x - left operand
* @param y - right operand
* @return x + y */
inline uint8_t add(uint8_t x, uint8_t y) {
return x^y;
}

/* ##### GF substraction ###### */
/* @brief Substraction in Galua Fields
/* ##### GF subtraction ###### */
/* @brief Subtraction in Galois Fields
* @param x - left operand
* @param y - right operand
* @return x - y */
inline uint8_t sub(uint8_t x, uint8_t y) {
return x^y;
}

/* @brief Multiplication in Galua Fields
/* @brief Multiplication in Galois Fields
* @param x - left operand
* @param y - rifht operand
* @param y - right operand
* @return x * y */
inline uint8_t mul(uint16_t x, uint16_t y){
if (x == 0 || y == 0)
return 0;
return exp[log[x] + log[y]];
}

/* @brief Division in Galua Fields
/* @brief Division in Galois Fields
* @param x - dividend
* @param y - divisor
* @return x / y */
Expand All @@ -132,7 +132,7 @@ inline uint8_t pow(uint8_t x, intmax_t power){
return exp[i];
}

/* @brief Inversion in Galua Fields
/* @brief Inversion in Galois Fields
* @param x - number
* @return inversion of x */
inline uint8_t inverse(uint8_t x){
Expand Down
22 changes: 11 additions & 11 deletions include/rs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
namespace RS {

#define MSG_CNT 3 // message-length polynomials count
#define POLY_CNT 14 // (ecc_length*2)-length polynomialc count
#define POLY_CNT 14 // (ecc_length*2)-length polynomials count

template <const uint8_t msg_length, // Message length without correction code
const uint8_t ecc_length> // Length of correction code
Expand Down Expand Up @@ -55,12 +55,12 @@ class ReedSolomon {
}

~ReedSolomon() {
// Dummy destructor, gcc-generated one crashes programm
// Dummy destructor, gcc-generated one crashes program
memory = NULL;
}

/* @brief Message block encoding
* @param *src - input message buffer (msg_lenth size)
* @param *src - input message buffer (msg_length size)
* @param *dst - output buffer for ecc (ecc_length size at least) */
void EncodeBlock(const void* src, void* dst) {
assert(msg_length + ecc_length < 256);
Expand All @@ -80,7 +80,7 @@ class ReedSolomon {
Poly *msg_out = &polynoms[ID_MSG_OUT];
Poly *gen = &polynoms[ID_GENERATOR];

// Weird shit, but without reseting msg_in it simply doesn't work
// Weird shit, but without resetting msg_in it simply doesn't work
msg_in->Reset();
msg_out->Reset();

Expand Down Expand Up @@ -114,7 +114,7 @@ class ReedSolomon {
}

/* @brief Message encoding
* @param *src - input message buffer (msg_lenth size)
* @param *src - input message buffer (msg_length size)
* @param *dst - output buffer (msg_length + ecc_length size at least) */
void Encode(const void* src, void* dst) {
uint8_t* dst_ptr = (uint8_t*) dst;
Expand All @@ -132,7 +132,7 @@ class ReedSolomon {
* @param *msg_out - output buffer (msg_length size at least)
* @param *erase_pos - known errors positions
* @param erase_count - count of known errors
* @return RESULT_SUCCESS if successfull, error code otherwise */
* @return RESULT_SUCCESS if successful, error code otherwise */
int DecodeBlock(const void* src, const void* ecc, void* dst, uint8_t* erase_pos = NULL, size_t erase_count = 0) {
assert(msg_length + ecc_length < 256);

Expand Down Expand Up @@ -202,11 +202,11 @@ class ReedSolomon {
reloc->at(j) = eloc->at(i);
}

// Fing errors
// Find errors
ok = FindErrors(reloc, src_len);
if(!ok) return 1;

// Error happened while finding errors (so helpfull :D)
// Error happened while finding errors (so helpful :D)
if(err->length == 0) return 1;

/* Adding found errors with known */
Expand All @@ -218,7 +218,7 @@ class ReedSolomon {
CorrectErrata(synd, epos, msg_in);

return_corrected_msg:
// Wrighting corrected message to output buffer
// Writing corrected message to output buffer
msg_out->length = dst_len;
memcpy(dst_ptr, msg_out->ptr(), msg_out->length * sizeof(uint8_t));
return 0;
Expand All @@ -229,7 +229,7 @@ class ReedSolomon {
* @param *msg_out - output buffer (msg_length size at least)
* @param *erase_pos - known errors positions
* @param erase_count - count of known errors
* @return RESULT_SUCCESS if successfull, error code otherwise */
* @return RESULT_SUCCESS if successful, error code otherwise */
int Decode(const void* src, void* dst, uint8_t* erase_pos = NULL, size_t erase_count = 0) {
const uint8_t *src_ptr = (const uint8_t*) src;
const uint8_t *ecc_ptr = src_ptr + msg_length;
Expand Down Expand Up @@ -472,7 +472,7 @@ class ReedSolomon {

uint32_t errs = err_loc->length - shift - 1;
if(((errs - erase_count) * 2 + erase_count) > ecc_length){
return false; /* Error count is greater then we can fix! */
return false; /* Error count is greater than we can fix! */
}

memcpy(error_loc->ptr(), err_loc->ptr() + shift, (err_loc->length - shift) * sizeof(uint8_t));
Expand Down

0 comments on commit edc9b1c

Please sign in to comment.