2022-07-15 03:01:30 +12:00
|
|
|
/* ultra.c - Ultracode */
|
|
|
|
/*
|
2019-03-21 22:14:24 +13:00
|
|
|
libzint - the open source barcode library
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
|
2019-03-21 22:14:24 +13:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
|
|
|
without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
SUCH DAMAGE.
|
|
|
|
*/
|
2022-07-15 03:01:30 +12:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause */
|
2019-03-21 22:14:24 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* This version was developed using AIMD/TSC15032-43 v0.99c Edit 60, dated 4th Nov 2015 */
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2019-03-21 22:14:24 +13:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "common.h"
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
#define ULT_EIGHTBIT_MODE 10
|
|
|
|
#define ULT_ASCII_MODE 20
|
|
|
|
#define ULT_C43_MODE 30
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
#define ULT_PREDICT_WINDOW 12
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
#define ULT_GFMUL(i, j) ((((i) == 0)||((j) == 0)) ? 0 : gfPwr[(gfLog[i] + gfLog[j])])
|
2019-12-16 01:58:59 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
static const char *const ult_fragment[27] = {
|
|
|
|
"http://", "https://", "http://www.", "https://www.",
|
|
|
|
"ftp://", "www.", ".com", ".edu", ".gov", ".int", ".mil", ".net", ".org",
|
|
|
|
".mobi", ".coop", ".biz", ".info", "mailto:", "tel:", ".cgi", ".asp",
|
|
|
|
".aspx", ".php", ".htm", ".html", ".shtml", "file:"
|
|
|
|
};
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const char ult_c43_set1[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 .,%";
|
|
|
|
static const char ult_c43_set2[] = "abcdefghijklmnopqrstuvwxyz:/?#[]@=_~!.,-";
|
|
|
|
static const char ult_c43_set3[] = "{}`()\"+'<>|$;&\\^*";
|
|
|
|
static const char ult_digit[] = "0123456789,/";
|
|
|
|
static const char ult_colour[] = "0CBMRYGKW";
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Max size and min cols adjusted to BWIPP values as updated 2021-07-14
|
|
|
|
https://github.com/bwipp/postscriptbarcode/commit/4255810845fa8d45c6192dd30aee1fdad1aaf0cc */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const int ult_maxsize[] = {37, 84, 161, 282};
|
2019-12-16 02:48:45 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const int ult_mincols[] = {5, 13, 22, 29};
|
2019-12-18 09:22:16 +13:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
static const int ult_kec[] = {0, 1, 2, 4, 6, 8}; /* Value K(EC) from Table 12 */
|
2019-12-18 09:22:16 +13:00
|
|
|
|
2021-09-30 04:25:59 +13:00
|
|
|
/* Taken from BWIPP - change in DCCU/DCCL tiles for revision 2 2021-09-28 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const unsigned short ult_dccu[2][32] = {
|
2022-07-15 03:01:30 +12:00
|
|
|
{ /* Revision 1 */
|
|
|
|
051363, 051563, 051653, 053153, 053163, 053513, 053563, 053613, /* 0-7 */
|
|
|
|
053653, 056153, 056163, 056313, 056353, 056363, 056513, 056563, /* 8-15 */
|
|
|
|
051316, 051356, 051536, 051616, 053156, 053516, 053536, 053616, /* 16-23 */
|
|
|
|
053636, 053656, 056136, 056156, 056316, 056356, 056516, 056536 /* 24-31 */
|
2021-09-30 04:25:59 +13:00
|
|
|
},
|
2022-07-15 03:01:30 +12:00
|
|
|
{ /* Revision 2 (inversion of DCCL Revision 1) */
|
|
|
|
015316, 016316, 013516, 016516, 013616, 015616, 013136, 015136, /* 0-7 */
|
|
|
|
016136, 013536, 016536, 013636, 013156, 016156, 015356, 013656, /* 8-15 */
|
|
|
|
015313, 016313, 013513, 016513, 013613, 015613, 013153, 015153, /* 16-23 */
|
|
|
|
016153, 016353, 013653, 015653, 013163, 015163, 015363, 013563 /* 24-31 */
|
2021-09-30 04:25:59 +13:00
|
|
|
},
|
2019-12-16 11:26:57 +13:00
|
|
|
};
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const unsigned short ult_dccl[2][32] = {
|
2022-07-15 03:01:30 +12:00
|
|
|
{ /* Revision 1 */
|
|
|
|
061351, 061361, 061531, 061561, 061631, 061651, 063131, 063151, /* 0-7 */
|
|
|
|
063161, 063531, 063561, 063631, 065131, 065161, 065351, 065631, /* 8-15 */
|
|
|
|
031351, 031361, 031531, 031561, 031631, 031651, 035131, 035151, /* 16-23 */
|
|
|
|
035161, 035361, 035631, 035651, 036131, 036151, 036351, 036531 /* 24-31 */
|
2021-09-30 04:25:59 +13:00
|
|
|
},
|
2022-07-15 03:01:30 +12:00
|
|
|
{ /* Revision 2 (inversion of DCCU Revision 1) */
|
|
|
|
036315, 036515, 035615, 035135, 036135, 031535, 036535, 031635, /* 0-7 */
|
|
|
|
035635, 035165, 036165, 031365, 035365, 036365, 031565, 036565, /* 8-15 */
|
|
|
|
061315, 065315, 063515, 061615, 065135, 061535, 063535, 061635, /* 16-23 */
|
|
|
|
063635, 065635, 063165, 065165, 061365, 065365, 061565, 063565 /* 24-31 */
|
2021-09-30 04:25:59 +13:00
|
|
|
},
|
2019-12-16 11:26:57 +13:00
|
|
|
};
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static const int ult_tiles[] = {
|
2022-07-15 03:01:30 +12:00
|
|
|
013135, 013136, 013153, 013156, 013163, 013165, 013513, 013515, 013516, 013531, /* 0-9 */
|
|
|
|
013535, 013536, 013561, 013563, 013565, 013613, 013615, 013616, 013631, 013635, /* 10-19 */
|
|
|
|
013636, 013651, 013653, 013656, 015135, 015136, 015153, 015163, 015165, 015313, /* 20-29 */
|
|
|
|
015315, 015316, 015351, 015353, 015356, 015361, 015363, 015365, 015613, 015615, /* 30-39 */
|
|
|
|
015616, 015631, 015635, 015636, 015651, 015653, 015656, 016135, 016136, 016153, /* 40-49 */
|
|
|
|
016156, 016165, 016313, 016315, 016316, 016351, 016353, 016356, 016361, 016363, /* 50-59 */
|
|
|
|
016365, 016513, 016515, 016516, 016531, 016535, 016536, 016561, 016563, 016565, /* 60-69 */
|
|
|
|
031315, 031316, 031351, 031356, 031361, 031365, 031513, 031515, 031516, 031531, /* 70-79 */
|
|
|
|
031535, 031536, 031561, 031563, 031565, 031613, 031615, 031631, 031635, 031636, /* 80-89 */
|
|
|
|
031651, 031653, 031656, 035131, 035135, 035136, 035151, 035153, 035156, 035161, /* 90-99 */
|
|
|
|
035163, 035165, 035315, 035316, 035351, 035356, 035361, 035365, 035613, 035615, /* 100-109 */
|
|
|
|
035616, 035631, 035635, 035636, 035651, 035653, 035656, 036131, 036135, 036136, /* 110-119 */
|
|
|
|
036151, 036153, 036156, 036163, 036165, 036315, 036316, 036351, 036356, 036361, /* 120-129 */
|
|
|
|
036365, 036513, 036515, 036516, 036531, 036535, 036536, 036561, 036563, 036565, /* 130-139 */
|
|
|
|
051313, 051315, 051316, 051351, 051353, 051356, 051361, 051363, 051365, 051513, /* 140-149 */
|
|
|
|
051516, 051531, 051536, 051561, 051563, 051613, 051615, 051616, 051631, 051635, /* 150-159 */
|
|
|
|
051636, 051651, 051653, 051656, 053131, 053135, 053136, 053151, 053153, 053156, /* 160-169 */
|
|
|
|
053161, 053163, 053165, 053513, 053516, 053531, 053536, 053561, 053563, 053613, /* 170-179 */
|
|
|
|
053615, 053616, 053631, 053635, 053636, 053651, 053653, 053656, 056131, 056135, /* 180-189 */
|
|
|
|
056136, 056151, 056153, 056156, 056161, 056163, 056165, 056313, 056315, 056316, /* 190-199 */
|
|
|
|
056351, 056353, 056356, 056361, 056363, 056365, 056513, 056516, 056531, 056536, /* 200-209 */
|
|
|
|
056561, 056563, 061313, 061315, 061316, 061351, 061353, 061356, 061361, 061363, /* 210-219 */
|
|
|
|
061365, 061513, 061515, 061516, 061531, 061535, 061536, 061561, 061563, 061565, /* 220-229 */
|
|
|
|
061615, 061631, 061635, 061651, 061653, 063131, 063135, 063136, 063151, 063153, /* 230-239 */
|
|
|
|
063156, 063161, 063163, 063165, 063513, 063515, 063516, 063531, 063535, 063536, /* 240-249 */
|
|
|
|
063561, 063563, 063565, 063613, 063615, 063631, 063635, 063651, 063653, 065131, /* 250-259 */
|
|
|
|
065135, 065136, 065151, 065153, 065156, 065161, 065163, 065165, 065313, 065315, /* 260-269 */
|
|
|
|
065316, 065351, 065353, 065356, 065361, 065363, 065365, 065613, 065615, 065631, /* 270-279 */
|
|
|
|
065635, 065651, 065653, 056565, 051515 /* 280-284 */
|
2019-12-16 11:26:57 +13:00
|
|
|
};
|
|
|
|
|
2019-12-16 01:58:59 +13:00
|
|
|
/* The following adapted from ECC283.C "RSEC codeword generator"
|
|
|
|
* from Annex B of Ultracode draft
|
|
|
|
* originally written by Ted Williams of Symbol Vision Corp.
|
|
|
|
* Dated 2001-03-09
|
|
|
|
* Corrected thanks to input from Terry Burton */
|
|
|
|
|
2021-09-27 11:55:16 +13:00
|
|
|
/*
|
2020-03-30 10:23:07 +13:00
|
|
|
* NOTE: Included here is an attempt to allow code compression within Ultracode. Unfortunately
|
|
|
|
* the copy of the standard this was written from was an early draft which includes self
|
|
|
|
* contradictions, so this is a "best guess" implementation. Because it is not guaranteed
|
|
|
|
* to be correct this compression is not applied by default. To enable compression set
|
2021-09-27 11:55:16 +13:00
|
|
|
*
|
2020-04-07 23:48:29 +12:00
|
|
|
* symbol->option_3 = ULTRA_COMPRESSION;
|
2021-09-27 11:55:16 +13:00
|
|
|
*
|
2020-03-30 10:35:25 +13:00
|
|
|
* Code compression should be enabled by default when it has been implemented according to
|
2020-03-30 10:23:07 +13:00
|
|
|
* a more reliable version of the specification.
|
|
|
|
*/
|
|
|
|
|
2019-12-16 01:58:59 +13:00
|
|
|
/* Generate divisor polynomial gQ(x) for GF283() given the required ECC size, 3 to 101 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static void ult_genPoly(const short EccSize, unsigned short gPoly[], const unsigned short gfPwr[],
|
|
|
|
const unsigned short gfLog[]) {
|
2019-12-16 01:58:59 +13:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
gPoly[0] = 1;
|
|
|
|
for (i = 1; i < (EccSize + 1); i++) gPoly[i] = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < EccSize; i++) {
|
|
|
|
for (j = i; j >= 0; j--)
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
gPoly[j + 1] = (gPoly[j] + ULT_GFMUL(gPoly[j + 1], gfPwr[i + 1])) % 283;
|
|
|
|
gPoly[0] = ULT_GFMUL(gPoly[0], gfPwr[i + 1]);
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
|
|
|
for (i = EccSize - 1; i >= 0; i -= 2) gPoly[i] = 283 - gPoly[i];
|
|
|
|
|
|
|
|
/* gPoly[i] is > 0 so modulo operation not needed */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Generate the log and antilog tables for GF283() multiplication & division */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static void ult_initLogTables(unsigned short gfPwr[], unsigned short gfLog[]) {
|
2019-12-16 01:58:59 +13:00
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (j = 0; j < 283; j++) gfLog[j] = 0;
|
|
|
|
i = 1;
|
|
|
|
for (j = 0; j < 282; j++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
/* j + 282 indices save doing the modulo operation in ULT_GFMUL */
|
2019-12-16 01:58:59 +13:00
|
|
|
gfPwr[j + 282] = gfPwr[j] = (short) i;
|
|
|
|
gfLog[i] = (short) j;
|
|
|
|
i = (i * 3) % 283;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static void ult_gf283(const short DataSize, const short EccSize, int Message[]) {
|
2019-12-16 01:58:59 +13:00
|
|
|
/* Input is complete message codewords in array Message[282]
|
|
|
|
* DataSize is number of message codewords
|
|
|
|
* EccSize is number of Reed-Solomon GF(283) check codewords to generate
|
|
|
|
*
|
|
|
|
* Upon exit, Message[282] contains complete 282 codeword Symbol Message
|
|
|
|
* including leading zeroes corresponding to each truncated codeword */
|
|
|
|
|
|
|
|
unsigned short gPoly[283], gfPwr[(282 * 2)], gfLog[283];
|
|
|
|
int i, j, n;
|
|
|
|
unsigned short t;
|
|
|
|
|
|
|
|
/* first build the log & antilog tables used in multiplication & division */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ult_initLogTables(gfPwr, gfLog);
|
2019-12-16 01:58:59 +13:00
|
|
|
|
|
|
|
/* then generate the division polynomial of length EccSize */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ult_genPoly(EccSize, gPoly, gfPwr, gfLog);
|
2019-12-16 01:58:59 +13:00
|
|
|
|
|
|
|
/* zero all EccSize codeword values */
|
|
|
|
for (j = 281; (j > (281 - EccSize)); j--) Message[j] = 0;
|
|
|
|
|
|
|
|
/* shift message codewords to the right, leave space for ECC checkwords */
|
|
|
|
for (i = DataSize - 1; (i >= 0); j--, i--) Message[j] = Message[i];
|
|
|
|
|
|
|
|
/* add zeroes to pad left end Message[] for truncated codewords */
|
|
|
|
j++;
|
|
|
|
for (i = 0; i < j; i++) Message[i] = 0;
|
|
|
|
|
|
|
|
/* generate (EccSize) Reed-Solomon checkwords */
|
|
|
|
for (n = j; n < (j + DataSize); n++) {
|
|
|
|
t = (Message[j + DataSize] + Message[n]) % 283;
|
|
|
|
for (i = 0; i < (EccSize - 1); i++) {
|
|
|
|
Message[j + DataSize + i] = (Message[j + DataSize + i + 1] + 283
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
- ULT_GFMUL(t, gPoly[EccSize - 1 - i])) % 283;
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
Message[j + DataSize + EccSize - 1] = (283 - ULT_GFMUL(t, gPoly[0])) % 283;
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
|
|
|
for (i = j + DataSize; i < (j + DataSize + EccSize); i++)
|
|
|
|
Message[i] = (283 - Message[i]) % 283;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of Ted Williams code */
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static int ult_find_fragment(const unsigned char source[], const int length, const int position) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int retval = -1;
|
2020-04-29 08:00:43 +12:00
|
|
|
int j, k, latch, fraglen;
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
for (j = 0; j < 27; j++) {
|
|
|
|
latch = 0;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fraglen = (int) strlen(ult_fragment[j]);
|
|
|
|
if ((position + fraglen) <= length) {
|
2019-12-11 10:15:23 +13:00
|
|
|
latch = 1;
|
2020-04-29 08:00:43 +12:00
|
|
|
for (k = 0; k < fraglen; k++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (source[position + k] != ult_fragment[j][k]) {
|
2019-12-11 10:15:23 +13:00
|
|
|
latch = 0;
|
2020-04-21 06:17:15 +12:00
|
|
|
break;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (latch) {
|
|
|
|
retval = j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode characters in 8-bit mode */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static float ult_look_ahead_eightbit(const unsigned char source[], const int length, const int in_locn,
|
|
|
|
const int current_mode, const int end_char, int cw[], int *cw_len, const int gs1) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int codeword_count = 0;
|
|
|
|
int i;
|
|
|
|
int letters_encoded = 0;
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (current_mode != ULT_EIGHTBIT_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 282; /* Unlatch */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count += 1;
|
|
|
|
}
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
i = in_locn;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
while ((i < length) && (i < end_char)) {
|
2019-12-12 10:10:07 +13:00
|
|
|
if ((source[i] == '[') && gs1) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 268; /* FNC1 */
|
2019-12-12 10:10:07 +13:00
|
|
|
} else {
|
|
|
|
cw[codeword_count] = source[i];
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
i++;
|
|
|
|
codeword_count++;
|
2020-04-29 01:11:49 +12:00
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
letters_encoded = i - in_locn;
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
*cw_len = codeword_count;
|
|
|
|
|
|
|
|
if (codeword_count == 0) {
|
2021-10-21 11:05:30 +13:00
|
|
|
return 0.0f;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
2021-08-10 23:04:25 +12:00
|
|
|
return (float) letters_encoded / (float) codeword_count;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode character in the ASCII mode/submode (including numeric compression) */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static float ult_look_ahead_ascii(unsigned char source[], const int length, const int in_locn,
|
|
|
|
const int current_mode, const int symbol_mode, const int end_char, int cw[], int *cw_len, int *encoded,
|
|
|
|
const int gs1) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int codeword_count = 0;
|
|
|
|
int i;
|
2020-04-10 09:08:54 +12:00
|
|
|
int first_digit, second_digit, done;
|
2019-12-11 10:15:23 +13:00
|
|
|
int letters_encoded = 0;
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (current_mode == ULT_EIGHTBIT_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 267; /* Latch ASCII Submode */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (current_mode == ULT_C43_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 282; /* Unlatch */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (symbol_mode == ULT_EIGHTBIT_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 267; /* Latch ASCII Submode */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
i = in_locn;
|
2019-12-11 10:15:23 +13:00
|
|
|
do {
|
|
|
|
/* Check for double digits */
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 0;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (i + 1 < length) {
|
|
|
|
first_digit = posn(ult_digit, source[i]);
|
|
|
|
second_digit = posn(ult_digit, source[i + 1]);
|
2019-12-11 10:15:23 +13:00
|
|
|
if ((first_digit != -1) && (second_digit != -1)) {
|
|
|
|
/* Double digit can be encoded */
|
|
|
|
if ((first_digit >= 0) && (first_digit <= 9) && (second_digit >= 0) && (second_digit <= 9)) {
|
|
|
|
/* Double digit numerics */
|
|
|
|
cw[codeword_count] = (10 * first_digit) + second_digit + 128;
|
|
|
|
codeword_count++;
|
|
|
|
i += 2;
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 1;
|
2019-12-11 10:15:23 +13:00
|
|
|
} else if ((first_digit >= 0) && (first_digit <= 9) && (second_digit == 10)) {
|
|
|
|
/* Single digit followed by selected decimal point character */
|
|
|
|
cw[codeword_count] = first_digit + 228;
|
|
|
|
codeword_count++;
|
|
|
|
i += 2;
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 1;
|
2019-12-11 10:15:23 +13:00
|
|
|
} else if ((first_digit == 10) && (second_digit >= 0) && (second_digit <= 9)) {
|
|
|
|
/* Selected decimal point character followed by single digit */
|
|
|
|
cw[codeword_count] = second_digit + 238;
|
|
|
|
codeword_count++;
|
|
|
|
i += 2;
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 1;
|
2020-04-21 06:17:15 +12:00
|
|
|
} else if ((first_digit >= 0) && (first_digit <= 9) && (second_digit == 11)) {
|
2019-12-11 10:15:23 +13:00
|
|
|
/* Single digit or decimal point followed by field deliminator */
|
|
|
|
cw[codeword_count] = first_digit + 248;
|
|
|
|
codeword_count++;
|
|
|
|
i += 2;
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 1;
|
2020-04-21 06:17:15 +12:00
|
|
|
} else if ((first_digit == 11) && (second_digit >= 0) && (second_digit <= 9)) {
|
2019-12-11 10:15:23 +13:00
|
|
|
/* Field deliminator followed by single digit or decimal point */
|
|
|
|
cw[codeword_count] = second_digit + 259;
|
|
|
|
codeword_count++;
|
|
|
|
i += 2;
|
2020-04-10 09:08:54 +12:00
|
|
|
done = 1;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-10 09:08:54 +12:00
|
|
|
if (!done && source[i] < 0x80) {
|
2019-12-12 10:10:07 +13:00
|
|
|
if ((source[i] == '[') && gs1) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 272; /* FNC1 */
|
2019-12-12 10:10:07 +13:00
|
|
|
} else {
|
|
|
|
cw[codeword_count] = source[i];
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
i++;
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} while ((i < length) && (i < end_char) && (source[i] < 0x80));
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
letters_encoded = i - in_locn;
|
2020-04-10 09:08:54 +12:00
|
|
|
if (encoded != NULL) {
|
|
|
|
*encoded = letters_encoded;
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
*cw_len = codeword_count;
|
|
|
|
|
|
|
|
if (codeword_count == 0) {
|
2021-10-21 11:05:30 +13:00
|
|
|
return 0.0f;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
2021-08-10 23:04:25 +12:00
|
|
|
return (float) letters_encoded / (float) codeword_count;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
|
2020-04-21 06:17:15 +12:00
|
|
|
/* Returns true if should latch to subset other than given `subset` */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static int ult_c43_should_latch_other(const unsigned char source[], const int length, const int locn,
|
|
|
|
const int subset, const int gs1) {
|
2020-12-23 23:57:24 +13:00
|
|
|
int i, fraglen, predict_window;
|
2020-04-21 06:17:15 +12:00
|
|
|
int cnt, alt_cnt, fragno;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
const char *const set = subset == 1 ? ult_c43_set1 : ult_c43_set2;
|
|
|
|
const char *const alt_set = subset == 2 ? ult_c43_set1 : ult_c43_set2;
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2020-04-21 06:17:15 +12:00
|
|
|
if (locn + 3 > length) {
|
|
|
|
return 0;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
2020-04-21 06:17:15 +12:00
|
|
|
predict_window = locn + 3;
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2020-04-21 06:17:15 +12:00
|
|
|
for (i = locn, cnt = 0, alt_cnt = 0; i < predict_window; i++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (source[i] <= 0x1F || source[i] >= 0x7F || (gs1 && source[i] == '[')) {
|
2020-04-21 06:17:15 +12:00
|
|
|
break;
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fragno = ult_find_fragment(source, length, i);
|
2020-04-21 06:17:15 +12:00
|
|
|
if (fragno != -1 && fragno != 26) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fraglen = (int) strlen(ult_fragment[fragno]);
|
2020-04-21 06:17:15 +12:00
|
|
|
predict_window += fraglen;
|
|
|
|
if (predict_window > length) {
|
|
|
|
predict_window = length;
|
|
|
|
}
|
|
|
|
i += fraglen - 1;
|
|
|
|
} else {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (posn(set, source[i]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
cnt++;
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (posn(alt_set, source[i]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
alt_cnt++;
|
|
|
|
}
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
|
2020-04-21 06:17:15 +12:00
|
|
|
return alt_cnt > cnt;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static int ult_get_subset(const unsigned char source[], const int length, const int in_locn,
|
|
|
|
const int current_subset) {
|
2020-04-21 06:17:15 +12:00
|
|
|
int fragno;
|
|
|
|
int subset = 0;
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fragno = ult_find_fragment(source, length, in_locn);
|
2019-12-11 10:15:23 +13:00
|
|
|
if ((fragno != -1) && (fragno != 26)) {
|
|
|
|
subset = 3;
|
2020-04-21 06:17:15 +12:00
|
|
|
} else if (current_subset == 2) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (posn(ult_c43_set2, source[in_locn]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
subset = 2;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} else if (posn(ult_c43_set1, source[in_locn]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
subset = 1;
|
|
|
|
}
|
|
|
|
} else {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (posn(ult_c43_set1, source[in_locn]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
subset = 1;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} else if (posn(ult_c43_set2, source[in_locn]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
subset = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subset == 0) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (posn(ult_c43_set3, source[in_locn]) != -1) {
|
2020-04-21 06:17:15 +12:00
|
|
|
subset = 3;
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
return subset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encode characters in the C43 compaction submode */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static float ult_look_ahead_c43(const unsigned char source[], const int length, const int in_locn,
|
|
|
|
const int current_mode, const int end_char, int subset, int cw[], int *cw_len, int *encoded,
|
|
|
|
const int gs1, const int debug_print) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int codeword_count = 0;
|
|
|
|
int subcodeword_count = 0;
|
|
|
|
int i;
|
|
|
|
int fragno;
|
2019-12-19 07:33:18 +13:00
|
|
|
int sublocn = in_locn;
|
2019-12-11 10:15:23 +13:00
|
|
|
int new_subset;
|
|
|
|
int unshift_set;
|
|
|
|
int base43_value;
|
|
|
|
int letters_encoded = 0;
|
|
|
|
int pad;
|
2022-07-15 03:01:30 +12:00
|
|
|
int *subcw = (int *) z_alloca(sizeof(int) * (length + 3) * 2);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (current_mode == ULT_EIGHTBIT_MODE) {
|
2019-12-11 10:15:23 +13:00
|
|
|
/* Check for permissable URL C43 macro sequences, otherwise encode directly */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fragno = ult_find_fragment(source, length, sublocn);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
if ((fragno == 2) || (fragno == 3)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* http://www. > http:// */
|
|
|
|
/* https://www. > https:// */
|
2019-12-11 10:15:23 +13:00
|
|
|
fragno -= 2;
|
|
|
|
}
|
|
|
|
|
2021-08-10 23:04:25 +12:00
|
|
|
switch (fragno) {
|
2022-07-15 03:01:30 +12:00
|
|
|
case 17: /* mailto: */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 276;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
2022-07-15 03:01:30 +12:00
|
|
|
case 18: /* tel: */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 277;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
2022-07-15 03:01:30 +12:00
|
|
|
case 26: /* file: */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 278;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
2022-07-15 03:01:30 +12:00
|
|
|
case 0: /* http:// */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 279;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
2022-07-15 03:01:30 +12:00
|
|
|
case 1: /* https:// */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 280;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
2022-07-15 03:01:30 +12:00
|
|
|
case 4: /* ftp:// */
|
2019-12-11 10:15:23 +13:00
|
|
|
cw[codeword_count] = 281;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (subset == 1) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 260; /* C43 Compaction Submode C1 */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if ((subset == 2) || (subset == 3)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 266; /* C43 Compaction Submode C2 */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} else if (current_mode == ULT_ASCII_MODE) {
|
2019-12-11 10:15:23 +13:00
|
|
|
if (subset == 1) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 278; /* C43 Compaction Submode C1 */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if ((subset == 2) || (subset == 3)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
cw[codeword_count] = 280; /* C43 Compaction Submode C2 */
|
2019-12-11 10:15:23 +13:00
|
|
|
codeword_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
unshift_set = subset;
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
while ((sublocn < length) && (sublocn < end_char)) {
|
2020-04-21 06:17:15 +12:00
|
|
|
/* Check for FNC1 */
|
|
|
|
if (gs1 && source[sublocn] == '[') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
new_subset = ult_get_subset(source, length, sublocn, subset);
|
2020-04-21 06:17:15 +12:00
|
|
|
|
|
|
|
if (new_subset == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((new_subset != subset) && ((new_subset == 1) || (new_subset == 2))) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (ult_c43_should_latch_other(source, length, sublocn, subset, gs1)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = 42; /* Latch to other C43 set */
|
2020-04-21 06:17:15 +12:00
|
|
|
subcodeword_count++;
|
|
|
|
unshift_set = new_subset;
|
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = 40; /* Shift to other C43 set for 1 char */
|
2020-04-21 06:17:15 +12:00
|
|
|
subcodeword_count++;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
subcw[subcodeword_count] = posn(new_subset == 1 ? ult_c43_set1 : ult_c43_set2, source[sublocn]);
|
2020-04-21 06:17:15 +12:00
|
|
|
subcodeword_count++;
|
|
|
|
sublocn++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subset = new_subset;
|
|
|
|
|
2019-12-11 10:15:23 +13:00
|
|
|
if (subset == 1) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
subcw[subcodeword_count] = posn(ult_c43_set1, source[sublocn]);
|
2019-12-11 10:15:23 +13:00
|
|
|
subcodeword_count++;
|
2019-12-19 07:33:18 +13:00
|
|
|
sublocn++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if (subset == 2) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
subcw[subcodeword_count] = posn(ult_c43_set2, source[sublocn]);
|
2019-12-11 10:15:23 +13:00
|
|
|
subcodeword_count++;
|
2019-12-19 07:33:18 +13:00
|
|
|
sublocn++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if (subset == 3) {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = 41; /* Shift to set 3 */
|
2019-12-11 10:15:23 +13:00
|
|
|
subcodeword_count++;
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
fragno = ult_find_fragment(source, length, sublocn);
|
2021-08-10 23:04:25 +12:00
|
|
|
if (fragno != -1 && fragno != 26) {
|
|
|
|
if (fragno <= 18) {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = fragno; /* C43 Set 3 codewords 0 to 18 */
|
2021-08-10 23:04:25 +12:00
|
|
|
subcodeword_count++;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2021-08-10 23:04:25 +12:00
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = fragno + 17; /* C43 Set 3 codewords 36 to 42 */
|
2021-08-10 23:04:25 +12:00
|
|
|
subcodeword_count++;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
sublocn += (int) strlen(ult_fragment[fragno]);
|
2021-08-10 23:04:25 +12:00
|
|
|
}
|
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* C43 Set 3 codewords 19 to 35 */
|
|
|
|
subcw[subcodeword_count] = posn(ult_c43_set3, source[sublocn]) + 19;
|
2019-12-11 10:15:23 +13:00
|
|
|
subcodeword_count++;
|
2019-12-19 07:33:18 +13:00
|
|
|
sublocn++;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
subset = unshift_set;
|
|
|
|
}
|
2020-06-05 05:45:25 +12:00
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
pad = 3 - (subcodeword_count % 3);
|
|
|
|
if (pad == 3) {
|
|
|
|
pad = 0;
|
|
|
|
}
|
2020-03-30 10:23:07 +13:00
|
|
|
|
2019-12-11 10:15:23 +13:00
|
|
|
for (i = 0; i < pad; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
subcw[subcodeword_count] = 42; /* Latch to other C43 set used as pad */
|
2019-12-11 10:15:23 +13:00
|
|
|
subcodeword_count++;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
|
|
|
printf("C43 codewords %.*s: (%d)", length, source + in_locn, subcodeword_count);
|
2020-04-21 06:17:15 +12:00
|
|
|
for (i = 0; i < subcodeword_count; i++) printf( " %d", subcw[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
letters_encoded = sublocn - in_locn;
|
2020-04-10 09:08:54 +12:00
|
|
|
if (encoded != NULL) {
|
|
|
|
*encoded = letters_encoded;
|
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
for (i = 0; i < subcodeword_count; i += 3) {
|
|
|
|
base43_value = (43 * 43 * subcw[i]) + (43 * subcw[i + 1]) + subcw[i + 2];
|
|
|
|
cw[codeword_count] = base43_value / 282;
|
|
|
|
codeword_count++;
|
|
|
|
cw[codeword_count] = base43_value % 282;
|
|
|
|
codeword_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*cw_len = codeword_count;
|
|
|
|
|
|
|
|
if (codeword_count == 0) {
|
2021-10-21 11:05:30 +13:00
|
|
|
return 0.0f;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
2021-08-10 23:04:25 +12:00
|
|
|
return (float) letters_encoded / (float) codeword_count;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Produces a set of codewords which are "somewhat" optimised - this could be improved on */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
static int ult_generate_codewords(struct zint_symbol *symbol, const unsigned char source[], const int length,
|
|
|
|
const int eci, const int gs1, const int symbol_mode, int *p_current_mode, int codewords[],
|
|
|
|
int codeword_count) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int i;
|
|
|
|
int crop_length;
|
2019-12-19 07:33:18 +13:00
|
|
|
int input_locn = 0;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
int current_mode;
|
2020-04-21 06:17:15 +12:00
|
|
|
int subset;
|
2019-12-11 10:15:23 +13:00
|
|
|
float eightbit_score;
|
|
|
|
float ascii_score;
|
|
|
|
float c43_score;
|
|
|
|
int end_char;
|
|
|
|
int block_length;
|
|
|
|
int fragment_length;
|
2020-04-10 09:08:54 +12:00
|
|
|
int ascii_encoded, c43_encoded;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
const int debug_print = (symbol->debug & ZINT_DEBUG_PRINT);
|
2022-07-15 03:01:30 +12:00
|
|
|
unsigned char *crop_source = (unsigned char *) z_alloca(length + 1);
|
|
|
|
char *mode = (char *) z_alloca(length + 1);
|
|
|
|
int *cw_fragment = (int *) z_alloca(sizeof(int) * (length * 2 + 1));
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2019-12-12 10:10:07 +13:00
|
|
|
/* Check for 06 Macro Sequence and crop accordingly */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (length >= 9
|
2019-12-12 10:10:07 +13:00
|
|
|
&& source[0] == '[' && source[1] == ')' && source[2] == '>' && source[3] == '\x1e'
|
|
|
|
&& source[4] == '0' && source[5] == '6' && source[6] == '\x1d'
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
&& source[length - 2] == '\x1e' && source[length - 1] == '\x04') {
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (symbol_mode == ULT_EIGHTBIT_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[codeword_count] = 271; /* 06 Macro */
|
2021-08-10 23:04:25 +12:00
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[codeword_count] = 273; /* 06 Macro */
|
2021-08-10 23:04:25 +12:00
|
|
|
}
|
|
|
|
codeword_count++;
|
2019-12-12 10:10:07 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
for (i = 7; i < (length - 2); i++) {
|
2021-08-10 23:04:25 +12:00
|
|
|
crop_source[i - 7] = source[i];
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
crop_length = length - 9;
|
2021-08-10 23:04:25 +12:00
|
|
|
crop_source[crop_length] = '\0';
|
2019-12-12 10:10:07 +13:00
|
|
|
} else {
|
|
|
|
/* Make a cropped version of input data - removes http:// and https:// if needed */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
for (i = input_locn; i < length; i++) {
|
2019-12-19 07:33:18 +13:00
|
|
|
crop_source[i - input_locn] = source[i];
|
2019-12-12 10:10:07 +13:00
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
crop_length = length - input_locn;
|
2019-12-12 10:10:07 +13:00
|
|
|
crop_source[crop_length] = '\0';
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:15:23 +13:00
|
|
|
/* Attempt encoding in all three modes to see which offers best compaction and store results */
|
2020-04-10 09:08:54 +12:00
|
|
|
if (symbol->option_3 == ULTRA_COMPRESSION || gs1) {
|
2020-03-30 10:23:07 +13:00
|
|
|
current_mode = symbol_mode;
|
|
|
|
input_locn = 0;
|
|
|
|
do {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
end_char = input_locn + ULT_PREDICT_WINDOW;
|
|
|
|
eightbit_score = ult_look_ahead_eightbit(crop_source, crop_length, input_locn, current_mode, end_char,
|
2021-06-10 22:15:39 +12:00
|
|
|
cw_fragment, &fragment_length, gs1);
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ascii_score = ult_look_ahead_ascii(crop_source, crop_length, input_locn, current_mode, symbol_mode,
|
2021-06-10 22:15:39 +12:00
|
|
|
end_char, cw_fragment, &fragment_length, &ascii_encoded, gs1);
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
subset = ult_c43_should_latch_other(crop_source, crop_length, input_locn, 1 /*subset*/, gs1) ? 2 : 1;
|
|
|
|
c43_score = ult_look_ahead_c43(crop_source, crop_length, input_locn, current_mode, end_char,
|
|
|
|
subset, cw_fragment, &fragment_length, &c43_encoded, gs1, 0 /*debug_print*/);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2020-03-30 10:23:07 +13:00
|
|
|
mode[input_locn] = 'a';
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
current_mode = ULT_ASCII_MODE;
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2020-03-30 10:23:07 +13:00
|
|
|
if ((c43_score > ascii_score) && (c43_score > eightbit_score)) {
|
|
|
|
mode[input_locn] = 'c';
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
current_mode = ULT_C43_MODE;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if ((eightbit_score > ascii_score) && (eightbit_score > c43_score)) {
|
2020-03-30 10:23:07 +13:00
|
|
|
mode[input_locn] = '8';
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
current_mode = ULT_EIGHTBIT_MODE;
|
2020-03-30 10:23:07 +13:00
|
|
|
}
|
2020-04-10 09:08:54 +12:00
|
|
|
if (mode[input_locn] == 'a') {
|
|
|
|
for (i = 0; i < ascii_encoded; i++) {
|
|
|
|
mode[input_locn + i] = 'a';
|
|
|
|
}
|
|
|
|
input_locn += ascii_encoded;
|
|
|
|
} else if (mode[input_locn] == 'c') {
|
|
|
|
for (i = 0; i < c43_encoded; i++) {
|
|
|
|
mode[input_locn + i] = 'c';
|
|
|
|
}
|
|
|
|
input_locn += c43_encoded;
|
|
|
|
} else {
|
|
|
|
input_locn++;
|
|
|
|
}
|
2020-03-30 10:23:07 +13:00
|
|
|
} while (input_locn < crop_length);
|
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Force eight-bit mode */
|
2020-03-30 10:23:07 +13:00
|
|
|
for (input_locn = 0; input_locn < crop_length; input_locn++) {
|
2019-12-19 07:33:18 +13:00
|
|
|
mode[input_locn] = '8';
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
2020-03-30 10:23:07 +13:00
|
|
|
}
|
2020-04-16 12:35:37 +12:00
|
|
|
mode[crop_length] = '\0';
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
printf("Mode (%d): %s\n", (int) strlen(mode), mode);
|
2020-04-10 09:08:54 +12:00
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (symbol_mode == ULT_EIGHTBIT_MODE && *p_current_mode != ULT_EIGHTBIT_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[codeword_count++] = 282; /* Unlatch to 8-bit mode */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eci) {
|
|
|
|
if (eci < 899) {
|
|
|
|
codewords[codeword_count++] = 272;
|
|
|
|
codewords[codeword_count++] = eci / 256;
|
|
|
|
codewords[codeword_count++] = eci % 256;
|
|
|
|
} else if (eci < 10000) {
|
|
|
|
codewords[codeword_count++] = 274;
|
|
|
|
codewords[codeword_count++] = eci / 100 + 128;
|
|
|
|
codewords[codeword_count++] = eci % 100 + 128;
|
|
|
|
} else {
|
|
|
|
codewords[codeword_count++] = 275;
|
|
|
|
codewords[codeword_count++] = eci / 10000 + 128;
|
|
|
|
codewords[codeword_count++] = (eci % 10000) / 100 + 128;
|
|
|
|
codewords[codeword_count++] = eci % 100 + 128;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:15:23 +13:00
|
|
|
/* Use results from test to perform actual mode switching */
|
|
|
|
current_mode = symbol_mode;
|
2019-12-19 07:33:18 +13:00
|
|
|
input_locn = 0;
|
2019-12-11 10:15:23 +13:00
|
|
|
do {
|
2020-04-29 01:11:49 +12:00
|
|
|
fragment_length = 0;
|
2019-12-11 10:15:23 +13:00
|
|
|
block_length = 0;
|
2020-04-29 01:11:49 +12:00
|
|
|
while (input_locn + block_length < crop_length && mode[input_locn + block_length] == mode[input_locn]) {
|
2019-12-11 10:15:23 +13:00
|
|
|
block_length++;
|
2020-04-29 01:11:49 +12:00
|
|
|
}
|
2019-12-11 10:15:23 +13:00
|
|
|
|
2021-08-10 23:04:25 +12:00
|
|
|
switch (mode[input_locn]) {
|
2019-12-11 10:15:23 +13:00
|
|
|
case 'a':
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ult_look_ahead_ascii(crop_source, crop_length, input_locn, current_mode, symbol_mode,
|
|
|
|
input_locn + block_length, cw_fragment, &fragment_length, NULL, gs1);
|
|
|
|
current_mode = ULT_ASCII_MODE;
|
2019-12-11 10:15:23 +13:00
|
|
|
break;
|
|
|
|
case 'c':
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
subset = ult_c43_should_latch_other(crop_source, crop_length, input_locn, 1 /*subset*/, gs1) ? 2 : 1;
|
|
|
|
ult_look_ahead_c43(crop_source, crop_length, input_locn, current_mode, input_locn + block_length,
|
|
|
|
subset, cw_fragment, &fragment_length, NULL, gs1, debug_print);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
|
|
|
/* Substitute temporary latch if possible */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (current_mode == ULT_EIGHTBIT_MODE && cw_fragment[0] == 260 && fragment_length >= 5
|
|
|
|
&& fragment_length <= 11) {
|
|
|
|
cw_fragment[0] = 256 + (fragment_length - 5) / 2; /* Temporary latch to submode 1 from Table 11 */
|
|
|
|
} else if (current_mode == ULT_EIGHTBIT_MODE && cw_fragment[0] == 266 && fragment_length >= 5
|
|
|
|
&& fragment_length <= 11) {
|
|
|
|
cw_fragment[0] = 262 + (fragment_length - 5) / 2; /* Temporary latch to submode 2 from Table 11 */
|
|
|
|
} else if (current_mode == ULT_ASCII_MODE && cw_fragment[0] == 278 && fragment_length >= 5
|
|
|
|
&& fragment_length <= 11) {
|
|
|
|
cw_fragment[0] = 274 + (fragment_length - 5) / 2; /* Temporary latch to submode 1 from Table 9 */
|
2019-12-11 10:15:23 +13:00
|
|
|
} else {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
current_mode = ULT_C43_MODE;
|
2019-12-11 10:15:23 +13:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '8':
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ult_look_ahead_eightbit(crop_source, crop_length, input_locn, current_mode, input_locn + block_length,
|
|
|
|
cw_fragment, &fragment_length, gs1);
|
|
|
|
current_mode = ULT_EIGHTBIT_MODE;
|
2019-12-11 10:15:23 +13:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < fragment_length; i++) {
|
|
|
|
codewords[codeword_count + i] = cw_fragment[i];
|
|
|
|
}
|
|
|
|
codeword_count += fragment_length;
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
input_locn += block_length;
|
|
|
|
} while (input_locn < crop_length);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
*p_current_mode = current_mode;
|
|
|
|
|
|
|
|
return codeword_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call `ult_generate_codewords()` for each segment, dealing with symbol mode and start codeword beforehand */
|
|
|
|
static int ult_generate_codewords_segs(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count,
|
|
|
|
int codewords[]) {
|
|
|
|
int i;
|
|
|
|
int codeword_count = 0;
|
|
|
|
int symbol_mode;
|
|
|
|
int current_mode;
|
|
|
|
int have_eci = 0;
|
|
|
|
const unsigned char *source = segs[0].source;
|
|
|
|
int length = segs[0].length;
|
|
|
|
const int eci = segs[0].eci;
|
|
|
|
const int gs1 = (symbol->input_mode & 0x07) == GS1_MODE;
|
|
|
|
|
|
|
|
for (i = 0; i < seg_count; i++) {
|
|
|
|
if (segs[i].eci) {
|
|
|
|
have_eci = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_eci || (symbol->option_3 != ULTRA_COMPRESSION && !gs1)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Force eight-bit mode by default as other modes are poorly documented */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
symbol_mode = ULT_EIGHTBIT_MODE;
|
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Decide start character codeword (from Table 5) */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
symbol_mode = ULT_ASCII_MODE;
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
if (source[i] >= 0x80) {
|
|
|
|
symbol_mode = ULT_EIGHTBIT_MODE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (symbol->output_options & READER_INIT) {
|
|
|
|
/* Reader Initialisation mode */
|
|
|
|
codeword_count = 2;
|
|
|
|
if (symbol_mode == ULT_ASCII_MODE) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[0] = 272; /* 7-bit ASCII mode */
|
|
|
|
codewords[1] = 271; /* FNC3 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[0] = 257; /* 8859-1 */
|
|
|
|
codewords[1] = 269; /* FNC3 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Calculate start character codeword */
|
|
|
|
codeword_count = 1;
|
|
|
|
if (symbol_mode == ULT_ASCII_MODE) {
|
|
|
|
if (gs1) {
|
|
|
|
codewords[0] = 273;
|
|
|
|
} else {
|
|
|
|
codewords[0] = 272;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ((eci >= 3) && (eci <= 18) && (eci != 14)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* ECI indicates use of character set within ISO/IEC 8859 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[0] = 257 + (eci - 3);
|
|
|
|
if (codewords[0] > 267) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Avoids ECI 14 for non-existant ISO/IEC 8859-12 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[0]--;
|
|
|
|
}
|
|
|
|
} else if ((eci > 18) && (eci <= 898)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* ECI indicates use of character set outside ISO/IEC 8859 */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[0] = 275 + (eci / 256);
|
|
|
|
codewords[1] = eci % 256;
|
|
|
|
codeword_count = 2;
|
|
|
|
} else if (eci == 899) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Non-language byte data */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[0] = 280;
|
|
|
|
} else if ((eci > 899) && (eci <= 9999)) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* ECI beyond 899 needs to use fixed length encodable ECI invocation (section 7.6.2) */
|
|
|
|
/* Encode as 3 codewords */
|
|
|
|
codewords[0] = 257; /* ISO/IEC 8859-1 used to enter 8-bit mode */
|
|
|
|
codewords[1] = 274; /* Encode ECI as 3 codewords */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[2] = (eci / 100) + 128;
|
|
|
|
codewords[3] = (eci % 100) + 128;
|
|
|
|
codeword_count = 4;
|
|
|
|
} else if (eci >= 10000) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Encode as 4 codewords */
|
|
|
|
codewords[0] = 257; /* ISO/IEC 8859-1 used to enter 8-bit mode */
|
|
|
|
codewords[1] = 275; /* Encode ECI as 4 codewords */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
codewords[2] = (eci / 10000) + 128;
|
|
|
|
codewords[3] = ((eci % 10000) / 100) + 128;
|
|
|
|
codewords[4] = (eci % 100) + 128;
|
|
|
|
codeword_count = 5;
|
|
|
|
} else {
|
2022-07-15 03:01:30 +12:00
|
|
|
codewords[0] = 257; /* Default is assumed to be ISO/IEC 8859-1 (ECI 3) */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((codewords[0] == 257) || (codewords[0] == 272)) {
|
|
|
|
int fragno = ult_find_fragment(source, length, 0);
|
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Check for http:// at start of input */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if ((fragno == 0) || (fragno == 2)) {
|
|
|
|
codewords[0] = 281;
|
|
|
|
source += 7;
|
|
|
|
length -= 7;
|
|
|
|
symbol_mode = ULT_EIGHTBIT_MODE;
|
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Check for https:// at start of input */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
} else if ((fragno == 1) || (fragno == 3)) {
|
|
|
|
codewords[0] = 282;
|
|
|
|
source += 8;
|
|
|
|
length -= 8;
|
|
|
|
symbol_mode = ULT_EIGHTBIT_MODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
current_mode = symbol_mode;
|
|
|
|
codeword_count = ult_generate_codewords(symbol, source, length, 0 /*eci*/, gs1, symbol_mode, ¤t_mode,
|
|
|
|
codewords, codeword_count);
|
|
|
|
|
|
|
|
for (i = 1; i < seg_count; i++) {
|
|
|
|
codeword_count = ult_generate_codewords(symbol, segs[i].source, segs[i].length, segs[i].eci, gs1, symbol_mode,
|
|
|
|
¤t_mode, codewords, codeword_count);
|
|
|
|
}
|
|
|
|
|
2019-12-11 10:15:23 +13:00
|
|
|
return codeword_count;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
INTERNAL int ultra(struct zint_symbol *symbol, struct zint_seg segs[], const int seg_count) {
|
2019-12-11 10:15:23 +13:00
|
|
|
int data_cw_count = 0;
|
2019-12-18 09:22:16 +13:00
|
|
|
int acc, qcc;
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
int scr[3] = {0}, scr_cw_count = 0; /* Symbol Control Region (only if have Structured Append) */
|
|
|
|
int dr_count;
|
2019-12-16 01:58:59 +13:00
|
|
|
int ecc_level;
|
|
|
|
int rows, columns;
|
|
|
|
int total_cws;
|
|
|
|
int pads;
|
|
|
|
int cw_memalloc;
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Allow for 3 pads in final 57th (60th incl. clock tracks) column of 5-row symbol (57 * 5 == 285) */
|
2021-06-10 22:15:39 +12:00
|
|
|
int codeword[282 + 3];
|
2019-12-19 07:33:18 +13:00
|
|
|
int i, j, locn;
|
2019-12-16 11:26:57 +13:00
|
|
|
int total_height, total_width;
|
|
|
|
char tilepat[6];
|
|
|
|
int tilex, tiley;
|
2019-12-18 09:22:16 +13:00
|
|
|
int dcc;
|
2021-09-30 04:25:59 +13:00
|
|
|
int revision_idx = 0;
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
const int debug_print = (symbol->debug & ZINT_DEBUG_PRINT);
|
2021-08-10 23:04:25 +12:00
|
|
|
int *data_codewords;
|
|
|
|
char *pattern;
|
2019-12-16 01:58:59 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
(void)seg_count;
|
|
|
|
|
2019-12-18 09:22:16 +13:00
|
|
|
if (symbol->eci > 811799) {
|
2020-04-10 09:08:54 +12:00
|
|
|
strcpy(symbol->errtxt, "590: ECI value not supported by Ultracode");
|
2019-12-18 09:22:16 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
if (symbol->structapp.count) {
|
|
|
|
int link2 = 2; /* Draft Table 7, Structured Append Group (SAG) with no File Number */
|
|
|
|
|
|
|
|
if (symbol->structapp.count < 2 || symbol->structapp.count > 8) {
|
2022-11-11 11:13:41 +13:00
|
|
|
strcpy(symbol->errtxt, "596: Structured Append count out of range (2-8)");
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
if (symbol->structapp.index < 1 || symbol->structapp.index > symbol->structapp.count) {
|
2022-11-11 11:13:41 +13:00
|
|
|
sprintf(symbol->errtxt, "597: Structured Append index out of range (1-%d)", symbol->structapp.count);
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
scr_cw_count = 1;
|
|
|
|
|
|
|
|
if (symbol->structapp.id[0]) {
|
|
|
|
int id, id_len;
|
|
|
|
|
- API: add new zint_symbol `dpmm` field for output resolution (BMP/
EMF/PCX/PNG/TIF only, i.e. excluding EPS, GIF & SVG)
- Add support for specifying scale by X-dimension and resolution
with new option `--scalexdimdp` for CLI/Tcl & new API function
`ZBarcode_Scale_From_XdimDp()` (+ `ZBarcode_XdimDp_From_Scale()`
& `ZBarcode_Default_Xdim()`) and new GUI popup; manual: document
- BMP/EMF/PCX/PNG/TIF: use new `dpmm` resolution field (for EMF
following Inkscape)
- backend_qt: add `dpmm()`, `vectorWidth()`, `vectorHeight()`,
`noPng()`, `getVersion()`, `takesGS1AIData()`, & `XdimDp` stuff
incl. new `QZintXdimDp` struct for passing around scale vars &
use in `getAsCLI()`; add comments
- Raise `scale` limit to 200 (from 100) to allow for large dpmm
- output: create directories & subdirectories as necessary for
output path using new function `out_fopen()` and use in BMP/EMF/
EPS/GIF/PCX/PNG/SVG/TIF
- DPLEIT/DPIDENT: format HRT according to (incomplete)
documentation, and set default height to 72X (from 50X)
- CODE128B renamed to CODE128AB as can use subsets A and/or B
- CODABAR: fix minimum height calc
- EMF: fix indexing of handles (zero-based not 1-based)
- GUI: fix symbology zap (previous technique of clearing and
re-loading settings without doing a sync no longer works);
fix UPCEAN guard descent enable
- MAILMARK: better error message if input < 14 characters
- GUI: add "Default" button for DAFT tracker ratio & enable/disable
various default buttons; use new `takesGS1AIData()` to
enable/disable GS1-specific checkboxes
- CLI: use new `validate_float()` to parse float options (7
significant digits allowed only, no scientific notation)
- DATAMATRIX/GRIDMATRIX/PDF417/QR/ULTRA: micro-optimize structapp
ID parse
- library/CLI: fiddle with static asserts (make CHAR_BIT sensitive,
supposedly)
- win32/README: update building libpng (assembly removed)
- README.linux: document incompatibility of Qt6 >= 6.3
- manual: expand Barcode Studio waffle
- test suite: change range separator to hyphen and allow multiple
excludes
2022-12-03 10:39:01 +13:00
|
|
|
for (id_len = 1; id_len < 6 && symbol->structapp.id[id_len]; id_len++);
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
|
|
|
|
if (id_len > 5) { /* 282 * 283 + 282 = 80088 */
|
2022-11-11 11:13:41 +13:00
|
|
|
strcpy(symbol->errtxt, "593: Structured Append ID too long (5 digit maximum)");
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = to_int((const unsigned char *) symbol->structapp.id, id_len);
|
|
|
|
if (id == -1) {
|
2022-11-11 11:13:41 +13:00
|
|
|
strcpy(symbol->errtxt, "594: Invalid Structured Append ID (digits only)");
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
if (id > 80088) {
|
2022-11-11 11:13:41 +13:00
|
|
|
sprintf(symbol->errtxt, "595: Structured Append ID '%d' out of range (1-80088)", id);
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
if (id) {
|
|
|
|
link2 = 3; /* Missing from draft Table 7 but mentioned 7.4.3 - SAG with File Number */
|
|
|
|
scr[1] = id / 283;
|
|
|
|
scr[2] = id % 283; /* 7.4.3.2 says 1-282 but can be 0 if id >= 283 */
|
|
|
|
scr_cw_count += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scr[0] = link2 * 70 + (symbol->structapp.count - 1) * 8 + symbol->structapp.index - 1;
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
cw_memalloc = segs_length(segs, seg_count) * 2;
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
if (cw_memalloc < 283) {
|
|
|
|
cw_memalloc = 283;
|
|
|
|
}
|
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
data_codewords = (int *) z_alloca(sizeof(int) * cw_memalloc);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
data_cw_count = ult_generate_codewords_segs(symbol, segs, seg_count, data_codewords);
|
2019-12-11 10:15:23 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
2021-08-10 23:04:25 +12:00
|
|
|
printf("Codewords (%d):", data_cw_count);
|
|
|
|
for (i = 0; i < data_cw_count; i++) {
|
|
|
|
printf(" %d", data_codewords[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2020-03-30 10:23:07 +13:00
|
|
|
}
|
2020-04-16 12:35:37 +12:00
|
|
|
#ifdef ZINT_TEST
|
2020-04-10 09:08:54 +12:00
|
|
|
if (symbol->debug & ZINT_DEBUG_TEST) {
|
|
|
|
debug_test_codeword_dump_int(symbol, data_codewords, data_cw_count);
|
|
|
|
}
|
2020-04-10 21:28:45 +12:00
|
|
|
#endif
|
2020-04-16 12:35:37 +12:00
|
|
|
|
2022-07-15 03:01:30 +12:00
|
|
|
data_cw_count += 2 + scr_cw_count; /* 2 == MCC + ACC (data codeword count includes start char) */
|
2020-04-16 12:35:37 +12:00
|
|
|
|
2021-09-30 04:25:59 +13:00
|
|
|
if (symbol->option_2 > 0) {
|
|
|
|
if (symbol->option_2 > 2) {
|
|
|
|
strcpy(symbol->errtxt, "592: Revision must be 1 or 2");
|
|
|
|
return ZINT_ERROR_INVALID_OPTION;
|
|
|
|
}
|
|
|
|
if (symbol->option_2 == 2) { /* Revision 2, swop and inversion of DCCU/DCCL tiles */
|
|
|
|
revision_idx = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-12 10:10:07 +13:00
|
|
|
/* Default ECC level is EC2 */
|
|
|
|
if ((symbol->option_1 <= 0) || (symbol->option_1 > 6)) {
|
|
|
|
ecc_level = 2;
|
|
|
|
} else {
|
|
|
|
ecc_level = symbol->option_1 - 1;
|
|
|
|
}
|
|
|
|
|
2019-12-18 09:22:16 +13:00
|
|
|
/* ECC calculation from section 7.7.2 */
|
2019-12-12 10:10:07 +13:00
|
|
|
if (ecc_level == 0) {
|
2019-12-18 09:22:16 +13:00
|
|
|
qcc = 3;
|
2019-12-12 10:10:07 +13:00
|
|
|
} else {
|
2019-12-18 09:22:16 +13:00
|
|
|
if ((data_cw_count % 25) == 0) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
qcc = (ult_kec[ecc_level] * (data_cw_count / 25)) + 3 + 2;
|
2019-12-18 09:22:16 +13:00
|
|
|
} else {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
qcc = (ult_kec[ecc_level] * ((data_cw_count / 25) + 1)) + 3 + 2;
|
2019-12-18 09:22:16 +13:00
|
|
|
}
|
2019-12-12 10:10:07 +13:00
|
|
|
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
2021-08-10 23:04:25 +12:00
|
|
|
printf("EC%d codewords: %d\n", ecc_level + 1, qcc);
|
2020-03-30 10:23:07 +13:00
|
|
|
}
|
2019-12-12 10:10:07 +13:00
|
|
|
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
acc = qcc - 3;
|
|
|
|
if (scr_cw_count) {
|
|
|
|
acc += 70; /* Link1 = 1 (* 70) means SCR present */
|
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
printf("MCC: %d, ACC: %d, SCR: %d", data_cw_count, acc, scr_cw_count);
|
|
|
|
if (scr_cw_count) {
|
|
|
|
printf(", SCR0: %d", scr[0]);
|
|
|
|
if (scr_cw_count > 1) {
|
|
|
|
printf(", SCR1: %d, SCR2: %d", scr[1], scr[2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2019-12-12 10:10:07 +13:00
|
|
|
/* Maximum capacity is 282 codewords */
|
2022-07-15 03:01:30 +12:00
|
|
|
total_cws = data_cw_count + qcc + 3; /* 3 == TCC pattern + RSEC pattern + QCC pattern */
|
2021-08-10 23:04:25 +12:00
|
|
|
if (total_cws - 3 > 282) {
|
2020-04-10 09:08:54 +12:00
|
|
|
strcpy(symbol->errtxt, "591: Data too long for selected error correction capacity");
|
2019-12-12 10:10:07 +13:00
|
|
|
return ZINT_ERROR_TOO_LONG;
|
|
|
|
}
|
|
|
|
|
2019-12-16 01:58:59 +13:00
|
|
|
rows = 5;
|
2019-12-16 02:48:45 +13:00
|
|
|
for (i = 2; i >= 0; i--) {
|
2022-07-15 03:01:30 +12:00
|
|
|
/* Total codewords less 6 (+ SCR) overhead (Start + MCC + ACC (+ SCR) + 3 TCC/RSEC/QCC patterns) */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (total_cws - (6 + scr_cw_count) <= ult_maxsize[i]) {
|
2019-12-16 02:48:45 +13:00
|
|
|
rows--;
|
|
|
|
}
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((total_cws % rows) == 0) {
|
|
|
|
pads = 0;
|
|
|
|
columns = total_cws / rows;
|
|
|
|
} else {
|
|
|
|
pads = rows - (total_cws % rows);
|
2019-12-16 11:26:57 +13:00
|
|
|
columns = (total_cws / rows) + 1;
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
2022-07-15 03:01:30 +12:00
|
|
|
columns += columns / 15; /* Secondary vertical clock tracks */
|
2019-12-16 01:58:59 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
printf("Calculated size is %d rows by %d columns (pads %d)\n", rows, columns, pads);
|
2020-03-30 10:23:07 +13:00
|
|
|
}
|
2019-12-16 01:58:59 +13:00
|
|
|
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
/* Insert MCC and ACC and possibly SCR into data codewords */
|
|
|
|
for (i = 282; i > 2 + scr_cw_count; i--) {
|
|
|
|
data_codewords[i] = data_codewords[i - (2 + scr_cw_count)];
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
2022-07-15 03:01:30 +12:00
|
|
|
data_codewords[1] = data_cw_count; /* MCC */
|
|
|
|
data_codewords[2] = acc; /* ACC */
|
|
|
|
for (i = 0; i < scr_cw_count; i++) { /* SCR */
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
data_codewords[3 + i] = scr[i];
|
|
|
|
}
|
2019-12-16 01:58:59 +13:00
|
|
|
|
|
|
|
/* Calculate error correction codewords (RSEC) */
|
2021-09-27 11:55:16 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
ult_gf283((short) data_cw_count, (short) qcc, data_codewords);
|
2019-12-16 01:58:59 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
2021-08-10 23:04:25 +12:00
|
|
|
printf("ECCs (%d):", qcc);
|
|
|
|
for (i = 0; i < qcc; i++) {
|
|
|
|
printf(" %d", data_codewords[(282 - qcc) + i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2019-12-16 01:58:59 +13:00
|
|
|
/* Rearrange to make final codeword sequence */
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
locn = 0;
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = data_codewords[282 - (data_cw_count + qcc)]; /* Start Character */
|
|
|
|
codeword[locn++] = data_cw_count; /* MCC */
|
2019-12-18 09:22:16 +13:00
|
|
|
for (i = 0; i < qcc; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = data_codewords[(282 - qcc) + i]; /* RSEC Region */
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = data_cw_count + qcc; /* TCC = C + Q - section 6.11.4 */
|
|
|
|
codeword[locn++] = 283; /* Separator */
|
|
|
|
codeword[locn++] = acc; /* ACC */
|
|
|
|
for (i = 0; i < scr_cw_count; i++) { /* SCR */
|
Add Structured Append support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, MAXICODE, MICROPDF417, PDF417, QRCODE, ULTRA
DOTCODE: use pre-calculated generator poly coeffs in Reed-Solomon for
performance improvement
PDF417/MICROPDF417: use common routine pdf417_initial()
GUI: code lines <= 118, shorthand widget_obj(),
shorten calling upcean_addon_gap(), upcean_guard_descent()
various backend: var name debug -> debug_print
2021-09-29 09:42:44 +13:00
|
|
|
codeword[locn++] = scr[i];
|
|
|
|
}
|
|
|
|
dr_count = data_cw_count - (3 + scr_cw_count);
|
|
|
|
for (i = 0; i < dr_count; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = data_codewords[(282 - (dr_count + qcc)) + i]; /* Data Region */
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
|
|
|
for (i = 0; i < pads; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = 284; /* Pad pattern */
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
2022-07-15 03:01:30 +12:00
|
|
|
codeword[locn++] = qcc; /* QCC */
|
2019-12-16 01:58:59 +13:00
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
2020-03-30 10:23:07 +13:00
|
|
|
printf("Rearranged codewords with ECC:\n");
|
|
|
|
for (i = 0; i < locn; i++) {
|
|
|
|
printf("%d ", codeword[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
2019-12-16 01:58:59 +13:00
|
|
|
}
|
|
|
|
|
2019-12-16 11:26:57 +13:00
|
|
|
total_height = (rows * 6) + 1;
|
2020-04-16 12:35:37 +12:00
|
|
|
total_width = columns + 6;
|
2019-12-16 11:26:57 +13:00
|
|
|
|
|
|
|
/* Build symbol */
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern = (char *) z_alloca(total_height * total_width);
|
2019-12-16 11:26:57 +13:00
|
|
|
|
|
|
|
for (i = 0; i < (total_height * total_width); i++) {
|
|
|
|
pattern[i] = 'W';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Border */
|
|
|
|
for (i = 0; i < total_width; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[i] = 'K'; /* Top */
|
|
|
|
pattern[(total_height * total_width) - i - 1] = 'K'; /* Bottom */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
for (i = 0; i < total_height; i++) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[total_width * i] = 'K'; /* Left */
|
2019-12-16 11:26:57 +13:00
|
|
|
pattern[(total_width * i) + 3] = 'K';
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + (total_width - 1)] = 'K'; /* Right */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clock tracks */
|
|
|
|
for (i = 0; i < total_height; i += 2) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + 1] = 'K'; /* Primary vertical clock track */
|
2019-12-16 11:26:57 +13:00
|
|
|
if (total_width > 20) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + 19] = 'K'; /* Secondary vertical clock track */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
if (total_width > 36) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + 35] = 'K'; /* Secondary vertical clock track */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
if (total_width > 52) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + 51] = 'K'; /* Secondary vertical clock track */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 6; i < total_height; i += 6) {
|
|
|
|
for (j = 5; j < total_width; j += 2) {
|
2022-07-15 03:01:30 +12:00
|
|
|
pattern[(total_width * i) + j] = 'K'; /* Horizontal clock track */
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Place tiles */
|
|
|
|
tilepat[5] = '\0';
|
|
|
|
tilex = 0;
|
|
|
|
tiley = 0;
|
2019-12-19 07:33:18 +13:00
|
|
|
for (i = 0; i < locn; i++) {
|
2019-12-16 11:26:57 +13:00
|
|
|
for (j = 0; j < 5; j++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
tilepat[4 - j] = ult_colour[(ult_tiles[codeword[i]] >> (3 * j)) & 0x07];
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
if ((tiley + 1) >= total_height) {
|
|
|
|
tiley = 0;
|
|
|
|
tilex++;
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
if (tilex == 14) {
|
2019-12-16 11:26:57 +13:00
|
|
|
tilex++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if (tilex == 30) {
|
2019-12-16 11:26:57 +13:00
|
|
|
tilex++;
|
2021-08-10 23:04:25 +12:00
|
|
|
} else if (tilex == 46) {
|
2019-12-16 11:26:57 +13:00
|
|
|
tilex++;
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 10:23:07 +13:00
|
|
|
|
2019-12-16 11:26:57 +13:00
|
|
|
for (j = 0; j < 5; j++) {
|
|
|
|
pattern[((tiley + j + 1) * total_width) + (tilex + 5)] = tilepat[j];
|
|
|
|
}
|
|
|
|
tiley += 6;
|
|
|
|
}
|
|
|
|
|
2019-12-18 09:22:16 +13:00
|
|
|
/* Add data column count */
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
dcc = columns - ult_mincols[rows - 2];
|
2019-12-18 09:22:16 +13:00
|
|
|
tilex = 2;
|
|
|
|
tiley = (total_height - 11) / 2;
|
|
|
|
/* DCCU */
|
|
|
|
for (j = 0; j < 5; j++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
tilepat[4 - j] = ult_colour[(ult_dccu[revision_idx][dcc] >> (3 * j)) & 0x07];
|
2019-12-18 09:22:16 +13:00
|
|
|
}
|
|
|
|
for (j = 0; j < 5; j++) {
|
|
|
|
pattern[((tiley + j) * total_width) + tilex] = tilepat[j];
|
|
|
|
}
|
|
|
|
/* DCCL */
|
|
|
|
tiley += 6;
|
|
|
|
for (j = 0; j < 5; j++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
tilepat[4 - j] = ult_colour[(ult_dccl[revision_idx][dcc] >> (3 * j)) & 0x07];
|
2019-12-18 09:22:16 +13:00
|
|
|
}
|
|
|
|
for (j = 0; j < 5; j++) {
|
|
|
|
pattern[((tiley + j) * total_width) + tilex] = tilepat[j];
|
|
|
|
}
|
|
|
|
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
if (debug_print) {
|
2020-03-30 10:23:07 +13:00
|
|
|
printf("DCC: %d\n", dcc);
|
2019-12-18 09:22:16 +13:00
|
|
|
|
2020-03-30 10:23:07 +13:00
|
|
|
for (i = 0; i < (total_height * total_width); i++) {
|
|
|
|
printf("%c", pattern[i]);
|
|
|
|
if ((i + 1) % total_width == 0) {
|
|
|
|
printf("\n");
|
|
|
|
}
|
2019-12-16 11:26:57 +13:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
/* Put pattern into symbol */
|
|
|
|
symbol->rows = total_height;
|
|
|
|
symbol->width = total_width;
|
|
|
|
|
|
|
|
for (i = 0; i < total_height; i++) {
|
|
|
|
symbol->row_height[i] = 1;
|
2021-08-10 23:04:25 +12:00
|
|
|
for (j = 0; j < total_width; j++) {
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
set_module_colour(symbol, i, j, posn(ult_colour, pattern[(i * total_width) + j]));
|
2019-12-19 07:33:18 +13:00
|
|
|
}
|
|
|
|
}
|
2021-06-20 00:11:23 +12:00
|
|
|
symbol->height = total_height;
|
2019-03-21 22:14:24 +13:00
|
|
|
|
2019-12-19 07:33:18 +13:00
|
|
|
return 0;
|
2019-03-21 22:14:24 +13:00
|
|
|
}
|
Add multiple segments support for AZTEC, CODEONE, DATAMATRIX, DOTCODE,
GRIDMATRIX, HANXIN, MAXICODE, MICROPDF417, PDF417, QRCODE, RMQR, ULTRA
RMQR: fix ECI encoding (wrong bit length for indicator)
MICROQR: check versions M1 and M2 for allowed characters so as to give
better error messages
DOTCODE: some small optimizations
common.c: add is_chr(), segs_length(), segs_cpy()
CODEONE/CODE128/DOTCODE/GRIDMATRIX/HANXIN/MAXICODE/QRCODE/ULTRA: add
namespace prefixes to static funcs/data
includes: use Z_ prefix, unuse double underscore prefixes (guard defines)
manual.txt: compress some tables using double/treble column sets
2022-05-10 06:50:50 +12:00
|
|
|
|
|
|
|
/* vim: set ts=4 sw=4 et : */
|