Merge branch 'master' of github.com:catid/lhc_rs

This commit is contained in:
Christopher Taylor 2017-06-02 23:52:07 -07:00
commit 7c2be9f17b
7 changed files with 53 additions and 52 deletions

View File

@ -321,7 +321,8 @@ LEO_FORCE_INLINE unsigned LastNonzeroBit32(unsigned x)
return (unsigned)index;
#else
// Note: Ignoring return value of 0 because x != 0
return 31 - (unsigned)__builtin_clzl(x);
static_assert(sizeof(unsigned) == 4, "Assuming 32 bit unsigneds in LastNonzeroBit32");
return 31 - (unsigned)__builtin_clz(x);
#endif
}

View File

@ -936,7 +936,7 @@ static void FFTInitialize()
}
}
for (unsigned i = 0; i < kOrder; ++i)
for (unsigned i = 0; i < kModulus; ++i)
FFTSkew[i] = LogLUT[FFTSkew[i]];
// Precalculate FWHT(Log[i]):
@ -1019,7 +1019,7 @@ void ReedSolomonEncode(
unsigned original_count,
unsigned recovery_count,
unsigned m,
void* const * data,
const void* const * data,
void** work)
{
// work <- data
@ -1057,6 +1057,7 @@ void ReedSolomonEncode(
}
}
const unsigned last_count = original_count % m;
if (m >= original_count)
goto skip_body;
@ -1100,7 +1101,6 @@ void ReedSolomonEncode(
temp);
}
const unsigned last_count = original_count % m;
if (last_count != 0)
{
const unsigned i = original_count - last_count;
@ -1296,8 +1296,8 @@ void ReedSolomonDecode(
unsigned recovery_count,
unsigned m, // NextPow2(recovery_count)
unsigned n, // NextPow2(m + original_count) = work_count
void* const * const original, // original_count entries
void* const * const recovery, // recovery_count entries
const void* const * const original, // original_count entries
const void* const * const recovery, // recovery_count entries
void** work) // n entries
{
// Fill in error locations

View File

@ -67,7 +67,7 @@ static const unsigned kPolynomial = 0x1002D;
// Fast Walsh-Hadamard Transform (FWHT) (mod kModulus)
// Transform for a variable number of bits (up to kOrder)
void FWHT(ffe_t* data, const unsigned bits);
//void FWHT(ffe_t* data, const unsigned bits);
// Transform specialized for the finite field order
void FWHT(ffe_t data[kOrder]);
@ -118,7 +118,7 @@ void ReedSolomonEncode(
unsigned original_count,
unsigned recovery_count,
unsigned m, // = NextPow2(recovery_count) * 2 = work_count
void* const * const data,
const void* const * const data,
void** work); // Size of GetEncodeWorkCount()
@ -131,8 +131,8 @@ void ReedSolomonDecode(
unsigned recovery_count,
unsigned m, // = NextPow2(recovery_count)
unsigned n, // = NextPow2(m + original_count) = work_count
void* const * const original, // original_count entries
void* const * const recovery, // recovery_count entries
const void* const * const original, // original_count entries
const void* const * const recovery, // recovery_count entries
void** work); // n entries

View File

@ -416,7 +416,7 @@ static void FFTInitialize()
}
}
for (unsigned i = 0; i < kOrder; ++i)
for (unsigned i = 0; i < kModulus; ++i)
FFTSkew[i] = LogLUT[FFTSkew[i]];
// Precalculate FWHT(Log[i]):
@ -783,7 +783,7 @@ static void IFFT_DIT4(
void IFFT_DIT(
const uint64_t bytes,
void* const* data,
const void* const* data,
const unsigned m_truncated,
void** work,
void** xor_result,
@ -1274,7 +1274,7 @@ void ReedSolomonEncode(
unsigned original_count,
unsigned recovery_count,
unsigned m,
void* const* data,
const void* const* data,
void** work)
{
// work <- IFFT(data, m, m)
@ -1290,6 +1290,7 @@ void ReedSolomonEncode(
m,
skewLUT);
const unsigned last_count = original_count % m;
if (m >= original_count)
goto skip_body;
@ -1312,7 +1313,6 @@ void ReedSolomonEncode(
}
// Handle final partial set of m pieces:
const unsigned last_count = original_count % m;
if (last_count != 0)
{
const unsigned i = original_count - last_count;
@ -1481,8 +1481,8 @@ void ReedSolomonDecode(
unsigned recovery_count,
unsigned m, // NextPow2(recovery_count)
unsigned n, // NextPow2(m + original_count) = work_count
void* const * const original, // original_count entries
void* const * const recovery, // recovery_count entries
const void* const * const original, // original_count entries
const void* const * const recovery, // recovery_count entries
void** work) // n entries
{
// Fill in error locations

View File

@ -68,7 +68,7 @@ static const unsigned kPolynomial = 0x11D;
// Transform for a variable number of elements
// m_truncated: Number of elements that are non-zero at the front of data
void FWHT(ffe_t* data, const unsigned m, const unsigned m_truncated);
//void FWHT(ffe_t* data, const unsigned m, const unsigned m_truncated);
//------------------------------------------------------------------------------
@ -129,7 +129,7 @@ void ReedSolomonEncode(
unsigned original_count,
unsigned recovery_count,
unsigned m, // = NextPow2(recovery_count) * 2 = work_count
void* const * const data,
const void* const * const data,
void** work); // Size of GetEncodeWorkCount()
@ -142,8 +142,8 @@ void ReedSolomonDecode(
unsigned recovery_count,
unsigned m, // = NextPow2(recovery_count)
unsigned n, // = NextPow2(m + original_count) = work_count
void* const * const original, // original_count entries
void* const * const recovery, // recovery_count entries
const void* const * const original, // original_count entries
const void* const * const recovery, // recovery_count entries
void** work); // n entries

View File

@ -105,7 +105,7 @@ LEO_EXPORT unsigned leo_encode_work_count(
static void EncodeM1(
uint64_t buffer_bytes,
unsigned original_count,
void* const * const original_data,
const void* const * const original_data,
void* recovery_data)
{
memcpy(recovery_data, original_data[0], buffer_bytes);
@ -120,13 +120,13 @@ static void EncodeM1(
}
LEO_EXPORT LeopardResult leo_encode(
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of work_data[] buffer pointers, from leo_encode_work_count()
void* const * const original_data, // Array of pointers to original data buffers
void** work_data, // Array of work buffers
unsigned flags) // Operation flags
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of work_data[] buffer pointers, from leo_encode_work_count()
const void* const * const original_data, // Array of pointers to original data buffers
void** work_data, // Array of work buffers
unsigned flags) // Operation flags
{
if (buffer_bytes <= 0 || buffer_bytes % 64 != 0)
return Leopard_InvalidSize;
@ -216,7 +216,7 @@ LEO_EXPORT unsigned leo_decode_work_count(
static void DecodeM1(
uint64_t buffer_bytes,
unsigned original_count,
void* const * const original_data,
const void* const * original_data,
const void* recovery_data,
void* work_data)
{
@ -233,14 +233,14 @@ static void DecodeM1(
}
LEO_EXPORT LeopardResult leo_decode(
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of buffer pointers in work_data[]
void* const * const original_data, // Array of original data buffers
void* const * const recovery_data, // Array of recovery data buffers
void** work_data, // Array of work data buffers
unsigned flags) // Operation flags
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of buffer pointers in work_data[]
const void* const * const original_data, // Array of original data buffers
const void* const * const recovery_data, // Array of recovery data buffers
void** work_data, // Array of work data buffers
unsigned flags) // Operation flags
{
if (buffer_bytes <= 0 || buffer_bytes % 64 != 0)
return Leopard_InvalidSize;

View File

@ -187,13 +187,13 @@ LEO_EXPORT unsigned leo_encode_work_count(
Returns other values on errors.
*/
LEO_EXPORT LeopardResult leo_encode(
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of work_data[] buffer pointers, from leo_encode_work_count()
void* const * const original_data, // Array of pointers to original data buffers
void** work_data, // Array of work buffers
unsigned flags); // Operation flags
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of work_data[] buffer pointers, from leo_encode_work_count()
const void* const * const original_data, // Array of pointers to original data buffers
void** work_data, // Array of work buffers
unsigned flags); // Operation flags
//------------------------------------------------------------------------------
@ -236,14 +236,14 @@ LEO_EXPORT unsigned leo_decode_work_count(
Returns other values on errors.
*/
LEO_EXPORT LeopardResult leo_decode(
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of buffer pointers in work_data[]
void* const * const original_data, // Array of original data buffers
void* const * const recovery_data, // Array of recovery data buffers
void** work_data, // Array of work data buffers
unsigned flags); // Operation flags
uint64_t buffer_bytes, // Number of bytes in each data buffer
unsigned original_count, // Number of original_data[] buffer pointers
unsigned recovery_count, // Number of recovery_data[] buffer pointers
unsigned work_count, // Number of buffer pointers in work_data[]
const void* const * const original_data, // Array of original data buffers
const void* const * const recovery_data, // Array of recovery data buffers
void** work_data, // Array of work data buffers
unsigned flags); // Operation flags
#ifdef __cplusplus