mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-12 22:25:59 -04:00
- PDF417/MICROPDF417: use latch not ps shift for padding when
spanning Text segments to avoid affecting 1st char of 2nd segment - PDF417/MICROPDF417: add optimized encoding, FAST_MODE for previous scheme; formatting changes - common.c/h: add `cnt_digits()`, comments in include and make more consistent, minor code fiddling - DOTCODE: replace `dc_n_digits()` with new `cnt_digits()` - test_qr: fix `test_qr_perf()` - composite: minor code fiddling - library: debug dump HIBC-processed input - BWIPP: update to latest
This commit is contained in:
parent
fbfaabf004
commit
e515f63fab
32 changed files with 3885 additions and 640 deletions
167
backend/common.h
167
backend/common.h
|
@ -90,7 +90,7 @@ typedef unsigned __int64 uint64_t;
|
|||
/* The most commonly used set */
|
||||
#define NEON_F IS_NUM_F /* NEON "0123456789" */
|
||||
|
||||
/* Simple versions of <cctype> functions with no dependence on locale */
|
||||
/* Simple versions of <ctype.h> functions with no dependence on locale */
|
||||
#define z_isdigit(c) ((c) <= '9' && (c) >= '0')
|
||||
#define z_isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
||||
#define z_islower(c) ((c) >= 'a' && (c) <= 'z')
|
||||
|
@ -146,75 +146,144 @@ typedef unsigned __int64 uint64_t;
|
|||
#define Z_COMMON_INLINE 1
|
||||
|
||||
#ifdef Z_COMMON_INLINE
|
||||
/* Return true (1) if a module is dark/black, otherwise false (0) */
|
||||
/* Returns true (1) if a module is dark/black, otherwise false (0) */
|
||||
# define module_is_set(s, y, x) (((s)->encoded_data[(y)][(x) >> 3] >> ((x) & 0x07)) & 1)
|
||||
|
||||
/* Set a module to dark/black */
|
||||
/* Sets a module to dark/black */
|
||||
# define set_module(s, y, x) do { (s)->encoded_data[(y)][(x) >> 3] |= 1 << ((x) & 0x07); } while (0)
|
||||
|
||||
/* Return true (1-8) if a module is colour, otherwise false (0) */
|
||||
/* Returns true (1-8) if a module is colour, otherwise false (0) */
|
||||
# define module_colour_is_set(s, y, x) ((s)->encoded_data[(y)][(x)])
|
||||
|
||||
/* Set a module to a colour */
|
||||
/* Sets a module to a colour */
|
||||
# define set_module_colour(s, y, x, c) do { (s)->encoded_data[(y)][(x)] = (c); } while (0)
|
||||
#endif
|
||||
|
||||
INTERNAL int ctoi(const char source);
|
||||
INTERNAL char itoc(const int source);
|
||||
INTERNAL int to_int(const unsigned char source[], const int length);
|
||||
INTERNAL void to_upper(unsigned char source[], const int length);
|
||||
INTERNAL int chr_cnt(const unsigned char string[], const int length, const unsigned char c);
|
||||
/* Converts a character 0-9, A-F to its equivalent integer value */
|
||||
INTERNAL int ctoi(const char source);
|
||||
|
||||
INTERNAL int is_chr(const unsigned int flg, const unsigned int c);
|
||||
INTERNAL int is_sane(const unsigned int flg, const unsigned char source[], const int length);
|
||||
INTERNAL int is_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
|
||||
const int length, int *posns);
|
||||
INTERNAL int posn(const char set_string[], const char data);
|
||||
/* Converts an integer value to its hexadecimal character */
|
||||
INTERNAL char itoc(const int source);
|
||||
|
||||
INTERNAL int bin_append_posn(const int arg, const int length, char *binary, const int bin_posn);
|
||||
/* Converts decimal string of length <= 9 to integer value. Returns -1 if not numeric */
|
||||
INTERNAL int to_int(const unsigned char source[], const int length);
|
||||
|
||||
#ifndef Z_COMMON_INLINE
|
||||
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
INTERNAL int module_colour_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord,
|
||||
const int colour);
|
||||
#endif
|
||||
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
/* Converts lower case characters to upper case in string `source` */
|
||||
INTERNAL void to_upper(unsigned char source[], const int length);
|
||||
|
||||
INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length);
|
||||
/* Returns the number of times a character occurs in `source` */
|
||||
INTERNAL int chr_cnt(const unsigned char source[], const int length, const unsigned char c);
|
||||
|
||||
INTERNAL int is_stackable(const int symbology);
|
||||
INTERNAL int is_extendable(const int symbology);
|
||||
INTERNAL int is_composite(const int symbology);
|
||||
INTERNAL int is_dotty(const int symbology);
|
||||
INTERNAL int is_fixed_ratio(const int symbology);
|
||||
|
||||
INTERNAL int is_twodigits(const unsigned char source[], const int length, const int position);
|
||||
/* Whether a character matches `flg` */
|
||||
INTERNAL int is_chr(const unsigned int flg, const unsigned int c);
|
||||
|
||||
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte);
|
||||
INTERNAL int is_valid_utf8(const unsigned char source[], const int length);
|
||||
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
|
||||
int *length, const int disallow_4byte);
|
||||
/* Verifies that a string only uses valid characters */
|
||||
INTERNAL int is_sane(const unsigned int flg, const unsigned char source[], const int length);
|
||||
|
||||
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,
|
||||
const float max_height, const int set_errtxt);
|
||||
/* Verifies that a string only uses valid characters, and returns `test_string` position of each in `posns` array */
|
||||
INTERNAL int is_sane_lookup(const char test_string[], const int test_length, const unsigned char source[],
|
||||
const int length, int *posns);
|
||||
|
||||
INTERNAL float stripf(const float arg);
|
||||
/* Returns the position of `data` in `set_string` */
|
||||
INTERNAL int posn(const char set_string[], const char data);
|
||||
|
||||
INTERNAL int segs_length(const struct zint_seg segs[], const int seg_count);
|
||||
INTERNAL void segs_cpy(const struct zint_symbol *symbol, const struct zint_seg segs[], const int seg_count,
|
||||
struct zint_seg local_segs[]);
|
||||
|
||||
INTERNAL int colour_to_red(const int colour);
|
||||
INTERNAL int colour_to_green(const int colour);
|
||||
INTERNAL int colour_to_blue(const int colour);
|
||||
/* Converts `arg` to a string representing its binary equivalent of length `length` and places in `binary` at
|
||||
`bin_posn`. Returns `bin_posn` + `length` */
|
||||
INTERNAL int bin_append_posn(const int arg, const int length, char *binary, const int bin_posn);
|
||||
|
||||
#ifdef ZINT_TEST
|
||||
INTERNAL void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigned char *codewords,
|
||||
const int length);
|
||||
INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length);
|
||||
#endif
|
||||
|
||||
#ifndef Z_COMMON_INLINE
|
||||
/* Returns true (1) if a module is dark/black, otherwise false (0) */
|
||||
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
|
||||
/* Sets a module to dark/black */
|
||||
INTERNAL void set_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
|
||||
/* Returns true (1-8) if a module is colour, otherwise false (0) */
|
||||
INTERNAL int module_colour_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
|
||||
/* Sets a module to a colour */
|
||||
INTERNAL void set_module_colour(struct zint_symbol *symbol, const int y_coord, const int x_coord,
|
||||
const int colour);
|
||||
#endif
|
||||
/* Sets a dark/black module to white (i.e. unsets) */
|
||||
INTERNAL void unset_module(struct zint_symbol *symbol, const int y_coord, const int x_coord);
|
||||
|
||||
/* Expands from a width pattern to a bit pattern */
|
||||
INTERNAL void expand(struct zint_symbol *symbol, const char data[], const int length);
|
||||
|
||||
|
||||
/* Whether `symbology` can have row binding */
|
||||
INTERNAL int is_stackable(const int symbology);
|
||||
|
||||
/* Whether `symbology` can have addon (EAN-2 and EAN-5) */
|
||||
INTERNAL int is_extendable(const int symbology);
|
||||
|
||||
/* Whether `symbology` can have composite 2D component data */
|
||||
INTERNAL int is_composite(const int symbology);
|
||||
|
||||
/* Whether `symbology` is a matrix design renderable as dots */
|
||||
INTERNAL int is_dotty(const int symbology);
|
||||
|
||||
/* Whether `symbology` has a fixed aspect ratio (matrix design) */
|
||||
INTERNAL int is_fixed_ratio(const int symbology);
|
||||
|
||||
|
||||
/* Whether next two characters are digits */
|
||||
INTERNAL int is_twodigits(const unsigned char source[], const int length, const int position);
|
||||
|
||||
/* Returns how many consecutive digits lie immediately ahead up to `max`, or all if `max` is -1 */
|
||||
INTERNAL int cnt_digits(const unsigned char source[], const int length, const int position, const int max);
|
||||
|
||||
|
||||
/* State machine to decode UTF-8 to Unicode codepoints (state 0 means done, state 12 means error) */
|
||||
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte);
|
||||
|
||||
/* Is string valid UTF-8? */
|
||||
INTERNAL int is_valid_utf8(const unsigned char source[], const int length);
|
||||
|
||||
/* Converts UTF-8 to Unicode. If `disallow_4byte` unset, allows all values (UTF-32). If `disallow_4byte` set,
|
||||
* only allows codepoints <= U+FFFF (ie four-byte sequences not allowed) (UTF-16, no surrogates) */
|
||||
INTERNAL int utf8_to_unicode(struct zint_symbol *symbol, const unsigned char source[], unsigned int vals[],
|
||||
int *length, const int disallow_4byte);
|
||||
|
||||
|
||||
/* Sets symbol height, returning a warning if not within minimum and/or maximum if given.
|
||||
`default_height` does not include height of fixed-height rows (i.e. separators/composite data) */
|
||||
INTERNAL int set_height(struct zint_symbol *symbol, const float min_row_height, const float default_height,
|
||||
const float max_height, const int set_errtxt);
|
||||
|
||||
|
||||
/* Removes excess precision from floats - see https://stackoverflow.com/q/503436 */
|
||||
INTERNAL float stripf(const float arg);
|
||||
|
||||
|
||||
/* Returns total length of segments */
|
||||
INTERNAL int segs_length(const struct zint_seg segs[], const int seg_count);
|
||||
|
||||
/* Shallow copies segments, adjusting default ECIs */
|
||||
INTERNAL void segs_cpy(const struct zint_symbol *symbol, const struct zint_seg segs[], const int seg_count,
|
||||
struct zint_seg local_segs[]);
|
||||
|
||||
|
||||
/* Returns red component if any of ultra colour indexing "0CBMRYGKW" */
|
||||
INTERNAL int colour_to_red(const int colour);
|
||||
|
||||
/* Returns green component if any of ultra colour indexing "0CBMRYGKW" */
|
||||
INTERNAL int colour_to_green(const int colour);
|
||||
|
||||
/* Returns blue component if any of ultra colour indexing "0CBMRYGKW" */
|
||||
INTERNAL int colour_to_blue(const int colour);
|
||||
|
||||
|
||||
#ifdef ZINT_TEST
|
||||
/* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */
|
||||
INTERNAL void debug_test_codeword_dump(struct zint_symbol *symbol, const unsigned char *codewords, const int length);
|
||||
/* Dumps decimal-formatted codewords in symbol->errtxt (for use in testing) */
|
||||
INTERNAL void debug_test_codeword_dump_int(struct zint_symbol *symbol, const int *codewords, const int length);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue