Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the EFM decoder logic #770

Merged
merged 2 commits into from
Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions tools/ld-process-efm/Datatypes/f3frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,41 +216,22 @@ bool F3Frame::isSubcodeSync1()
// Private methods ----------------------------------------------------------------------------------------------------

// Method to translate 14-bit EFM value into 8-bit byte
// Returns -1 if the EFM value is could not be converted
// Returns -1 if the EFM value could not be converted (which never happens,
// since we always correct to the most likely value)
qint16 F3Frame::translateEfm(qint16 efmValue)
{
qint16 result = -1;
qint16 lutPos = 0;
while (result == -1 && lutPos < 256) {
if (efm2numberLUT[lutPos] == efmValue) result = lutPos;
lutPos++;
}

// Was 14-bit EFM symbol invalid?
if (result == -1) {
// Symbol was invalid
invalidEfmSymbols++;

// Attempt to recover symbol using cosine similarity lookup
result = -1;
lutPos = 0;
while (result == -1 && lutPos < 16384) {
if (efmerr2positionLUT[lutPos] == efmValue) result = lutPos;
lutPos++;
}

// Was lookup successful?
if (result != -1) {
// Get the translated value from the second LUT
result = efmerr2valueLUT[result];
correctedEfmSymbols++;
for (qint16 lutPos = 0; lutPos < 256; lutPos++) {
if (efm2numberLUT[lutPos] == efmValue) {
// Symbol was valid
validEfmSymbols++;
return lutPos;
}
} else {
// Symbol was valid
validEfmSymbols++;
}

return result;
// Symbol was invalid. Correct it using cosine similarity lookup.
invalidEfmSymbols++;
correctedEfmSymbols++;
return efmerr2valueLUT[efmValue & 0x3fff];
}

// Method to get 'width' bits (max 15) from a byte array starting from bit 'bitIndex'
Expand Down
Loading