Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 451a324

Browse files
committed
Tesseract 4.1.1 plus ucrt libs
1 parent a5dcb61 commit 451a324

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+143
-95
lines changed

include/leptonica/allheaders.h

Lines changed: 77 additions & 47 deletions
Large diffs are not rendered by default.

include/leptonica/arrayaccess.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
*--------------------------------------------------*/
122122
/*! 1 bit access - get */
123123
#define GET_DATA_BIT(pdata, n) \
124-
((*((l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
124+
((*((const l_uint32 *)(pdata) + ((n) >> 5)) >> (31 - ((n) & 31))) & 1)
125125

126126
/*! 1 bit access - set */
127127
#define SET_DATA_BIT(pdata, n) \
@@ -136,21 +136,21 @@
136136
*((l_uint32 *)(pdata) + ((n) >> 5)) = \
137137
((*((l_uint32 *)(pdata) + ((n) >> 5)) \
138138
& (~(0x80000000 >> ((n) & 31)))) \
139-
| ((val) << (31 - ((n) & 31))))
139+
| ((l_uint32)(val) << (31 - ((n) & 31))))
140140

141141
/*--------------------------------------------------*
142142
* 2 bit access *
143143
*--------------------------------------------------*/
144144
/*! 2 bit access - get */
145145
#define GET_DATA_DIBIT(pdata, n) \
146-
((*((l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
146+
((*((const l_uint32 *)(pdata) + ((n) >> 4)) >> (2 * (15 - ((n) & 15)))) & 3)
147147

148148
/*! 2 bit access - set value (0 ... 3) */
149149
#define SET_DATA_DIBIT(pdata, n, val) \
150150
*((l_uint32 *)(pdata) + ((n) >> 4)) = \
151151
((*((l_uint32 *)(pdata) + ((n) >> 4)) \
152152
& (~(0xc0000000 >> (2 * ((n) & 15))))) \
153-
| (((val) & 3) << (30 - 2 * ((n) & 15))))
153+
| ((l_uint32)((val) & 3) << (30 - 2 * ((n) & 15))))
154154

155155
/*! 2 bit access - clear */
156156
#define CLEAR_DATA_DIBIT(pdata, n) \
@@ -162,14 +162,14 @@
162162
*--------------------------------------------------*/
163163
/*! 4 bit access - get */
164164
#define GET_DATA_QBIT(pdata, n) \
165-
((*((l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
165+
((*((const l_uint32 *)(pdata) + ((n) >> 3)) >> (4 * (7 - ((n) & 7)))) & 0xf)
166166

167167
/*! 4 bit access - set value (0 ... 15) */
168168
#define SET_DATA_QBIT(pdata, n, val) \
169169
*((l_uint32 *)(pdata) + ((n) >> 3)) = \
170170
((*((l_uint32 *)(pdata) + ((n) >> 3)) \
171171
& (~(0xf0000000 >> (4 * ((n) & 7))))) \
172-
| (((val) & 15) << (28 - 4 * ((n) & 7))))
172+
| ((l_uint32)((val) & 15) << (28 - 4 * ((n) & 7))))
173173

174174
/*! 4 bit access - clear */
175175
#define CLEAR_DATA_QBIT(pdata, n) \
@@ -182,11 +182,11 @@
182182
#ifdef L_BIG_ENDIAN
183183
/*! 8 bit access - get */
184184
#define GET_DATA_BYTE(pdata, n) \
185-
(*((l_uint8 *)(pdata) + (n)))
185+
(*((const l_uint8 *)(pdata) + (n)))
186186
#else /* L_LITTLE_ENDIAN */
187187
/*! 8 bit access - get */
188188
#define GET_DATA_BYTE(pdata, n) \
189-
(*(l_uint8 *)((l_uintptr_t)((l_uint8 *)(pdata) + (n)) ^ 3))
189+
(*(l_uint8 *)((l_uintptr_t)((const l_uint8 *)(pdata) + (n)) ^ 3))
190190
#endif /* L_BIG_ENDIAN */
191191

192192
#ifdef L_BIG_ENDIAN
@@ -206,11 +206,11 @@
206206
#ifdef L_BIG_ENDIAN
207207
/*! 16 bit access - get */
208208
#define GET_DATA_TWO_BYTES(pdata, n) \
209-
(*((l_uint16 *)(pdata) + (n)))
209+
(*((const l_uint16 *)(pdata) + (n)))
210210
#else /* L_LITTLE_ENDIAN */
211211
/*! 16 bit access - get */
212212
#define GET_DATA_TWO_BYTES(pdata, n) \
213-
(*(l_uint16 *)((l_uintptr_t)((l_uint16 *)(pdata) + (n)) ^ 2))
213+
(*(l_uint16 *)((l_uintptr_t)((const l_uint16 *)(pdata) + (n)) ^ 2))
214214
#endif /* L_BIG_ENDIAN */
215215

216216
#ifdef L_BIG_ENDIAN
@@ -229,7 +229,7 @@
229229
*--------------------------------------------------*/
230230
/*! 32 bit access - get */
231231
#define GET_DATA_FOUR_BYTES(pdata, n) \
232-
(*((l_uint32 *)(pdata) + (n)))
232+
(*((const l_uint32 *)(pdata) + (n)))
233233

234234
/*! 32 bit access - set (0 ... 4294967295) */
235235
#define SET_DATA_FOUR_BYTES(pdata, n, val) \

include/leptonica/environ.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,14 @@ typedef uintptr_t l_uintptr_t;
119119
#if !defined(HAVE_LIBWEBP)
120120
#define HAVE_LIBWEBP 0
121121
#endif
122+
#if !defined(HAVE_LIBWEBP_ANIM)
123+
#define HAVE_LIBWEBP_ANIM 0
124+
#endif
122125
#if !defined(HAVE_LIBJP2K)
123126
#define HAVE_LIBJP2K 0
124127
#endif
125128

129+
126130
/*-----------------------------------------------------------------------*
127131
* Leptonica supports OpenJPEG 2.0+. If you have a version of openjpeg *
128132
* (HAVE_LIBJP2K == 1) that is >= 2.0, set the path to the openjpeg.h *
@@ -330,6 +334,11 @@ typedef struct L_WallTimer L_WALLTIMER;
330334
/*------------------------------------------------------------------------*
331335
* Control printing of error, warning, and info messages *
332336
* *
337+
* Leptonica never sends output to stdout. By default, all messages *
338+
* go to stderr. However, we provide a mechanism for runtime *
339+
* redirection of output, using a custom stderr handler defined *
340+
* by the user. See utils1.c for details and examples. *
341+
* *
333342
* To omit all messages to stderr, simply define NO_CONSOLE_IO on the *
334343
* command line. For finer grained control, we have a mechanism *
335344
* based on the message severity level. The following assumes that *
@@ -428,7 +437,7 @@ enum {
428437
#endif
429438

430439

431-
/*! The run-time message severity threshold is defined in utils.c. */
440+
/*! The run-time message severity threshold is defined in utils1.c. */
432441
LEPT_DLL extern l_int32 LeptMsgSeverity;
433442

434443
/*
@@ -508,32 +517,32 @@ LEPT_DLL extern l_int32 LeptMsgSeverity;
508517

509518
#define L_ERROR(a, ...) \
510519
IF_SEV(L_SEVERITY_ERROR, \
511-
(void)fprintf(stderr, "Error in %s: " a, __VA_ARGS__), \
520+
(void)lept_stderr("Error in %s: " a, __VA_ARGS__), \
512521
(void)0)
513522
#define L_WARNING(a, ...) \
514523
IF_SEV(L_SEVERITY_WARNING, \
515-
(void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
524+
(void)lept_stderr("Warning in %s: " a, __VA_ARGS__), \
516525
(void)0)
517526
#define L_INFO(a, ...) \
518527
IF_SEV(L_SEVERITY_INFO, \
519-
(void)fprintf(stderr, "Info in %s: " a, __VA_ARGS__), \
528+
(void)lept_stderr("Info in %s: " a, __VA_ARGS__), \
520529
(void)0)
521530

522531
#if 0 /* Alternative method for controlling L_* message output */
523532
#define L_ERROR(a, ...) \
524533
{ if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
525534
L_SEVERITY_ERROR >= LeptMsgSeverity) \
526-
fprintf(stderr, "Error in %s: " a, __VA_ARGS__) \
535+
lept_stderr("Error in %s: " a, __VA_ARGS__) \
527536
}
528537
#define L_WARNING(a, ...) \
529538
{ if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
530539
L_SEVERITY_WARNING >= LeptMsgSeverity) \
531-
fprintf(stderr, "Warning in %s: " a, __VA_ARGS__) \
540+
lept_stderr("Warning in %s: " a, __VA_ARGS__) \
532541
}
533542
#define L_INFO(a, ...) \
534543
{ if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
535544
L_SEVERITY_INFO >= LeptMsgSeverity) \
536-
fprintf(stderr, "Info in %s: " a, __VA_ARGS__) \
545+
lept_stderr("Info in %s: " a, __VA_ARGS__) \
537546
}
538547
#endif
539548

include/leptonica/gplot.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define GPLOT_VERSION_NUMBER 1
4545

46-
#define NUM_GPLOT_STYLES 5
46+
#define NUM_GPLOT_STYLES 5
4747
enum GPLOT_STYLE {
4848
GPLOT_LINES = 0,
4949
GPLOT_POINTS = 1,
@@ -52,13 +52,14 @@ enum GPLOT_STYLE {
5252
GPLOT_DOTS = 4
5353
};
5454

55-
#define NUM_GPLOT_OUTPUTS 5
55+
#define NUM_GPLOT_OUTPUTS 6
5656
enum GPLOT_OUTPUT {
5757
GPLOT_NONE = 0,
5858
GPLOT_PNG = 1,
5959
GPLOT_PS = 2,
6060
GPLOT_EPS = 3,
61-
GPLOT_LATEX = 4
61+
GPLOT_LATEX = 4,
62+
GPLOT_PNM = 5,
6263
};
6364

6465
enum GPLOT_SCALING {
@@ -79,7 +80,7 @@ struct GPlot
7980
struct Sarray *cmddata; /*!< command file contents */
8081
struct Sarray *datanames; /*!< data file names */
8182
struct Sarray *plotdata; /*!< plot data (1 string/file) */
82-
struct Sarray *plottitles; /*!< title for each individual plot */
83+
struct Sarray *plotlabels; /*!< label for each individual plot */
8384
struct Numa *plotstyles; /*!< plot style for individual plots */
8485
l_int32 nplots; /*!< current number of plots */
8586
char *outname; /*!< output file name */

include/leptonica/imageio.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ enum {
111111
IFF_SPIX = 19
112112
};
113113

114+
/* Convenient macro for checking requested tiff output */
115+
#define L_FORMAT_IS_TIFF(f) ((f) == IFF_TIFF || (f) == IFF_TIFF_PACKBITS || \
116+
(f) == IFF_TIFF_RLE || (f) == IFF_TIFF_G3 || \
117+
(f) == IFF_TIFF_G4 || (f) == IFF_TIFF_LZW || \
118+
(f) == IFF_TIFF_ZIP || (f) == IFF_TIFF_JPEG)
119+
114120

115121
/* --------------------------------------------------------------- *
116122
* Format header ids *

include/leptonica/pix.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@
100100
* Box size adjustment flags
101101
* Flags for modifying box boundaries using a second box
102102
* Handling overlapping bounding boxes in boxa
103+
* Selecting or making a box from two (intersecting) boxes
103104
* Flags for replacing invalid boxes
104-
* Flags for box corners
105+
* Flags for box corners and center
105106
* Horizontal warp
106107
* Pixel selection for resampling
107108
* Thinning flags
@@ -1109,6 +1110,18 @@ enum {
11091110
};
11101111

11111112

1113+
/*-------------------------------------------------------------------------*
1114+
* Selecting or making a box from two (intersecting) boxes *
1115+
*-------------------------------------------------------------------------*/
1116+
/*! Box Combine or Select */
1117+
enum {
1118+
L_GEOMETRIC_UNION = 1, /*!< use union of two boxes */
1119+
L_GEOMETRIC_INTERSECTION = 2, /*!< use intersection of two boxes */
1120+
L_LARGEST_AREA = 3, /*!< use box with largest area */
1121+
L_SMALLEST_AREA = 4 /*!< use box with smallest area */
1122+
};
1123+
1124+
11121125
/*-------------------------------------------------------------------------*
11131126
* Flags for replacing invalid boxes *
11141127
*-------------------------------------------------------------------------*/
@@ -1120,14 +1133,15 @@ enum {
11201133

11211134

11221135
/*-------------------------------------------------------------------------*
1123-
* Flags for box corners *
1136+
* Flags for box corners and center *
11241137
*-------------------------------------------------------------------------*/
1125-
/*! Box Corners */
1138+
/*! Box Corners and Center */
11261139
enum {
11271140
L_UPPER_LEFT = 1, /*!< UL corner */
11281141
L_UPPER_RIGHT = 2, /*!< UR corner */
11291142
L_LOWER_LEFT = 3, /*!< LL corner */
1130-
L_LOWER_RIGHT = 4 /*!< LR corner */
1143+
L_LOWER_RIGHT = 4, /*!< LR corner */
1144+
L_BOX_CENTER = 5 /*!< center */
11311145
};
11321146

11331147

include/tesseract/capi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ typedef enum TessPageSegMode {
115115
PSM_SINGLE_CHAR,
116116
PSM_SPARSE_TEXT,
117117
PSM_SPARSE_TEXT_OSD,
118+
PSM_RAW_LINE,
118119
PSM_COUNT
119120
} TessPageSegMode;
120121
typedef enum TessPageIteratorLevel {

include/tesseract/genericvector.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include <algorithm>
2323
#include <cassert>
24+
#include <climits> // for LONG_MAX
25+
#include <cstdint> // for uint32_t
2426
#include <cstdio>
2527
#include <cstdlib>
2628

@@ -375,7 +377,7 @@ inline bool LoadDataFromFile(const char* filename, GenericVector<char>* data) {
375377
FILE* fp = fopen(filename, "rb");
376378
if (fp != nullptr) {
377379
fseek(fp, 0, SEEK_END);
378-
long size = ftell(fp);
380+
auto size = std::ftell(fp);
379381
fseek(fp, 0, SEEK_SET);
380382
// Trying to open a directory on Linux sets size to LONG_MAX. Catch it here.
381383
if (size > 0 && size < LONG_MAX) {
@@ -407,17 +409,6 @@ inline bool SaveDataToFile(const GenericVector<char>& data,
407409
fclose(fp);
408410
return result;
409411
}
410-
// Reads a file as a vector of STRING.
411-
inline bool LoadFileLinesToStrings(const STRING& filename,
412-
GenericVector<STRING>* lines) {
413-
GenericVector<char> data;
414-
if (!LoadDataFromFile(filename.string(), &data)) {
415-
return false;
416-
}
417-
STRING lines_str(&data[0], data.size());
418-
lines_str.split('\n', lines);
419-
return true;
420-
}
421412

422413
template <typename T>
423414
bool cmp_eq(T const& t1, T const& t2) {

include/tesseract/renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <string> // for std::string
2525
#include "genericvector.h"
2626
#include "platform.h"
27+
#include "strngs.h" // for STRING
2728

2829
struct Pix;
2930

include/tesseract/tess_version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
#define TESSERACT_MAJOR_VERSION 4
2222
#define TESSERACT_MINOR_VERSION 1
23-
#define TESSERACT_MICRO_VERSION 0
23+
#define TESSERACT_MICRO_VERSION 1
2424
#define TESSERACT_VERSION \
2525
(TESSERACT_MAJOR_VERSION << 16 | \
2626
TESSERACT_MINOR_VERSION << 8 | \
2727
TESSERACT_MICRO_VERSION)
28-
#define TESSERACT_VERSION_STR "4.1.0"
28+
#define TESSERACT_VERSION_STR "4.1.1"
2929

3030
#endif // TESSERACT_API_VERSION_H_

0 commit comments

Comments
 (0)