large.c: replace binary_load/add() etc with uint64_t based large_load/add() etc for performance

This commit is contained in:
gitlost 2020-06-14 14:42:40 +01:00
parent 3690c19749
commit e8a238aad1
14 changed files with 1566 additions and 804 deletions

View file

@ -49,20 +49,82 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
unsigned char *expected;
};
struct item data[] = {
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 0, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 0, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 0, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 8*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 9*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/*10*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
/* 0*/ { BARCODE_RSS14, "1234567890123", 0, 100, 30, 0, 1, 96, "010111010010000001001110000000010100001011111010110100011001100101111111110001011011000111000101" },
/* 1*/ { BARCODE_RSS14, "0000004537076", 0, 100, 30, 0, 1, 96, "010101001000000001000100000000010111111100101010111101111101010101111111110111010100100000000101" },
/* 2*/ { BARCODE_RSS14, "0000004537077", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101010110000000101111100000111011111111011010101" },
/* 3*/ { BARCODE_RSS14, "0000004537078", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111101001010101011010000000101111000000011011111111011010101" },
/* 4*/ { BARCODE_RSS14, "0000000001596", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010111101111101010101111100000111011111111011010101" },
/* 5*/ { BARCODE_RSS14, "0000000001597", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011111110111010101" },
/* 6*/ { BARCODE_RSS14, "0000000001598", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101011010000000101111000000011011111110111010101" },
/* 7*/ { BARCODE_RSS14, "0000000000000", 0, 100, 30, 0, 1, 96, "010101001000000001000111111110010111111100101010101010110000000101111111110111011111111011010101" },
/* 8*/ { BARCODE_RSS14, "0000000257117", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010101010110000000101111110000011000111111011010101" },
/* 9*/ { BARCODE_RSS14, "0000000536592", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111100101010101010110000000101100000000111011101100011110101" },
/* 10*/ { BARCODE_RSS14, "0000001644132", 0, 100, 30, 0, 1, 96, "010101001000000001001111100000010111111100101010100100001111010101111100000111000001101111010101" },
/* 11*/ { BARCODE_RSS14, "0000002421052", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111100101010101010110000000101111100000111011100010001101101" },
/* 12*/ { BARCODE_RSS14, "0000003217955", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010111111100101010101010110000000101111111000001000000111001010101" },
/* 13*/ { BARCODE_RSS14, "0000004792584", 0, 100, 30, 0, 1, 96, "010101001000000001000111110000010111111101001010111011111101010101111111110111010110101111111101" },
/* 14*/ { BARCODE_RSS14, "0000006062184", 0, 100, 30, 0, 1, 96, "010101001000000001000111111110010111111101001010110111111101010101111111110111001010011011111101" },
/* 15*/ { BARCODE_RSS14, "0000007734882", 0, 100, 30, 0, 1, 96, "010101001000000001000111111110010111111101001010110111000010010101111111000111001010001100111101" },
/* 16*/ { BARCODE_RSS14, "0000008845782", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111101001010111101111101010101111111000001000010101000011101" },
/* 17*/ { BARCODE_RSS14, "0000009329661", 0, 100, 30, 0, 1, 96, "010101001000000001001111111000010111111101010010111011111101010101111000000011010110101111111101" },
/* 18*/ { BARCODE_RSS14, "0000009607386", 0, 100, 30, 0, 1, 96, "010101001000000001011111000000010111111101010010100111001011110101111111110111011100011011110101" },
/* 19*/ { BARCODE_RSS14, "0000010718286", 0, 100, 30, 0, 1, 96, "010101001000000001000111110000010111111101010010100100001111010101111100000111000001101111010101" },
/* 20*/ { BARCODE_RSS14, "0000011607006", 0, 100, 30, 0, 1, 96, "010101001000000001000111111110010111111101010010101101000100000101111000000011010011100001101101" },
/* 21*/ { BARCODE_RSS14, "0004360130997", 0, 100, 30, 0, 1, 96, "010101001000000001000100000000010110010010011110101010110000000101111000000011011111111011010101" },
/* 22*/ { BARCODE_RSS14, "0004360386504", 0, 100, 30, 0, 1, 96, "010101001000000001000111000000010110010010011110111011111101010101111111100011010110101111111101" },
/* 23*/ { BARCODE_RSS14, "0009142746747", 0, 100, 30, 0, 1, 96, "010101000100000001000111111110010100111110001010101010110000000101111111000111011101100011110101" },
/* 24*/ { BARCODE_RSS14, "0012319818547", 0, 100, 30, 0, 1, 96, "010101000100000001000100000000010110001100101000101010110000000101111111000111001100011110010101" },
/* 25*/ { BARCODE_RSS14, "0013775011335", 0, 100, 30, 0, 1, 96, "010101000100000001000100000000010101001100000110101010110000000101111100000111011111010011100101" },
/* 26*/ { BARCODE_RSS14, "0018894538190", 0, 100, 30, 0, 1, 96, "010101000010000001000100000000010110100100111100101010110000000101111111110001010001100011110101" },
/* 27*/ { BARCODE_RSS14, "0021059247735", 0, 100, 30, 0, 1, 96, "010101000010000001000100000000010101000011001100101010110000000101111111100011010110111000001101" },
/* 28*/ { BARCODE_RSS14, "0024094346235", 0, 100, 30, 0, 1, 96, "010101000001000001000100000000010111010000111010101010110000000101100000000111000110011001101101" },
/* 29*/ { BARCODE_RSS14, "1995000595035", 0, 100, 30, 0, 1, 96, "010100011011000001001110000000010111010111010000101010110000000101111000000011000110011001101101" },
/* 30*/ { BARCODE_RSS14, "9999999999999", 0, 100, 30, 0, 1, 96, "010010111011100001000111111110010111101101001110100011111101010101111111000001000111110101011101" },
/* 31*/ { BARCODE_RSS14_CC, "0000000000000", 0, 100, 30, 0, 5, 100, "0000010010111011100001001110000000010111101101001110110001010111110101111111110001000111110101011101" },
/* 32*/ { BARCODE_RSS14_CC, "0000729476171", 0, 100, 30, 0, 5, 100, "0000010010111011100001011100000000010111100110100010101010110000000101111111100011011111111011010101" },
/* 33*/ { BARCODE_RSS14_CC, "0004359674363", 0, 100, 30, 0, 5, 100, "0000010010111011100001011100000000010101110010000100101010110000000101111000000011011101100011110101" },
/* 34*/ { BARCODE_RSS14_CC, "0009142871421", 0, 100, 30, 0, 5, 100, "0000010010111101000011000111111110010100010111110010101010110000000101111111000111001100011110010101" },
/* 35*/ { BARCODE_RSS14_CC, "0012319591881", 0, 100, 30, 0, 5, 100, "0000010010111101000011000100000000010101000111010000101010110000000101111111000111011100010001101101" },
/* 36*/ { BARCODE_RSS14_CC, "6975446373038", 0, 100, 30, 0, 5, 100, "0000010111001110010111001111111000010101000111010000101010110000000101111100000111011111111011010101" },
/* 37*/ { BARCODE_RSS14_CC, "9999999999999", 0, 100, 30, 0, 5, 100, "0000010110101111011111001111111000010110111100100010100110111001110101111111110001001100110001110101" },
/* 38*/ { BARCODE_RSS_LTD, "1234567890123", 0, 100, 30, 0, 1, 74, "01001100111100101000100111010110101011001001010010101001010000011100011101" },
/* 39*/ { BARCODE_RSS_LTD, "0000002013570", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110100101101011001010111111110111111010101010101" },
/* 40*/ { BARCODE_RSS_LTD, "0000002013571", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101011010100011010101010101000000100000011101" },
/* 41*/ { BARCODE_RSS_LTD, "0000002013572", 0, 100, 30, 0, 1, 74, "01010101010100000011000000110101010010111001010101010101000000110000001101" },
/* 42*/ { BARCODE_RSS_LTD, "0000000917879", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110100110101010011010100110111011111010110011101" },
/* 43*/ { BARCODE_RSS_LTD, "0000000000000", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101110101001001010101010101000000100000011101" },
/* 44*/ { BARCODE_RSS_LTD, "0000000183063", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110110101010010011010000001110000001010101010101" },
/* 45*/ { BARCODE_RSS_LTD, "0000000183064", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110010101010111001010101010101000111100000111101" },
/* 46*/ { BARCODE_RSS_LTD, "0000000820063", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110010101010011011010000011110001111010101010101" },
/* 47*/ { BARCODE_RSS_LTD, "0000000820064", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110110101101001001010101010101011111100011111101" },
/* 48*/ { BARCODE_RSS_LTD, "0000001000775", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110010110101011001010001111110111111010101010101" },
/* 49*/ { BARCODE_RSS_LTD, "0000001000776", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101110101010001010101010101000001100000111101" },
/* 50*/ { BARCODE_RSS_LTD, "0000001491020", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110010101010110011010000011110000011010101010101" },
/* 51*/ { BARCODE_RSS_LTD, "0000001491021", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101001010110011010101010101001111100001111101" },
/* 52*/ { BARCODE_RSS_LTD, "0000001979844", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101010100011011010000111110011111010101010101" },
/* 53*/ { BARCODE_RSS_LTD, "0000001979845", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101110100101001010101010101000000100000000101" },
/* 54*/ { BARCODE_RSS_LTD, "0000001996938", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110101101010001011010000000010000001010101010101" },
/* 55*/ { BARCODE_RSS_LTD, "0000001996939", 0, 100, 30, 0, 1, 74, "01010101010100000010000001110110110101010001010101010101011111101111111101" },
/* 56*/ { BARCODE_RSS_LTD, "0000012013571", 0, 100, 30, 0, 1, 74, "01010101010111000000100000010101010010100111010001110111100101001101101101" },
/* 57*/ { BARCODE_RSS_LTD, "0368610347973", 0, 100, 30, 0, 1, 74, "01000000111000000101010101010010101011101001010101010101000000100000011101" },
/* 58*/ { BARCODE_RSS_LTD, "0368612361544", 0, 100, 30, 0, 1, 74, "01010101010100011110000011110101001101010011010101010101000000100000011101" },
/* 59*/ { BARCODE_RSS_LTD, "1651255074973", 0, 100, 30, 0, 1, 74, "01000001111000111101010101010101101001010011010101010101000000100000011101" },
/* 60*/ { BARCODE_RSS_LTD, "1651257088544", 0, 100, 30, 0, 1, 74, "01010101010101111110001111110101101001101001010101010101000000100000011101" },
/* 61*/ { BARCODE_RSS_LTD, "1999999999999", 0, 100, 30, 0, 1, 74, "01001111001101101011011111010101011010110001010100001011100011010111100101" },
/* 62*/ { BARCODE_RSS_LTD_CC, "0000000000000", 0, 100, 30, 0, 6, 74, "01010101010100000110000011110100101011010011010101010101000000100000011101" },
/* 63*/ { BARCODE_RSS_LTD_CC, "0000002013571", 0, 100, 30, 0, 6, 74, "01010101010100000111000001110101101010001011010101010101000000100000011101" },
/* 64*/ { BARCODE_RSS_LTD_CC, "0987141101324", 0, 100, 30, 0, 6, 74, "01000001111000001101010101010110101010100011010101010101000000100000011101" },
/* 65*/ { BARCODE_RSS_LTD_CC, "0987143114895", 0, 100, 30, 0, 6, 74, "01010101010100111110000111110101110101010001010101010101000000100000011101" },
/* 66*/ { BARCODE_RSS_LTD_CC, "1971422931828", 0, 100, 30, 0, 6, 74, "01000011111001111101010101010100101010100111010101010101000000100000011101" },
/* 67*/ { BARCODE_RSS_LTD_CC, "1971424945399", 0, 100, 30, 0, 6, 74, "01010101010100000010000000010110101010010011010101010101000000100000011101" },
/* 68*/ { BARCODE_RSS_LTD_CC, "1999999999999", 0, 100, 30, 0, 6, 74, "01000010000001010101000001010110101101001001010100001011100011010111100101" },
/* 69*/ { BARCODE_RSS_LTD, "1651257071912", 0, 100, 30, 0, 1, 74, "01000001111000111101010101010101110101001001010101010101011111101111111101" },
/* 70*/ { BARCODE_RSS_LTD_CC, "0987144605916", 0, 100, 30, 0, 6, 74, "01010101010100111110000111110110101101001001010101010101001111100001111101" },
};
int data_size = sizeof(data) / sizeof(struct item);
char *text;
for (int i = 0; i < data_size; i++) {
if (index != -1 && i != index) continue;
@ -73,22 +135,28 @@ static void test_binary_div_modulo_divisor(int index, int generate, int debug) {
symbol->symbology = data[i].symbology;
symbol->debug |= debug;
int length = strlen(data[i].data);
if (symbol->symbology == BARCODE_RSS14_CC || symbol->symbology == BARCODE_RSS_LTD_CC) {
text = "[20]01";
strcpy(symbol->primary, data[i].data);
} else {
text = data[i].data;
}
int length = strlen(text);
ret = ZBarcode_Encode(symbol, data[i].data, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d\n", i, ret, data[i].ret_encode);
ret = ZBarcode_Encode(symbol, text, length);
assert_equal(ret, data[i].ret_encode, "i:%d ZBarcode_Encode ret %d != %d (%s)\n", i, ret, data[i].ret_encode, symbol->errtxt);
if (generate) {
printf(" /*%2d*/ { %s, \"%s\", %d, %.0f, %.0f, %d, %d, %d, ",
printf(" /*%3d*/ { %s, \"%s\", %d, %.0f, %.0f, %d, %d, %d, ",
i, testUtilBarcodeName(data[i].symbology), data[i].data, ret, data[i].w, data[i].h, data[i].ret_vector, symbol->rows, symbol->width);
testUtilModulesDump(symbol, "", " },\n");
testUtilModulesDumpRow(symbol, symbol->rows - 1, "", " },\n");
} else {
assert_equal(symbol->rows, data[i].expected_rows, "i:%d symbol->rows %d != %d\n", i, symbol->rows, data[i].expected_rows);
assert_equal(symbol->width, data[i].expected_width, "i:%d symbol->width %d != %d\n", i, symbol->width, data[i].expected_width);
int width, row;
ret = testUtilModulesCmp(symbol, data[i].expected, &width, &row);
assert_zero(ret, "i:%d testUtilModulesCmp ret %d != 0 width %d row %d\n", i, ret, width, row);
int width;
ret = testUtilModulesCmpRow(symbol, symbol->rows - 1, data[i].expected, &width);
assert_zero(ret, "i:%d testUtilModulesCmpRow ret %d != 0 width %d row %d\n", i, ret, width, symbol->rows - 1);
ret = ZBarcode_Buffer_Vector(symbol, 0);
assert_equal(ret, data[i].ret_vector, "i:%d ZBarcode_Buffer_Vector ret %d != %d\n", i, ret, data[i].ret_vector);