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

Implemented cosine similarity correction for EFM symbols in ld-proces… #536

Merged
merged 1 commit into from
Aug 13, 2020
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
34 changes: 32 additions & 2 deletions tools/ld-process-efm/Datatypes/f3frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ F3Frame::F3Frame()
{
validEfmSymbols = 0;
invalidEfmSymbols = 0;
correctedEfmSymbols = 0;

isSync0 = false;
isSync1 = false;
Expand All @@ -50,6 +51,7 @@ F3Frame::F3Frame(uchar *tValuesIn, qint32 tLength)
{
validEfmSymbols = 0;
invalidEfmSymbols = 0;
correctedEfmSymbols = 0;

isSync0 = false;
isSync1 = false;
Expand Down Expand Up @@ -175,6 +177,12 @@ qint64 F3Frame::getNumberOfInvalidEfmSymbols()
return invalidEfmSymbols;
}

// Return the number of corrected EFM symbols in the frame
qint64 F3Frame::getNumberOfCorrectedEfmSymbols()
{
return correctedEfmSymbols;
}

// This method returns the 32 data symbols for the F3 Frame
uchar *F3Frame::getDataSymbols()
{
Expand Down Expand Up @@ -208,7 +216,7 @@ bool F3Frame::isSubcodeSync1()
// Private methods ----------------------------------------------------------------------------------------------------

// Method to translate 14-bit EFM value into 8-bit byte
// Returns -1 if the EFM value is invalid
// Returns -1 if the EFM value is could not be converted
qint16 F3Frame::translateEfm(qint16 efmValue)
{
qint16 result = -1;
Expand All @@ -218,7 +226,29 @@ qint16 F3Frame::translateEfm(qint16 efmValue)
lutPos++;
}

if (result == -1) invalidEfmSymbols++; else validEfmSymbols++;
// 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++;
}
} else {
// Symbol was valid
validEfmSymbols++;
}

return result;
}
Expand Down
Loading