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

Commit

Permalink
tesseract 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Jul 25, 2019
1 parent c1d611a commit a5dcb61
Show file tree
Hide file tree
Showing 52 changed files with 3,099 additions and 11,645 deletions.
71 changes: 0 additions & 71 deletions PKGBUILD

This file was deleted.

2,249 changes: 1,136 additions & 1,113 deletions include/leptonica/allheaders.h

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions include/leptonica/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,23 @@ typedef struct L_Bytea L_BYTEA;
/*------------------------------------------------------------------------*
* Array flags *
*------------------------------------------------------------------------*/
/*! Flags for interpolation in Numa */
/*! Numa Interpolation */
enum {
L_LINEAR_INTERP = 1, /*!< linear */
L_QUADRATIC_INTERP = 2 /*!< quadratic */
};

/*! Flags for added borders in Numa and Fpix */
/*! Border Adding */
enum {
L_CONTINUED_BORDER = 1, /*!< extended with same value */
L_SLOPE_BORDER = 2, /*!< extended with constant normal derivative */
L_MIRRORED_BORDER = 3 /*!< mirrored */
};

/*! Flags for data type converted from Numa */
/*! Numa Data Conversion */
enum {
L_INTEGER_VALUE = 1, /*!< convert to integer */
L_FLOAT_VALUE = 2 /*!< convert to float */
};


#endif /* LEPTONICA_ARRAY_H */
6 changes: 6 additions & 0 deletions include/leptonica/arrayaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,27 @@
* defined for SET macros. If SET_DATA_QBIT were defined as a
* compound macro, in analogy to l_setDataQbit(), it requires
* surrounding braces:
* \code
* #define SET_DATA_QBIT(pdata, n, val) \
* {l_uint32 *_TEMP_WORD_PTR_; \
* _TEMP_WORD_PTR_ = (l_uint32 *)(pdata) + ((n) >> 3); \
* *_TEMP_WORD_PTR_ &= ~(0xf0000000 >> (4 * ((n) & 7))); \
* *_TEMP_WORD_PTR_ |= (((val) & 15) << (28 - 4 * ((n) & 7)));}
* \endcode
* but if used in an if/else
* \code
* if (x)
* SET_DATA_QBIT(...);
* else
* ...
* \endcode
* the compiler sees
* \code
* if (x)
* {......};
* else
* ...
* \endcode
* The semicolon comes after the brace and will not compile.
* This can be fixed in the call by either omitting the semicolon
* or requiring another set of braces around SET_DATA_QBIT(), but
Expand Down
1 change: 1 addition & 0 deletions include/leptonica/bmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*/

/*! Constants for deciding when text block is divided into paragraphs */
/*! Split Text */
enum {
SPLIT_ON_LEADING_WHITE = 1, /*!< tab or space at beginning of line */
SPLIT_ON_BLANK_LINE = 2, /*!< newline with optional white space */
Expand Down
45 changes: 37 additions & 8 deletions include/leptonica/bmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,36 @@
* BMP file header *
*-------------------------------------------------------------*/

/*! BMP file header */
/*! BMP file header
*
* Notes:
* (1) The bfSize field is stored as a 32 bit integer and includes
* the size of the BMP_FileHeader, BMP_InfoHeader, the color
* table (if any), and the size of the DIB bits.
* (2) The bfOffBits field is also stored as a 32 bit integer and
* contains the absolute offset in bytes of the image data
* in this file. Some bmp files have additional data after the
* BMP_InfoHeader and before the color table (if it exists).
* However, enabling reading of these files makes the reader
* vulnerable to various malware attacks. Therefore we do not
* read bmp files with extra data, and require that the size
* of the color table in bytes is
* offset - sizeof(BMP_FileHeader) - sizeof(BMP_InfoHeader)
* (3) Use arrays of l_uint8[] to make an endianness agnostic
* access to the BMP_FileHeader easier.
*/
struct BMP_FileHeader
{
l_int16 bfType; /*!< file type; must be "BM" */
l_int16 bfSize; /*!< length of the file;
l_uint8 bfType[2]; /*!< file type; must be "BM" */
l_uint8 bfSize[4]; /*!< length of the file;
sizeof(BMP_FileHeader) +
sizeof(BMP_InfoHeader) +
size of optional extra data +
size of color table +
size of DIB bits */
l_int16 bfFill1; /*!< remainder of the bfSize field */
l_int16 bfReserved1; /*!< don't care (set to 0) */
l_int16 bfReserved2; /*!< don't care (set to 0) */
l_int16 bfOffBits; /*!< offset from beginning of file */
l_int16 bfFill2; /*!< remainder of the bfOffBits field */
l_uint8 bfReserved1[2]; /*!< don't care (set to 0) */
l_uint8 bfReserved2[2]; /*!< don't care (set to 0) */
l_uint8 bfOffBits[4]; /*!< offset from beginning of file */
};
typedef struct BMP_FileHeader BMP_FH;

Expand Down Expand Up @@ -92,4 +108,17 @@ typedef struct BMP_InfoHeader BMP_IH;
#define BMP_IHBYTES sizeof(BMP_IH)


/*-------------------------------------------------------------*
* Align BMP headers on 4 byte boundaries *
*-------------------------------------------------------------*/

/*! BMP_IH is misaligned, causing crashes on some big-endians.
* A packed struct forces alignment. */
#if defined(__GNUC__)
typedef struct __attribute__((__packed__)) {
BMP_FH bmpfh;
BMP_IH bmpih;
} BMP_HEADER;
#endif

#endif /* LEPTONICA_BMP_H */
2 changes: 2 additions & 0 deletions include/leptonica/ccbord.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
*/

/*! Use in ccbaStepChainsToPixCoords() */
/*! CCB Coords */
enum {
CCB_LOCAL_COORDS = 1,
CCB_GLOBAL_COORDS = 2
};

/*! Use in ccbaGenerateSPGlobalLocs() */
/*! CCB Points */
enum {
CCB_SAVE_ALL_PTS = 1,
CCB_SAVE_TURNING_PTS = 2
Expand Down
98 changes: 59 additions & 39 deletions include/leptonica/environ.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,39 @@ typedef uintptr_t l_uintptr_t;
* non-functioning stubs to be linked.
*/
#if !defined(HAVE_CONFIG_H) && !defined(ANDROID_BUILD) && !defined(OS_IOS)
#define HAVE_LIBJPEG 1
#define HAVE_LIBTIFF 1
#define HAVE_LIBPNG 1
#define HAVE_LIBZ 1
#define HAVE_LIBGIF 0
#define HAVE_LIBUNGIF 0
#define HAVE_LIBWEBP 0
#define HAVE_LIBJP2K 0

/*-------------------------------------------------------------------------*
* Leptonica supports OpenJPEG 2.0+. If you have a version of openjpeg *
* (HAVE_LIBJP2K == 1) that is >= 2.0, set the path to the openjpeg.h *
* header in angle brackets here. *
*-------------------------------------------------------------------------*/
#define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>
#if !defined(HAVE_LIBJPEG)
#define HAVE_LIBJPEG 1
#endif
#if !defined(HAVE_LIBTIFF)
#define HAVE_LIBTIFF 1
#endif
#if !defined(HAVE_LIBPNG)
#define HAVE_LIBPNG 1
#endif
#if !defined(HAVE_LIBZ)
#define HAVE_LIBZ 1
#endif
#if !defined(HAVE_LIBGIF)
#define HAVE_LIBGIF 0
#endif
#if !defined(HAVE_LIBUNGIF)
#define HAVE_LIBUNGIF 0
#endif
#if !defined(HAVE_LIBWEBP)
#define HAVE_LIBWEBP 0
#endif
#if !defined(HAVE_LIBJP2K)
#define HAVE_LIBJP2K 0
#endif

/*-----------------------------------------------------------------------*
* Leptonica supports OpenJPEG 2.0+. If you have a version of openjpeg *
* (HAVE_LIBJP2K == 1) that is >= 2.0, set the path to the openjpeg.h *
* header in angle brackets here. *
*-----------------------------------------------------------------------*/
#define LIBJP2K_HEADER <openjpeg-2.3/openjpeg.h>

#endif /* ! HAVE_CONFIG_H etc. */

/*--------------------------------------------------------------------*
Expand Down Expand Up @@ -171,6 +189,7 @@ typedef uintptr_t l_uintptr_t;
/*--------------------------------------------------------------------*
* Built-in types *
*--------------------------------------------------------------------*/
typedef int l_ok; /*!< return type 0 if OK, 1 on error */
typedef signed char l_int8; /*!< signed 8-bit value */
typedef unsigned char l_uint8; /*!< unsigned 8-bit value */
typedef short l_int16; /*!< signed 16-bit value */
Expand Down Expand Up @@ -207,16 +226,16 @@ LEPT_DLL extern l_int32 LeptDebugOK; /* default is 0 */
*------------------------------------------------------------------------*/
#ifndef L_MIN
/*! Minimum of %x and %y */
#define L_MIN(x,y) (((x) < (y)) ? (x) : (y))
#define L_MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif

#ifndef L_MAX
/*! Maximum of %x and %y */
#define L_MAX(x,y) (((x) > (y)) ? (x) : (y))
#define L_MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif

#ifndef L_ABS
/*! Absoulute value of %x */
/*! Absolute value of %x */
#define L_ABS(x) (((x) < 0) ? (-1 * (x)) : (x))
#endif

Expand Down Expand Up @@ -263,7 +282,7 @@ LEPT_DLL extern l_int32 LeptDebugOK; /* default is 0 */
/*------------------------------------------------------------------------*
* Simple search state variables *
*------------------------------------------------------------------------*/
/*! Simple search state variables */
/*! Search State */
enum {
L_NOT_FOUND = 0,
L_FOUND = 1
Expand All @@ -273,7 +292,7 @@ enum {
/*------------------------------------------------------------------------*
* Path separator conversion *
*------------------------------------------------------------------------*/
/*! Path separator conversion */
/*! Path Separators */
enum {
UNIX_PATH_SEPCHAR = 0,
WIN_PATH_SEPCHAR = 1
Expand Down Expand Up @@ -346,7 +365,8 @@ typedef struct L_WallTimer L_WALLTIMER;
* "Print messages that have an equal or greater severity than this." *
*------------------------------------------------------------------------*/

/*! Control printing of error, warning and info messages */
/*! Control printing of error, warning and info messages */
/*! Message Control */
enum {
L_SEVERITY_EXTERNAL = 0, /* Get the severity from the environment */
L_SEVERITY_ALL = 1, /* Lowest severity: print all messages */
Expand Down Expand Up @@ -466,51 +486,51 @@ LEPT_DLL extern l_int32 LeptMsgSeverity;
#ifdef NO_CONSOLE_IO

#define PROCNAME(name)
#define ERROR_INT(a,b,c) ((l_int32)(c))
#define ERROR_FLOAT(a,b,c) ((l_float32)(c))
#define ERROR_PTR(a,b,c) ((void *)(c))
#define L_ERROR(a,...)
#define L_WARNING(a,...)
#define L_INFO(a,...)
#define ERROR_INT(a, b, c) ((l_int32)(c))
#define ERROR_FLOAT(a, b, c) ((l_float32)(c))
#define ERROR_PTR(a, b, c) ((void *)(c))
#define L_ERROR(a, ...)
#define L_WARNING(a, ...)
#define L_INFO(a, ...)

#else

#define PROCNAME(name) static const char procName[] = name
#define IF_SEV(l,t,f) \
#define IF_SEV(l, t, f) \
((l) >= MINIMUM_SEVERITY && (l) >= LeptMsgSeverity ? (t) : (f))

#define ERROR_INT(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a),(b),(c)), (l_int32)(c))
#define ERROR_FLOAT(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a),(b),(c)), (l_float32)(c))
#define ERROR_PTR(a,b,c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a),(b),(c)), (void *)(c))
#define ERROR_INT(a, b, c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorInt((a), (b), (c)), (l_int32)(c))
#define ERROR_FLOAT(a, b, c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorFloat((a), (b), (c)), (l_float32)(c))
#define ERROR_PTR(a, b, c) \
IF_SEV(L_SEVERITY_ERROR, returnErrorPtr((a), (b), (c)), (void *)(c))

#define L_ERROR(a,...) \
#define L_ERROR(a, ...) \
IF_SEV(L_SEVERITY_ERROR, \
(void)fprintf(stderr, "Error in %s: " a, __VA_ARGS__), \
(void)0)
#define L_WARNING(a,...) \
#define L_WARNING(a, ...) \
IF_SEV(L_SEVERITY_WARNING, \
(void)fprintf(stderr, "Warning in %s: " a, __VA_ARGS__), \
(void)0)
#define L_INFO(a,...) \
#define L_INFO(a, ...) \
IF_SEV(L_SEVERITY_INFO, \
(void)fprintf(stderr, "Info in %s: " a, __VA_ARGS__), \
(void)0)

#if 0 /* Alternative method for controlling L_* message output */
#define L_ERROR(a,...) \
#define L_ERROR(a, ...) \
{ if (L_SEVERITY_ERROR >= MINIMUM_SEVERITY && \
L_SEVERITY_ERROR >= LeptMsgSeverity) \
fprintf(stderr, "Error in %s: " a, __VA_ARGS__) \
}
#define L_WARNING(a,...) \
#define L_WARNING(a, ...) \
{ if (L_SEVERITY_WARNING >= MINIMUM_SEVERITY && \
L_SEVERITY_WARNING >= LeptMsgSeverity) \
fprintf(stderr, "Warning in %s: " a, __VA_ARGS__) \
}
#define L_INFO(a,...) \
#define L_INFO(a, ...) \
{ if (L_SEVERITY_INFO >= MINIMUM_SEVERITY && \
L_SEVERITY_INFO >= LeptMsgSeverity) \
fprintf(stderr, "Info in %s: " a, __VA_ARGS__) \
Expand Down
Loading

0 comments on commit a5dcb61

Please sign in to comment.