mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-04-04 22:17:38 +00:00
Refactor the Golay 24,12,8 code and its uses.
This commit is contained in:
parent
8dc54ed21f
commit
ffb4bdb042
6 changed files with 43 additions and 32 deletions
|
|
@ -1090,23 +1090,25 @@ unsigned int CGolay24128::decode23127(unsigned int code)
|
|||
return code >> 11;
|
||||
}
|
||||
|
||||
unsigned int CGolay24128::decode24128(unsigned int input, bool& valid)
|
||||
bool CGolay24128::decode24128(unsigned int in, unsigned int& out)
|
||||
{
|
||||
unsigned int syndrome = ::get_syndrome_23127(input >> 1);
|
||||
unsigned int syndrome = ::get_syndrome_23127(in >> 1);
|
||||
unsigned int error_pattern = DECODING_TABLE_23127[syndrome] << 1;
|
||||
|
||||
unsigned int output = input ^ error_pattern;
|
||||
out = in ^ error_pattern;
|
||||
|
||||
valid = (CUtils::countBits(syndrome) < 3U) || !(CUtils::countBits(output) & 1);
|
||||
bool valid = (CUtils::countBits(syndrome) < 3U) || !(CUtils::countBits(out) & 1);
|
||||
|
||||
return output >> 12;
|
||||
out >>= 12;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
unsigned int CGolay24128::decode24128(unsigned char* bytes, bool& valid)
|
||||
bool CGolay24128::decode24128(unsigned char* in, unsigned int& out)
|
||||
{
|
||||
assert(bytes != NULL);
|
||||
assert(in != NULL);
|
||||
|
||||
unsigned int code = (bytes[0U] << 16) | (bytes[1U] << 8) | (bytes[2U] << 0);
|
||||
unsigned int code = (in[0U] << 16) | (in[1U] << 8) | (in[2U] << 0);
|
||||
|
||||
return decode24128(code, valid);
|
||||
return decode24128(code, out);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue