Skip to content

Commit

Permalink
chore: cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hschimke committed Dec 22, 2024
1 parent dc7b8af commit 4a5f45c
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 260 deletions.
2 changes: 1 addition & 1 deletion src/binary_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,4 @@ impl<B: Binarizer> fmt::Display for BinaryBitmap<B> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self.matrix.borrow())
}
}
}
12 changes: 8 additions & 4 deletions src/common/reedsolomon/ReedSolomonTestCase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ fn test_data_matrix() {
0x70, 0x68, 0x6D, 0x66, 0x2F, 0x64, 0x70, 0x6E, 0x30, 0x71, 0x30, 0x7B, 0x79, 0x6A,
0x6F, 0x68, 0x30, 0x81, 0xF0, 0x88, 0x1F, 0xB5,
],
&[0x1C, 0x64, 0xEE, 0xEB, 0xD0, 0x1D, 0x00, 0x03, 0xF0, 0x1C, 0xF1, 0xD0, 0x6D, 0x00,
0x98, 0xDA, 0x80, 0x88, 0xBE, 0xFF, 0xB7, 0xFA, 0xA9, 0x95],
&[
0x1C, 0x64, 0xEE, 0xEB, 0xD0, 0x1D, 0x00, 0x03, 0xF0, 0x1C, 0xF1, 0xD0, 0x6D, 0x00,
0x98, 0xDA, 0x80, 0x88, 0xBE, 0xFF, 0xB7, 0xFA, 0xA9, 0x95,
],
);
// synthetic test cases
test_encode_decode_random(dm256, 220, 35);
Expand All @@ -74,8 +76,10 @@ fn test_qr_code() {
0x61, 0x67, 0x65, 0x3B, 0x3B, 0x00, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11, 0xEC, 0x11,
0xEC, 0x11, 0xEC, 0x11,
],
&[0xD8, 0xB8, 0xEF, 0x14, 0xEC, 0xD0, 0xCC, 0x85, 0x73, 0x40, 0x0B, 0xB5, 0x5A, 0xB8,
0x8B, 0x2E, 0x08, 0x62],
&[
0xD8, 0xB8, 0xEF, 0x14, 0xEC, 0xD0, 0xCC, 0x85, 0x73, 0x40, 0x0B, 0xB5, 0x5A, 0xB8,
0x8B, 0x2E, 0x08, 0x62,
],
);
// real life test cases
// synthetic test cases
Expand Down
128 changes: 67 additions & 61 deletions src/datamatrix/encoder/error_correction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,75 +23,73 @@ use super::SymbolInfo;
* Error Correction Code for ECC200.
*/

const FACTOR_SIZE : usize = 16;
const FACTOR_SIZE: usize = 16;

/**
* Lookup table which factors to use for which number of error correction codewords.
* See FACTORS.
*/
const FACTOR_SETS: [u32; FACTOR_SIZE] = [5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68];
const FACTOR_SETS: [u32; FACTOR_SIZE] =
[5, 7, 10, 11, 12, 14, 18, 20, 24, 28, 36, 42, 48, 56, 62, 68];

/**
* Precomputed polynomial factors for ECC 200.
*/
const FACTORS: [&[u32];FACTOR_SIZE] =
[
&[228, 48, 15, 111, 62],
&[23, 68, 144, 134, 240, 92, 254],
&[28, 24, 185, 166, 223, 248, 116, 255, 110, 61],
&[175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120],
&[41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242],
&[
156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185,
],
&[
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188,
],
&[
15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186,
172,
],
&[
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, 254, 124, 12,
181, 184, 96, 50, 193,
],
&[
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, 138, 110,
213, 141, 136, 120, 151, 233, 168, 93, 255,
],
&[
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, 229, 18,
2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112,
],
&[
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, 95, 100, 9,
167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226,
5, 9, 5,
],
&[
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, 191, 106,
16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, 176,
87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19,
],
&[
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, 150, 159,
36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, 144, 238, 22, 150,
201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53,
143, 46,
],
&[
242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, 185, 112,
134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27,
218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, 232, 7, 94, 166, 224,
124, 86, 47, 11, 204,
],
&[
220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, 213, 136,
248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, 66, 139, 153, 185,
202, 167, 179, 25, 220, 232, 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25,
49, 232, 211, 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186,
],
];
const FACTORS: [&[u32]; FACTOR_SIZE] = [
&[228, 48, 15, 111, 62],
&[23, 68, 144, 134, 240, 92, 254],
&[28, 24, 185, 166, 223, 248, 116, 255, 110, 61],
&[175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120],
&[41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242],
&[
156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185,
],
&[
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48, 90, 188,
],
&[
15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27, 174, 186, 172,
],
&[
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172, 254, 124, 12, 181,
184, 96, 50, 193,
],
&[
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17, 138, 110, 213,
141, 136, 120, 151, 233, 168, 93, 255,
],
&[
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182, 229, 18, 2,
4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25, 225, 98, 81, 112,
],
&[
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175, 95, 100, 9,
167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5,
9, 5,
],
&[
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87, 191, 106, 16,
147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44, 176, 87, 187,
147, 160, 175, 69, 213, 92, 253, 225, 19,
],
&[
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235, 150, 159, 36,
223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232, 144, 238, 22, 150, 201, 117,
62, 207, 164, 13, 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46,
],
&[
242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37, 185, 112, 134,
230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51,
63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47,
11, 204,
],
&[
220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127, 213, 136, 248,
180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236, 66, 139, 153, 185, 202, 167,
179, 25, 220, 232, 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211,
189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186,
],
];

const MODULO_VALUE: usize = 0x12D;

Expand Down Expand Up @@ -168,7 +166,15 @@ pub fn encodeECC200(codewords: &str, symbolInfo: &SymbolInfo) -> Result<String>
sb.push_str(&ecc);
} else {
//sb.setLength(sb.capacity());
sb.push_str(&vec![char::default();(symbolInfo.getDataCapacity() + symbolInfo.getErrorCodewords()) as usize - sb.chars().count()].into_iter().collect::<String>());
sb.push_str(
&vec![
char::default();
(symbolInfo.getDataCapacity() + symbolInfo.getErrorCodewords()) as usize
- sb.chars().count()
]
.into_iter()
.collect::<String>(),
);
let mut dataSizes = vec![0u32; blockCount];
let mut errorSizes = vec![0u32; blockCount];
for i in 0..blockCount {
Expand Down
10 changes: 5 additions & 5 deletions src/datamatrix/encoder/symbol_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ impl SymbolInfo {
rectangular: false,
dataCapacity: 1558,
errorCodewords: 620,
matrixWidth:22,
matrixHeight:22,
dataRegions:36,
rsBlockData:-1,
rsBlockError:62,
matrixWidth: 22,
matrixHeight: 22,
dataRegions: 36,
rsBlockData: -1,
rsBlockError: 62,
isSymbolInfo144: true,
}
// let mut new_symbol = Self::with_details(false, 1558, 620, 22, 22, 36, -1, 62);
Expand Down
Loading

0 comments on commit 4a5f45c

Please sign in to comment.