-
-
Notifications
You must be signed in to change notification settings - Fork 465
Remove legacy OneToFourBitPattern
function from Code93 decoder
#972
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. If you feel like improving this PR, please see my comments. I thought about changing the constexpr
part inside the Code128 decoder as a reference first, but I don't have the time right now.
|
||
namespace ZXing::OneD::Code93 { | ||
|
||
const std::array<std::array<int, 6>, 48> CODE_PATTERNS = { { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see this in the header and making it constexpr
.
0x11A, 0x158, 0x14C, 0x146, 0x12C, 0x116, 0x1B4, 0x1B2, 0x1AC, 0x1A6, // K-T | ||
0x196, 0x19A, 0x16C, 0x166, 0x136, 0x13A, // U-Z | ||
0x12E, 0x1D4, 0x1D2, 0x1CA, 0x16E, 0x176, 0x1AE, // - - % | ||
0x126, 0x1DA, 0x1D6, 0x132, 0x15E, // Control chars ($)==a, (%)==b, (/)==c, (+)==d, * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saving the comment regarding the control characters would be nice.
0x126, 0x1DA, 0x1D6, 0x132, 0x15E, // Control chars ($)==a, (%)==b, (/)==c, (+)==d, * | ||
}; | ||
|
||
static_assert(Size(ALPHABET) == Size(CHARACTER_ENCODINGS), "table size mismatch"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This static_assert
should also be preserved.
// quiet zone is half the width of a character symbol | ||
constexpr float QUIET_ZONE_SCALE = 0.5f; | ||
|
||
//TODO: make this a constexpr variable initialization | ||
static auto E2E_PATTERNS = [ ] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be able to implement this TODO (see also comment above)?
@@ -99,9 +95,13 @@ Barcode Code93Reader::decodePattern(int rowNumber, PatternView& next, std::uniqu | |||
if (!next.skipSymbol()) | |||
return {}; | |||
|
|||
txt += LookupBitPattern(OneToFourBitPattern<CHAR_LEN, CHAR_SUM>(next), CHARACTER_ENCODINGS, ALPHABET); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LookupBitPattern
helper use could very well stay.
@@ -62,46 +61,6 @@ static bool DecodeDigit(const PatternView& view, std::string& txt, int* lgPatter | |||
AppendBit(*lgPattern, bestMatch >= 10); | |||
|
|||
return true; | |||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave this disabled code alone. It might be useful as documentation in the future.
This PR removes the
OneToFourBitPattern
function, which was part of the legacy Code93 decoding logic.Code93 now consistently uses
NormalizedE2EPattern
, instead ofOneToFourBitPattern
.Removing this helps simplify the code and reduce technical debt.
Key changes:
OneToFourBitPattern
with the standardizedNormalizedE2EPattern
approach, already used across other symbologies.ODCode93Patterns.cpp
: Contains theCODE_PATTERNS
definition for Code93.ODCode93Patterns.h
: Corresponding header for pattern definitions.Modified files:
ODCode93Reader.cpp
: RemovedOneToFourBitPattern
, updated decoding logic to useNormalizedE2EPattern
.ODMultiUPCEANReader.cpp
: Removed residual mentions ofOneToFourBitPattern
from an unused/dead code path inDecodeDigit
. This was done for cleanup and consistency.ODRowReader.h
: RemovedOneToFourBitPattern
, which is no more needed.core/CMakeLists.txt
: Added the newODCode93Patterns
files to the build.Please review the changes and let me know if further adjustments are needed.
Thank you.