add ReadQRCodewords

This commit is contained in:
Henry Schimke
2023-03-30 10:32:42 -05:00
parent af626afc15
commit ae5539e270
4 changed files with 120 additions and 36 deletions

View File

@@ -24,7 +24,7 @@ impl FormatInformation {
pub fn DecodeMQR(formatInfoBits: u32) -> Self {
todo!()
// // We don't use the additional masking (with 0x4445) to work around potentially non complying MicroQRCode encoders
// auto fi = FindBestFormatInfo(0, FORMAT_INFO_DECODE_LOOKUP_MICRO, {formatInfoBits, MirrorBits(formatInfoBits)});
// let fi = FindBestFormatInfo(0, FORMAT_INFO_DECODE_LOOKUP_MICRO, {formatInfoBits, MirrorBits(formatInfoBits)});
// constexpr uint8_t BITS_TO_VERSION[] = {1, 2, 2, 3, 3, 4, 4, 4};
@@ -37,6 +37,30 @@ impl FormatInformation {
// return fi;
}
pub fn MirrorBits(bits: u32) -> u32 {
todo!()
// return BitHacks::Reverse(bits) >> 17;
}
pub fn FindBestFormatInfo(mask: u32, lookup: [(u32, u32); 32], bits: &[u32]) -> Self {
todo!()
// FormatInformation fi;
// // Some QR codes apparently do not apply the XOR mask. Try without and with additional masking.
// for (auto mask : {0, mask})
// for (int bitsIndex = 0; bitsIndex < Size(bits); ++bitsIndex)
// for (const auto& [pattern, index] : lookup) {
// // Find the int in lookup with fewest bits differing
// if (int hammingDist = BitHacks::CountBitsSet((bits[bitsIndex] ^ mask) ^ pattern); hammingDist < fi.hammingDistance) {
// fi.index = index;
// fi.hammingDistance = hammingDist;
// fi.bitsIndex = bitsIndex;
// }
// }
// return fi;
}
pub fn isValid(&self) -> bool {
todo!()
}