Use POSIX data types and macros (#878)

* api: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccmain: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccstruct: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* classify: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* cutil: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* dict: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* textord: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* training: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* wordrec: Replace Tesseract data types by POSIX data types

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccutil: Replace Tesseract data types by POSIX data types

Now all Tesseract data types which are no longer needed can be removed
from ccutil/host.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccmain: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccstruct: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* classify: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* dict: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* lstm: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* textord: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* wordrec: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* ccutil: Replace Tesseract's MIN_*INT, MAX_*INT* by POSIX *INT*_MIN, *INT*_MAX

Remove the macros which are now unused from ccutil/host.h.
Remove also the obsolete history comments.

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* Fix build error caused by ambiguous ClipToRange

Error message vom Appveyor CI:

    C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2672: 'ClipToRange': no matching overloaded function found [C:\projects\tesseract\build\libtesseract.vcxproj]
    C:\projects\tesseract\ccstruct\coutln.cpp(818): error C2782: 'T ClipToRange(const T &,const T &,const T &)': template parameter 'T' is ambiguous [C:\projects\tesseract\build\libtesseract.vcxproj]
      c:\projects\tesseract\ccutil\helpers.h(122): note: see declaration of 'ClipToRange'
      C:\projects\tesseract\ccstruct\coutln.cpp(818): note: could be 'char'
      C:\projects\tesseract\ccstruct\coutln.cpp(818): note: or       'int'

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* unittest: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>

* arch: Replace Tesseract's MAX_INT8 by POSIX INT8_MAX

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2018-03-13 21:36:30 +01:00 committed by zdenop
parent 40c71bfcb8
commit 023e1b340e
222 changed files with 2505 additions and 2529 deletions

View File

@ -285,7 +285,7 @@ bool TessBaseAPI::GetIntVariable(const char *name, int *value) const {
IntParam *p = ParamUtils::FindParam<IntParam>( IntParam *p = ParamUtils::FindParam<IntParam>(
name, GlobalParams()->int_params, tesseract_->params()->int_params); name, GlobalParams()->int_params, tesseract_->params()->int_params);
if (p == NULL) return false; if (p == NULL) return false;
*value = (inT32)(*p); *value = (int32_t)(*p);
return true; return true;
} }
@ -1697,7 +1697,7 @@ char* TessBaseAPI::GetTSVText(int page_number) {
/** The 5 numbers output for each box (the usual 4 and a page number.) */ /** The 5 numbers output for each box (the usual 4 and a page number.) */
const int kNumbersPerBlob = 5; const int kNumbersPerBlob = 5;
/** /**
* The number of bytes taken by each number. Since we use inT16 for ICOORD, * The number of bytes taken by each number. Since we use int16_t for ICOORD,
* assume only 5 digits max. * assume only 5 digits max.
*/ */
const int kBytesPerNumber = 5; const int kBytesPerNumber = 5;
@ -1707,7 +1707,7 @@ const int kBytesPerNumber = 5;
* original UTF8 characters, and one kMaxBytesPerLine for safety. * original UTF8 characters, and one kMaxBytesPerLine for safety.
*/ */
const int kBytesPerBoxFileLine = (kBytesPerNumber + 1) * kNumbersPerBlob + 1; const int kBytesPerBoxFileLine = (kBytesPerNumber + 1) * kNumbersPerBlob + 1;
/** Max bytes in the decimal representation of inT64. */ /** Max bytes in the decimal representation of int64_t. */
const int kBytesPer64BitNumber = 20; const int kBytesPer64BitNumber = 20;
/** /**
* A maximal single box could occupy kNumbersPerBlob numbers at * A maximal single box could occupy kNumbersPerBlob numbers at
@ -2479,7 +2479,7 @@ ROW *TessBaseAPI::MakeTessOCRRow(float baseline,
float xheight, float xheight,
float descender, float descender,
float ascender) { float ascender) {
inT32 xstarts[] = {-32000}; int32_t xstarts[] = {-32000};
double quad_coeffs[] = {0, 0, baseline}; double quad_coeffs[] = {0, 0, baseline};
return new ROW(1, return new ROW(1,
xstarts, xstarts,

View File

@ -103,7 +103,7 @@ void IntSimdMatrix::MatrixDotVector(const GENERIC_2D_ARRAY<int8_t>& w,
int total = 0; int total = 0;
for (int j = 0; j < num_in; ++j) total += wi[j] * u[j]; for (int j = 0; j < num_in; ++j) total += wi[j] * u[j];
// Add in the bias and correct for integer values. // Add in the bias and correct for integer values.
v[i] = (static_cast<double>(total) / MAX_INT8 + wi[num_in]) * scales[i]; v[i] = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * scales[i];
} }
} else { } else {
const int8_t* w_data = shaped_w_.data(); const int8_t* w_data = shaped_w_.data();

View File

@ -84,7 +84,7 @@ inline void ExtractResults(__m256i& result, __m256i& shift_id,
((int32_t*)&result)[0] ((int32_t*)&result)[0]
#endif #endif
; ;
*v++ = (static_cast<double>(res) / MAX_INT8 + *wi++) * *scales++; *v++ = (static_cast<double>(res) / INT8_MAX + *wi++) * *scales++;
// Rotate the results in int32_t units, so the next result is ready. // Rotate the results in int32_t units, so the next result is ready.
result = _mm256_permutevar8x32_epi32(result, shift_id); result = _mm256_permutevar8x32_epi32(result, shift_id);
} }

View File

@ -31,7 +31,7 @@ static void PartialMatrixDotVector1(const int8_t* wi, const double* scales,
double* v) { double* v) {
int total = IntDotProductSSE(u, wi, num_in); int total = IntDotProductSSE(u, wi, num_in);
// Add in the bias and correct for integer values. // Add in the bias and correct for integer values.
*v = (static_cast<double>(total) / MAX_INT8 + wi[num_in]) * *scales; *v = (static_cast<double>(total) / INT8_MAX + wi[num_in]) * *scales;
} }
#endif // __SSE4_1__ #endif // __SSE4_1__

View File

@ -44,7 +44,7 @@
namespace tesseract { namespace tesseract {
BOOL8 Tesseract::word_adaptable( //should we adapt? BOOL8 Tesseract::word_adaptable( //should we adapt?
WERD_RES *word, WERD_RES *word,
uinT16 mode) { uint16_t mode) {
if (tessedit_adaption_debug) { if (tessedit_adaption_debug) {
tprintf("Running word_adaptable() for %s rating %.4f certainty %.4f\n", tprintf("Running word_adaptable() for %s rating %.4f certainty %.4f\n",
word->best_choice == NULL ? "" : word->best_choice == NULL ? "" :

View File

@ -268,11 +268,11 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
} }
GenericVector<BLOB_CHOICE*> blob_choices; GenericVector<BLOB_CHOICE*> blob_choices;
ASSERT_HOST(!word_res->chopped_word->blobs.empty()); ASSERT_HOST(!word_res->chopped_word->blobs.empty());
float rating = static_cast<float>(MAX_INT8); float rating = static_cast<float>(INT8_MAX);
for (int i = 0; i < word_res->chopped_word->NumBlobs(); ++i) { for (int i = 0; i < word_res->chopped_word->NumBlobs(); ++i) {
// The rating and certainty are not quite arbitrary. Since // The rating and certainty are not quite arbitrary. Since
// select_blob_to_chop uses the worst certainty to choose, they all have // select_blob_to_chop uses the worst certainty to choose, they all have
// to be different, so starting with MAX_INT8, subtract 1/8 for each blob // to be different, so starting with INT8_MAX, subtract 1/8 for each blob
// in here, and then divide by e each time they are chopped, which // in here, and then divide by e each time they are chopped, which
// should guarantee a set of unequal values for the whole tree of blobs // should guarantee a set of unequal values for the whole tree of blobs
// produced, however much chopping is required. The chops are thus only // produced, however much chopping is required. The chops are thus only

View File

@ -80,8 +80,8 @@ void Tesseract::recog_pseudo_word(PAGE_RES* page_res,
* @param pr_it the page results iterator * @param pr_it the page results iterator
*/ */
BOOL8 Tesseract::recog_interactive(PAGE_RES_IT* pr_it) { BOOL8 Tesseract::recog_interactive(PAGE_RES_IT* pr_it) {
inT16 char_qual; int16_t char_qual;
inT16 good_char_qual; int16_t good_char_qual;
WordData word_data(*pr_it); WordData word_data(*pr_it);
SetupWordPassN(2, &word_data); SetupWordPassN(2, &word_data);
@ -636,8 +636,8 @@ void Tesseract::rejection_passes(PAGE_RES* page_res,
stats_.doc_blob_quality += blob_quality; stats_.doc_blob_quality += blob_quality;
int outline_errs = word_outline_errs(word); int outline_errs = word_outline_errs(word);
stats_.doc_outline_errs += outline_errs; stats_.doc_outline_errs += outline_errs;
inT16 all_char_quality; int16_t all_char_quality;
inT16 accepted_all_char_quality; int16_t accepted_all_char_quality;
word_char_quality(word, page_res_it.row()->row, word_char_quality(word, page_res_it.row()->row,
&all_char_quality, &accepted_all_char_quality); &all_char_quality, &accepted_all_char_quality);
stats_.doc_char_quality += all_char_quality; stats_.doc_char_quality += all_char_quality;
@ -757,8 +757,8 @@ void Tesseract::script_pos_pass(PAGE_RES* page_res) {
// Helper finds the gap between the index word and the next. // Helper finds the gap between the index word and the next.
static void WordGap(const PointerVector<WERD_RES>& words, int index, int* right, static void WordGap(const PointerVector<WERD_RES>& words, int index, int* right,
int* next_left) { int* next_left) {
*right = -MAX_INT32; *right = -INT32_MAX;
*next_left = MAX_INT32; *next_left = INT32_MAX;
if (index < words.size()) { if (index < words.size()) {
*right = words[index]->word->bounding_box().right(); *right = words[index]->word->bounding_box().right();
if (index + 1 < words.size()) if (index + 1 < words.size())
@ -812,11 +812,11 @@ static int SelectBestWords(double rating_ratio,
// Start of the current run in each. // Start of the current run in each.
int start_b = b, start_n = n; int start_b = b, start_n = n;
while (b < best_words->size() || n < new_words->size()) { while (b < best_words->size() || n < new_words->size()) {
int b_right = -MAX_INT32; int b_right = -INT32_MAX;
int next_b_left = MAX_INT32; int next_b_left = INT32_MAX;
WordGap(*best_words, b, &b_right, &next_b_left); WordGap(*best_words, b, &b_right, &next_b_left);
int n_right = -MAX_INT32; int n_right = -INT32_MAX;
int next_n_left = MAX_INT32; int next_n_left = INT32_MAX;
WordGap(*new_words, n, &n_right, &next_n_left); WordGap(*new_words, n, &n_right, &next_n_left);
if (MAX(b_right, n_right) < MIN(next_b_left, next_n_left)) { if (MAX(b_right, n_right) < MIN(next_b_left, next_n_left)) {
// The word breaks overlap. [start_b,b] and [start_n, n] match. // The word breaks overlap. [start_b,b] and [start_n, n] match.
@ -1793,7 +1793,7 @@ ACCEPTABLE_WERD_TYPE Tesseract::acceptable_word_string(
BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) { BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
BOOL8 show_map_detail = FALSE; BOOL8 show_map_detail = FALSE;
inT16 i; int16_t i;
if (!test_pt) if (!test_pt)
return FALSE; return FALSE;
@ -1880,17 +1880,17 @@ BOOL8 Tesseract::check_debug_pt(WERD_RES *word, int location) {
*/ */
static void find_modal_font( // good chars in word static void find_modal_font( // good chars in word
STATS* fonts, // font stats STATS* fonts, // font stats
inT16* font_out, // output font int16_t* font_out, // output font
int8_t* font_count // output count int8_t* font_count // output count
) { ) {
inT16 font; //font index int16_t font; //font index
inT32 count; //pile couat int32_t count; //pile count
if (fonts->get_total () > 0) { if (fonts->get_total () > 0) {
font = (inT16) fonts->mode (); font = (int16_t) fonts->mode ();
*font_out = font; *font_out = font;
count = fonts->pile_count (font); count = fonts->pile_count (font);
*font_count = count < MAX_INT8 ? count : MAX_INT8; *font_count = count < INT8_MAX ? count : INT8_MAX;
fonts->add (font, -*font_count); fonts->add (font, -*font_count);
} }
else { else {
@ -1935,7 +1935,7 @@ void Tesseract::set_word_fonts(WERD_RES *word) {
} }
// Find the top and 2nd choice for the word. // Find the top and 2nd choice for the word.
int score1 = 0, score2 = 0; int score1 = 0, score2 = 0;
inT16 font_id1 = -1, font_id2 = -1; int16_t font_id1 = -1, font_id2 = -1;
for (int f = 0; f < fontinfo_size; ++f) { for (int f = 0; f < fontinfo_size; ++f) {
if (tessedit_debug_fonts && font_total_score[f] > 0) { if (tessedit_debug_fonts && font_total_score[f] > 0) {
tprintf("Font %s, total score = %d\n", tprintf("Font %s, total score = %d\n",
@ -1953,10 +1953,10 @@ void Tesseract::set_word_fonts(WERD_RES *word) {
} }
word->fontinfo = font_id1 >= 0 ? &fontinfo_table_.get(font_id1) : NULL; word->fontinfo = font_id1 >= 0 ? &fontinfo_table_.get(font_id1) : NULL;
word->fontinfo2 = font_id2 >= 0 ? &fontinfo_table_.get(font_id2) : NULL; word->fontinfo2 = font_id2 >= 0 ? &fontinfo_table_.get(font_id2) : NULL;
// Each score has a limit of MAX_UINT16, so divide by that to get the number // Each score has a limit of UINT16_MAX, so divide by that to get the number
// of "votes" for that font, ie number of perfect scores. // of "votes" for that font, ie number of perfect scores.
word->fontinfo_id_count = ClipToRange(score1 / MAX_UINT16, 1, MAX_INT8); word->fontinfo_id_count = ClipToRange<int>(score1 / UINT16_MAX, 1, INT8_MAX);
word->fontinfo_id2_count = ClipToRange(score2 / MAX_UINT16, 0, MAX_INT8); word->fontinfo_id2_count = ClipToRange<int>(score2 / UINT16_MAX, 0, INT8_MAX);
if (score1 > 0) { if (score1 > 0) {
FontInfo fi = fontinfo_table_.get(font_id1); FontInfo fi = fontinfo_table_.get(font_id1);
if (tessedit_debug_fonts) { if (tessedit_debug_fonts) {
@ -1998,7 +1998,7 @@ void Tesseract::font_recognition_pass(PAGE_RES* page_res) {
doc_fonts.add(word->fontinfo2->universal_id, word->fontinfo_id2_count); doc_fonts.add(word->fontinfo2->universal_id, word->fontinfo_id2_count);
} }
} }
inT16 doc_font; // modal font int16_t doc_font; // modal font
int8_t doc_font_count; // modal font int8_t doc_font_count; // modal font
find_modal_font(&doc_fonts, &doc_font, &doc_font_count); find_modal_font(&doc_fonts, &doc_font, &doc_font_count);
if (doc_font_count == 0) if (doc_font_count == 0)

View File

@ -52,8 +52,8 @@ struct DocQualCallbacks {
} }
WERD_RES* word; WERD_RES* word;
inT16 match_count; int16_t match_count;
inT16 accepted_match_count; int16_t accepted_match_count;
}; };
/************************************************************************* /*************************************************************************
@ -62,7 +62,7 @@ struct DocQualCallbacks {
* ASSUME blobs in both initial word and box_word are in ascending order of * ASSUME blobs in both initial word and box_word are in ascending order of
* left hand blob edge. * left hand blob edge.
*************************************************************************/ *************************************************************************/
inT16 Tesseract::word_blob_quality(WERD_RES *word, ROW *row) { int16_t Tesseract::word_blob_quality(WERD_RES *word, ROW *row) {
if (word->bln_boxes == NULL || if (word->bln_boxes == NULL ||
word->rebuild_word == NULL || word->rebuild_word->blobs.empty()) word->rebuild_word == NULL || word->rebuild_word->blobs.empty())
return 0; return 0;
@ -74,9 +74,9 @@ inT16 Tesseract::word_blob_quality(WERD_RES *word, ROW *row) {
return cb.match_count; return cb.match_count;
} }
inT16 Tesseract::word_outline_errs(WERD_RES *word) { int16_t Tesseract::word_outline_errs(WERD_RES *word) {
inT16 i = 0; int16_t i = 0;
inT16 err_count = 0; int16_t err_count = 0;
if (word->rebuild_word != NULL) { if (word->rebuild_word != NULL) {
for (int b = 0; b < word->rebuild_word->NumBlobs(); ++b) { for (int b = 0; b < word->rebuild_word->NumBlobs(); ++b) {
@ -96,8 +96,8 @@ inT16 Tesseract::word_outline_errs(WERD_RES *word) {
*************************************************************************/ *************************************************************************/
void Tesseract::word_char_quality(WERD_RES *word, void Tesseract::word_char_quality(WERD_RES *word,
ROW *row, ROW *row,
inT16 *match_count, int16_t *match_count,
inT16 *accepted_match_count) { int16_t *accepted_match_count) {
if (word->bln_boxes == NULL || word->rebuild_word == NULL || if (word->bln_boxes == NULL || word->rebuild_word == NULL ||
word->rebuild_word->blobs.empty()) { word->rebuild_word->blobs.empty()) {
*match_count = 0; *match_count = 0;
@ -128,7 +128,7 @@ void Tesseract::unrej_good_chs(WERD_RES *word, ROW *row) {
NewPermanentTessCallback(&cb, &DocQualCallbacks::AcceptIfGoodQuality)); NewPermanentTessCallback(&cb, &DocQualCallbacks::AcceptIfGoodQuality));
} }
inT16 Tesseract::count_outline_errs(char c, inT16 outline_count) { int16_t Tesseract::count_outline_errs(char c, int16_t outline_count) {
int expected_outline_count; int expected_outline_count;
if (STRING (outlines_odd).contains (c)) if (STRING (outlines_odd).contains (c))
@ -237,15 +237,15 @@ void Tesseract::unrej_good_quality_words( //unreject potential
void Tesseract::doc_and_block_rejection( //reject big chunks void Tesseract::doc_and_block_rejection( //reject big chunks
PAGE_RES_IT &page_res_it, PAGE_RES_IT &page_res_it,
BOOL8 good_quality_doc) { BOOL8 good_quality_doc) {
inT16 block_no = 0; int16_t block_no = 0;
inT16 row_no = 0; int16_t row_no = 0;
BLOCK_RES *current_block; BLOCK_RES *current_block;
ROW_RES *current_row; ROW_RES *current_row;
BOOL8 rej_word; BOOL8 rej_word;
BOOL8 prev_word_rejected; BOOL8 prev_word_rejected;
inT16 char_quality = 0; int16_t char_quality = 0;
inT16 accepted_char_quality; int16_t accepted_char_quality;
if (page_res_it.page_res->rej_count * 100.0 / if (page_res_it.page_res->rej_count * 100.0 /
page_res_it.page_res->char_count > tessedit_reject_doc_percent) { page_res_it.page_res->char_count > tessedit_reject_doc_percent) {
@ -596,9 +596,9 @@ void Tesseract::tilde_delete(PAGE_RES_IT &page_res_it) {
PAGE_RES_IT copy_it; PAGE_RES_IT copy_it;
BOOL8 deleting_from_bol = FALSE; BOOL8 deleting_from_bol = FALSE;
BOOL8 marked_delete_point = FALSE; BOOL8 marked_delete_point = FALSE;
inT16 debug_delete_mode; int16_t debug_delete_mode;
CRUNCH_MODE delete_mode; CRUNCH_MODE delete_mode;
inT16 x_debug_delete_mode; int16_t x_debug_delete_mode;
CRUNCH_MODE x_delete_mode; CRUNCH_MODE x_delete_mode;
page_res_it.restart_page(); page_res_it.restart_page();
@ -896,7 +896,7 @@ GARBAGE_LEVEL Tesseract::garbage_word(WERD_RES *word, BOOL8 ok_dict_word) {
* >75% of the outline BBs have longest dimension < 0.5xht * >75% of the outline BBs have longest dimension < 0.5xht
*************************************************************************/ *************************************************************************/
CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, inT16 &delete_mode) { CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, int16_t &delete_mode) {
int word_len = word->reject_map.length (); int word_len = word->reject_map.length ();
float rating_per_ch; float rating_per_ch;
TBOX box; //BB of word TBOX box; //BB of word
@ -967,7 +967,7 @@ CRUNCH_MODE Tesseract::word_deletable(WERD_RES *word, inT16 &delete_mode) {
return CR_NONE; return CR_NONE;
} }
inT16 Tesseract::failure_count(WERD_RES *word) { int16_t Tesseract::failure_count(WERD_RES *word) {
const char *str = word->best_choice->unichar_string().string(); const char *str = word->best_choice->unichar_string().string();
int tess_rejs = 0; int tess_rejs = 0;
@ -981,9 +981,9 @@ inT16 Tesseract::failure_count(WERD_RES *word) {
BOOL8 Tesseract::noise_outlines(TWERD *word) { BOOL8 Tesseract::noise_outlines(TWERD *word) {
TBOX box; // BB of outline TBOX box; // BB of outline
inT16 outline_count = 0; int16_t outline_count = 0;
inT16 small_outline_count = 0; int16_t small_outline_count = 0;
inT16 max_dimension; int16_t max_dimension;
float small_limit = kBlnXHeight * crunch_small_outlines_size; float small_limit = kBlnXHeight * crunch_small_outlines_size;
for (int b = 0; b < word->NumBlobs(); ++b) { for (int b = 0; b < word->NumBlobs(); ++b) {

View File

@ -30,6 +30,6 @@ enum GARBAGE_LEVEL
G_TERRIBLE G_TERRIBLE
}; };
inT16 word_blob_quality(WERD_RES *word, ROW *row); int16_t word_blob_quality(WERD_RES *word, ROW *row);
void reject_whole_page(PAGE_RES_IT &page_res_it); void reject_whole_page(PAGE_RES_IT &page_res_it);
#endif #endif

View File

@ -664,12 +664,12 @@ void EquationDetect::SplitCPHor(ColPartition* part,
// the previous blob may have a "more right" right side. // the previous blob may have a "more right" right side.
// Account for this by always keeping the largest "right" // Account for this by always keeping the largest "right"
// so far. // so far.
int previous_right = MIN_INT32; int previous_right = INT32_MIN;
// Look for the next split in the partition. // Look for the next split in the partition.
for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) { for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) {
const TBOX& box = box_it.data()->bounding_box(); const TBOX& box = box_it.data()->bounding_box();
if (previous_right != MIN_INT32 && if (previous_right != INT32_MIN &&
box.left() - previous_right > kThreshold) { box.left() - previous_right > kThreshold) {
// We have a split position. Split the partition in two pieces. // We have a split position. Split the partition in two pieces.
// Insert the left piece in the grid and keep processing the right. // Insert the left piece in the grid and keep processing the right.
@ -708,17 +708,17 @@ void EquationDetect::SplitCPHorLite(ColPartition* part,
// Account for this by always keeping the largest "right" // Account for this by always keeping the largest "right"
// so far. // so far.
TBOX union_box; TBOX union_box;
int previous_right = MIN_INT32; int previous_right = INT32_MIN;
BLOBNBOX_C_IT box_it(part->boxes()); BLOBNBOX_C_IT box_it(part->boxes());
for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) { for (box_it.mark_cycle_pt(); !box_it.cycled_list(); box_it.forward()) {
const TBOX& box = box_it.data()->bounding_box(); const TBOX& box = box_it.data()->bounding_box();
if (previous_right != MIN_INT32 && if (previous_right != INT32_MIN &&
box.left() - previous_right > kThreshold) { box.left() - previous_right > kThreshold) {
// We have a split position. // We have a split position.
splitted_boxes->push_back(union_box); splitted_boxes->push_back(union_box);
previous_right = MIN_INT32; previous_right = INT32_MIN;
} }
if (previous_right == MIN_INT32) { if (previous_right == INT32_MIN) {
union_box = box; union_box = box;
} else { } else {
union_box += box; union_box += box;
@ -728,7 +728,7 @@ void EquationDetect::SplitCPHorLite(ColPartition* part,
} }
// Add the last piece. // Add the last piece.
if (previous_right != MIN_INT32) { if (previous_right != INT32_MIN) {
splitted_boxes->push_back(union_box); splitted_boxes->push_back(union_box);
} }
} }

View File

@ -46,7 +46,7 @@ namespace tesseract {
* @param[out] page_res * @param[out] page_res
*/ */
void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor, void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
inT32 word_count, int32_t word_count,
PAGE_RES *page_res) { PAGE_RES *page_res) {
BLOCK_RES_IT block_res_it; BLOCK_RES_IT block_res_it;
ROW_RES_IT row_res_it; ROW_RES_IT row_res_it;
@ -54,9 +54,9 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
WERD_RES_IT word_res_it_to; WERD_RES_IT word_res_it_to;
WERD_RES *word_res; WERD_RES *word_res;
WERD_RES_LIST fuzzy_space_words; WERD_RES_LIST fuzzy_space_words;
inT16 new_length; int16_t new_length;
BOOL8 prevent_null_wd_fixsp; // DON'T process blobless wds BOOL8 prevent_null_wd_fixsp; // DON'T process blobless wds
inT32 word_index; // current word int32_t word_index; // current word
block_res_it.set_to_list(&page_res->block_res_list); block_res_it.set_to_list(&page_res->block_res_list);
word_index = 0; word_index = 0;
@ -145,9 +145,9 @@ void Tesseract::fix_fuzzy_spaces(ETEXT_DESC *monitor,
void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm, void Tesseract::fix_fuzzy_space_list(WERD_RES_LIST &best_perm,
ROW *row, ROW *row,
BLOCK* block) { BLOCK* block) {
inT16 best_score; int16_t best_score;
WERD_RES_LIST current_perm; WERD_RES_LIST current_perm;
inT16 current_score; int16_t current_score;
BOOL8 improved = FALSE; BOOL8 improved = FALSE;
best_score = eval_word_spacing(best_perm); // default score best_score = eval_word_spacing(best_perm); // default score
@ -236,16 +236,16 @@ void Tesseract::match_current_words(WERD_RES_LIST &words, ROW *row,
* confirmed. The only score is from the joined 1. "PS7a713/7a" scores 2. * confirmed. The only score is from the joined 1. "PS7a713/7a" scores 2.
* *
*/ */
inT16 Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) { int16_t Tesseract::eval_word_spacing(WERD_RES_LIST &word_res_list) {
WERD_RES_IT word_res_it(&word_res_list); WERD_RES_IT word_res_it(&word_res_list);
inT16 total_score = 0; int16_t total_score = 0;
inT16 word_count = 0; int16_t word_count = 0;
inT16 done_word_count = 0; int16_t done_word_count = 0;
inT16 word_len; int16_t word_len;
inT16 i; int16_t i;
inT16 offset; int16_t offset;
WERD_RES *word; // current word WERD_RES *word; // current word
inT16 prev_word_score = 0; int16_t prev_word_score = 0;
BOOL8 prev_word_done = FALSE; BOOL8 prev_word_done = FALSE;
BOOL8 prev_char_1 = FALSE; // prev ch a "1/I/l"? BOOL8 prev_char_1 = FALSE; // prev ch a "1/I/l"?
BOOL8 prev_char_digit = FALSE; // prev ch 2..9 or 0 BOOL8 prev_char_digit = FALSE; // prev ch 2..9 or 0
@ -376,16 +376,16 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
WERD_RES *prev_word; WERD_RES *prev_word;
WERD_RES *combo; WERD_RES *combo;
WERD *copy_word; WERD *copy_word;
inT16 prev_right = -MAX_INT16; int16_t prev_right = -INT16_MAX;
TBOX box; TBOX box;
inT16 gap; int16_t gap;
inT16 min_gap = MAX_INT16; int16_t min_gap = INT16_MAX;
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
word = word_it.data(); word = word_it.data();
if (!word->part_of_combo) { if (!word->part_of_combo) {
box = word->word->bounding_box(); box = word->word->bounding_box();
if (prev_right > -MAX_INT16) { if (prev_right > -INT16_MAX) {
gap = box.left() - prev_right; gap = box.left() - prev_right;
if (gap < min_gap) if (gap < min_gap)
min_gap = gap; min_gap = gap;
@ -393,16 +393,16 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
prev_right = box.right(); prev_right = box.right();
} }
} }
if (min_gap < MAX_INT16) { if (min_gap < INT16_MAX) {
prev_right = -MAX_INT16; // back to start prev_right = -INT16_MAX; // back to start
word_it.set_to_list(&words); word_it.set_to_list(&words);
// Note: we can't use cycle_pt due to inserted combos at start of list. // Note: we can't use cycle_pt due to inserted combos at start of list.
for (; (prev_right == -MAX_INT16) || !word_it.at_first(); for (; (prev_right == -INT16_MAX) || !word_it.at_first();
word_it.forward()) { word_it.forward()) {
word = word_it.data(); word = word_it.data();
if (!word->part_of_combo) { if (!word->part_of_combo) {
box = word->word->bounding_box(); box = word->word->bounding_box();
if (prev_right > -MAX_INT16) { if (prev_right > -INT16_MAX) {
gap = box.left() - prev_right; gap = box.left() - prev_right;
if (gap <= min_gap) { if (gap <= min_gap) {
prev_word = prev_word_it.data(); prev_word = prev_word_it.data();
@ -446,8 +446,8 @@ void transform_to_next_perm(WERD_RES_LIST &words) {
} }
namespace tesseract { namespace tesseract {
void Tesseract::dump_words(WERD_RES_LIST &perm, inT16 score, void Tesseract::dump_words(WERD_RES_LIST &perm, int16_t score,
inT16 mode, BOOL8 improved) { int16_t mode, BOOL8 improved) {
WERD_RES_IT word_res_it(&perm); WERD_RES_IT word_res_it(&perm);
if (debug_fix_space_level > 0) { if (debug_fix_space_level > 0) {
@ -537,8 +537,8 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row,
WERD_RES *word_res; WERD_RES *word_res;
WERD_RES_LIST sub_word_list; WERD_RES_LIST sub_word_list;
WERD_RES_IT sub_word_list_it(&sub_word_list); WERD_RES_IT sub_word_list_it(&sub_word_list);
inT16 blob_index; int16_t blob_index;
inT16 new_length; int16_t new_length;
float junk; float junk;
word_res = word_res_it.data(); word_res = word_res_it.data();
@ -568,12 +568,12 @@ void Tesseract::fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row,
void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, void Tesseract::fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row,
BLOCK* block) { BLOCK* block) {
inT16 best_score; int16_t best_score;
WERD_RES_IT best_perm_it(&best_perm); WERD_RES_IT best_perm_it(&best_perm);
WERD_RES_LIST current_perm; WERD_RES_LIST current_perm;
WERD_RES_IT current_perm_it(&current_perm); WERD_RES_IT current_perm_it(&current_perm);
WERD_RES *old_word_res; WERD_RES *old_word_res;
inT16 current_score; int16_t current_score;
BOOL8 improved = FALSE; BOOL8 improved = FALSE;
best_score = fp_eval_word_spacing(best_perm); // default score best_score = fp_eval_word_spacing(best_perm); // default score
@ -626,8 +626,8 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
C_BLOB_IT new_blob_it; C_BLOB_IT new_blob_it;
C_BLOB_IT new_rej_cblob_it; C_BLOB_IT new_rej_cblob_it;
WERD *new_word; WERD *new_word;
inT16 start_of_noise_blob; int16_t start_of_noise_blob;
inT16 i; int16_t i;
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {
blob_index = worst_noise_blob(word_it.data(), &noise_score); blob_index = worst_noise_blob(word_it.data(), &noise_score);
@ -677,7 +677,7 @@ void Tesseract::break_noisiest_blob_word(WERD_RES_LIST &words) {
word_res->ClearResults(); word_res->ClearResults();
} }
inT16 Tesseract::worst_noise_blob(WERD_RES *word_res, int16_t Tesseract::worst_noise_blob(WERD_RES *word_res,
float *worst_noise_score) { float *worst_noise_score) {
float noise_score[512]; float noise_score[512];
int i; int i;
@ -759,9 +759,9 @@ inT16 Tesseract::worst_noise_blob(WERD_RES *word_res,
float Tesseract::blob_noise_score(TBLOB *blob) { float Tesseract::blob_noise_score(TBLOB *blob) {
TBOX box; // BB of outline TBOX box; // BB of outline
inT16 outline_count = 0; int16_t outline_count = 0;
inT16 max_dimension; int16_t max_dimension;
inT16 largest_outline_dimension = 0; int16_t largest_outline_dimension = 0;
for (TESSLINE* ol = blob->outlines; ol != NULL; ol= ol->next) { for (TESSLINE* ol = blob->outlines; ol != NULL; ol= ol->next) {
outline_count++; outline_count++;
@ -795,7 +795,7 @@ float Tesseract::blob_noise_score(TBLOB *blob) {
void fixspace_dbg(WERD_RES *word) { void fixspace_dbg(WERD_RES *word) {
TBOX box = word->word->bounding_box(); TBOX box = word->word->bounding_box();
BOOL8 show_map_detail = FALSE; BOOL8 show_map_detail = FALSE;
inT16 i; int16_t i;
box.print(); box.print();
tprintf(" \"%s\" ", word->best_choice->unichar_string().string()); tprintf(" \"%s\" ", word->best_choice->unichar_string().string());
@ -827,11 +827,11 @@ void fixspace_dbg(WERD_RES *word) {
* Penalise any potential noise chars * Penalise any potential noise chars
*/ */
namespace tesseract { namespace tesseract {
inT16 Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) { int16_t Tesseract::fp_eval_word_spacing(WERD_RES_LIST &word_res_list) {
WERD_RES_IT word_it(&word_res_list); WERD_RES_IT word_it(&word_res_list);
WERD_RES *word; WERD_RES *word;
inT16 score = 0; int16_t score = 0;
inT16 i; int16_t i;
float small_limit = kBlnXHeight * fixsp_small_outlines_size; float small_limit = kBlnXHeight * fixsp_small_outlines_size;
for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) { for (word_it.mark_cycle_pt(); !word_it.cycled_list(); word_it.forward()) {

View File

@ -100,8 +100,8 @@ int Tesseract::CountMisfitTops(WERD_RES *word_res) {
// See comment above for overall algorithm. // See comment above for overall algorithm.
float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res, float Tesseract::ComputeCompatibleXheight(WERD_RES *word_res,
float* baseline_shift) { float* baseline_shift) {
STATS top_stats(0, MAX_UINT8); STATS top_stats(0, UINT8_MAX);
STATS shift_stats(-MAX_UINT8, MAX_UINT8); STATS shift_stats(-UINT8_MAX, UINT8_MAX);
int bottom_shift = 0; int bottom_shift = 0;
int num_blobs = word_res->rebuild_word->NumBlobs(); int num_blobs = word_res->rebuild_word->NumBlobs();
do { do {

View File

@ -54,14 +54,14 @@
* number of points. * number of points.
**********************************************************************/ **********************************************************************/
inT32 pixels_to_pts( //convert coords int32_t pixels_to_pts( //convert coords
inT32 pixels, int32_t pixels,
inT32 pix_res //resolution int32_t pix_res //resolution
) { ) {
float pts; //converted value float pts; //converted value
pts = pixels * 72.0 / pix_res; pts = pixels * 72.0 / pix_res;
return (inT32) (pts + 0.5); //round it return (int32_t) (pts + 0.5); //round it
} }
namespace tesseract { namespace tesseract {
@ -248,8 +248,8 @@ char determine_newline_type( //test line ends
WERD *next_word, //next word WERD *next_word, //next word
BLOCK *next_block //block of next word BLOCK *next_block //block of next word
) { ) {
inT16 end_gap; //to right edge int16_t end_gap; //to right edge
inT16 width; //of next word int16_t width; //of next word
TBOX word_box; //bounding TBOX word_box; //bounding
TBOX next_box; //next word TBOX next_box; //next word
TBOX block_box; //block bounding TBOX block_box; //block bounding
@ -265,7 +265,7 @@ char determine_newline_type( //test line ends
block_box = block->bounding_box (); block_box = block->bounding_box ();
//gap to eol //gap to eol
end_gap = block_box.right () - word_box.right (); end_gap = block_box.right () - word_box.right ();
end_gap -= (inT32) block->space (); end_gap -= (int32_t) block->space ();
width = next_box.right () - next_box.left (); width = next_box.right () - next_box.left ();
// tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n", // tprintf("end_gap=%d-%d=%d, width=%d-%d=%d, nl=%d\n",
// block_box.right(),word_box.right(),end_gap, // block_box.right(),word_box.right(),end_gap,
@ -395,7 +395,7 @@ void Tesseract::set_unlv_suspects(WERD_RES *word_res) {
} }
} }
inT16 Tesseract::count_alphas(const WERD_CHOICE &word) { int16_t Tesseract::count_alphas(const WERD_CHOICE &word) {
int count = 0; int count = 0;
for (int i = 0; i < word.length(); ++i) { for (int i = 0; i < word.length(); ++i) {
if (word.unicharset()->get_isalpha(word.unichar_id(i))) if (word.unicharset()->get_isalpha(word.unichar_id(i)))
@ -405,7 +405,7 @@ inT16 Tesseract::count_alphas(const WERD_CHOICE &word) {
} }
inT16 Tesseract::count_alphanums(const WERD_CHOICE &word) { int16_t Tesseract::count_alphanums(const WERD_CHOICE &word) {
int count = 0; int count = 0;
for (int i = 0; i < word.length(); ++i) { for (int i = 0; i < word.length(); ++i) {
if (word.unicharset()->get_isalpha(word.unichar_id(i)) || if (word.unicharset()->get_isalpha(word.unichar_id(i)) ||

View File

@ -473,7 +473,7 @@ Pix* PageIterator::GetImage(PageIteratorLevel level, int padding,
pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1, pixDilateBrick(resized_mask, resized_mask, 2 * padding + 1,
2 * padding + 1); 2 * padding + 1);
pixInvert(resized_mask, resized_mask); pixInvert(resized_mask, resized_mask);
pixSetMasked(grey_pix, resized_mask, MAX_UINT32); pixSetMasked(grey_pix, resized_mask, UINT32_MAX);
pixDestroy(&resized_mask); pixDestroy(&resized_mask);
} }
return grey_pix; return grey_pix;
@ -493,9 +493,9 @@ bool PageIterator::Baseline(PageIteratorLevel level,
? word->bounding_box() ? word->bounding_box()
: row->bounding_box(); : row->bounding_box();
int left = box.left(); int left = box.left();
ICOORD startpt(left, static_cast<inT16>(row->base_line(left) + 0.5)); ICOORD startpt(left, static_cast<int16_t>(row->base_line(left) + 0.5));
int right = box.right(); int right = box.right();
ICOORD endpt(right, static_cast<inT16>(row->base_line(right) + 0.5)); ICOORD endpt(right, static_cast<int16_t>(row->base_line(right) + 0.5));
// Rotate to image coordinates and convert to global image coords. // Rotate to image coordinates and convert to global image coords.
startpt.rotate(it_->block()->block->re_rotation()); startpt.rotate(it_->block()->block->re_rotation());
endpt.rotate(it_->block()->block->re_rotation()); endpt.rotate(it_->block()->block->re_rotation());

View File

@ -71,7 +71,7 @@ static Pix* RemoveEnclosingCircle(Pix* pixs) {
l_int32 max_count; l_int32 max_count;
pixCountConnComp(pixt, 8, &max_count); pixCountConnComp(pixt, 8, &max_count);
// The count has to go up before we start looking for the minimum. // The count has to go up before we start looking for the minimum.
l_int32 min_count = MAX_INT32; l_int32 min_count = INT32_MAX;
Pix* pixout = NULL; Pix* pixout = NULL;
for (int i = 1; i < kMaxCircleErosions; i++) { for (int i = 1; i < kMaxCircleErosions; i++) {
pixDestroy(&pixt); pixDestroy(&pixt);

View File

@ -395,7 +395,7 @@ void pgeditor_show_point( // display coords
namespace tesseract { namespace tesseract {
BOOL8 Tesseract::process_cmd_win_event( // UI command semantics BOOL8 Tesseract::process_cmd_win_event( // UI command semantics
inT32 cmd_event, // which menu item? int32_t cmd_event, // which menu item?
char *new_value // any prompt data char *new_value // any prompt data
) { ) {
char msg[160]; char msg[160];
@ -820,19 +820,19 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) {
return true; return true;
} }
/* /*
Note the double coercions of(COLOUR)((inT32)editor_image_word_bb_color) Note the double coercions of(COLOUR)((int32_t)editor_image_word_bb_color)
etc. are to keep the compiler happy. etc. are to keep the compiler happy.
*/ */
// display bounding box // display bounding box
if (word->display_flag(DF_BOX)) { if (word->display_flag(DF_BOX)) {
word->bounding_box().plot(image_win, word->bounding_box().plot(image_win,
(ScrollView::Color)((inT32) (ScrollView::Color)((int32_t)
editor_image_word_bb_color), editor_image_word_bb_color),
(ScrollView::Color)((inT32) (ScrollView::Color)((int32_t)
editor_image_word_bb_color)); editor_image_word_bb_color));
ScrollView::Color c = (ScrollView::Color) ScrollView::Color c = (ScrollView::Color)
((inT32) editor_image_blob_bb_color); ((int32_t) editor_image_blob_bb_color);
image_win->Pen(c); image_win->Pen(c);
c_it.set_to_list(word->cblob_list()); c_it.set_to_list(word->cblob_list());
for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward()) for (c_it.mark_cycle_pt(); !c_it.cycled_list(); c_it.forward())
@ -907,8 +907,8 @@ BOOL8 Tesseract::word_display(PAGE_RES_IT* pr_it) {
if (!displayed_something) // display BBox anyway if (!displayed_something) // display BBox anyway
word->bounding_box().plot(image_win, word->bounding_box().plot(image_win,
(ScrollView::Color)((inT32) editor_image_word_bb_color), (ScrollView::Color)((int32_t) editor_image_word_bb_color),
(ScrollView::Color)((inT32) (ScrollView::Color)((int32_t)
editor_image_word_bb_color)); editor_image_word_bb_color));
return TRUE; return TRUE;
} }

View File

@ -29,7 +29,7 @@
namespace tesseract { namespace tesseract {
const inT16 kMaxBoxEdgeDiff = 2; const int16_t kMaxBoxEdgeDiff = 2;
// Sets flags necessary for recognition in the training mode. // Sets flags necessary for recognition in the training mode.
// Opens and returns the pointer to the output file. // Opens and returns the pointer to the output file.

View File

@ -54,7 +54,7 @@ CLISTIZEH (STRING) CLISTIZE (STRING)
*************************************************************************/ *************************************************************************/
namespace tesseract { namespace tesseract {
void Tesseract::set_done(WERD_RES *word, inT16 pass) { void Tesseract::set_done(WERD_RES *word, int16_t pass) {
word->done = word->tess_accepted && word->done = word->tess_accepted &&
(strchr(word->best_choice->unichar_string().string(), ' ') == NULL); (strchr(word->best_choice->unichar_string().string(), ' ') == NULL);
bool word_is_ambig = word->best_choice->dangerous_ambig_found(); bool word_is_ambig = word->best_choice->dangerous_ambig_found();
@ -85,7 +85,7 @@ void Tesseract::set_done(WERD_RES *word, inT16 pass) {
* *
* Sets a reject map for the word. * Sets a reject map for the word.
*************************************************************************/ *************************************************************************/
void Tesseract::make_reject_map(WERD_RES *word, ROW *row, inT16 pass) { void Tesseract::make_reject_map(WERD_RES *word, ROW *row, int16_t pass) {
int i; int i;
int offset; int offset;
@ -176,8 +176,8 @@ void Tesseract::make_reject_map(WERD_RES *word, ROW *row, inT16 pass) {
void reject_blanks(WERD_RES *word) { void reject_blanks(WERD_RES *word) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0'; for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0';
offset += word->best_choice->unichar_lengths()[i], i += 1) { offset += word->best_choice->unichar_lengths()[i], i += 1) {
@ -189,8 +189,8 @@ void reject_blanks(WERD_RES *word) {
namespace tesseract { namespace tesseract {
void Tesseract::reject_I_1_L(WERD_RES *word) { void Tesseract::reject_I_1_L(WERD_RES *word) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0'; for (i = 0, offset = 0; word->best_choice->unichar_string()[offset] != '\0';
offset += word->best_choice->unichar_lengths()[i], i += 1) { offset += word->best_choice->unichar_lengths()[i], i += 1) {
@ -292,11 +292,11 @@ void Tesseract::reject_edge_blobs(WERD_RES *word) {
BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) { BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
const char *word; const char *word;
const char *lengths; const char *lengths;
inT16 word_len; //its length int16_t word_len; //its length
inT16 first_alphanum_index_; int16_t first_alphanum_index_;
inT16 first_alphanum_offset_; int16_t first_alphanum_offset_;
inT16 i; int16_t i;
inT16 offset; int16_t offset;
BOOL8 non_conflict_set_char; //non conf set a/n? BOOL8 non_conflict_set_char; //non conf set a/n?
BOOL8 conflict = FALSE; BOOL8 conflict = FALSE;
BOOL8 allow_1s; BOOL8 allow_1s;
@ -425,7 +425,7 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
allow_1s = (alpha_count (word, lengths) == 0) || allow_1s = (alpha_count (word, lengths) == 0) ||
(word_res->best_choice->permuter () == NUMBER_PERM); (word_res->best_choice->permuter () == NUMBER_PERM);
inT16 offset; int16_t offset;
conflict = FALSE; conflict = FALSE;
for (i = 0, offset = 0; word[offset] != '\0'; for (i = 0, offset = 0; word[offset] != '\0';
offset += word_res->best_choice->unichar_lengths()[i++]) { offset += word_res->best_choice->unichar_lengths()[i++]) {
@ -466,10 +466,10 @@ BOOL8 Tesseract::one_ell_conflict(WERD_RES *word_res, BOOL8 update_map) {
} }
inT16 Tesseract::first_alphanum_index(const char *word, int16_t Tesseract::first_alphanum_index(const char *word,
const char *word_lengths) { const char *word_lengths) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) { for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
if (unicharset.get_isalpha(word + offset, word_lengths[i]) || if (unicharset.get_isalpha(word + offset, word_lengths[i]) ||
@ -479,10 +479,10 @@ inT16 Tesseract::first_alphanum_index(const char *word,
return -1; return -1;
} }
inT16 Tesseract::first_alphanum_offset(const char *word, int16_t Tesseract::first_alphanum_offset(const char *word,
const char *word_lengths) { const char *word_lengths) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) { for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
if (unicharset.get_isalpha(word + offset, word_lengths[i]) || if (unicharset.get_isalpha(word + offset, word_lengths[i]) ||
@ -492,11 +492,11 @@ inT16 Tesseract::first_alphanum_offset(const char *word,
return -1; return -1;
} }
inT16 Tesseract::alpha_count(const char *word, int16_t Tesseract::alpha_count(const char *word,
const char *word_lengths) { const char *word_lengths) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
inT16 count = 0; int16_t count = 0;
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) { for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
if (unicharset.get_isalpha (word + offset, word_lengths[i])) if (unicharset.get_isalpha (word + offset, word_lengths[i]))
@ -508,8 +508,8 @@ inT16 Tesseract::alpha_count(const char *word,
BOOL8 Tesseract::word_contains_non_1_digit(const char *word, BOOL8 Tesseract::word_contains_non_1_digit(const char *word,
const char *word_lengths) { const char *word_lengths) {
inT16 i; int16_t i;
inT16 offset; int16_t offset;
for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) { for (i = 0, offset = 0; word[offset] != '\0'; offset += word_lengths[i++]) {
if (unicharset.get_isdigit (word + offset, word_lengths[i]) && if (unicharset.get_isdigit (word + offset, word_lengths[i]) &&
@ -555,7 +555,7 @@ void Tesseract::dont_allow_1Il(WERD_RES *word) {
} }
inT16 Tesseract::count_alphanums(WERD_RES *word_res) { int16_t Tesseract::count_alphanums(WERD_RES *word_res) {
int count = 0; int count = 0;
const WERD_CHOICE *best_choice = word_res->best_choice; const WERD_CHOICE *best_choice = word_res->best_choice;
for (int i = 0; i < word_res->reject_map.length(); ++i) { for (int i = 0; i < word_res->reject_map.length(); ++i) {
@ -580,8 +580,8 @@ void Tesseract::reject_mostly_rejects(WERD_RES *word) {
BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) { BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) {
inT16 char_quality; int16_t char_quality;
inT16 accepted_char_quality; int16_t accepted_char_quality;
if (word->best_choice->unichar_lengths().length() <= 1) if (word->best_choice->unichar_lengths().length() <= 1)
return FALSE; return FALSE;
@ -604,7 +604,7 @@ BOOL8 Tesseract::repeated_nonalphanum_wd(WERD_RES *word, ROW *row) {
return FALSE; return FALSE;
} }
inT16 Tesseract::safe_dict_word(const WERD_RES *werd_res) { int16_t Tesseract::safe_dict_word(const WERD_RES *werd_res) {
const WERD_CHOICE &word = *werd_res->best_choice; const WERD_CHOICE &word = *werd_res->best_choice;
int dict_word_type = werd_res->tesseract->dict_word(word); int dict_word_type = werd_res->tesseract->dict_word(word);
return dict_word_type == DOC_DAWG_PERM ? 0 : dict_word_type; return dict_word_type == DOC_DAWG_PERM ? 0 : dict_word_type;

View File

@ -678,7 +678,7 @@ bool ResultIterator::BidiDebug(int min_level) const {
IntParam *p = ParamUtils::FindParam<IntParam>( IntParam *p = ParamUtils::FindParam<IntParam>(
"bidi_debug", GlobalParams()->int_params, "bidi_debug", GlobalParams()->int_params,
tesseract_->params()->int_params); tesseract_->params()->int_params);
if (p != NULL) debug_level = (inT32)(*p); if (p != NULL) debug_level = (int32_t)(*p);
return debug_level >= min_level; return debug_level >= min_level;
} }

View File

@ -699,11 +699,11 @@ void Tesseract::PrepareForPageseg() {
// Find the max splitter strategy over all langs. // Find the max splitter strategy over all langs.
ShiroRekhaSplitter::SplitStrategy max_pageseg_strategy = ShiroRekhaSplitter::SplitStrategy max_pageseg_strategy =
static_cast<ShiroRekhaSplitter::SplitStrategy>( static_cast<ShiroRekhaSplitter::SplitStrategy>(
static_cast<inT32>(pageseg_devanagari_split_strategy)); static_cast<int32_t>(pageseg_devanagari_split_strategy));
for (int i = 0; i < sub_langs_.size(); ++i) { for (int i = 0; i < sub_langs_.size(); ++i) {
ShiroRekhaSplitter::SplitStrategy pageseg_strategy = ShiroRekhaSplitter::SplitStrategy pageseg_strategy =
static_cast<ShiroRekhaSplitter::SplitStrategy>( static_cast<ShiroRekhaSplitter::SplitStrategy>(
static_cast<inT32>(sub_langs_[i]->pageseg_devanagari_split_strategy)); static_cast<int32_t>(sub_langs_[i]->pageseg_devanagari_split_strategy));
if (pageseg_strategy > max_pageseg_strategy) if (pageseg_strategy > max_pageseg_strategy)
max_pageseg_strategy = pageseg_strategy; max_pageseg_strategy = pageseg_strategy;
pixDestroy(&sub_langs_[i]->pix_binary_); pixDestroy(&sub_langs_[i]->pix_binary_);
@ -730,11 +730,11 @@ void Tesseract::PrepareForTessOCR(BLOCK_LIST* block_list,
// Find the max splitter strategy over all langs. // Find the max splitter strategy over all langs.
ShiroRekhaSplitter::SplitStrategy max_ocr_strategy = ShiroRekhaSplitter::SplitStrategy max_ocr_strategy =
static_cast<ShiroRekhaSplitter::SplitStrategy>( static_cast<ShiroRekhaSplitter::SplitStrategy>(
static_cast<inT32>(ocr_devanagari_split_strategy)); static_cast<int32_t>(ocr_devanagari_split_strategy));
for (int i = 0; i < sub_langs_.size(); ++i) { for (int i = 0; i < sub_langs_.size(); ++i) {
ShiroRekhaSplitter::SplitStrategy ocr_strategy = ShiroRekhaSplitter::SplitStrategy ocr_strategy =
static_cast<ShiroRekhaSplitter::SplitStrategy>( static_cast<ShiroRekhaSplitter::SplitStrategy>(
static_cast<inT32>(sub_langs_[i]->ocr_devanagari_split_strategy)); static_cast<int32_t>(sub_langs_[i]->ocr_devanagari_split_strategy));
if (ocr_strategy > max_ocr_strategy) if (ocr_strategy > max_ocr_strategy)
max_ocr_strategy = ocr_strategy; max_ocr_strategy = ocr_strategy;
} }

View File

@ -118,14 +118,14 @@ struct TesseractStats {
last_char_was_tilde(false), last_char_was_tilde(false),
write_results_empty_block(true) {} write_results_empty_block(true) {}
inT32 adaption_word_number; int32_t adaption_word_number;
inT16 doc_blob_quality; int16_t doc_blob_quality;
inT16 doc_outline_errs; int16_t doc_outline_errs;
inT16 doc_char_quality; int16_t doc_char_quality;
inT16 good_char_count; int16_t good_char_count;
inT16 doc_good_char_quality; int16_t doc_good_char_quality;
inT32 word_count; // count of word in the document int32_t word_count; // count of word in the document
inT32 dict_words; // number of dicitionary words in the document int32_t dict_words; // number of dicitionary words in the document
STRING dump_words_str; // accumulator used by dump_words() STRING dump_words_str; // accumulator used by dump_words()
// Flags used by write_results() // Flags used by write_results()
bool tilde_crunch_written; bool tilde_crunch_written;
@ -499,8 +499,8 @@ class Tesseract : public Wordrec {
UNICHAR_ID get_rep_char(WERD_RES *word); // what char is repeated? UNICHAR_ID get_rep_char(WERD_RES *word); // what char is repeated?
BOOL8 acceptable_number_string(const char *s, BOOL8 acceptable_number_string(const char *s,
const char *lengths); const char *lengths);
inT16 count_alphanums(const WERD_CHOICE &word); int16_t count_alphanums(const WERD_CHOICE &word);
inT16 count_alphas(const WERD_CHOICE &word); int16_t count_alphas(const WERD_CHOICE &word);
//// tessedit.h //////////////////////////////////////////////////////// //// tessedit.h ////////////////////////////////////////////////////////
void read_config_file(const char *filename, SetParamConstraint constraint); void read_config_file(const char *filename, SetParamConstraint constraint);
// Initialize for potentially a set of languages defined by the language // Initialize for potentially a set of languages defined by the language
@ -572,7 +572,7 @@ class Tesseract : public Wordrec {
void process_image_event( // action in image win void process_image_event( // action in image win
const SVEvent &event); const SVEvent &event);
BOOL8 process_cmd_win_event( // UI command semantics BOOL8 process_cmd_win_event( // UI command semantics
inT32 cmd_event, // which menu item? int32_t cmd_event, // which menu item?
char *new_value // any prompt data char *new_value // any prompt data
); );
void debug_word(PAGE_RES* page_res, const TBOX &selection_box); void debug_word(PAGE_RES* page_res, const TBOX &selection_box);
@ -588,18 +588,18 @@ class Tesseract : public Wordrec {
void blob_feature_display(PAGE_RES* page_res, const TBOX& selection_box); void blob_feature_display(PAGE_RES* page_res, const TBOX& selection_box);
//// reject.h ////////////////////////////////////////////////////////// //// reject.h //////////////////////////////////////////////////////////
// make rej map for word // make rej map for word
void make_reject_map(WERD_RES *word, ROW *row, inT16 pass); void make_reject_map(WERD_RES *word, ROW *row, int16_t pass);
BOOL8 one_ell_conflict(WERD_RES *word_res, BOOL8 update_map); BOOL8 one_ell_conflict(WERD_RES *word_res, BOOL8 update_map);
inT16 first_alphanum_index(const char *word, int16_t first_alphanum_index(const char *word,
const char *word_lengths); const char *word_lengths);
inT16 first_alphanum_offset(const char *word, int16_t first_alphanum_offset(const char *word,
const char *word_lengths); const char *word_lengths);
inT16 alpha_count(const char *word, int16_t alpha_count(const char *word,
const char *word_lengths); const char *word_lengths);
BOOL8 word_contains_non_1_digit(const char *word, BOOL8 word_contains_non_1_digit(const char *word,
const char *word_lengths); const char *word_lengths);
void dont_allow_1Il(WERD_RES *word); void dont_allow_1Il(WERD_RES *word);
inT16 count_alphanums( //how many alphanums int16_t count_alphanums( //how many alphanums
WERD_RES *word); WERD_RES *word);
void flip_0O(WERD_RES *word); void flip_0O(WERD_RES *word);
BOOL8 non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id); BOOL8 non_0_digit(const UNICHARSET& ch_set, UNICHAR_ID unichar_id);
@ -611,8 +611,8 @@ class Tesseract : public Wordrec {
void nn_recover_rejects(WERD_RES *word, ROW *row); void nn_recover_rejects(WERD_RES *word, ROW *row);
void set_done( //set done flag void set_done( //set done flag
WERD_RES *word, WERD_RES *word,
inT16 pass); int16_t pass);
inT16 safe_dict_word(const WERD_RES *werd_res); // is best_choice in dict? int16_t safe_dict_word(const WERD_RES *werd_res); // is best_choice in dict?
void flip_hyphens(WERD_RES *word); void flip_hyphens(WERD_RES *word);
void reject_I_1_L(WERD_RES *word); void reject_I_1_L(WERD_RES *word);
void reject_edge_blobs(WERD_RES *word); void reject_edge_blobs(WERD_RES *word);
@ -620,7 +620,7 @@ class Tesseract : public Wordrec {
//// adaptions.h /////////////////////////////////////////////////////// //// adaptions.h ///////////////////////////////////////////////////////
BOOL8 word_adaptable( //should we adapt? BOOL8 word_adaptable( //should we adapt?
WERD_RES *word, WERD_RES *word,
uinT16 mode); uint16_t mode);
//// tfacepp.cpp /////////////////////////////////////////////////////// //// tfacepp.cpp ///////////////////////////////////////////////////////
void recog_word_recursive(WERD_RES* word); void recog_word_recursive(WERD_RES* word);
@ -635,20 +635,20 @@ class Tesseract : public Wordrec {
BlamerBundle *orig_bb) const; BlamerBundle *orig_bb) const;
//// fixspace.cpp /////////////////////////////////////////////////////// //// fixspace.cpp ///////////////////////////////////////////////////////
BOOL8 digit_or_numeric_punct(WERD_RES *word, int char_position); BOOL8 digit_or_numeric_punct(WERD_RES *word, int char_position);
inT16 eval_word_spacing(WERD_RES_LIST &word_res_list); int16_t eval_word_spacing(WERD_RES_LIST &word_res_list);
void match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK* block); void match_current_words(WERD_RES_LIST &words, ROW *row, BLOCK* block);
inT16 fp_eval_word_spacing(WERD_RES_LIST &word_res_list); int16_t fp_eval_word_spacing(WERD_RES_LIST &word_res_list);
void fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block); void fix_noisy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block);
void fix_fuzzy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block); void fix_fuzzy_space_list(WERD_RES_LIST &best_perm, ROW *row, BLOCK* block);
void fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK* block); void fix_sp_fp_word(WERD_RES_IT &word_res_it, ROW *row, BLOCK* block);
void fix_fuzzy_spaces( //find fuzzy words void fix_fuzzy_spaces( //find fuzzy words
ETEXT_DESC *monitor, //progress monitor ETEXT_DESC *monitor, //progress monitor
inT32 word_count, //count of words in doc int32_t word_count, //count of words in doc
PAGE_RES *page_res); PAGE_RES *page_res);
void dump_words(WERD_RES_LIST &perm, inT16 score, void dump_words(WERD_RES_LIST &perm, int16_t score,
inT16 mode, BOOL8 improved); int16_t mode, BOOL8 improved);
BOOL8 fixspace_thinks_word_done(WERD_RES *word); BOOL8 fixspace_thinks_word_done(WERD_RES *word);
inT16 worst_noise_blob(WERD_RES *word_res, float *worst_noise_score); int16_t worst_noise_blob(WERD_RES *word_res, float *worst_noise_score);
float blob_noise_score(TBLOB *blob); float blob_noise_score(TBLOB *blob);
void break_noisiest_blob_word(WERD_RES_LIST &words); void break_noisiest_blob_word(WERD_RES_LIST &words);
//// docqual.cpp //////////////////////////////////////////////////////// //// docqual.cpp ////////////////////////////////////////////////////////
@ -666,15 +666,15 @@ class Tesseract : public Wordrec {
BOOL8 good_quality_doc); BOOL8 good_quality_doc);
void convert_bad_unlv_chs(WERD_RES *word_res); void convert_bad_unlv_chs(WERD_RES *word_res);
void tilde_delete(PAGE_RES_IT &page_res_it); void tilde_delete(PAGE_RES_IT &page_res_it);
inT16 word_blob_quality(WERD_RES *word, ROW *row); int16_t word_blob_quality(WERD_RES *word, ROW *row);
void word_char_quality(WERD_RES *word, ROW *row, inT16 *match_count, void word_char_quality(WERD_RES *word, ROW *row, int16_t *match_count,
inT16 *accepted_match_count); int16_t *accepted_match_count);
void unrej_good_chs(WERD_RES *word, ROW *row); void unrej_good_chs(WERD_RES *word, ROW *row);
inT16 count_outline_errs(char c, inT16 outline_count); int16_t count_outline_errs(char c, int16_t outline_count);
inT16 word_outline_errs(WERD_RES *word); int16_t word_outline_errs(WERD_RES *word);
BOOL8 terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level); BOOL8 terrible_word_crunch(WERD_RES *word, GARBAGE_LEVEL garbage_level);
CRUNCH_MODE word_deletable(WERD_RES *word, inT16 &delete_mode); CRUNCH_MODE word_deletable(WERD_RES *word, int16_t &delete_mode);
inT16 failure_count(WERD_RES *word); int16_t failure_count(WERD_RES *word);
BOOL8 noise_outlines(TWERD *word); BOOL8 noise_outlines(TWERD *word);
//// pagewalk.cpp /////////////////////////////////////////////////////// //// pagewalk.cpp ///////////////////////////////////////////////////////
void void

View File

@ -143,7 +143,7 @@ void Tesseract::recog_word_recursive(WERD_RES *word) {
**********************************************************************/ **********************************************************************/
void Tesseract::split_and_recog_word(WERD_RES *word) { void Tesseract::split_and_recog_word(WERD_RES *word) {
// Find the biggest blob gap in the chopped_word. // Find the biggest blob gap in the chopped_word.
int bestgap = -MAX_INT32; int bestgap = -INT32_MAX;
int split_index = 0; int split_index = 0;
for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) { for (int b = 1; b < word->chopped_word->NumBlobs(); ++b) {
TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box(); TBOX prev_box = word->chopped_word->blobs[b - 1]->bounding_box();

View File

@ -181,7 +181,7 @@ void ImageThresholder::SetImage(const Pix* pix) {
// Caller must use pixDestroy to free the created Pix. // Caller must use pixDestroy to free the created Pix.
/// Returns false on error. /// Returns false on error.
bool ImageThresholder::ThresholdToPix(PageSegMode pageseg_mode, Pix** pix) { bool ImageThresholder::ThresholdToPix(PageSegMode pageseg_mode, Pix** pix) {
if (image_width_ > MAX_INT16 || image_height_ > MAX_INT16) { if (image_width_ > INT16_MAX || image_height_ > INT16_MAX) {
tprintf("Image too large: (%d, %d)\n", image_width_, image_height_); tprintf("Image too large: (%d, %d)\n", image_width_, image_height_);
return false; return false;
} }
@ -301,13 +301,13 @@ void ImageThresholder::ThresholdRectToPix(Pix* src_pix,
Pix** pix) const { Pix** pix) const {
PERF_COUNT_START("ThresholdRectToPix") PERF_COUNT_START("ThresholdRectToPix")
*pix = pixCreate(rect_width_, rect_height_, 1); *pix = pixCreate(rect_width_, rect_height_, 1);
uinT32* pixdata = pixGetData(*pix); uint32_t* pixdata = pixGetData(*pix);
int wpl = pixGetWpl(*pix); int wpl = pixGetWpl(*pix);
int src_wpl = pixGetWpl(src_pix); int src_wpl = pixGetWpl(src_pix);
uinT32* srcdata = pixGetData(src_pix); uint32_t* srcdata = pixGetData(src_pix);
for (int y = 0; y < rect_height_; ++y) { for (int y = 0; y < rect_height_; ++y) {
const uinT32* linedata = srcdata + (y + rect_top_) * src_wpl; const uint32_t* linedata = srcdata + (y + rect_top_) * src_wpl;
uinT32* pixline = pixdata + y * wpl; uint32_t* pixline = pixdata + y * wpl;
for (int x = 0; x < rect_width_; ++x) { for (int x = 0; x < rect_width_; ++x) {
bool white_result = true; bool white_result = true;
for (int ch = 0; ch < num_channels; ++ch) { for (int ch = 0; ch < num_channels; ++ch) {

View File

@ -317,7 +317,7 @@ void BlamerBundle::SetChopperBlame(const WERD_RES* word, bool debug) {
int num_blobs = word->chopped_word->blobs.size(); int num_blobs = word->chopped_word->blobs.size();
int box_index = 0; int box_index = 0;
int blob_index = 0; int blob_index = 0;
inT16 truth_x = -1; int16_t truth_x = -1;
while (box_index < truth_word_.length() && blob_index < num_blobs) { while (box_index < truth_word_.length() && blob_index < num_blobs) {
truth_x = norm_truth_word_.BlobBox(box_index).right(); truth_x = norm_truth_word_.BlobBox(box_index).right();
TBLOB * curr_blob = word->chopped_word->blobs[blob_index]; TBLOB * curr_blob = word->chopped_word->blobs[blob_index];
@ -416,15 +416,15 @@ void BlamerBundle::SetupCorrectSegmentation(const TWERD* word, bool debug) {
int num_blobs = word->NumBlobs(); int num_blobs = word->NumBlobs();
if (num_blobs == 0) return; // No blobs to play with. if (num_blobs == 0) return; // No blobs to play with.
int blob_index = 0; int blob_index = 0;
inT16 next_box_x = word->blobs[blob_index]->bounding_box().right(); int16_t next_box_x = word->blobs[blob_index]->bounding_box().right();
for (int truth_idx = 0; blob_index < num_blobs && for (int truth_idx = 0; blob_index < num_blobs &&
truth_idx < norm_truth_word_.length(); truth_idx < norm_truth_word_.length();
++blob_index) { ++blob_index) {
++next_box_col; ++next_box_col;
inT16 curr_box_x = next_box_x; int16_t curr_box_x = next_box_x;
if (blob_index + 1 < num_blobs) if (blob_index + 1 < num_blobs)
next_box_x = word->blobs[blob_index + 1]->bounding_box().right(); next_box_x = word->blobs[blob_index + 1]->bounding_box().right();
inT16 truth_x = norm_truth_word_.BlobBox(truth_idx).right(); int16_t truth_x = norm_truth_word_.BlobBox(truth_idx).right();
debug_str.add_str_int("Box x coord vs. truth: ", curr_box_x); debug_str.add_str_int("Box x coord vs. truth: ", curr_box_x);
debug_str.add_str_int(" ", truth_x); debug_str.add_str_int(" ", truth_x);
debug_str += "\n"; debug_str += "\n";

View File

@ -30,7 +30,7 @@
#include "strngs.h" #include "strngs.h"
#include "tesscallback.h" #include "tesscallback.h"
static const inT16 kBlamerBoxTolerance = 5; static const int16_t kBlamerBoxTolerance = 5;
// Enum for expressing the source of error. // Enum for expressing the source of error.
// Note: Please update kIncorrectResultReasonNames when modifying this enum. // Note: Please update kIncorrectResultReasonNames when modifying this enum.

View File

@ -118,11 +118,11 @@ void BLOBNBOX::chop( //chop blobs
FCOORD rotation, //for landscape FCOORD rotation, //for landscape
float xheight //of line float xheight //of line
) { ) {
inT16 blobcount; //no of blobs int16_t blobcount; //no of blobs
BLOBNBOX *newblob; //fake blob BLOBNBOX *newblob; //fake blob
BLOBNBOX *blob; //current blob BLOBNBOX *blob; //current blob
inT16 blobindex; //number of chop int16_t blobindex; //number of chop
inT16 leftx; //left edge of blob int16_t leftx; //left edge of blob
float blobwidth; //width of each float blobwidth; //width of each
float rightx; //right edge to scan float rightx; //right edge to scan
float ymin, ymax; //limits of new blob float ymin, ymax; //limits of new blob
@ -131,14 +131,14 @@ void BLOBNBOX::chop( //chop blobs
BLOBNBOX_IT blob_it; //blob iterator BLOBNBOX_IT blob_it; //blob iterator
//get no of chops //get no of chops
blobcount = (inT16) floor (box.width () / xheight); blobcount = (int16_t) floor (box.width () / xheight);
if (blobcount > 1 && cblob_ptr != NULL) { if (blobcount > 1 && cblob_ptr != NULL) {
//width of each //width of each
blobwidth = (float) (box.width () + 1) / blobcount; blobwidth = (float) (box.width () + 1) / blobcount;
for (blobindex = blobcount - 1, rightx = box.right (); for (blobindex = blobcount - 1, rightx = box.right ();
blobindex >= 0; blobindex--, rightx -= blobwidth) { blobindex >= 0; blobindex--, rightx -= blobwidth) {
ymin = (float) MAX_INT32; ymin = (float) INT32_MAX;
ymax = (float) -MAX_INT32; ymax = (float) -INT32_MAX;
blob_it = *start_it; blob_it = *start_it;
do { do {
blob = blob_it.data (); blob = blob_it.data ();
@ -150,11 +150,11 @@ void BLOBNBOX::chop( //chop blobs
} }
while (blob != end_it->data ()); while (blob != end_it->data ());
if (ymin < ymax) { if (ymin < ymax) {
leftx = (inT16) floor (rightx - blobwidth); leftx = (int16_t) floor (rightx - blobwidth);
if (leftx < box.left ()) if (leftx < box.left ())
leftx = box.left (); //clip to real box leftx = box.left (); //clip to real box
bl = ICOORD (leftx, (inT16) floor (ymin)); bl = ICOORD (leftx, (int16_t) floor (ymin));
tr = ICOORD ((inT16) ceil (rightx), (inT16) ceil (ymax)); tr = ICOORD ((int16_t) ceil (rightx), (int16_t) ceil (ymax));
if (blobindex == 0) if (blobindex == 0)
box = TBOX (bl, tr); //change box box = TBOX (bl, tr); //change box
else { else {
@ -175,7 +175,7 @@ void BLOBNBOX::chop( //chop blobs
// indexed by BlobNeighbourDir. // indexed by BlobNeighbourDir.
void BLOBNBOX::NeighbourGaps(int gaps[BND_COUNT]) const { void BLOBNBOX::NeighbourGaps(int gaps[BND_COUNT]) const {
for (int dir = 0; dir < BND_COUNT; ++dir) { for (int dir = 0; dir < BND_COUNT; ++dir) {
gaps[dir] = MAX_INT16; gaps[dir] = INT16_MAX;
BLOBNBOX* neighbour = neighbours_[dir]; BLOBNBOX* neighbour = neighbours_[dir];
if (neighbour != NULL) { if (neighbour != NULL) {
const TBOX& n_box = neighbour->bounding_box(); const TBOX& n_box = neighbour->bounding_box();
@ -498,15 +498,15 @@ void find_cblob_limits( //get y limits
FCOORD rotation, //for landscape FCOORD rotation, //for landscape
float &ymin, //output y limits float &ymin, //output y limits
float &ymax) { float &ymax) {
inT16 stepindex; //current point int16_t stepindex; //current point
ICOORD pos; //current coords ICOORD pos; //current coords
ICOORD vec; //rotated step ICOORD vec; //rotated step
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
//outlines //outlines
C_OUTLINE_IT out_it = blob->out_list (); C_OUTLINE_IT out_it = blob->out_list ();
ymin = (float) MAX_INT32; ymin = (float) INT32_MAX;
ymax = (float) -MAX_INT32; ymax = (float) -INT32_MAX;
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) { for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
outline = out_it.data (); outline = out_it.data ();
pos = outline->start_pos (); //get coords pos = outline->start_pos (); //get coords
@ -537,15 +537,15 @@ void find_cblob_vlimits( //get y limits
float rightx, float rightx,
float &ymin, //output y limits float &ymin, //output y limits
float &ymax) { float &ymax) {
inT16 stepindex; //current point int16_t stepindex; //current point
ICOORD pos; //current coords ICOORD pos; //current coords
ICOORD vec; //rotated step ICOORD vec; //rotated step
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
//outlines //outlines
C_OUTLINE_IT out_it = blob->out_list (); C_OUTLINE_IT out_it = blob->out_list ();
ymin = (float) MAX_INT32; ymin = (float) INT32_MAX;
ymax = (float) -MAX_INT32; ymax = (float) -INT32_MAX;
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) { for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
outline = out_it.data (); outline = out_it.data ();
pos = outline->start_pos (); //get coords pos = outline->start_pos (); //get coords
@ -574,15 +574,15 @@ void find_cblob_hlimits( //get x limits
float topy, float topy,
float &xmin, //output x limits float &xmin, //output x limits
float &xmax) { float &xmax) {
inT16 stepindex; //current point int16_t stepindex; //current point
ICOORD pos; //current coords ICOORD pos; //current coords
ICOORD vec; //rotated step ICOORD vec; //rotated step
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
//outlines //outlines
C_OUTLINE_IT out_it = blob->out_list (); C_OUTLINE_IT out_it = blob->out_list ();
xmin = (float) MAX_INT32; xmin = (float) INT32_MAX;
xmax = (float) -MAX_INT32; xmax = (float) -INT32_MAX;
for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) { for (out_it.mark_cycle_pt (); !out_it.cycled_list (); out_it.forward ()) {
outline = out_it.data (); outline = out_it.data ();
pos = outline->start_pos (); //get coords pos = outline->start_pos (); //get coords
@ -886,8 +886,8 @@ void vertical_coutline_projection( //project outlines
) { ) {
ICOORD pos; //current point ICOORD pos; //current point
ICOORD step; //edge step ICOORD step; //edge step
inT32 length; //of outline int32_t length; //of outline
inT16 stepindex; //current step int16_t stepindex; //current step
C_OUTLINE_IT out_it = outline->child (); C_OUTLINE_IT out_it = outline->child ();
pos = outline->start_pos (); pos = outline->start_pos ();

View File

@ -235,7 +235,7 @@ class BLOBNBOX:public ELIST_LINK
red_box = new_box; red_box = new_box;
reduced = true; reduced = true;
} }
inT32 enclosed_area() const { int32_t enclosed_area() const {
return area; return area;
} }
bool joined_to_prev() const { bool joined_to_prev() const {
@ -510,13 +510,13 @@ class BLOBNBOX:public ELIST_LINK
TabType right_tab_type_; // Indicates tab-stop assessment TabType right_tab_type_; // Indicates tab-stop assessment
BlobRegionType region_type_; // Type of region this blob belongs to BlobRegionType region_type_; // Type of region this blob belongs to
BlobTextFlowType flow_; // Quality of text flow. BlobTextFlowType flow_; // Quality of text flow.
inT16 left_rule_; // x-coord of nearest but not crossing rule line int16_t left_rule_; // x-coord of nearest but not crossing rule line
inT16 right_rule_; // x-coord of nearest but not crossing rule line int16_t right_rule_; // x-coord of nearest but not crossing rule line
inT16 left_crossing_rule_; // x-coord of nearest or crossing rule line int16_t left_crossing_rule_; // x-coord of nearest or crossing rule line
inT16 right_crossing_rule_; // x-coord of nearest or crossing rule line int16_t right_crossing_rule_; // x-coord of nearest or crossing rule line
inT16 base_char_top_; // y-coord of top/bottom of diacritic base, int16_t base_char_top_; // y-coord of top/bottom of diacritic base,
inT16 base_char_bottom_; // if it exists else top/bottom of this blob. int16_t base_char_bottom_; // if it exists else top/bottom of this blob.
inT16 baseline_y_; // Estimate of baseline position. int16_t baseline_y_; // Estimate of baseline position.
int line_crossings_; // Number of line intersections touched. int line_crossings_; // Number of line intersections touched.
BLOBNBOX* base_char_blob_; // The blob that was the base char. BLOBNBOX* base_char_blob_; // The blob that was the base char.
float horz_stroke_width_; // Median horizontal stroke width float horz_stroke_width_; // Median horizontal stroke width
@ -641,8 +641,8 @@ class TO_ROW: public ELIST2_LINK
BOOL8 merged; BOOL8 merged;
BOOL8 all_caps; // had no ascenders BOOL8 all_caps; // had no ascenders
BOOL8 used_dm_model; // in guessing pitch BOOL8 used_dm_model; // in guessing pitch
inT16 projection_left; // start of projection int16_t projection_left; // start of projection
inT16 projection_right; // start of projection int16_t projection_right; // start of projection
PITCH_TYPE pitch_decision; // how strong is decision PITCH_TYPE pitch_decision; // how strong is decision
float fixed_pitch; // pitch or 0 float fixed_pitch; // pitch or 0
float fp_space; // sp if fixed pitch float fp_space; // sp if fixed pitch
@ -656,9 +656,9 @@ class TO_ROW: public ELIST2_LINK
float descdrop; // descenders float descdrop; // descenders
float body_size; // of CJK characters. Assumed to be float body_size; // of CJK characters. Assumed to be
// xheight+ascrise for non-CJK text. // xheight+ascrise for non-CJK text.
inT32 min_space; // min size for real space int32_t min_space; // min size for real space
inT32 max_nonspace; // max size of non-space int32_t max_nonspace; // max size of non-space
inT32 space_threshold; // space vs nonspace int32_t space_threshold; // space vs nonspace
float kern_size; // average non-space float kern_size; // average non-space
float space_size; // average space float space_size; // average space
WERD_LIST rep_words; // repeated chars WERD_LIST rep_words; // repeated chars
@ -785,8 +785,8 @@ class TO_BLOCK:public ELIST_LINK
float fixed_pitch; //pitch or 0 float fixed_pitch; //pitch or 0
float kern_size; //average non-space float kern_size; //average non-space
float space_size; //average space float space_size; //average space
inT32 min_space; //min definite space int32_t min_space; //min definite space
inT32 max_nonspace; //max definite int32_t max_nonspace; //max definite
float fp_space; //sp if fixed pitch float fp_space; //sp if fixed pitch
float fp_nonsp; //nonsp if fixed pitch float fp_nonsp; //nonsp if fixed pitch
float pr_space; //sp if prop float pr_space; //sp if prop

View File

@ -223,10 +223,10 @@ void TESSLINE::SetupFromPos() {
// Recomputes the bounding box from the points in the loop. // Recomputes the bounding box from the points in the loop.
void TESSLINE::ComputeBoundingBox() { void TESSLINE::ComputeBoundingBox() {
int minx = MAX_INT32; int minx = INT32_MAX;
int miny = MAX_INT32; int miny = INT32_MAX;
int maxx = -MAX_INT32; int maxx = -INT32_MAX;
int maxy = -MAX_INT32; int maxy = -INT32_MAX;
// Find boundaries. // Find boundaries.
start = loop->pos; start = loop->pos;
@ -258,8 +258,8 @@ void TESSLINE::ComputeBoundingBox() {
// have to divide by the modulus of vec. // have to divide by the modulus of vec.
void TESSLINE::MinMaxCrossProduct(const TPOINT vec, void TESSLINE::MinMaxCrossProduct(const TPOINT vec,
int* min_xp, int* max_xp) const { int* min_xp, int* max_xp) const {
*min_xp = MAX_INT32; *min_xp = INT32_MAX;
*max_xp = MIN_INT32; *max_xp = INT32_MIN;
EDGEPT* this_edge = loop; EDGEPT* this_edge = loop;
do { do {
if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) { if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
@ -940,8 +940,8 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
if (outline1->is_hole) if (outline1->is_hole)
continue; // Holes do not count as separable. continue; // Holes do not count as separable.
TPOINT mid_pt1( TPOINT mid_pt1(
static_cast<inT16>((outline1->topleft.x + outline1->botright.x) / 2), static_cast<int16_t>((outline1->topleft.x + outline1->botright.x) / 2),
static_cast<inT16>((outline1->topleft.y + outline1->botright.y) / 2)); static_cast<int16_t>((outline1->topleft.y + outline1->botright.y) / 2));
int mid_prod1 = CROSS(mid_pt1, vertical); int mid_prod1 = CROSS(mid_pt1, vertical);
int min_prod1, max_prod1; int min_prod1, max_prod1;
outline1->MinMaxCrossProduct(vertical, &min_prod1, &max_prod1); outline1->MinMaxCrossProduct(vertical, &min_prod1, &max_prod1);
@ -950,8 +950,8 @@ bool divisible_blob(TBLOB *blob, bool italic_blob, TPOINT* location) {
if (outline2->is_hole) if (outline2->is_hole)
continue; // Holes do not count as separable. continue; // Holes do not count as separable.
TPOINT mid_pt2( TPOINT mid_pt2(
static_cast<inT16>((outline2->topleft.x + outline2->botright.x) / 2), static_cast<int16_t>((outline2->topleft.x + outline2->botright.x) / 2),
static_cast<inT16>((outline2->topleft.y + outline2->botright.y) / 2)); static_cast<int16_t>((outline2->topleft.y + outline2->botright.y) / 2));
int mid_prod2 = CROSS(mid_pt2, vertical); int mid_prod2 = CROSS(mid_pt2, vertical);
int min_prod2, max_prod2; int min_prod2, max_prod2;
outline2->MinMaxCrossProduct(vertical, &min_prod2, &max_prod2); outline2->MinMaxCrossProduct(vertical, &min_prod2, &max_prod2);
@ -991,8 +991,8 @@ void divide_blobs(TBLOB *blob, TBLOB *other_blob, bool italic_blob,
while (outline != NULL) { while (outline != NULL) {
TPOINT mid_pt( TPOINT mid_pt(
static_cast<inT16>((outline->topleft.x + outline->botright.x) / 2), static_cast<int16_t>((outline->topleft.x + outline->botright.x) / 2),
static_cast<inT16>((outline->topleft.y + outline->botright.y) / 2)); static_cast<int16_t>((outline->topleft.y + outline->botright.y) / 2));
int mid_prod = CROSS(mid_pt, vertical); int mid_prod = CROSS(mid_pt, vertical);
if (mid_prod < location_prod) { if (mid_prod < location_prod) {
// Outline is in left blob. // Outline is in left blob.

View File

@ -49,7 +49,7 @@ class WERD;
struct TPOINT { struct TPOINT {
TPOINT(): x(0), y(0) {} TPOINT(): x(0), y(0) {}
TPOINT(inT16 vx, inT16 vy) : x(vx), y(vy) {} TPOINT(int16_t vx, int16_t vy) : x(vx), y(vy) {}
TPOINT(const ICOORD &ic) : x(ic.x()), y(ic.y()) {} TPOINT(const ICOORD &ic) : x(ic.x()), y(ic.y()) {}
void operator+=(const TPOINT& other) { void operator+=(const TPOINT& other) {
@ -68,8 +68,8 @@ struct TPOINT {
static bool IsCrossed(const TPOINT& a0, const TPOINT& a1, const TPOINT& b0, static bool IsCrossed(const TPOINT& a0, const TPOINT& a1, const TPOINT& b0,
const TPOINT& b1); const TPOINT& b1);
inT16 x; // absolute x coord. int16_t x; // absolute x coord.
inT16 y; // absolute y coord. int16_t y; // absolute y coord.
}; };
typedef TPOINT VECTOR; // structure for coordinates. typedef TPOINT VECTOR; // structure for coordinates.

View File

@ -35,8 +35,8 @@
bool read_unlv_file( //print list of sides bool read_unlv_file( //print list of sides
STRING name, //basename of file STRING name, //basename of file
inT32 xsize, //image size int32_t xsize, //image size
inT32 ysize, //image size int32_t ysize, //image size
BLOCK_LIST *blocks //output list BLOCK_LIST *blocks //output list
) { ) {
FILE *pdfp; //file pointer FILE *pdfp; //file pointer
@ -54,8 +54,8 @@ bool read_unlv_file( //print list of sides
while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) { while (tfscanf(pdfp, "%d %d %d %d %*s", &x, &y, &width, &height) >= 4) {
//make rect block //make rect block
block = new BLOCK (name.string (), TRUE, 0, 0, block = new BLOCK (name.string (), TRUE, 0, 0,
(inT16) x, (inT16) (ysize - y - height), (int16_t) x, (int16_t) (ysize - y - height),
(inT16) (x + width), (inT16) (ysize - y)); (int16_t) (x + width), (int16_t) (ysize - y));
//on end of list //on end of list
block_it.add_to_end (block); block_it.add_to_end (block);
} }

View File

@ -25,8 +25,8 @@
bool read_unlv_file( //print list of sides bool read_unlv_file( //print list of sides
STRING name, //basename of file STRING name, //basename of file
inT32 xsize, //image size int32_t xsize, //image size
inT32 ysize, //image size int32_t ysize, //image size
BLOCK_LIST *blocks //output list BLOCK_LIST *blocks //output list
); );
void FullPageBlock(int width, int height, BLOCK_LIST *blocks); void FullPageBlock(int width, int height, BLOCK_LIST *blocks);

View File

@ -49,9 +49,9 @@ ICOORD C_OUTLINE::step_coords[4] = {
*/ */
C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right, C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right,
inT16 length) int16_t length)
: box(bot_left, top_right), start(startpt->pos), offsets(NULL) { : box(bot_left, top_right), start(startpt->pos), offsets(NULL) {
inT16 stepindex; //index to step int16_t stepindex; //index to step
CRACKEDGE *edgept; //current point CRACKEDGE *edgept; //current point
stepcount = length; //no of steps stepcount = length; //no of steps
@ -60,7 +60,7 @@ C_OUTLINE::C_OUTLINE(CRACKEDGE* startpt, ICOORD bot_left, ICOORD top_right,
return; return;
} }
//get memory //get memory
steps = (uinT8 *) alloc_mem (step_mem()); steps = (uint8_t *) alloc_mem (step_mem());
memset(steps, 0, step_mem()); memset(steps, 0, step_mem());
edgept = startpt; edgept = startpt;
@ -80,21 +80,21 @@ C_OUTLINE::C_OUTLINE (
//constructor //constructor
//steps to copy //steps to copy
ICOORD startpt, DIR128 * new_steps, ICOORD startpt, DIR128 * new_steps,
inT16 length //length of loop int16_t length //length of loop
):start (startpt), offsets(NULL) { ):start (startpt), offsets(NULL) {
inT8 dirdiff; //direction difference int8_t dirdiff; //direction difference
DIR128 prevdir; //previous direction DIR128 prevdir; //previous direction
DIR128 dir; //current direction DIR128 dir; //current direction
DIR128 lastdir; //dir of last step DIR128 lastdir; //dir of last step
TBOX new_box; //easy bounding TBOX new_box; //easy bounding
inT16 stepindex; //index to step int16_t stepindex; //index to step
inT16 srcindex; //source steps int16_t srcindex; //source steps
ICOORD pos; //current position ICOORD pos; //current position
pos = startpt; pos = startpt;
stepcount = length; // No. of steps. stepcount = length; // No. of steps.
ASSERT_HOST(length >= 0); ASSERT_HOST(length >= 0);
steps = static_cast<uinT8*>(alloc_mem(step_mem())); // Get memory. steps = static_cast<uint8_t*>(alloc_mem(step_mem())); // Get memory.
memset(steps, 0, step_mem()); memset(steps, 0, step_mem());
lastdir = new_steps[length - 1]; lastdir = new_steps[length - 1];
@ -140,15 +140,15 @@ inT16 length //length of loop
C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(NULL) { C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(NULL) {
TBOX new_box; //easy bounding TBOX new_box; //easy bounding
inT16 stepindex; //index to step int16_t stepindex; //index to step
inT16 dirdiff; //direction change int16_t dirdiff; //direction change
ICOORD pos; //current position ICOORD pos; //current position
ICOORD prevpos; //previous dest point ICOORD prevpos; //previous dest point
ICOORD destpos; //destination point ICOORD destpos; //destination point
inT16 destindex; //index to step int16_t destindex; //index to step
DIR128 dir; //coded direction DIR128 dir; //coded direction
uinT8 new_step; uint8_t new_step;
stepcount = srcline->stepcount * 2; stepcount = srcline->stepcount * 2;
if (stepcount == 0) { if (stepcount == 0) {
@ -158,7 +158,7 @@ C_OUTLINE::C_OUTLINE(C_OUTLINE* srcline, FCOORD rotation) : offsets(NULL) {
return; return;
} }
//get memory //get memory
steps = (uinT8 *) alloc_mem (step_mem()); steps = (uint8_t *) alloc_mem (step_mem());
memset(steps, 0, step_mem()); memset(steps, 0, step_mem());
for (int iteration = 0; iteration < 2; ++iteration) { for (int iteration = 0; iteration < 2; ++iteration) {
@ -252,10 +252,10 @@ void C_OUTLINE::FakeOutline(const TBOX& box, C_OUTLINE_LIST* outlines) {
* Compute the area of the outline. * Compute the area of the outline.
*/ */
inT32 C_OUTLINE::area() const { int32_t C_OUTLINE::area() const {
int stepindex; //current step int stepindex; //current step
inT32 total_steps; //steps to do int32_t total_steps; //steps to do
inT32 total; //total area int32_t total; //total area
ICOORD pos; //position of point ICOORD pos; //position of point
ICOORD next_step; //step to next pix ICOORD next_step; //step to next pix
// We aren't going to modify the list, or its contents, but there is // We aren't going to modify the list, or its contents, but there is
@ -286,8 +286,8 @@ inT32 C_OUTLINE::area() const {
* Compute the perimeter of the outline and its first level children. * Compute the perimeter of the outline and its first level children.
*/ */
inT32 C_OUTLINE::perimeter() const { int32_t C_OUTLINE::perimeter() const {
inT32 total_steps; // Return value. int32_t total_steps; // Return value.
// We aren't going to modify the list, or its contents, but there is // We aren't going to modify the list, or its contents, but there is
// no const iterator. // no const iterator.
C_OUTLINE_IT it(const_cast<C_OUTLINE_LIST*>(&children)); C_OUTLINE_IT it(const_cast<C_OUTLINE_LIST*>(&children));
@ -305,10 +305,10 @@ inT32 C_OUTLINE::perimeter() const {
* Compute the area of the outline. * Compute the area of the outline.
*/ */
inT32 C_OUTLINE::outer_area() const { int32_t C_OUTLINE::outer_area() const {
int stepindex; //current step int stepindex; //current step
inT32 total_steps; //steps to do int32_t total_steps; //steps to do
inT32 total; //total area int32_t total; //total area
ICOORD pos; //position of point ICOORD pos; //position of point
ICOORD next_step; //step to next pix ICOORD next_step; //step to next pix
@ -337,7 +337,7 @@ inT32 C_OUTLINE::outer_area() const {
* @param threshold winding number on size * @param threshold winding number on size
*/ */
inT32 C_OUTLINE::count_transitions(inT32 threshold) { int32_t C_OUTLINE::count_transitions(int32_t threshold) {
BOOL8 first_was_max_x; //what was first BOOL8 first_was_max_x; //what was first
BOOL8 first_was_max_y; BOOL8 first_was_max_y;
BOOL8 looking_for_max_x; //what is next BOOL8 looking_for_max_x; //what is next
@ -345,11 +345,11 @@ inT32 C_OUTLINE::count_transitions(inT32 threshold) {
BOOL8 looking_for_max_y; //what is next BOOL8 looking_for_max_y; //what is next
BOOL8 looking_for_min_y; BOOL8 looking_for_min_y;
int stepindex; //current step int stepindex; //current step
inT32 total_steps; //steps to do int32_t total_steps; //steps to do
//current limits //current limits
inT32 max_x, min_x, max_y, min_y; int32_t max_x, min_x, max_y, min_y;
inT32 initial_x, initial_y; //initial limits int32_t initial_x, initial_y; //initial limits
inT32 total; //total changes int32_t total; //total changes
ICOORD pos; //position of point ICOORD pos; //position of point
ICOORD next_step; //step to next pix ICOORD next_step; //step to next pix
@ -465,9 +465,9 @@ inT32 C_OUTLINE::count_transitions(inT32 threshold) {
BOOL8 BOOL8
C_OUTLINE::operator<(const C_OUTLINE& other) const { C_OUTLINE::operator<(const C_OUTLINE& other) const {
inT16 count = 0; //winding count int16_t count = 0; //winding count
ICOORD pos; //position of point ICOORD pos; //position of point
inT32 stepindex; //index to cstep int32_t stepindex; //index to cstep
if (!box.overlap (other.box)) if (!box.overlap (other.box))
return FALSE; //can't be contained return FALSE; //can't be contained
@ -497,12 +497,12 @@ C_OUTLINE::operator<(const C_OUTLINE& other) const {
* @param point point to wind around * @param point point to wind around
*/ */
inT16 C_OUTLINE::winding_number(ICOORD point) const { int16_t C_OUTLINE::winding_number(ICOORD point) const {
inT16 stepindex; //index to cstep int16_t stepindex; //index to cstep
inT16 count; //winding count int16_t count; //winding count
ICOORD vec; //to current point ICOORD vec; //to current point
ICOORD stepvec; //step vector ICOORD stepvec; //step vector
inT32 cross; //cross product int32_t cross; //cross product
vec = start - point; //vector to it vec = start - point; //vector to it
count = 0; count = 0;
@ -534,12 +534,12 @@ inT16 C_OUTLINE::winding_number(ICOORD point) const {
* @return the sum direction delta of the outline. * @return the sum direction delta of the outline.
*/ */
inT16 C_OUTLINE::turn_direction() const { //winding number int16_t C_OUTLINE::turn_direction() const { //winding number
DIR128 prevdir; //previous direction DIR128 prevdir; //previous direction
DIR128 dir; //current direction DIR128 dir; //current direction
inT16 stepindex; //index to cstep int16_t stepindex; //index to cstep
inT8 dirdiff; //direction difference int8_t dirdiff; //direction difference
inT16 count; //winding count int16_t count; //winding count
if (stepcount == 0) if (stepcount == 0)
return 128; return 128;
@ -565,9 +565,9 @@ inT16 C_OUTLINE::turn_direction() const { //winding number
void C_OUTLINE::reverse() { //reverse drection void C_OUTLINE::reverse() { //reverse drection
DIR128 halfturn = MODULUS / 2; //amount to shift DIR128 halfturn = MODULUS / 2; //amount to shift
DIR128 stepdir; //direction of step DIR128 stepdir; //direction of step
inT16 stepindex; //index to cstep int16_t stepindex; //index to cstep
inT16 farindex; //index to other side int16_t farindex; //index to other side
inT16 halfsteps; //half of stepcount int16_t halfsteps; //half of stepcount
halfsteps = (stepcount + 1) / 2; halfsteps = (stepcount + 1) / 2;
for (stepindex = 0; stepindex < halfsteps; stepindex++) { for (stepindex = 0; stepindex < halfsteps; stepindex++) {
@ -794,9 +794,8 @@ void C_OUTLINE::ComputeEdgeOffsets(int threshold, Pix* pix) {
(best_x - x) * best_diff; (best_x - x) * best_diff;
} }
offsets[s].offset_numerator = offsets[s].offset_numerator =
static_cast<inT8>(ClipToRange(offset, -MAX_INT8, MAX_INT8)); ClipToRange<int>(offset, -INT8_MAX, INT8_MAX);
offsets[s].pixel_diff = static_cast<uinT8>(ClipToRange(best_diff, 0 , offsets[s].pixel_diff = ClipToRange<int>(best_diff, 0, UINT8_MAX);
MAX_UINT8));
if (negative) gradient = -gradient; if (negative) gradient = -gradient;
// Compute gradient angle quantized to 256 directions, rotated by 64 (pi/2) // Compute gradient angle quantized to 256 directions, rotated by 64 (pi/2)
// to convert from gradient direction to edge direction. // to convert from gradient direction to edge direction.
@ -879,9 +878,8 @@ void C_OUTLINE::ComputeBinaryOffsets() {
offset = pos_totals[dir_index] - best_diff * edge_pos; offset = pos_totals[dir_index] - best_diff * edge_pos;
} }
offsets[s].offset_numerator = offsets[s].offset_numerator =
static_cast<inT8>(ClipToRange(offset, -MAX_INT8, MAX_INT8)); ClipToRange<int>(offset, -INT8_MAX, INT8_MAX);
offsets[s].pixel_diff = static_cast<uinT8>(ClipToRange(best_diff, 0 , offsets[s].pixel_diff = ClipToRange<int>(best_diff, 0, UINT8_MAX);
MAX_UINT8));
// The direction is just the vector from start to end of the window. // The direction is just the vector from start to end of the window.
FCOORD direction(head_pos.x() - tail_pos.x(), head_pos.y() - tail_pos.y()); FCOORD direction(head_pos.x() - tail_pos.x(), head_pos.y() - tail_pos.y());
offsets[s].direction = direction.to_direction(); offsets[s].direction = direction.to_direction();
@ -942,7 +940,7 @@ void C_OUTLINE::render_outline(int left, int top, Pix* pix) const {
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void C_OUTLINE::plot(ScrollView* window, ScrollView::Color colour) const { void C_OUTLINE::plot(ScrollView* window, ScrollView::Color colour) const {
inT16 stepindex; // index to cstep int16_t stepindex; // index to cstep
ICOORD pos; // current position ICOORD pos; // current position
DIR128 stepdir; // direction of step DIR128 stepdir; // direction of step
@ -1015,7 +1013,7 @@ C_OUTLINE& C_OUTLINE::operator=(const C_OUTLINE& source) {
if (steps != NULL) if (steps != NULL)
free_mem(steps); free_mem(steps);
stepcount = source.stepcount; stepcount = source.stepcount;
steps = (uinT8 *) alloc_mem (step_mem()); steps = (uint8_t *) alloc_mem (step_mem());
memmove (steps, source.steps, step_mem()); memmove (steps, source.steps, step_mem());
if (!children.empty ()) if (!children.empty ())
children.clear (); children.clear ();

View File

@ -29,7 +29,7 @@
class DENORM; class DENORM;
#define INTERSECTING MAX_INT16//no winding number #define INTERSECTING INT16_MAX//no winding number
//mask to get step //mask to get step
#define STEP_MASK 3 #define STEP_MASK 3
@ -57,9 +57,9 @@ enum C_OUTLINE_FLAGS
// If the pixel_diff is zero, it means that the direction of the gradient // If the pixel_diff is zero, it means that the direction of the gradient
// is in conflict with the step direction, so this step is to be ignored. // is in conflict with the step direction, so this step is to be ignored.
struct EdgeOffset { struct EdgeOffset {
inT8 offset_numerator; int8_t offset_numerator;
uinT8 pixel_diff; uint8_t pixel_diff;
uinT8 direction; uint8_t direction;
}; };
class DLLSYM C_OUTLINE; //forward declaration class DLLSYM C_OUTLINE; //forward declaration
@ -76,10 +76,10 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
CRACKEDGE *startpt, //from edge detector CRACKEDGE *startpt, //from edge detector
ICOORD bot_left, //bounding box //length of loop ICOORD bot_left, //bounding box //length of loop
ICOORD top_right, ICOORD top_right,
inT16 length); int16_t length);
C_OUTLINE(ICOORD startpt, //start of loop C_OUTLINE(ICOORD startpt, //start of loop
DIR128 *new_steps, //steps in loop DIR128 *new_steps, //steps in loop
inT16 length); //length of loop int16_t length); //length of loop
//outline to copy //outline to copy
C_OUTLINE(C_OUTLINE *srcline, FCOORD rotation); //and rotate C_OUTLINE(C_OUTLINE *srcline, FCOORD rotation); //and rotate
@ -112,30 +112,30 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
return box; return box;
} }
void set_step( //set a step void set_step( //set a step
inT16 stepindex, //index of step int16_t stepindex, //index of step
inT8 stepdir) { //chain code int8_t stepdir) { //chain code
int shift = stepindex%4 * 2; int shift = stepindex%4 * 2;
uinT8 mask = 3 << shift; uint8_t mask = 3 << shift;
steps[stepindex/4] = ((stepdir << shift) & mask) | steps[stepindex/4] = ((stepdir << shift) & mask) |
(steps[stepindex/4] & ~mask); (steps[stepindex/4] & ~mask);
//squeeze 4 into byte //squeeze 4 into byte
} }
void set_step( //set a step void set_step( //set a step
inT16 stepindex, //index of step int16_t stepindex, //index of step
DIR128 stepdir) { //direction DIR128 stepdir) { //direction
//clean it //clean it
inT8 chaindir = stepdir.get_dir() >> (DIRBITS - 2); int8_t chaindir = stepdir.get_dir() >> (DIRBITS - 2);
//difference //difference
set_step(stepindex, chaindir); set_step(stepindex, chaindir);
//squeeze 4 into byte //squeeze 4 into byte
} }
inT32 pathlength() const { //get path length int32_t pathlength() const { //get path length
return stepcount; return stepcount;
} }
// Return step at a given index as a DIR128. // Return step at a given index as a DIR128.
DIR128 step_dir(int index) const { DIR128 step_dir(int index) const {
return DIR128((inT16)(((steps[index/4] >> (index%4 * 2)) & STEP_MASK) << return DIR128((int16_t)(((steps[index/4] >> (index%4 * 2)) & STEP_MASK) <<
(DIRBITS - 2))); (DIRBITS - 2)));
} }
// Return the step vector for the given outline position. // Return the step vector for the given outline position.
@ -194,11 +194,11 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
return (steps[index / 4] >> (index % 4 * 2)) & STEP_MASK; return (steps[index / 4] >> (index % 4 * 2)) & STEP_MASK;
} }
inT32 area() const; // Returns area of self and 1st level children. int32_t area() const; // Returns area of self and 1st level children.
inT32 perimeter() const; // Total perimeter of self and 1st level children. int32_t perimeter() const; // Total perimeter of self and 1st level children.
inT32 outer_area() const; // Returns area of self only. int32_t outer_area() const; // Returns area of self only.
inT32 count_transitions( //count maxima int32_t count_transitions( //count maxima
inT32 threshold); //size threshold int32_t threshold); //size threshold
BOOL8 operator< ( //containment test BOOL8 operator< ( //containment test
const C_OUTLINE & other) const; const C_OUTLINE & other) const;
@ -207,10 +207,10 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
{ {
return other < *this; //use the < to do it return other < *this; //use the < to do it
} }
inT16 winding_number( //get winding number int16_t winding_number( //get winding number
ICOORD testpt) const; //around this point ICOORD testpt) const; //around this point
//get direction //get direction
inT16 turn_direction() const; int16_t turn_direction() const;
void reverse(); //reverse direction void reverse(); //reverse direction
void move( // reposition outline void move( // reposition outline
@ -281,9 +281,9 @@ class DLLSYM C_OUTLINE:public ELIST_LINK {
TBOX box; // bounding box TBOX box; // bounding box
ICOORD start; // start coord ICOORD start; // start coord
inT16 stepcount; // no of steps int16_t stepcount; // no of steps
BITS16 flags; // flags about outline BITS16 flags; // flags about outline
uinT8 *steps; // step array uint8_t *steps; // step array
EdgeOffset* offsets; // Higher precision edge. EdgeOffset* offsets; // Higher precision edge.
C_OUTLINE_LIST children; // child elements C_OUTLINE_LIST children; // child elements
static ICOORD step_coords[4]; static ICOORD step_coords[4];

View File

@ -28,9 +28,9 @@ class CRACKEDGE {
CRACKEDGE() {} CRACKEDGE() {}
ICOORD pos; /*position of crack */ ICOORD pos; /*position of crack */
inT8 stepx; //edge step int8_t stepx; //edge step
inT8 stepy; int8_t stepy;
inT8 stepdir; //chaincode int8_t stepdir; //chaincode
CRACKEDGE *prev; /*previous point */ CRACKEDGE *prev; /*previous point */
CRACKEDGE *next; /*next point */ CRACKEDGE *next; /*next point */
}; };

View File

@ -39,7 +39,7 @@ DPPoint* DPPoint::Solve(int min_step, int max_step, bool debug,
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
for (int offset = min_step; offset <= max_step; ++offset) { for (int offset = min_step; offset <= max_step; ++offset) {
DPPoint* prev = offset <= i ? points + i - offset : NULL; DPPoint* prev = offset <= i ? points + i - offset : NULL;
inT64 new_cost = (points[i].*cost_func)(prev); int64_t new_cost = (points[i].*cost_func)(prev);
if (points[i].best_prev_ != NULL && offset > min_step * 2 && if (points[i].best_prev_ != NULL && offset > min_step * 2 &&
new_cost > points[i].total_cost_) new_cost > points[i].total_cost_)
break; // Find only the first minimum if going over twice the min. break; // Find only the first minimum if going over twice the min.
@ -65,25 +65,25 @@ DPPoint* DPPoint::Solve(int min_step, int max_step, bool debug,
} }
// A CostFunc that takes the variance of step into account in the cost. // A CostFunc that takes the variance of step into account in the cost.
inT64 DPPoint::CostWithVariance(const DPPoint* prev) { int64_t DPPoint::CostWithVariance(const DPPoint* prev) {
if (prev == NULL || prev == this) { if (prev == NULL || prev == this) {
UpdateIfBetter(0, 1, NULL, 0, 0, 0); UpdateIfBetter(0, 1, NULL, 0, 0, 0);
return 0; return 0;
} }
int delta = this - prev; int delta = this - prev;
inT32 n = prev->n_ + 1; int32_t n = prev->n_ + 1;
inT32 sig_x = prev->sig_x_ + delta; int32_t sig_x = prev->sig_x_ + delta;
inT64 sig_xsq = prev->sig_xsq_ + delta * delta; int64_t sig_xsq = prev->sig_xsq_ + delta * delta;
inT64 cost = (sig_xsq - sig_x * sig_x / n) / n; int64_t cost = (sig_xsq - sig_x * sig_x / n) / n;
cost += prev->total_cost_; cost += prev->total_cost_;
UpdateIfBetter(cost, prev->total_steps_ + 1, prev, n, sig_x, sig_xsq); UpdateIfBetter(cost, prev->total_steps_ + 1, prev, n, sig_x, sig_xsq);
return cost; return cost;
} }
// Update the other members if the cost is lower. // Update the other members if the cost is lower.
void DPPoint::UpdateIfBetter(inT64 cost, inT32 steps, const DPPoint* prev, void DPPoint::UpdateIfBetter(int64_t cost, int32_t steps, const DPPoint* prev,
inT32 n, inT32 sig_x, inT64 sig_xsq) { int32_t n, int32_t sig_x, int64_t sig_xsq) {
if (cost < total_cost_) { if (cost < total_cost_) {
total_cost_ = cost; total_cost_ = cost;
total_steps_ = steps; total_steps_ = steps;

View File

@ -46,10 +46,10 @@ class DPPoint {
// The cost function evaluates the total cost at this (excluding this's // The cost function evaluates the total cost at this (excluding this's
// local_cost) and if it beats this's total_cost, then // local_cost) and if it beats this's total_cost, then
// replace the appropriate values in this. // replace the appropriate values in this.
typedef inT64 (DPPoint::*CostFunc)(const DPPoint* prev); typedef int64_t (DPPoint::*CostFunc)(const DPPoint* prev);
DPPoint() DPPoint()
: local_cost_(0), total_cost_(MAX_INT32), total_steps_(1), best_prev_(NULL), : local_cost_(0), total_cost_(INT32_MAX), total_steps_(1), best_prev_(NULL),
n_(0), sig_x_(0), sig_xsq_(0) { n_(0), sig_x_(0), sig_xsq_(0) {
} }
@ -62,7 +62,7 @@ class DPPoint {
CostFunc cost_func, int size, DPPoint* points); CostFunc cost_func, int size, DPPoint* points);
// A CostFunc that takes the variance of step into account in the cost. // A CostFunc that takes the variance of step into account in the cost.
inT64 CostWithVariance(const DPPoint* prev); int64_t CostWithVariance(const DPPoint* prev);
// Accessors. // Accessors.
int total_cost() const { int total_cost() const {
@ -82,18 +82,18 @@ class DPPoint {
// Code common to different cost functions. // Code common to different cost functions.
// Update the other members if the cost is lower. // Update the other members if the cost is lower.
void UpdateIfBetter(inT64 cost, inT32 steps, const DPPoint* prev, void UpdateIfBetter(int64_t cost, int32_t steps, const DPPoint* prev,
inT32 n, inT32 sig_x, inT64 sig_xsq); int32_t n, int32_t sig_x, int64_t sig_xsq);
inT32 local_cost_; // Cost of this point on its own. int32_t local_cost_; // Cost of this point on its own.
inT32 total_cost_; // Sum of all costs in best path to here. int32_t total_cost_; // Sum of all costs in best path to here.
// During cost calculations local_cost is excluded. // During cost calculations local_cost is excluded.
inT32 total_steps_; // Number of steps in best path to here. int32_t total_steps_; // Number of steps in best path to here.
const DPPoint* best_prev_; // Pointer to prev point in best path from here. const DPPoint* best_prev_; // Pointer to prev point in best path from here.
// Information for computing the variance part of the cost. // Information for computing the variance part of the cost.
inT32 n_; // Number of steps in best path to here for variance. int32_t n_; // Number of steps in best path to here for variance.
inT32 sig_x_; // Sum of step sizes for computing variance. int32_t sig_x_; // Sum of step sizes for computing variance.
inT64 sig_xsq_; // Sum of squares of steps for computing variance. int64_t sig_xsq_; // Sum of squares of steps for computing variance.
}; };
} // namespace tesseract. } // namespace tesseract.

View File

@ -60,7 +60,7 @@ bool FontInfoTable::DeSerialize(TFile* fp) {
// properties as font_id. // properties as font_id.
bool FontInfoTable::SetContainsFontProperties( bool FontInfoTable::SetContainsFontProperties(
int font_id, const GenericVector<ScoredFont>& font_set) const { int font_id, const GenericVector<ScoredFont>& font_set) const {
uinT32 properties = get(font_id).properties; uint32_t properties = get(font_id).properties;
for (int f = 0; f < font_set.size(); ++f) { for (int f = 0; f < font_set.size(); ++f) {
if (get(font_set[f].fontinfo_id).properties == properties) if (get(font_set[f].fontinfo_id).properties == properties)
return true; return true;
@ -73,7 +73,7 @@ bool FontInfoTable::SetContainsMultipleFontProperties(
const GenericVector<ScoredFont>& font_set) const { const GenericVector<ScoredFont>& font_set) const {
if (font_set.empty()) return false; if (font_set.empty()) return false;
int first_font = font_set[0].fontinfo_id; int first_font = font_set[0].fontinfo_id;
uinT32 properties = get(first_font).properties; uint32_t properties = get(first_font).properties;
for (int f = 1; f < font_set.size(); ++f) { for (int f = 1; f < font_set.size(); ++f) {
if (get(font_set[f].fontinfo_id).properties != properties) if (get(font_set[f].fontinfo_id).properties != properties)
return true; return true;
@ -150,7 +150,7 @@ void FontSetDeleteCallback(FontSet fs) {
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
// Callbacks used by UnicityTable to read/write FontInfo/FontSet structures. // Callbacks used by UnicityTable to read/write FontInfo/FontSet structures.
bool read_info(TFile* f, FontInfo* fi) { bool read_info(TFile* f, FontInfo* fi) {
inT32 size; int32_t size;
if (f->FReadEndian(&size, sizeof(size), 1) != 1) return false; if (f->FReadEndian(&size, sizeof(size), 1) != 1) return false;
char* font_name = new char[size + 1]; char* font_name = new char[size + 1];
fi->name = font_name; fi->name = font_name;
@ -162,7 +162,7 @@ bool read_info(TFile* f, FontInfo* fi) {
} }
bool write_info(FILE* f, const FontInfo& fi) { bool write_info(FILE* f, const FontInfo& fi) {
inT32 size = strlen(fi.name); int32_t size = strlen(fi.name);
if (fwrite(&size, sizeof(size), 1, f) != 1) return false; if (fwrite(&size, sizeof(size), 1, f) != 1) return false;
if (static_cast<int>(fwrite(fi.name, sizeof(*fi.name), size, f)) != size) if (static_cast<int>(fwrite(fi.name, sizeof(*fi.name), size, f)) != size)
return false; return false;
@ -171,7 +171,7 @@ bool write_info(FILE* f, const FontInfo& fi) {
} }
bool read_spacing_info(TFile* f, FontInfo* fi) { bool read_spacing_info(TFile* f, FontInfo* fi) {
inT32 vec_size, kern_size; int32_t vec_size, kern_size;
if (f->FReadEndian(&vec_size, sizeof(vec_size), 1) != 1) return false; if (f->FReadEndian(&vec_size, sizeof(vec_size), 1) != 1) return false;
ASSERT_HOST(vec_size >= 0); ASSERT_HOST(vec_size >= 0);
if (vec_size == 0) return true; if (vec_size == 0) return true;
@ -199,12 +199,12 @@ bool read_spacing_info(TFile* f, FontInfo* fi) {
} }
bool write_spacing_info(FILE* f, const FontInfo& fi) { bool write_spacing_info(FILE* f, const FontInfo& fi) {
inT32 vec_size = (fi.spacing_vec == NULL) ? 0 : fi.spacing_vec->size(); int32_t vec_size = (fi.spacing_vec == NULL) ? 0 : fi.spacing_vec->size();
if (fwrite(&vec_size, sizeof(vec_size), 1, f) != 1) return false; if (fwrite(&vec_size, sizeof(vec_size), 1, f) != 1) return false;
inT16 x_gap_invalid = -1; int16_t x_gap_invalid = -1;
for (int i = 0; i < vec_size; ++i) { for (int i = 0; i < vec_size; ++i) {
FontSpacingInfo *fs = fi.spacing_vec->get(i); FontSpacingInfo *fs = fi.spacing_vec->get(i);
inT32 kern_size = (fs == NULL) ? -1 : fs->kerned_x_gaps.size(); int32_t kern_size = (fs == NULL) ? -1 : fs->kerned_x_gaps.size();
if (fs == NULL) { if (fs == NULL) {
// Valid to have the identical fwrites. Writing invalid x-gaps. // Valid to have the identical fwrites. Writing invalid x-gaps.
if (fwrite(&(x_gap_invalid), sizeof(x_gap_invalid), 1, f) != 1 || if (fwrite(&(x_gap_invalid), sizeof(x_gap_invalid), 1, f) != 1 ||

View File

@ -32,27 +32,27 @@ namespace tesseract {
class BitVector; class BitVector;
// Simple struct to hold a font and a score. The scores come from the low-level // Simple struct to hold a font and a score. The scores come from the low-level
// integer matcher, so they are in the uinT16 range. Fonts are an index to // integer matcher, so they are in the uint16_t range. Fonts are an index to
// fontinfo_table. // fontinfo_table.
// These get copied around a lot, so best to keep them small. // These get copied around a lot, so best to keep them small.
struct ScoredFont { struct ScoredFont {
ScoredFont() : fontinfo_id(-1), score(0) {} ScoredFont() : fontinfo_id(-1), score(0) {}
ScoredFont(int font_id, uinT16 classifier_score) ScoredFont(int font_id, uint16_t classifier_score)
: fontinfo_id(font_id), score(classifier_score) {} : fontinfo_id(font_id), score(classifier_score) {}
// Index into fontinfo table, but inside the classifier, may be a shapetable // Index into fontinfo table, but inside the classifier, may be a shapetable
// index. // index.
inT32 fontinfo_id; int32_t fontinfo_id;
// Raw score from the low-level classifier. // Raw score from the low-level classifier.
uinT16 score; uint16_t score;
}; };
// Struct for information about spacing between characters in a particular font. // Struct for information about spacing between characters in a particular font.
struct FontSpacingInfo { struct FontSpacingInfo {
inT16 x_gap_before; int16_t x_gap_before;
inT16 x_gap_after; int16_t x_gap_after;
GenericVector<UNICHAR_ID> kerned_unichar_ids; GenericVector<UNICHAR_ID> kerned_unichar_ids;
GenericVector<inT16> kerned_x_gaps; GenericVector<int16_t> kerned_x_gaps;
}; };
/* /*
@ -115,12 +115,12 @@ struct FontInfo {
bool is_fraktur() const { return (properties & 16) != 0; } bool is_fraktur() const { return (properties & 16) != 0; }
char* name; char* name;
uinT32 properties; uint32_t properties;
// The universal_id is a field reserved for the initialization process // The universal_id is a field reserved for the initialization process
// to assign a unique id number to all fonts loaded for the current // to assign a unique id number to all fonts loaded for the current
// combination of languages. This id will then be returned by // combination of languages. This id will then be returned by
// ResultIterator::WordFontAttributes. // ResultIterator::WordFontAttributes.
inT32 universal_id; int32_t universal_id;
// Horizontal spacing between characters (indexed by UNICHAR_ID). // Horizontal spacing between characters (indexed by UNICHAR_ID).
GenericVector<FontSpacingInfo *> *spacing_vec; GenericVector<FontSpacingInfo *> *spacing_vec;
}; };

View File

@ -45,9 +45,9 @@ namespace tesseract {
WordFeature::WordFeature() : x_(0), y_(0), dir_(0) { WordFeature::WordFeature() : x_(0), y_(0), dir_(0) {
} }
WordFeature::WordFeature(const FCOORD& fcoord, uinT8 dir) WordFeature::WordFeature(const FCOORD& fcoord, uint8_t dir)
: x_(IntCastRounded(fcoord.x())), : x_(IntCastRounded(fcoord.x())),
y_(ClipToRange(IntCastRounded(fcoord.y()), 0, MAX_UINT8)), y_(ClipToRange<int>(IntCastRounded(fcoord.y()), 0, UINT8_MAX)),
dir_(dir) { dir_(dir) {
} }
@ -171,7 +171,7 @@ bool ImageData::Serialize(TFile* fp) const {
// WARNING: Will not work across different endian machines. // WARNING: Will not work across different endian machines.
if (!boxes_.Serialize(fp)) return false; if (!boxes_.Serialize(fp)) return false;
if (!box_texts_.SerializeClasses(fp)) return false; if (!box_texts_.SerializeClasses(fp)) return false;
inT8 vertical = vertical_text_; int8_t vertical = vertical_text_;
if (fp->FWrite(&vertical, sizeof(vertical), 1) != 1) return false; if (fp->FWrite(&vertical, sizeof(vertical), 1) != 1) return false;
return true; return true;
} }
@ -188,7 +188,7 @@ bool ImageData::DeSerialize(TFile* fp) {
// WARNING: Will not work across different endian machines. // WARNING: Will not work across different endian machines.
if (!boxes_.DeSerialize(fp)) return false; if (!boxes_.DeSerialize(fp)) return false;
if (!box_texts_.DeSerializeClasses(fp)) return false; if (!box_texts_.DeSerializeClasses(fp)) return false;
inT8 vertical = 0; int8_t vertical = 0;
if (fp->FRead(&vertical, sizeof(vertical), 1) != 1) return false; if (fp->FRead(&vertical, sizeof(vertical), 1) != 1) return false;
vertical_text_ = vertical != 0; vertical_text_ = vertical != 0;
return true; return true;
@ -197,14 +197,14 @@ bool ImageData::DeSerialize(TFile* fp) {
// As DeSerialize, but only seeks past the data - hence a static method. // As DeSerialize, but only seeks past the data - hence a static method.
bool ImageData::SkipDeSerialize(TFile* fp) { bool ImageData::SkipDeSerialize(TFile* fp) {
if (!STRING::SkipDeSerialize(fp)) return false; if (!STRING::SkipDeSerialize(fp)) return false;
inT32 page_number; int32_t page_number;
if (fp->FRead(&page_number, sizeof(page_number), 1) != 1) return false; if (fp->FRead(&page_number, sizeof(page_number), 1) != 1) return false;
if (!GenericVector<char>::SkipDeSerialize(fp)) return false; if (!GenericVector<char>::SkipDeSerialize(fp)) return false;
if (!STRING::SkipDeSerialize(fp)) return false; if (!STRING::SkipDeSerialize(fp)) return false;
if (!STRING::SkipDeSerialize(fp)) return false; if (!STRING::SkipDeSerialize(fp)) return false;
if (!GenericVector<TBOX>::SkipDeSerialize(fp)) return false; if (!GenericVector<TBOX>::SkipDeSerialize(fp)) return false;
if (!GenericVector<STRING>::SkipDeSerializeClasses(fp)) return false; if (!GenericVector<STRING>::SkipDeSerializeClasses(fp)) return false;
inT8 vertical = 0; int8_t vertical = 0;
return fp->FRead(&vertical, sizeof(vertical), 1) == 1; return fp->FRead(&vertical, sizeof(vertical), 1) == 1;
} }
@ -389,14 +389,14 @@ DocumentData::~DocumentData() {
// Reads all the pages in the given lstmf filename to the cache. The reader // Reads all the pages in the given lstmf filename to the cache. The reader
// is used to read the file. // is used to read the file.
bool DocumentData::LoadDocument(const char* filename, int start_page, bool DocumentData::LoadDocument(const char* filename, int start_page,
inT64 max_memory, FileReader reader) { int64_t max_memory, FileReader reader) {
SetDocument(filename, max_memory, reader); SetDocument(filename, max_memory, reader);
pages_offset_ = start_page; pages_offset_ = start_page;
return ReCachePages(); return ReCachePages();
} }
// Sets up the document, without actually loading it. // Sets up the document, without actually loading it.
void DocumentData::SetDocument(const char* filename, inT64 max_memory, void DocumentData::SetDocument(const char* filename, int64_t max_memory,
FileReader reader) { FileReader reader) {
SVAutoLock lock_p(&pages_mutex_); SVAutoLock lock_p(&pages_mutex_);
SVAutoLock lock(&general_mutex_); SVAutoLock lock(&general_mutex_);
@ -486,9 +486,9 @@ bool DocumentData::IsPageAvailable(int index, ImageData** page) {
// Removes all pages from memory and frees the memory, but does not forget // Removes all pages from memory and frees the memory, but does not forget
// the document metadata. // the document metadata.
inT64 DocumentData::UnCache() { int64_t DocumentData::UnCache() {
SVAutoLock lock(&pages_mutex_); SVAutoLock lock(&pages_mutex_);
inT64 memory_saved = memory_used(); int64_t memory_saved = memory_used();
pages_.clear(); pages_.clear();
pages_offset_ = -1; pages_offset_ = -1;
set_total_pages(-1); set_total_pages(-1);
@ -564,7 +564,7 @@ bool DocumentData::ReCachePages() {
} }
// A collection of DocumentData that knows roughly how much memory it is using. // A collection of DocumentData that knows roughly how much memory it is using.
DocumentCache::DocumentCache(inT64 max_memory) DocumentCache::DocumentCache(int64_t max_memory)
: num_pages_per_doc_(0), max_memory_(max_memory) {} : num_pages_per_doc_(0), max_memory_(max_memory) {}
DocumentCache::~DocumentCache() {} DocumentCache::~DocumentCache() {}
@ -574,7 +574,7 @@ bool DocumentCache::LoadDocuments(const GenericVector<STRING>& filenames,
CachingStrategy cache_strategy, CachingStrategy cache_strategy,
FileReader reader) { FileReader reader) {
cache_strategy_ = cache_strategy; cache_strategy_ = cache_strategy;
inT64 fair_share_memory = 0; int64_t fair_share_memory = 0;
// In the round-robin case, each DocumentData handles restricting its content // In the round-robin case, each DocumentData handles restricting its content
// to its fair share of memory. In the sequential case, DocumentCache // to its fair share of memory. In the sequential case, DocumentCache
// determines which DocumentDatas are held entirely in memory. // determines which DocumentDatas are held entirely in memory.
@ -665,7 +665,7 @@ const ImageData* DocumentCache::GetPageSequential(int serial) {
documents_[doc_index]->GetPage(serial % num_pages_per_doc_); documents_[doc_index]->GetPage(serial % num_pages_per_doc_);
// Count up total memory. Background loading makes it more complicated to // Count up total memory. Background loading makes it more complicated to
// keep a running count. // keep a running count.
inT64 total_memory = 0; int64_t total_memory = 0;
for (int d = 0; d < num_docs; ++d) { for (int d = 0; d < num_docs; ++d) {
total_memory += documents_[d]->memory_used(); total_memory += documents_[d]->memory_used();
} }

View File

@ -55,7 +55,7 @@ enum CachingStrategy {
class WordFeature { class WordFeature {
public: public:
WordFeature(); WordFeature();
WordFeature(const FCOORD& fcoord, uinT8 dir); WordFeature(const FCOORD& fcoord, uint8_t dir);
// Computes the maximum x and y value in the features. // Computes the maximum x and y value in the features.
static void ComputeSize(const GenericVector<WordFeature>& features, static void ComputeSize(const GenericVector<WordFeature>& features,
@ -76,9 +76,9 @@ class WordFeature {
bool DeSerialize(bool swap, FILE* fp); bool DeSerialize(bool swap, FILE* fp);
private: private:
inT16 x_; int16_t x_;
uinT8 y_; uint8_t y_;
uinT8 dir_; uint8_t dir_;
}; };
// A floating-point version of WordFeature, used as an intermediate during // A floating-point version of WordFeature, used as an intermediate during
@ -190,7 +190,7 @@ class ImageData {
private: private:
STRING imagefilename_; // File to read image from. STRING imagefilename_; // File to read image from.
inT32 page_number_; // Page number if multi-page tif or -1. int32_t page_number_; // Page number if multi-page tif or -1.
GenericVector<char> image_data_; // PNG file data. GenericVector<char> image_data_; // PNG file data.
STRING language_; // Language code for image. STRING language_; // Language code for image.
STRING transcription_; // UTF-8 ground truth of image. STRING transcription_; // UTF-8 ground truth of image.
@ -209,10 +209,10 @@ class DocumentData {
// Reads all the pages in the given lstmf filename to the cache. The reader // Reads all the pages in the given lstmf filename to the cache. The reader
// is used to read the file. // is used to read the file.
bool LoadDocument(const char* filename, int start_page, inT64 max_memory, bool LoadDocument(const char* filename, int start_page, int64_t max_memory,
FileReader reader); FileReader reader);
// Sets up the document, without actually loading it. // Sets up the document, without actually loading it.
void SetDocument(const char* filename, inT64 max_memory, FileReader reader); void SetDocument(const char* filename, int64_t max_memory, FileReader reader);
// Writes all the pages to the given filename. Returns false on error. // Writes all the pages to the given filename. Returns false on error.
bool SaveDocument(const char* filename, FileWriter writer); bool SaveDocument(const char* filename, FileWriter writer);
bool SaveToBuffer(GenericVector<char>* buffer); bool SaveToBuffer(GenericVector<char>* buffer);
@ -228,7 +228,7 @@ class DocumentData {
SVAutoLock lock(&general_mutex_); SVAutoLock lock(&general_mutex_);
return total_pages_; return total_pages_;
} }
inT64 memory_used() const { int64_t memory_used() const {
SVAutoLock lock(&general_mutex_); SVAutoLock lock(&general_mutex_);
return memory_used_; return memory_used_;
} }
@ -263,7 +263,7 @@ class DocumentData {
bool IsCached() const { return NumPages() >= 0; } bool IsCached() const { return NumPages() >= 0; }
// Removes all pages from memory and frees the memory, but does not forget // Removes all pages from memory and frees the memory, but does not forget
// the document metadata. Returns the memory saved. // the document metadata. Returns the memory saved.
inT64 UnCache(); int64_t UnCache();
// Shuffles all the pages in the document. // Shuffles all the pages in the document.
void Shuffle(); void Shuffle();
@ -273,7 +273,7 @@ class DocumentData {
SVAutoLock lock(&general_mutex_); SVAutoLock lock(&general_mutex_);
total_pages_ = total; total_pages_ = total;
} }
void set_memory_used(inT64 memory_used) { void set_memory_used(int64_t memory_used) {
SVAutoLock lock(&general_mutex_); SVAutoLock lock(&general_mutex_);
memory_used_ = memory_used; memory_used_ = memory_used;
} }
@ -291,9 +291,9 @@ class DocumentData {
// Total number of pages in document (may exceed size of pages_.) // Total number of pages in document (may exceed size of pages_.)
int total_pages_; int total_pages_;
// Total of all pix sizes in the document. // Total of all pix sizes in the document.
inT64 memory_used_; int64_t memory_used_;
// Max memory to use at any time. // Max memory to use at any time.
inT64 max_memory_; int64_t max_memory_;
// Saved reader from LoadDocument to allow re-caching. // Saved reader from LoadDocument to allow re-caching.
FileReader reader_; FileReader reader_;
// Mutex that protects pages_ and pages_offset_ against multiple parallel // Mutex that protects pages_ and pages_offset_ against multiple parallel
@ -311,7 +311,7 @@ class DocumentData {
// content. // content.
class DocumentCache { class DocumentCache {
public: public:
explicit DocumentCache(inT64 max_memory); explicit DocumentCache(int64_t max_memory);
~DocumentCache(); ~DocumentCache();
// Deletes all existing documents from the cache. // Deletes all existing documents from the cache.
@ -368,7 +368,7 @@ class DocumentCache {
// GetPageSequential to determine the document index. // GetPageSequential to determine the document index.
int num_pages_per_doc_; int num_pages_per_doc_;
// Max memory allowed in this cache. // Max memory allowed in this cache.
inT64 max_memory_; int64_t max_memory_;
}; };
} // namespace tesseract } // namespace tesseract

View File

@ -132,7 +132,7 @@ const ICOORD & op2) {
* Scalar product of 2 ICOORDS. * Scalar product of 2 ICOORDS.
**********************************************************************/ **********************************************************************/
inline inT32 inline int32_t
operator% ( //scalar product operator% ( //scalar product
const ICOORD & op1, //operands const ICOORD & op1, //operands
const ICOORD & op2) { const ICOORD & op2) {
@ -146,7 +146,7 @@ const ICOORD & op2) {
* Cross product of 2 ICOORDS. * Cross product of 2 ICOORDS.
**********************************************************************/ **********************************************************************/
inline inT32 operator *( //cross product inline int32_t operator *( //cross product
const ICOORD &op1, //operands const ICOORD &op1, //operands
const ICOORD &op2) { const ICOORD &op2) {
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord; return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
@ -161,7 +161,7 @@ inline inT32 operator *( //cross product
inline ICOORD operator *( //scalar multiply inline ICOORD operator *( //scalar multiply
const ICOORD &op1, //operands const ICOORD &op1, //operands
inT16 scale) { int16_t scale) {
ICOORD result; //output ICOORD result; //output
result.xcoord = op1.xcoord * scale; result.xcoord = op1.xcoord * scale;
@ -171,7 +171,7 @@ inline ICOORD operator *( //scalar multiply
inline ICOORD operator *( //scalar multiply inline ICOORD operator *( //scalar multiply
inT16 scale, int16_t scale,
const ICOORD &op1 //operands const ICOORD &op1 //operands
) { ) {
ICOORD result; //output ICOORD result; //output
@ -191,7 +191,7 @@ inline ICOORD operator *( //scalar multiply
inline ICOORD & inline ICOORD &
operator*= ( //scalar multiply operator*= ( //scalar multiply
ICOORD & op1, //operands ICOORD & op1, //operands
inT16 scale) { int16_t scale) {
op1.xcoord *= scale; op1.xcoord *= scale;
op1.ycoord *= scale; op1.ycoord *= scale;
return op1; return op1;
@ -207,7 +207,7 @@ inT16 scale) {
inline ICOORD inline ICOORD
operator/ ( //scalar divide operator/ ( //scalar divide
const ICOORD & op1, //operands const ICOORD & op1, //operands
inT16 scale) { int16_t scale) {
ICOORD result; //output ICOORD result; //output
result.xcoord = op1.xcoord / scale; result.xcoord = op1.xcoord / scale;
@ -225,7 +225,7 @@ inT16 scale) {
inline ICOORD & inline ICOORD &
operator/= ( //scalar divide operator/= ( //scalar divide
ICOORD & op1, //operands ICOORD & op1, //operands
inT16 scale) { int16_t scale) {
op1.xcoord /= scale; op1.xcoord /= scale;
op1.ycoord /= scale; op1.ycoord /= scale;
return op1; return op1;
@ -240,10 +240,10 @@ inT16 scale) {
inline void ICOORD::rotate( //rotate by vector inline void ICOORD::rotate( //rotate by vector
const FCOORD& vec) { const FCOORD& vec) {
inT16 tmp; int16_t tmp;
tmp = (inT16) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5); tmp = (int16_t) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
ycoord = (inT16) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5); ycoord = (int16_t) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
xcoord = tmp; xcoord = tmp;
} }

View File

@ -38,7 +38,7 @@ class LLSQ {
void add(const LLSQ& other); void add(const LLSQ& other);
// Deletes an element with a weight of 1. // Deletes an element with a weight of 1.
void remove(double x, double y); void remove(double x, double y);
inT32 count() const { // no of elements int32_t count() const { // no of elements
return static_cast<int>(total_weight + 0.5); return static_cast<int>(total_weight + 0.5);
} }

View File

@ -463,14 +463,14 @@ class GENERIC_2D_ARRAY {
protected: protected:
// Factored helper to serialize the size. // Factored helper to serialize the size.
bool SerializeSize(FILE* fp) const { bool SerializeSize(FILE* fp) const {
inT32 size = dim1_; int32_t size = dim1_;
if (fwrite(&size, sizeof(size), 1, fp) != 1) return false; if (fwrite(&size, sizeof(size), 1, fp) != 1) return false;
size = dim2_; size = dim2_;
if (fwrite(&size, sizeof(size), 1, fp) != 1) return false; if (fwrite(&size, sizeof(size), 1, fp) != 1) return false;
return true; return true;
} }
bool SerializeSize(tesseract::TFile* fp) const { bool SerializeSize(tesseract::TFile* fp) const {
inT32 size = dim1_; int32_t size = dim1_;
if (fp->FWrite(&size, sizeof(size), 1) != 1) return false; if (fp->FWrite(&size, sizeof(size), 1) != 1) return false;
size = dim2_; size = dim2_;
if (fp->FWrite(&size, sizeof(size), 1) != 1) return false; if (fp->FWrite(&size, sizeof(size), 1) != 1) return false;
@ -479,7 +479,7 @@ class GENERIC_2D_ARRAY {
// Factored helper to deserialize the size. // Factored helper to deserialize the size.
// If swap is true, assumes a big/little-endian swap is needed. // If swap is true, assumes a big/little-endian swap is needed.
bool DeSerializeSize(bool swap, FILE* fp) { bool DeSerializeSize(bool swap, FILE* fp) {
inT32 size1, size2; int32_t size1, size2;
if (fread(&size1, sizeof(size1), 1, fp) != 1) return false; if (fread(&size1, sizeof(size1), 1, fp) != 1) return false;
if (fread(&size2, sizeof(size2), 1, fp) != 1) return false; if (fread(&size2, sizeof(size2), 1, fp) != 1) return false;
if (swap) { if (swap) {
@ -490,7 +490,7 @@ class GENERIC_2D_ARRAY {
return true; return true;
} }
bool DeSerializeSize(tesseract::TFile* fp) { bool DeSerializeSize(tesseract::TFile* fp) {
inT32 size1, size2; int32_t size1, size2;
if (fp->FReadEndian(&size1, sizeof(size1), 1) != 1) return false; if (fp->FReadEndian(&size1, sizeof(size1), 1) != 1) return false;
if (fp->FReadEndian(&size2, sizeof(size2), 1) != 1) return false; if (fp->FReadEndian(&size2, sizeof(size2), 1) != 1) return false;
Resize(size1, size2, empty_); Resize(size1, size2, empty_);

View File

@ -19,7 +19,7 @@
#include "mod128.h" #include "mod128.h"
const inT16 idirtab[] = { const int16_t idirtab[] = {
1000, 0, 998, 49, 995, 98, 989, 146, 1000, 0, 998, 49, 995, 98, 989, 146,
980, 195, 970, 242, 956, 290, 941, 336, 980, 195, 970, 242, 956, 290, 941, 336,
923, 382, 903, 427, 881, 471, 857, 514, 923, 382, 903, 427, 881, 471, 857, 514,

View File

@ -33,33 +33,33 @@ class DLLSYM DIR128
} //empty constructor } //empty constructor
DIR128( //constructor DIR128( //constructor
inT16 value) { //value to assign int16_t value) { //value to assign
value %= MODULUS; //modulo arithmetic value %= MODULUS; //modulo arithmetic
if (value < 0) if (value < 0)
value += MODULUS; //done properly value += MODULUS; //done properly
dir = (inT8) value; dir = (int8_t) value;
} }
DIR128(const FCOORD fc); //quantize vector DIR128(const FCOORD fc); //quantize vector
DIR128 & operator= ( //assign of inT16 DIR128 & operator= ( //assign of int16_t
inT16 value) { //value to assign int16_t value) { //value to assign
value %= MODULUS; //modulo arithmetic value %= MODULUS; //modulo arithmetic
if (value < 0) if (value < 0)
value += MODULUS; //done properly value += MODULUS; //done properly
dir = (inT8) value; dir = (int8_t) value;
return *this; return *this;
} }
inT8 operator- ( //subtraction int8_t operator- ( //subtraction
const DIR128 & minus) const//for signed result const DIR128 & minus) const//for signed result
{ {
//result //result
inT16 result = dir - minus.dir; int16_t result = dir - minus.dir;
if (result > MODULUS / 2) if (result > MODULUS / 2)
result -= MODULUS; //get in range result -= MODULUS; //get in range
else if (result < -MODULUS / 2) else if (result < -MODULUS / 2)
result += MODULUS; result += MODULUS;
return (inT8) result; return (int8_t) result;
} }
DIR128 operator+ ( //addition DIR128 operator+ ( //addition
const DIR128 & add) const //of itself const DIR128 & add) const //of itself
@ -74,11 +74,11 @@ class DLLSYM DIR128
*this = dir + add.dir; //let = do the work *this = dir + add.dir; //let = do the work
return *this; return *this;
} }
inT8 get_dir() const { //access function int8_t get_dir() const { //access function
return dir; return dir;
} }
private: private:
inT8 dir; //a direction int8_t dir; //a direction
}; };
#endif #endif

View File

@ -34,11 +34,11 @@ ELISTIZE (BLOCK)
*/ */
BLOCK::BLOCK(const char *name, //< filename BLOCK::BLOCK(const char *name, //< filename
BOOL8 prop, //< proportional BOOL8 prop, //< proportional
inT16 kern, //< kerning int16_t kern, //< kerning
inT16 space, //< spacing int16_t space, //< spacing
inT16 xmin, //< bottom left int16_t xmin, //< bottom left
inT16 ymin, inT16 xmax, //< top right int16_t ymin, int16_t xmax, //< top right
inT16 ymax) int16_t ymax)
: PDBLK (xmin, ymin, xmax, ymax), : PDBLK (xmin, ymin, xmax, ymax),
filename(name), filename(name),
re_rotation_(1.0f, 0.0f), re_rotation_(1.0f, 0.0f),

View File

@ -42,12 +42,12 @@ class BLOCK:public ELIST_LINK, public PDBLK
} }
BLOCK(const char *name, //< filename BLOCK(const char *name, //< filename
BOOL8 prop, //< proportional BOOL8 prop, //< proportional
inT16 kern, //< kerning int16_t kern, //< kerning
inT16 space, //< spacing int16_t space, //< spacing
inT16 xmin, //< bottom left int16_t xmin, //< bottom left
inT16 ymin, int16_t ymin,
inT16 xmax, //< top right int16_t xmax, //< top right
inT16 ymax); int16_t ymax);
~BLOCK () { ~BLOCK () {
} }
@ -60,20 +60,20 @@ class BLOCK:public ELIST_LINK, public PDBLK
* @param ch_pitch pitch if fixed * @param ch_pitch pitch if fixed
*/ */
void set_stats(BOOL8 prop, void set_stats(BOOL8 prop,
inT16 kern, int16_t kern,
inT16 space, int16_t space,
inT16 ch_pitch) { int16_t ch_pitch) {
proportional = prop; proportional = prop;
kerning = (inT8) kern; kerning = (int8_t) kern;
spacing = space; spacing = space;
pitch = ch_pitch; pitch = ch_pitch;
} }
/// set char size /// set char size
void set_xheight(inT32 height) { void set_xheight(int32_t height) {
xheight = height; xheight = height;
} }
/// set font class /// set font class
void set_font_class(inT16 font) { void set_font_class(int16_t font) {
font_class = font; font_class = font;
} }
/// return proportional /// return proportional
@ -87,19 +87,19 @@ class BLOCK:public ELIST_LINK, public PDBLK
right_to_left_ = value; right_to_left_ = value;
} }
/// return pitch /// return pitch
inT32 fixed_pitch() const { int32_t fixed_pitch() const {
return pitch; return pitch;
} }
/// return kerning /// return kerning
inT16 kern() const { int16_t kern() const {
return kerning; return kerning;
} }
/// return font class /// return font class
inT16 font() const { int16_t font() const {
return font_class; return font_class;
} }
/// return spacing /// return spacing
inT16 space() const { int16_t space() const {
return spacing; return spacing;
} }
/// return filename /// return filename
@ -107,7 +107,7 @@ class BLOCK:public ELIST_LINK, public PDBLK
return filename.string (); return filename.string ();
} }
/// return xheight /// return xheight
inT32 x_height() const { int32_t x_height() const {
return xheight; return xheight;
} }
float cell_over_xheight() const { float cell_over_xheight() const {
@ -195,11 +195,11 @@ class BLOCK:public ELIST_LINK, public PDBLK
private: private:
BOOL8 proportional; //< proportional BOOL8 proportional; //< proportional
bool right_to_left_; //< major script is right to left. bool right_to_left_; //< major script is right to left.
inT8 kerning; //< inter blob gap int8_t kerning; //< inter blob gap
inT16 spacing; //< inter word gap int16_t spacing; //< inter word gap
inT16 pitch; //< pitch of non-props int16_t pitch; //< pitch of non-props
inT16 font_class; //< correct font class int16_t font_class; //< correct font class
inT32 xheight; //< height of chars int32_t xheight; //< height of chars
float cell_over_xheight_; //< Ratio of cell height to xheight. float cell_over_xheight_; //< Ratio of cell height to xheight.
STRING filename; //< name of block STRING filename; //< name of block
ROW_LIST rows; //< rows in block ROW_LIST rows; //< rows in block

View File

@ -33,14 +33,14 @@ ELISTIZE (ROW)
* The words are added directly. * The words are added directly.
**********************************************************************/ **********************************************************************/
ROW::ROW ( //constructor ROW::ROW ( //constructor
inT32 spline_size, //no of segments int32_t spline_size, //no of segments
inT32 * xstarts, //segment boundaries int32_t * xstarts, //segment boundaries
double *coeffs, //coefficients double *coeffs, //coefficients
float x_height, //line height float x_height, //line height
float ascenders, //ascender size float ascenders, //ascender size
float descenders, //descender drop float descenders, //descender drop
inT16 kern, //char gap int16_t kern, //char gap
inT16 space //word gap int16_t space //word gap
) )
: baseline(spline_size, xstarts, coeffs), : baseline(spline_size, xstarts, coeffs),
para_(NULL) { para_(NULL) {
@ -65,8 +65,8 @@ inT16 space //word gap
ROW::ROW( //constructor ROW::ROW( //constructor
TO_ROW *to_row, //source row TO_ROW *to_row, //source row
inT16 kern, //char gap int16_t kern, //char gap
inT16 space //word gap int16_t space //word gap
) : para_(NULL) { ) : para_(NULL) {
kerning = kern; //just store stuff kerning = kern; //just store stuff
spacing = space; spacing = space;
@ -101,8 +101,8 @@ TBOX ROW::restricted_bounding_box(bool upper_dots, bool lower_dots) const {
void ROW::recalc_bounding_box() { //recalculate BB void ROW::recalc_bounding_box() { //recalculate BB
WERD *word; //current word WERD *word; //current word
WERD_IT it = &words; //words of ROW WERD_IT it = &words; //words of ROW
inT16 left; //of word int16_t left; //of word
inT16 prev_left; //old left int16_t prev_left; //old left
if (!it.empty ()) { if (!it.empty ()) {
word = it.data (); word = it.data ();

View File

@ -36,18 +36,18 @@ class ROW:public ELIST_LINK
ROW() { ROW() {
} //empty constructor } //empty constructor
ROW( //constructor ROW( //constructor
inT32 spline_size, //no of segments int32_t spline_size, //no of segments
inT32 *xstarts, //segment boundaries int32_t *xstarts, //segment boundaries
double *coeffs, //coefficients //ascender size double *coeffs, //coefficients //ascender size
float x_height, float x_height,
float ascenders, float ascenders,
float descenders, //descender size float descenders, //descender size
inT16 kern, //char gap int16_t kern, //char gap
inT16 space); //word gap int16_t space); //word gap
ROW( //constructor ROW( //constructor
TO_ROW *row, //textord row TO_ROW *row, //textord row
inT16 kern, //char gap int16_t kern, //char gap
inT16 space); //word gap int16_t space); //word gap
WERD_LIST *word_list() { //get words WERD_LIST *word_list() { //get words
return &words; return &words;
@ -64,7 +64,7 @@ class ROW:public ELIST_LINK
void set_x_height(float new_xheight) { // set x height void set_x_height(float new_xheight) { // set x height
xheight = new_xheight; xheight = new_xheight;
} }
inT32 kern() const { //return kerning int32_t kern() const { //return kerning
return kerning; return kerning;
} }
float body_size() const { //return body size float body_size() const { //return body size
@ -73,7 +73,7 @@ class ROW:public ELIST_LINK
void set_body_size(float new_size) { // set body size void set_body_size(float new_size) { // set body size
bodysize = new_size; bodysize = new_size;
} }
inT32 space() const { //return spacing int32_t space() const { //return spacing
return spacing; return spacing;
} }
float ascenders() const { //return size float ascenders() const { //return size
@ -89,16 +89,16 @@ class ROW:public ELIST_LINK
// lower noise/diacritic elements. // lower noise/diacritic elements.
TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const; TBOX restricted_bounding_box(bool upper_dots, bool lower_dots) const;
void set_lmargin(inT16 lmargin) { void set_lmargin(int16_t lmargin) {
lmargin_ = lmargin; lmargin_ = lmargin;
} }
void set_rmargin(inT16 rmargin) { void set_rmargin(int16_t rmargin) {
rmargin_ = rmargin; rmargin_ = rmargin;
} }
inT16 lmargin() const { int16_t lmargin() const {
return lmargin_; return lmargin_;
} }
inT16 rmargin() const { int16_t rmargin() const {
return rmargin_; return rmargin_;
} }
@ -141,8 +141,8 @@ class ROW:public ELIST_LINK
ROW& operator= (const ROW & source); ROW& operator= (const ROW & source);
private: private:
inT32 kerning; //inter char gap int32_t kerning; //inter char gap
inT32 spacing; //inter word gap int32_t spacing; //inter word gap
TBOX bound_box; //bounding box TBOX bound_box; //bounding box
float xheight; //height of line float xheight; //height of line
float ascrise; //size of ascenders float ascrise; //size of ascenders
@ -154,8 +154,8 @@ class ROW:public ELIST_LINK
// These get set after blocks have been determined. // These get set after blocks have been determined.
bool has_drop_cap_; bool has_drop_cap_;
inT16 lmargin_; // Distance to left polyblock margin. int16_t lmargin_; // Distance to left polyblock margin.
inT16 rmargin_; // Distance to right polyblock margin. int16_t rmargin_; // Distance to right polyblock margin.
// This gets set during paragraph analysis. // This gets set during paragraph analysis.
PARA *para_; // Paragraph of which this row is part. PARA *para_; // Paragraph of which this row is part.

View File

@ -896,8 +896,8 @@ void WERD_RES::FakeWordFromRatings(PermuterType permuter) {
word_choice->set_permuter(permuter); word_choice->set_permuter(permuter);
for (int b = 0; b < num_blobs; ++b) { for (int b = 0; b < num_blobs; ++b) {
UNICHAR_ID unichar_id = UNICHAR_SPACE; UNICHAR_ID unichar_id = UNICHAR_SPACE;
float rating = MAX_INT32; float rating = INT32_MAX;
float certainty = -MAX_INT32; float certainty = -INT32_MAX;
BLOB_CHOICE_LIST* choices = ratings->get(b, b); BLOB_CHOICE_LIST* choices = ratings->get(b, b);
if (choices != NULL && !choices->empty()) { if (choices != NULL && !choices->empty()) {
BLOB_CHOICE_IT bc_it(choices); BLOB_CHOICE_IT bc_it(choices);
@ -1307,7 +1307,7 @@ static void ComputeBlobEnds(const WERD_RES& word, C_BLOB_LIST* next_word_blobs,
} }
// This blob_box is crap, so for now we are only looking for the // This blob_box is crap, so for now we are only looking for the
// boundaries between them. // boundaries between them.
int blob_end = MAX_INT32; int blob_end = INT32_MAX;
if (!blob_it.at_first() || next_word_blobs != NULL) { if (!blob_it.at_first() || next_word_blobs != NULL) {
if (blob_it.at_first()) if (blob_it.at_first())
blob_it.set_to_list(next_word_blobs); blob_it.set_to_list(next_word_blobs);
@ -1673,8 +1673,8 @@ WERD_RES *PAGE_RES_IT::forward_block() {
} }
void PAGE_RES_IT::rej_stat_word() { void PAGE_RES_IT::rej_stat_word() {
inT16 chars_in_word; int16_t chars_in_word;
inT16 rejects_in_word = 0; int16_t rejects_in_word = 0;
chars_in_word = word_res->reject_map.length (); chars_in_word = word_res->reject_map.length ();
page_res->char_count += chars_in_word; page_res->char_count += chars_in_word;

View File

@ -57,8 +57,8 @@ ELISTIZEH (WERD_RES)
*************************************************************************/ *************************************************************************/
class PAGE_RES { // page result class PAGE_RES { // page result
public: public:
inT32 char_count; int32_t char_count;
inT32 rej_count; int32_t rej_count;
BLOCK_RES_LIST block_res_list; BLOCK_RES_LIST block_res_list;
BOOL8 rejected; BOOL8 rejected;
// Updated every time PAGE_RES_IT iterating on this PAGE_RES moves to // Updated every time PAGE_RES_IT iterating on this PAGE_RES moves to
@ -97,10 +97,10 @@ class PAGE_RES { // page result
class BLOCK_RES:public ELIST_LINK { class BLOCK_RES:public ELIST_LINK {
public: public:
BLOCK * block; // real block BLOCK * block; // real block
inT32 char_count; // chars in block int32_t char_count; // chars in block
inT32 rej_count; // rejected chars int32_t rej_count; // rejected chars
inT16 font_class; // int16_t font_class; //
inT16 row_count; int16_t row_count;
float x_height; float x_height;
BOOL8 font_assigned; // block already BOOL8 font_assigned; // block already
// processed // processed
@ -125,9 +125,9 @@ class BLOCK_RES:public ELIST_LINK {
class ROW_RES:public ELIST_LINK { class ROW_RES:public ELIST_LINK {
public: public:
ROW * row; // real row ROW * row; // real row
inT32 char_count; // chars in block int32_t char_count; // chars in block
inT32 rej_count; // rejected chars int32_t rej_count; // rejected chars
inT32 whole_word_rej_count; // rejs in total rej wds int32_t whole_word_rej_count; // rejs in total rej wds
WERD_RES_LIST word_res_list; WERD_RES_LIST word_res_list;
ROW_RES() { ROW_RES() {
@ -282,13 +282,13 @@ class WERD_RES : public ELIST_LINK {
BOOL8 done; // ready for output? BOOL8 done; // ready for output?
bool small_caps; // word appears to be small caps bool small_caps; // word appears to be small caps
bool odd_size; // word is bigger than line or leader dots. bool odd_size; // word is bigger than line or leader dots.
inT8 italic; int8_t italic;
inT8 bold; int8_t bold;
// The fontinfos are pointers to data owned by the classifier. // The fontinfos are pointers to data owned by the classifier.
const FontInfo* fontinfo; const FontInfo* fontinfo;
const FontInfo* fontinfo2; const FontInfo* fontinfo2;
inT8 fontinfo_id_count; // number of votes int8_t fontinfo_id_count; // number of votes
inT8 fontinfo_id2_count; // number of votes int8_t fontinfo_id2_count; // number of votes
BOOL8 guessed_x_ht; BOOL8 guessed_x_ht;
BOOL8 guessed_caps_ht; BOOL8 guessed_caps_ht;
CRUNCH_MODE unlv_crunch_mode; CRUNCH_MODE unlv_crunch_mode;

View File

@ -37,9 +37,9 @@ CLISTIZE (PDBLK)
* Constructor for a simple rectangular block. * Constructor for a simple rectangular block.
**********************************************************************/ **********************************************************************/
PDBLK::PDBLK ( //rectangular block PDBLK::PDBLK ( //rectangular block
inT16 xmin, //bottom left int16_t xmin, //bottom left
inT16 ymin, inT16 xmax, //top right int16_t ymin, int16_t xmax, //top right
inT16 ymax): box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) { int16_t ymax): box (ICOORD (xmin, ymin), ICOORD (xmax, ymax)) {
//boundaries //boundaries
ICOORDELT_IT left_it = &leftside; ICOORDELT_IT left_it = &leftside;
ICOORDELT_IT right_it = &rightside; ICOORDELT_IT right_it = &rightside;
@ -177,7 +177,7 @@ Pix* PDBLK::render_mask(const FCOORD& rerotation, TBOX* mask_box) {
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void PDBLK::plot( //draw outline void PDBLK::plot( //draw outline
ScrollView* window, //window to draw in ScrollView* window, //window to draw in
inT32 serial, //serial number int32_t serial, //serial number
ScrollView::Color colour //colour to draw in ScrollView::Color colour //colour to draw in
) { ) {
ICOORD startpt; //start of outline ICOORD startpt; //start of outline
@ -342,9 +342,9 @@ void BLOCK_RECT_IT::forward() { //next rectangle
* Get the the start and width of a line in the block. * Get the the start and width of a line in the block.
**********************************************************************/ **********************************************************************/
inT16 BLOCK_LINE_IT::get_line( //get a line int16_t BLOCK_LINE_IT::get_line( //get a line
inT16 y, //line to get int16_t y, //line to get
inT16 &xext //output extent int16_t &xext //output extent
) { ) {
ICOORD bleft; //bounding box ICOORD bleft; //bounding box
ICOORD tright; //of block & rect ICOORD tright; //of block & rect

View File

@ -39,10 +39,10 @@ class PDBLK {
index_ = 0; index_ = 0;
} }
/// simple constructor /// simple constructor
PDBLK(inT16 xmin, //< bottom left PDBLK(int16_t xmin, //< bottom left
inT16 ymin, int16_t ymin,
inT16 xmax, //< top right int16_t xmax, //< top right
inT16 ymax); int16_t ymax);
/// set vertex lists /// set vertex lists
///@param left list of left vertices ///@param left list of left vertices
@ -84,7 +84,7 @@ class PDBLK {
///@param window window to draw in ///@param window window to draw in
///@param serial serial number ///@param serial serial number
///@param colour colour to draw in ///@param colour colour to draw in
void plot(ScrollView *window, inT32 serial, ScrollView::Color colour); void plot(ScrollView *window, int32_t serial, ScrollView::Color colour);
#endif // GRAPHICS_DISABLED #endif // GRAPHICS_DISABLED
/// assignment /// assignment
@ -133,8 +133,8 @@ class DLLSYM BLOCK_RECT_IT //rectangle iterator
} }
private: private:
inT16 ymin; //< bottom of rectangle int16_t ymin; //< bottom of rectangle
inT16 ymax; //< top of rectangle int16_t ymax; //< top of rectangle
PDBLK *block; //< block to iterate PDBLK *block; //< block to iterate
ICOORDELT_IT left_it; //< boundary iterators ICOORDELT_IT left_it; //< boundary iterators
ICOORDELT_IT right_it; ICOORDELT_IT right_it;
@ -162,8 +162,8 @@ class DLLSYM BLOCK_LINE_IT
///get a line ///get a line
///@param y line to get ///@param y line to get
///@param xext output extent ///@param xext output extent
inT16 get_line(inT16 y, int16_t get_line(int16_t y,
inT16 &xext); int16_t &xext);
private: private:
PDBLK * block; //< block to iterate PDBLK * block; //< block to iterate

View File

@ -44,8 +44,8 @@ void ICOORD::set_with_shrink(int x, int y) {
// Fit the vector into an ICOORD, which is 16 bit. // Fit the vector into an ICOORD, which is 16 bit.
int factor = 1; int factor = 1;
int max_extent = MAX(abs(x), abs(y)); int max_extent = MAX(abs(x), abs(y));
if (max_extent > MAX_INT16) if (max_extent > INT16_MAX)
factor = max_extent / MAX_INT16 + 1; factor = max_extent / INT16_MAX + 1;
xcoord = x / factor; xcoord = x / factor;
ycoord = y / factor; ycoord = y / factor;
} }
@ -108,11 +108,11 @@ void ICOORD::setup_render(ICOORD* major_step, ICOORD* minor_step,
// Returns the standard feature direction corresponding to this. // Returns the standard feature direction corresponding to this.
// See binary_angle_plus_pi below for a description of the direction. // See binary_angle_plus_pi below for a description of the direction.
uinT8 FCOORD::to_direction() const { uint8_t FCOORD::to_direction() const {
return binary_angle_plus_pi(angle()); return binary_angle_plus_pi(angle());
} }
// Sets this with a unit vector in the given standard feature direction. // Sets this with a unit vector in the given standard feature direction.
void FCOORD::from_direction(uinT8 direction) { void FCOORD::from_direction(uint8_t direction) {
double radians = angle_from_direction(direction); double radians = angle_from_direction(direction);
xcoord = cos(radians); xcoord = cos(radians);
ycoord = sin(radians); ycoord = sin(radians);
@ -121,12 +121,12 @@ void FCOORD::from_direction(uinT8 direction) {
// Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a // Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a
// standard feature direction as an unsigned angle in 256ths of a circle // standard feature direction as an unsigned angle in 256ths of a circle
// measured anticlockwise from (-1, 0). // measured anticlockwise from (-1, 0).
uinT8 FCOORD::binary_angle_plus_pi(double radians) { uint8_t FCOORD::binary_angle_plus_pi(double radians) {
return Modulo(IntCastRounded((radians + M_PI) * 128.0 / M_PI), 256); return Modulo(IntCastRounded((radians + M_PI) * 128.0 / M_PI), 256);
} }
// Inverse of binary_angle_plus_pi returns an angle in radians for the // Inverse of binary_angle_plus_pi returns an angle in radians for the
// given standard feature direction. // given standard feature direction.
double FCOORD::angle_from_direction(uinT8 direction) { double FCOORD::angle_from_direction(uint8_t direction) {
return direction * M_PI / 128.0 - M_PI; return direction * M_PI / 128.0 - M_PI;
} }

View File

@ -39,8 +39,8 @@ class ICOORD
///constructor ///constructor
///@param xin x value ///@param xin x value
///@param yin y value ///@param yin y value
ICOORD(inT16 xin, ICOORD(int16_t xin,
inT16 yin) { int16_t yin) {
xcoord = xin; xcoord = xin;
ycoord = yin; ycoord = yin;
} }
@ -49,20 +49,20 @@ class ICOORD
} }
///access function ///access function
inT16 x() const { int16_t x() const {
return xcoord; return xcoord;
} }
///access_function ///access_function
inT16 y() const { int16_t y() const {
return ycoord; return ycoord;
} }
///rewrite function ///rewrite function
void set_x(inT16 xin) { void set_x(int16_t xin) {
xcoord = xin; //write new value xcoord = xin; //write new value
} }
///rewrite function ///rewrite function
void set_y(inT16 yin) { //value to set void set_y(int16_t yin) { //value to set
ycoord = yin; ycoord = yin;
} }
@ -119,22 +119,22 @@ class ICOORD
///subtract ///subtract
friend ICOORD & operator-= (ICOORD &, const ICOORD &); friend ICOORD & operator-= (ICOORD &, const ICOORD &);
///scalar product ///scalar product
friend inT32 operator% (const ICOORD &, const ICOORD &); friend int32_t operator% (const ICOORD &, const ICOORD &);
///cross product ///cross product
friend inT32 operator *(const ICOORD &, friend int32_t operator *(const ICOORD &,
const ICOORD &); const ICOORD &);
///multiply ///multiply
friend ICOORD operator *(const ICOORD &, friend ICOORD operator *(const ICOORD &,
inT16); int16_t);
///multiply ///multiply
friend ICOORD operator *(inT16, friend ICOORD operator *(int16_t,
const ICOORD &); const ICOORD &);
///multiply ///multiply
friend ICOORD & operator*= (ICOORD &, inT16); friend ICOORD & operator*= (ICOORD &, int16_t);
///divide ///divide
friend ICOORD operator/ (const ICOORD &, inT16); friend ICOORD operator/ (const ICOORD &, int16_t);
///divide ///divide
friend ICOORD & operator/= (ICOORD &, inT16); friend ICOORD & operator/= (ICOORD &, int16_t);
///rotate ///rotate
///@param vec by vector ///@param vec by vector
void rotate(const FCOORD& vec); void rotate(const FCOORD& vec);
@ -154,8 +154,8 @@ class ICOORD
bool DeSerialize(bool swap, FILE* fp); bool DeSerialize(bool swap, FILE* fp);
protected: protected:
inT16 xcoord; //< x value int16_t xcoord; //< x value
inT16 ycoord; //< y value int16_t ycoord; //< y value
}; };
class DLLSYM ICOORDELT:public ELIST_LINK, public ICOORD class DLLSYM ICOORDELT:public ELIST_LINK, public ICOORD
@ -171,8 +171,8 @@ class DLLSYM ICOORDELT:public ELIST_LINK, public ICOORD
///constructor ///constructor
///@param xin x value ///@param xin x value
///@param yin y value ///@param yin y value
ICOORDELT(inT16 xin, ICOORDELT(int16_t xin,
inT16 yin) { int16_t yin) {
xcoord = xin; xcoord = xin;
ycoord = yin; ycoord = yin;
} }
@ -251,17 +251,17 @@ class DLLSYM FCOORD
} }
// Returns the standard feature direction corresponding to this. // Returns the standard feature direction corresponding to this.
// See binary_angle_plus_pi below for a description of the direction. // See binary_angle_plus_pi below for a description of the direction.
uinT8 to_direction() const; uint8_t to_direction() const;
// Sets this with a unit vector in the given standard feature direction. // Sets this with a unit vector in the given standard feature direction.
void from_direction(uinT8 direction); void from_direction(uint8_t direction);
// Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a // Converts an angle in radians (from ICOORD::angle or FCOORD::angle) to a
// standard feature direction as an unsigned angle in 256ths of a circle // standard feature direction as an unsigned angle in 256ths of a circle
// measured anticlockwise from (-1, 0). // measured anticlockwise from (-1, 0).
static uinT8 binary_angle_plus_pi(double angle); static uint8_t binary_angle_plus_pi(double angle);
// Inverse of binary_angle_plus_pi returns an angle in radians for the // Inverse of binary_angle_plus_pi returns an angle in radians for the
// given standard feature direction. // given standard feature direction.
static double angle_from_direction(uinT8 direction); static double angle_from_direction(uint8_t direction);
// Returns the point on the given line nearest to this, ie the point such // Returns the point on the given line nearest to this, ie the point such
// that the vector point->this is perpendicular to the line. // that the vector point->this is perpendicular to the line.
// The line is defined as a line_point and a dir_vector for its direction. // The line is defined as a line_point and a dir_vector for its direction.

View File

@ -59,7 +59,7 @@ const int par2 = 6750 / (approx_dist * approx_dist);
TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE* c_outline) { TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE* c_outline) {
TBOX loop_box; // bounding box TBOX loop_box; // bounding box
inT32 area; // loop area int32_t area; // loop area
EDGEPT stack_edgepts[FASTEDGELENGTH]; // converted path EDGEPT stack_edgepts[FASTEDGELENGTH]; // converted path
EDGEPT* edgepts = stack_edgepts; EDGEPT* edgepts = stack_edgepts;
@ -116,15 +116,15 @@ edgesteps_to_edgepts ( //convert outline
C_OUTLINE * c_outline, //input C_OUTLINE * c_outline, //input
EDGEPT edgepts[] //output is array EDGEPT edgepts[] //output is array
) { ) {
inT32 length; //steps in path int32_t length; //steps in path
ICOORD pos; //current coords ICOORD pos; //current coords
inT32 stepindex; //current step int32_t stepindex; //current step
inT32 stepinc; //increment int32_t stepinc; //increment
inT32 epindex; //current EDGEPT int32_t epindex; //current EDGEPT
inT32 count; //repeated steps int32_t count; //repeated steps
ICOORD vec; //for this 8 step ICOORD vec; //for this 8 step
ICOORD prev_vec; ICOORD prev_vec;
inT8 epdir; //of this step int8_t epdir; //of this step
DIR128 prevdir; //prvious dir DIR128 prevdir; //prvious dir
DIR128 dir; //of this step DIR128 dir; //of this step
@ -556,7 +556,7 @@ void cutline( //recursive refine
perp = LENGTH (vecsum); perp = LENGTH (vecsum);
ASSERT_HOST (perp != 0); ASSERT_HOST (perp != 0);
if (maxperp < 256 * MAX_INT16) { if (maxperp < 256 * INT16_MAX) {
maxperp <<= 8; maxperp <<= 8;
maxperp /= perp; /*true max perp */ maxperp /= perp; /*true max perp */
} }
@ -564,7 +564,7 @@ void cutline( //recursive refine
maxperp /= perp; maxperp /= perp;
maxperp <<= 8; /*avoid overflow */ maxperp <<= 8; /*avoid overflow */
} }
if (squaresum < 256 * MAX_INT16) if (squaresum < 256 * INT16_MAX)
/*mean squared perp */ /*mean squared perp */
perp = (squaresum << 8) / (perp * ptcount); perp = (squaresum << 8) / (perp * ptcount);
else else

View File

@ -30,7 +30,7 @@
#endif #endif
#define PBLOCK_LABEL_SIZE 150 #define PBLOCK_LABEL_SIZE 150
#define INTERSECTING MAX_INT16 #define INTERSECTING INT16_MAX
int lessthan(const void *first, const void *second); int lessthan(const void *first, const void *second);
@ -99,12 +99,12 @@ void POLY_BLOCK::compute_bb() { //constructor
* @param point point to wind around * @param point point to wind around
*/ */
inT16 POLY_BLOCK::winding_number(const ICOORD &point) { int16_t POLY_BLOCK::winding_number(const ICOORD &point) {
inT16 count; //winding count int16_t count; //winding count
ICOORD pt; //current point ICOORD pt; //current point
ICOORD vec; //point to current point ICOORD vec; //point to current point
ICOORD vvec; //current point to next point ICOORD vvec; //current point to next point
inT32 cross; //cross product int32_t cross; //cross product
ICOORDELT_IT it = &vertices; //iterator ICOORDELT_IT it = &vertices; //iterator
count = 0; count = 0;
@ -138,7 +138,7 @@ inT16 POLY_BLOCK::winding_number(const ICOORD &point) {
/// @return true if other is inside this. /// @return true if other is inside this.
bool POLY_BLOCK::contains(POLY_BLOCK *other) { bool POLY_BLOCK::contains(POLY_BLOCK *other) {
inT16 count; // winding count int16_t count; // winding count
ICOORDELT_IT it = &vertices; // iterator ICOORDELT_IT it = &vertices; // iterator
ICOORD vertex; ICOORD vertex;
@ -193,8 +193,8 @@ void POLY_BLOCK::rotate(FCOORD rotation) {
pos.set_x (pt->x ()); pos.set_x (pt->x ());
pos.set_y (pt->y ()); pos.set_y (pt->y ());
pos.rotate (rotation); pos.rotate (rotation);
pt->set_x ((inT16) (floor (pos.x () + 0.5))); pt->set_x ((int16_t) (floor (pos.x () + 0.5)));
pt->set_y ((inT16) (floor (pos.y () + 0.5))); pt->set_y ((int16_t) (floor (pos.y () + 0.5)));
pts.forward (); pts.forward ();
} }
while (!pts.at_first ()); while (!pts.at_first ());
@ -243,7 +243,7 @@ void POLY_BLOCK::move(ICOORD shift) {
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void POLY_BLOCK::plot(ScrollView* window, inT32 num) { void POLY_BLOCK::plot(ScrollView* window, int32_t num) {
ICOORDELT_IT v = &vertices; ICOORDELT_IT v = &vertices;
window->Pen(ColorForPolyBlockType(type)); window->Pen(ColorForPolyBlockType(type));
@ -271,8 +271,8 @@ void POLY_BLOCK::plot(ScrollView* window, inT32 num) {
void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) { void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
inT16 y; int16_t y;
inT16 width; int16_t width;
PB_LINE_IT *lines; PB_LINE_IT *lines;
ICOORDELT_IT s_it; ICOORDELT_IT s_it;
@ -303,7 +303,7 @@ void POLY_BLOCK::fill(ScrollView* window, ScrollView::Color colour) {
/// @return true if the polygons of other and this overlap. /// @return true if the polygons of other and this overlap.
bool POLY_BLOCK::overlap(POLY_BLOCK *other) { bool POLY_BLOCK::overlap(POLY_BLOCK *other) {
inT16 count; // winding count int16_t count; // winding count
ICOORDELT_IT it = &vertices; // iterator ICOORDELT_IT it = &vertices; // iterator
ICOORD vertex; ICOORD vertex;
@ -341,7 +341,7 @@ bool POLY_BLOCK::overlap(POLY_BLOCK *other) {
} }
ICOORDELT_LIST *PB_LINE_IT::get_line(inT16 y) { ICOORDELT_LIST *PB_LINE_IT::get_line(int16_t y) {
ICOORDELT_IT v, r; ICOORDELT_IT v, r;
ICOORDELT_LIST *result; ICOORDELT_LIST *result;
ICOORDELT *x, *current, *previous; ICOORDELT *x, *current, *previous;
@ -361,7 +361,7 @@ ICOORDELT_LIST *PB_LINE_IT::get_line(inT16 y) {
(current->x () - previous->x ()) * (fy - (current->x () - previous->x ()) * (fy -
previous->y ()) / previous->y ()) /
(current->y () - previous->y ())); (current->y () - previous->y ()));
x = new ICOORDELT ((inT16) fx, 0); x = new ICOORDELT ((int16_t) fx, 0);
r.add_to_end (x); r.add_to_end (x);
} }
} }

View File

@ -61,7 +61,7 @@ class DLLSYM POLY_BLOCK {
// Move by adding shift to all coordinates. // Move by adding shift to all coordinates.
void move(ICOORD shift); void move(ICOORD shift);
void plot(ScrollView* window, inT32 num); void plot(ScrollView* window, int32_t num);
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
void fill(ScrollView* window, ScrollView::Color colour); void fill(ScrollView* window, ScrollView::Color colour);
@ -76,7 +76,7 @@ class DLLSYM POLY_BLOCK {
// Returns the winding number of this around the test_pt. // Returns the winding number of this around the test_pt.
// Positive for anticlockwise, negative for clockwise, and zero for // Positive for anticlockwise, negative for clockwise, and zero for
// test_pt outside this. // test_pt outside this.
inT16 winding_number(const ICOORD &test_pt); int16_t winding_number(const ICOORD &test_pt);
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
// Static utility functions to handle the PolyBlockType. // Static utility functions to handle the PolyBlockType.
@ -105,7 +105,7 @@ class DLLSYM PB_LINE_IT {
// Each element of the returned list is the start (x) and extent(y) of // Each element of the returned list is the start (x) and extent(y) of
// a run inside the region. // a run inside the region.
// Delete the returned list after use. // Delete the returned list after use.
ICOORDELT_LIST *get_line(inT16 y); ICOORDELT_LIST *get_line(int16_t y);
private: private:
POLY_BLOCK * block; POLY_BLOCK * block;

View File

@ -36,7 +36,7 @@ class QLSQ
void remove( //delete element void remove( //delete element
double x, //coords to delete double x, //coords to delete
double y); double y);
inT32 count() { //no of elements int32_t count() { //no of elements
return n; return n;
} }
@ -53,7 +53,7 @@ class QLSQ
} }
private: private:
inT32 n; //no of elements int32_t n; //no of elements
double a, b, c; //result double a, b, c; //result
double sigx; //sum of x double sigx; //sum of x
double sigy; //sum of y double sigy; //sum of y

View File

@ -48,8 +48,8 @@ class QUAD_COEFFS
y - q = ax^2 - 2apx + ap^2 + bx - bp + c y - q = ax^2 - 2apx + ap^2 + bx - bp + c
y = ax^2 + (b - 2ap)x + (c - bp + ap^2 + q) y = ax^2 + (b - 2ap)x + (c - bp + ap^2 + q)
************************************************************/ ************************************************************/
inT16 p = vec.x (); int16_t p = vec.x ();
inT16 q = vec.y (); int16_t q = vec.y ();
c = (float) (c - b * p + a * p * p + q); c = (float) (c - b * p + a * p * p + q);
b = (float) (b - 2 * a * p); b = (float) (b - 2 * a * p);

View File

@ -36,14 +36,14 @@
**********************************************************************/ **********************************************************************/
QSPLINE::QSPLINE( //constructor QSPLINE::QSPLINE( //constructor
inT32 count, //no of segments int32_t count, //no of segments
inT32 *xstarts, //start coords int32_t *xstarts, //start coords
double *coeffs //coefficients double *coeffs //coefficients
) { ) {
inT32 index; //segment index int32_t index; //segment index
//get memory //get memory
xcoords = (inT32 *) alloc_mem ((count + 1) * sizeof (inT32)); xcoords = (int32_t *) alloc_mem ((count + 1) * sizeof (int32_t));
quadratics = (QUAD_COEFFS *) alloc_mem (count * sizeof (QUAD_COEFFS)); quadratics = (QUAD_COEFFS *) alloc_mem (count * sizeof (QUAD_COEFFS));
segments = count; segments = count;
for (index = 0; index < segments; index++) { for (index = 0; index < segments; index++) {
@ -73,14 +73,14 @@ int degree //fit required
) { ) {
int pointindex; /*no along text line */ int pointindex; /*no along text line */
int segment; /*segment no */ int segment; /*segment no */
inT32 *ptcounts; //no in each segment int32_t *ptcounts; //no in each segment
QLSQ qlsq; /*accumulator */ QLSQ qlsq; /*accumulator */
segments = segcount; segments = segcount;
xcoords = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32)); xcoords = (int32_t *) alloc_mem ((segcount + 1) * sizeof (int32_t));
ptcounts = (inT32 *) alloc_mem ((segcount + 1) * sizeof (inT32)); ptcounts = (int32_t *) alloc_mem ((segcount + 1) * sizeof (int32_t));
quadratics = (QUAD_COEFFS *) alloc_mem (segcount * sizeof (QUAD_COEFFS)); quadratics = (QUAD_COEFFS *) alloc_mem (segcount * sizeof (QUAD_COEFFS));
memmove (xcoords, xstarts, (segcount + 1) * sizeof (inT32)); memmove (xcoords, xstarts, (segcount + 1) * sizeof (int32_t));
ptcounts[0] = 0; /*none in any yet */ ptcounts[0] = 0; /*none in any yet */
for (segment = 0, pointindex = 0; pointindex < pointcount; pointindex++) { for (segment = 0, pointindex = 0; pointindex < pointcount; pointindex++) {
while (segment < segcount && xpts[pointindex] >= xstarts[segment]) { while (segment < segcount && xpts[pointindex] >= xstarts[segment]) {
@ -175,9 +175,9 @@ const QSPLINE & source) {
free_mem(quadratics); free_mem(quadratics);
segments = source.segments; segments = source.segments;
xcoords = (inT32 *) alloc_mem ((segments + 1) * sizeof (inT32)); xcoords = (int32_t *) alloc_mem ((segments + 1) * sizeof (int32_t));
quadratics = (QUAD_COEFFS *) alloc_mem (segments * sizeof (QUAD_COEFFS)); quadratics = (QUAD_COEFFS *) alloc_mem (segments * sizeof (QUAD_COEFFS));
memmove (xcoords, source.xcoords, (segments + 1) * sizeof (inT32)); memmove (xcoords, source.xcoords, (segments + 1) * sizeof (int32_t));
memmove (quadratics, source.quadratics, segments * sizeof (QUAD_COEFFS)); memmove (quadratics, source.quadratics, segments * sizeof (QUAD_COEFFS));
return *this; return *this;
} }
@ -217,7 +217,7 @@ double QSPLINE::step( //find step functions
double QSPLINE::y( //evaluate double QSPLINE::y( //evaluate
double x //coord to evaluate at double x //coord to evaluate at
) const { ) const {
inT32 index; //segment index int32_t index; //segment index
index = spline_index (x); index = spline_index (x);
return quadratics[index].y (x);//in correct segment return quadratics[index].y (x);//in correct segment
@ -230,12 +230,12 @@ double QSPLINE::y( //evaluate
* Return the index to the largest xcoord not greater than x. * Return the index to the largest xcoord not greater than x.
**********************************************************************/ **********************************************************************/
inT32 QSPLINE::spline_index( //evaluate int32_t QSPLINE::spline_index( //evaluate
double x //coord to evaluate at double x //coord to evaluate at
) const { ) const {
inT32 index; //segment index int32_t index; //segment index
inT32 bottom; //bottom of range int32_t bottom; //bottom of range
inT32 top; //top of range int32_t top; //top of range
bottom = 0; bottom = 0;
top = segments; top = segments;
@ -259,8 +259,8 @@ inT32 QSPLINE::spline_index( //evaluate
void QSPLINE::move( // reposition spline void QSPLINE::move( // reposition spline
ICOORD vec // by vector ICOORD vec // by vector
) { ) {
inT32 segment; //index of segment int32_t segment; //index of segment
inT16 x_shift = vec.x (); int16_t x_shift = vec.x ();
for (segment = 0; segment < segments; segment++) { for (segment = 0; segment < segments; segment++) {
xcoords[segment] += x_shift; xcoords[segment] += x_shift;
@ -348,7 +348,7 @@ void QSPLINE::extrapolate( //linear extrapolation
segments = dest_segment; segments = dest_segment;
free_mem(xcoords); free_mem(xcoords);
free_mem(quadratics); free_mem(quadratics);
xcoords = (inT32 *) xstarts; xcoords = (int32_t *) xstarts;
quadratics = quads; quadratics = quads;
} }
@ -364,8 +364,8 @@ void QSPLINE::plot( //draw it
ScrollView* window, //window to draw in ScrollView* window, //window to draw in
ScrollView::Color colour //colour to draw in ScrollView::Color colour //colour to draw in
) const { ) const {
inT32 segment; //index of segment int32_t segment; //index of segment
inT16 step; //index of poly piece int16_t step; //index of poly piece
double increment; //x increment double increment; //x increment
double x; //x coord double x; //x coord
@ -391,8 +391,8 @@ void QSPLINE::plot(Pix *pix) const {
return; return;
} }
inT32 segment; // Index of segment int32_t segment; // Index of segment
inT16 step; // Index of poly piece int16_t step; // Index of poly piece
double increment; // x increment double increment; // x increment
double x; // x coord double x; // x coord
double height = static_cast<double>(pixGetHeight(pix)); double height = static_cast<double>(pixGetHeight(pix));

View File

@ -48,8 +48,8 @@ class QSPLINE
QSPLINE( //copy constructor QSPLINE( //copy constructor
const QSPLINE &src); const QSPLINE &src);
QSPLINE( //constructor QSPLINE( //constructor
inT32 count, //number of segments int32_t count, //number of segments
inT32 *xstarts, //segment starts int32_t *xstarts, //segment starts
double *coeffs); //coefficients double *coeffs); //coefficients
~QSPLINE (); //destructor ~QSPLINE (); //destructor
QSPLINE ( //least squares fit QSPLINE ( //least squares fit
@ -90,10 +90,10 @@ class QSPLINE
private: private:
inT32 spline_index( //binary search int32_t spline_index( //binary search
double x) const; //for x double x) const; //for x
inT32 segments; //no of segments int32_t segments; //no of segments
inT32 *xcoords; //no of coords int32_t *xcoords; //no of coords
QUAD_COEFFS *quadratics; //spline pieces QUAD_COEFFS *quadratics; //spline pieces
}; };
#endif #endif

View File

@ -172,7 +172,7 @@ BLOB_CHOICE* FindMatchingChoice(UNICHAR_ID char_id,
return NULL; return NULL;
} }
const char *WERD_CHOICE::permuter_name(uinT8 permuter) { const char *WERD_CHOICE::permuter_name(uint8_t permuter) {
return kPermuterTypeNames[permuter]; return kPermuterTypeNames[permuter];
} }
@ -227,7 +227,7 @@ void WERD_CHOICE::init(const char *src_string,
const char *src_lengths, const char *src_lengths,
float src_rating, float src_rating,
float src_certainty, float src_certainty,
uinT8 src_permuter) { uint8_t src_permuter) {
int src_string_len = strlen(src_string); int src_string_len = strlen(src_string);
if (src_string_len == 0) { if (src_string_len == 0) {
this->init(8); this->init(8);

View File

@ -82,10 +82,10 @@ class BLOB_CHOICE: public ELIST_LINK
float certainty() const { float certainty() const {
return certainty_; return certainty_;
} }
inT16 fontinfo_id() const { int16_t fontinfo_id() const {
return fontinfo_id_; return fontinfo_id_;
} }
inT16 fontinfo_id2() const { int16_t fontinfo_id2() const {
return fontinfo_id2_; return fontinfo_id2_;
} }
const GenericVector<tesseract::ScoredFont>& fonts() const { const GenericVector<tesseract::ScoredFont>& fonts() const {
@ -114,10 +114,10 @@ class BLOB_CHOICE: public ELIST_LINK
const MATRIX_COORD& matrix_cell() { const MATRIX_COORD& matrix_cell() {
return matrix_cell_; return matrix_cell_;
} }
inT16 xgap_before() const { int16_t xgap_before() const {
return xgap_before_; return xgap_before_;
} }
inT16 xgap_after() const { int16_t xgap_after() const {
return xgap_after_; return xgap_after_;
} }
float min_xheight() const { float min_xheight() const {
@ -157,10 +157,10 @@ class BLOB_CHOICE: public ELIST_LINK
matrix_cell_.col = col; matrix_cell_.col = col;
matrix_cell_.row = row; matrix_cell_.row = row;
} }
void set_xgap_before(inT16 gap) { void set_xgap_before(int16_t gap) {
xgap_before_ = gap; xgap_before_ = gap;
} }
void set_xgap_after(inT16 gap) { void set_xgap_after(int16_t gap) {
xgap_after_ = gap; xgap_after_ = gap;
} }
void set_classifier(BlobChoiceClassifier classifier) { void set_classifier(BlobChoiceClassifier classifier) {
@ -199,8 +199,8 @@ class BLOB_CHOICE: public ELIST_LINK
UNICHAR_ID unichar_id_; // unichar id UNICHAR_ID unichar_id_; // unichar id
// Fonts and scores. Allowed to be empty. // Fonts and scores. Allowed to be empty.
GenericVector<tesseract::ScoredFont> fonts_; GenericVector<tesseract::ScoredFont> fonts_;
inT16 fontinfo_id_; // char font information int16_t fontinfo_id_; // char font information
inT16 fontinfo_id2_; // 2nd choice font information int16_t fontinfo_id2_; // 2nd choice font information
// Rating is the classifier distance weighted by the length of the outline // Rating is the classifier distance weighted by the length of the outline
// in the blob. In terms of probability, classifier distance is -klog p such // in the blob. In terms of probability, classifier distance is -klog p such
// that the resulting distance is in the range [0, 1] and then // that the resulting distance is in the range [0, 1] and then
@ -216,8 +216,8 @@ class BLOB_CHOICE: public ELIST_LINK
// Holds the position of this choice in the ratings matrix. // Holds the position of this choice in the ratings matrix.
// Used to location position in the matrix during path backtracking. // Used to location position in the matrix during path backtracking.
MATRIX_COORD matrix_cell_; MATRIX_COORD matrix_cell_;
inT16 xgap_before_; int16_t xgap_before_;
inT16 xgap_after_; int16_t xgap_after_;
// X-height range (in image pixels) that this classification supports. // X-height range (in image pixels) that this classification supports.
float min_xheight_; float min_xheight_;
float max_xheight_; float max_xheight_;
@ -269,7 +269,7 @@ const char *ScriptPosToString(tesseract::ScriptPos script_pos);
class WERD_CHOICE : public ELIST_LINK { class WERD_CHOICE : public ELIST_LINK {
public: public:
static const float kBadRating; static const float kBadRating;
static const char *permuter_name(uinT8 permuter); static const char *permuter_name(uint8_t permuter);
WERD_CHOICE(const UNICHARSET *unicharset) WERD_CHOICE(const UNICHARSET *unicharset)
: unicharset_(unicharset) { this->init(8); } : unicharset_(unicharset) { this->init(8); }
@ -279,7 +279,7 @@ class WERD_CHOICE : public ELIST_LINK {
const char *src_lengths, const char *src_lengths,
float src_rating, float src_rating,
float src_certainty, float src_certainty,
uinT8 src_permuter, uint8_t src_permuter,
const UNICHARSET &unicharset) const UNICHARSET &unicharset)
: unicharset_(&unicharset) { : unicharset_(&unicharset) {
this->init(src_string, src_lengths, src_rating, this->init(src_string, src_lengths, src_rating,
@ -339,7 +339,7 @@ class WERD_CHOICE : public ELIST_LINK {
min_x_height_ = min_height; min_x_height_ = min_height;
max_x_height_ = max_height; max_x_height_ = max_height;
} }
inline uinT8 permuter() const { inline uint8_t permuter() const {
return permuter_; return permuter_;
} }
const char *permuter_name() const; const char *permuter_name() const;
@ -368,7 +368,7 @@ class WERD_CHOICE : public ELIST_LINK {
inline void set_certainty(float new_val) { inline void set_certainty(float new_val) {
certainty_ = new_val; certainty_ = new_val;
} }
inline void set_permuter(uinT8 perm) { inline void set_permuter(uint8_t perm) {
permuter_ = perm; permuter_ = perm;
} }
// Note: this function should only be used if all the fields // Note: this function should only be used if all the fields
@ -433,7 +433,7 @@ class WERD_CHOICE : public ELIST_LINK {
/// in src_string are assumed to all be of length 1. /// in src_string are assumed to all be of length 1.
void init(const char *src_string, const char *src_lengths, void init(const char *src_string, const char *src_lengths,
float src_rating, float src_certainty, float src_rating, float src_certainty,
uinT8 src_permuter); uint8_t src_permuter);
/// Set the fields in this choice to be default (bad) values. /// Set the fields in this choice to be default (bad) values.
inline void make_bad() { inline void make_bad() {
@ -619,7 +619,7 @@ class WERD_CHOICE : public ELIST_LINK {
// xheight computed from the result, or 0 if inconsistent. // xheight computed from the result, or 0 if inconsistent.
float min_x_height_; float min_x_height_;
float max_x_height_; float max_x_height_;
uinT8 permuter_; // permuter code uint8_t permuter_; // permuter code
// Normally, the ratings_ matrix represents the recognition results in order // Normally, the ratings_ matrix represents the recognition results in order
// from left-to-right. However, some engines (say Cube) may return // from left-to-right. However, some engines (say Cube) may return

View File

@ -62,7 +62,7 @@ TBOX::TBOX( // constructor
**********************************************************************/ **********************************************************************/
TBOX::TBOX( //constructor TBOX::TBOX( //constructor
inT16 left, inT16 bottom, inT16 right, inT16 top) int16_t left, int16_t bottom, int16_t right, int16_t top)
: bot_left(left, bottom), top_right(right, top) { : bot_left(left, bottom), top_right(right, top) {
} }
@ -86,10 +86,10 @@ void TBOX::rotate_large(const FCOORD& vec) {
TBOX TBOX::intersection( //shared area box TBOX TBOX::intersection( //shared area box
const TBOX &box) const { const TBOX &box) const {
inT16 left; int16_t left;
inT16 bottom; int16_t bottom;
inT16 right; int16_t right;
inT16 top; int16_t top;
if (overlap (box)) { if (overlap (box)) {
if (box.bot_left.x () > bot_left.x ()) if (box.bot_left.x () > bot_left.x ())
left = box.bot_left.x (); left = box.bot_left.x ();
@ -112,10 +112,10 @@ TBOX TBOX::intersection( //shared area box
top = top_right.y (); top = top_right.y ();
} }
else { else {
left = MAX_INT16; left = INT16_MAX;
bottom = MAX_INT16; bottom = INT16_MAX;
top = -MAX_INT16; top = -INT16_MAX;
right = -MAX_INT16; right = -INT16_MAX;
} }
return TBOX (left, bottom, right, top); return TBOX (left, bottom, right, top);
} }
@ -242,10 +242,10 @@ TBOX& operator&=(TBOX& op1, const TBOX& op2) {
op1.top_right.set_y (op2.top_right.y ()); op1.top_right.set_y (op2.top_right.y ());
} }
else { else {
op1.bot_left.set_x (MAX_INT16); op1.bot_left.set_x (INT16_MAX);
op1.bot_left.set_y (MAX_INT16); op1.bot_left.set_y (INT16_MAX);
op1.top_right.set_x (-MAX_INT16); op1.top_right.set_x (-INT16_MAX);
op1.top_right.set_y (-MAX_INT16); op1.top_right.set_y (-INT16_MAX);
} }
return op1; return op1;
} }

View File

@ -30,7 +30,7 @@
class DLLSYM TBOX { // bounding box class DLLSYM TBOX { // bounding box
public: public:
TBOX (): // empty constructor making a null box TBOX (): // empty constructor making a null box
bot_left (MAX_INT16, MAX_INT16), top_right (-MAX_INT16, -MAX_INT16) { bot_left (INT16_MAX, INT16_MAX), top_right (-INT16_MAX, -INT16_MAX) {
} }
TBOX( // constructor TBOX( // constructor
@ -38,7 +38,7 @@ class DLLSYM TBOX { // bounding box
const ICOORD pt2); // the other corner const ICOORD pt2); // the other corner
TBOX( // constructor TBOX( // constructor
inT16 left, inT16 bottom, inT16 right, inT16 top); int16_t left, int16_t bottom, int16_t right, int16_t top);
TBOX( // box around FCOORD TBOX( // box around FCOORD
const FCOORD pt); const FCOORD pt);
@ -51,28 +51,28 @@ class DLLSYM TBOX { // bounding box
return bot_left == other.bot_left && top_right == other.top_right; return bot_left == other.bot_left && top_right == other.top_right;
} }
inT16 top() const { // coord of top int16_t top() const { // coord of top
return top_right.y (); return top_right.y ();
} }
void set_top(int y) { void set_top(int y) {
top_right.set_y(y); top_right.set_y(y);
} }
inT16 bottom() const { // coord of bottom int16_t bottom() const { // coord of bottom
return bot_left.y (); return bot_left.y ();
} }
void set_bottom(int y) { void set_bottom(int y) {
bot_left.set_y(y); bot_left.set_y(y);
} }
inT16 left() const { // coord of left int16_t left() const { // coord of left
return bot_left.x (); return bot_left.x ();
} }
void set_left(int x) { void set_left(int x) {
bot_left.set_x(x); bot_left.set_x(x);
} }
inT16 right() const { // coord of right int16_t right() const { // coord of right
return top_right.x (); return top_right.x ();
} }
void set_right(int x) { void set_right(int x) {
@ -101,21 +101,21 @@ class DLLSYM TBOX { // bounding box
return top_right; return top_right;
} }
inT16 height() const { // how high is it? int16_t height() const { // how high is it?
if (!null_box ()) if (!null_box ())
return top_right.y () - bot_left.y (); return top_right.y () - bot_left.y ();
else else
return 0; return 0;
} }
inT16 width() const { // how high is it? int16_t width() const { // how high is it?
if (!null_box ()) if (!null_box ())
return top_right.x () - bot_left.x (); return top_right.x () - bot_left.x ();
else else
return 0; return 0;
} }
inT32 area() const { // what is the area? int32_t area() const { // what is the area?
if (!null_box ()) if (!null_box ())
return width () * height (); return width () * height ();
else else
@ -131,22 +131,22 @@ class DLLSYM TBOX { // bounding box
} }
void move_bottom_edge( // move one edge void move_bottom_edge( // move one edge
const inT16 y) { // by +/- y const int16_t y) { // by +/- y
bot_left += ICOORD (0, y); bot_left += ICOORD (0, y);
} }
void move_left_edge( // move one edge void move_left_edge( // move one edge
const inT16 x) { // by +/- x const int16_t x) { // by +/- x
bot_left += ICOORD (x, 0); bot_left += ICOORD (x, 0);
} }
void move_right_edge( // move one edge void move_right_edge( // move one edge
const inT16 x) { // by +/- x const int16_t x) { // by +/- x
top_right += ICOORD (x, 0); top_right += ICOORD (x, 0);
} }
void move_top_edge( // move one edge void move_top_edge( // move one edge
const inT16 y) { // by +/- y const int16_t y) { // by +/- y
top_right += ICOORD (0, y); top_right += ICOORD (0, y);
} }
@ -158,29 +158,29 @@ class DLLSYM TBOX { // bounding box
void move( // move box void move( // move box
const FCOORD vec) { // by float vector const FCOORD vec) { // by float vector
bot_left.set_x ((inT16) floor (bot_left.x () + vec.x ())); bot_left.set_x ((int16_t) floor (bot_left.x () + vec.x ()));
// round left // round left
bot_left.set_y ((inT16) floor (bot_left.y () + vec.y ())); bot_left.set_y ((int16_t) floor (bot_left.y () + vec.y ()));
// round down // round down
top_right.set_x ((inT16) ceil (top_right.x () + vec.x ())); top_right.set_x ((int16_t) ceil (top_right.x () + vec.x ()));
// round right // round right
top_right.set_y ((inT16) ceil (top_right.y () + vec.y ())); top_right.set_y ((int16_t) ceil (top_right.y () + vec.y ()));
// round up // round up
} }
void scale( // scale box void scale( // scale box
const float f) { // by multiplier const float f) { // by multiplier
bot_left.set_x ((inT16) floor (bot_left.x () * f)); // round left bot_left.set_x ((int16_t) floor (bot_left.x () * f)); // round left
bot_left.set_y ((inT16) floor (bot_left.y () * f)); // round down bot_left.set_y ((int16_t) floor (bot_left.y () * f)); // round down
top_right.set_x ((inT16) ceil (top_right.x () * f)); // round right top_right.set_x ((int16_t) ceil (top_right.x () * f)); // round right
top_right.set_y ((inT16) ceil (top_right.y () * f)); // round up top_right.set_y ((int16_t) ceil (top_right.y () * f)); // round up
} }
void scale( // scale box void scale( // scale box
const FCOORD vec) { // by float vector const FCOORD vec) { // by float vector
bot_left.set_x ((inT16) floor (bot_left.x () * vec.x ())); bot_left.set_x ((int16_t) floor (bot_left.x () * vec.x ()));
bot_left.set_y ((inT16) floor (bot_left.y () * vec.y ())); bot_left.set_y ((int16_t) floor (bot_left.y () * vec.y ()));
top_right.set_x ((inT16) ceil (top_right.x () * vec.x ())); top_right.set_x ((int16_t) ceil (top_right.x () * vec.x ()));
top_right.set_y ((inT16) ceil (top_right.y () * vec.y ())); top_right.set_y ((int16_t) ceil (top_right.y () * vec.y ()));
} }
// rotate doesn't enlarge the box - it just rotates the bottom-left // rotate doesn't enlarge the box - it just rotates the bottom-left
@ -310,8 +310,8 @@ class DLLSYM TBOX { // bounding box
inline TBOX::TBOX( // constructor inline TBOX::TBOX( // constructor
const FCOORD pt // floating centre const FCOORD pt // floating centre
) { ) {
bot_left = ICOORD ((inT16) floor (pt.x ()), (inT16) floor (pt.y ())); bot_left = ICOORD ((int16_t) floor (pt.x ()), (int16_t) floor (pt.y ()));
top_right = ICOORD ((inT16) ceil (pt.x ()), (inT16) ceil (pt.y ())); top_right = ICOORD ((int16_t) ceil (pt.x ()), (int16_t) ceil (pt.y ()));
} }
@ -400,7 +400,7 @@ inline bool TBOX::x_overlap(const TBOX &box) const {
**********************************************************************/ **********************************************************************/
inline bool TBOX::major_x_overlap(const TBOX &box) const { inline bool TBOX::major_x_overlap(const TBOX &box) const {
inT16 overlap = box.width(); int16_t overlap = box.width();
if (this->left() > box.left()) { if (this->left() > box.left()) {
overlap -= this->left() - box.left(); overlap -= this->left() - box.left();
} }
@ -427,7 +427,7 @@ inline bool TBOX::y_overlap(const TBOX &box) const {
**********************************************************************/ **********************************************************************/
inline bool TBOX::major_y_overlap(const TBOX &box) const { inline bool TBOX::major_y_overlap(const TBOX &box) const {
inT16 overlap = box.height(); int16_t overlap = box.height();
if (this->bottom() > box.bottom()) { if (this->bottom() > box.bottom()) {
overlap -= this->bottom() - box.bottom(); overlap -= this->bottom() - box.bottom();
} }

View File

@ -272,15 +272,15 @@ REJMAP &REJMAP::operator=(const REJMAP &source) {
return *this; return *this;
} }
void REJMAP::initialise(inT16 length) { void REJMAP::initialise(int16_t length) {
ptr.reset(new REJ[length]); ptr.reset(new REJ[length]);
len = length; len = length;
} }
inT16 REJMAP::accept_count() { //How many accepted? int16_t REJMAP::accept_count() { //How many accepted?
int i; int i;
inT16 count = 0; int16_t count = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (ptr[i].accepted ()) if (ptr[i].accepted ())
@ -313,7 +313,7 @@ BOOL8 REJMAP::quality_recoverable_rejects() { //Any potential rejs?
void REJMAP::remove_pos( //Cut out an element void REJMAP::remove_pos( //Cut out an element
inT16 pos //element to remove int16_t pos //element to remove
) { ) {
ASSERT_HOST (pos >= 0); ASSERT_HOST (pos >= 0);
ASSERT_HOST (pos < len); ASSERT_HOST (pos < len);

View File

@ -204,7 +204,7 @@ class REJ
class REJMAP class REJMAP
{ {
std::unique_ptr<REJ[]> ptr; // ptr to the chars std::unique_ptr<REJ[]> ptr; // ptr to the chars
inT16 len; // Number of chars int16_t len; //Number of chars
public: public:
REJMAP() : len(0) {} REJMAP() : len(0) {}
@ -214,27 +214,27 @@ class REJMAP
REJMAP &operator=(const REJMAP &source); REJMAP &operator=(const REJMAP &source);
// Sets up the ptr array to length, whatever it was before. // Sets up the ptr array to length, whatever it was before.
void initialise(inT16 length); void initialise(int16_t length);
REJ &operator[]( // access function REJ &operator[]( // access function
inT16 index) const // map index int16_t index) const // map index
{ {
ASSERT_HOST(index < len); ASSERT_HOST(index < len);
return ptr[index]; // no bounds checks return ptr[index]; // no bounds checks
} }
inT32 length() const { //map length int32_t length() const { //map length
return len; return len;
} }
inT16 accept_count(); //How many accepted? int16_t accept_count(); //How many accepted?
inT16 reject_count() { //How many rejects? int16_t reject_count() { //How many rejects?
return len - accept_count (); return len - accept_count ();
} }
void remove_pos( //Cut out an element void remove_pos( //Cut out an element
inT16 pos); //element to remove int16_t pos); //element to remove
void print(FILE *fp); void print(FILE *fp);

View File

@ -186,8 +186,8 @@ class SEAM {
// A range such that all splits in *this SEAM are contained within blobs in // A range such that all splits in *this SEAM are contained within blobs in
// the range [index - widthn_,index + widthp_] where index is the index of // the range [index - widthn_,index + widthp_] where index is the index of
// this SEAM in the seams vector. // this SEAM in the seams vector.
inT8 widthp_; int8_t widthp_;
inT8 widthn_; int8_t widthn_;
// Number of splits_ that are used. // Number of splits_ that are used.
uint8_t num_splits_; uint8_t num_splits_;
// Set of pairs of points that are the ends of each split in the SEAM. // Set of pairs of points that are the ends of each split in the SEAM.

View File

@ -37,14 +37,14 @@ using tesseract::KDPairInc;
* *
* Construct a new stats element by allocating and zeroing the memory. * Construct a new stats element by allocating and zeroing the memory.
**********************************************************************/ **********************************************************************/
STATS::STATS(inT32 min_bucket_value, inT32 max_bucket_value_plus_1) { STATS::STATS(int32_t min_bucket_value, int32_t max_bucket_value_plus_1) {
if (max_bucket_value_plus_1 <= min_bucket_value) { if (max_bucket_value_plus_1 <= min_bucket_value) {
min_bucket_value = 0; min_bucket_value = 0;
max_bucket_value_plus_1 = 1; max_bucket_value_plus_1 = 1;
} }
rangemin_ = min_bucket_value; // setup rangemin_ = min_bucket_value; // setup
rangemax_ = max_bucket_value_plus_1; rangemax_ = max_bucket_value_plus_1;
buckets_ = new inT32[rangemax_ - rangemin_]; buckets_ = new int32_t[rangemax_ - rangemin_];
clear(); clear();
} }
@ -59,13 +59,13 @@ STATS::STATS() {
* *
* Alter the range on an existing stats element. * Alter the range on an existing stats element.
**********************************************************************/ **********************************************************************/
bool STATS::set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1) { bool STATS::set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1) {
if (max_bucket_value_plus_1 <= min_bucket_value) { if (max_bucket_value_plus_1 <= min_bucket_value) {
return false; return false;
} }
if (rangemax_ - rangemin_ != max_bucket_value_plus_1 - min_bucket_value) { if (rangemax_ - rangemin_ != max_bucket_value_plus_1 - min_bucket_value) {
delete [] buckets_; delete [] buckets_;
buckets_ = new inT32[max_bucket_value_plus_1 - min_bucket_value]; buckets_ = new int32_t[max_bucket_value_plus_1 - min_bucket_value];
} }
rangemin_ = min_bucket_value; // setup rangemin_ = min_bucket_value; // setup
rangemax_ = max_bucket_value_plus_1; rangemax_ = max_bucket_value_plus_1;
@ -96,7 +96,7 @@ STATS::~STATS() { delete[] buckets_; }
* *
* Add a set of samples to (or delete from) a pile. * Add a set of samples to (or delete from) a pile.
**********************************************************************/ **********************************************************************/
void STATS::add(inT32 value, inT32 count) { void STATS::add(int32_t value, int32_t count) {
if (buckets_ == NULL) { if (buckets_ == NULL) {
return; return;
} }
@ -110,12 +110,12 @@ void STATS::add(inT32 value, inT32 count) {
* *
* Find the mode of a stats class. * Find the mode of a stats class.
**********************************************************************/ **********************************************************************/
inT32 STATS::mode() const { // get mode of samples int32_t STATS::mode() const { // get mode of samples
if (buckets_ == NULL) { if (buckets_ == NULL) {
return rangemin_; return rangemin_;
} }
inT32 max = buckets_[0]; // max cell count int32_t max = buckets_[0]; // max cell count
inT32 maxindex = 0; // index of max int32_t maxindex = 0; // index of max
for (int index = rangemax_ - rangemin_ - 1; index > 0; --index) { for (int index = rangemax_ - rangemin_ - 1; index > 0; --index) {
if (buckets_[index] > max) { if (buckets_[index] > max) {
max = buckets_[index]; // find biggest max = buckets_[index]; // find biggest
@ -134,9 +134,9 @@ double STATS::mean() const { //get mean of samples
if (buckets_ == NULL || total_count_ <= 0) { if (buckets_ == NULL || total_count_ <= 0) {
return static_cast<double>(rangemin_); return static_cast<double>(rangemin_);
} }
inT64 sum = 0; int64_t sum = 0;
for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) { for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) {
sum += static_cast<inT64>(index) * buckets_[index]; sum += static_cast<int64_t>(index) * buckets_[index];
} }
return static_cast<double>(sum) / total_count_ + rangemin_; return static_cast<double>(sum) / total_count_ + rangemin_;
} }
@ -150,10 +150,10 @@ double STATS::sd() const { //standard deviation
if (buckets_ == NULL || total_count_ <= 0) { if (buckets_ == NULL || total_count_ <= 0) {
return 0.0; return 0.0;
} }
inT64 sum = 0; int64_t sum = 0;
double sqsum = 0.0; double sqsum = 0.0;
for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) { for (int index = rangemax_ - rangemin_ - 1; index >= 0; --index) {
sum += static_cast<inT64>(index) * buckets_[index]; sum += static_cast<int64_t>(index) * buckets_[index];
sqsum += static_cast<double>(index) * index * buckets_[index]; sqsum += static_cast<double>(index) * index * buckets_[index];
} }
double variance = static_cast<double>(sum) / total_count_; double variance = static_cast<double>(sum) / total_count_;
@ -201,11 +201,11 @@ double STATS::ile(double frac) const {
* *
* Find REAL minimum bucket - ile(0.0) isn't necessarily correct * Find REAL minimum bucket - ile(0.0) isn't necessarily correct
**********************************************************************/ **********************************************************************/
inT32 STATS::min_bucket() const { // Find min int32_t STATS::min_bucket() const { // Find min
if (buckets_ == NULL || total_count_ == 0) { if (buckets_ == NULL || total_count_ == 0) {
return rangemin_; return rangemin_;
} }
inT32 min = 0; int32_t min = 0;
for (min = 0; (min < rangemax_ - rangemin_) && (buckets_[min] == 0); min++); for (min = 0; (min < rangemax_ - rangemin_) && (buckets_[min] == 0); min++);
return rangemin_ + min; return rangemin_ + min;
} }
@ -216,11 +216,11 @@ inT32 STATS::min_bucket() const { // Find min
* Find REAL maximum bucket - ile(1.0) isn't necessarily correct * Find REAL maximum bucket - ile(1.0) isn't necessarily correct
**********************************************************************/ **********************************************************************/
inT32 STATS::max_bucket() const { // Find max int32_t STATS::max_bucket() const { // Find max
if (buckets_ == NULL || total_count_ == 0) { if (buckets_ == NULL || total_count_ == 0) {
return rangemin_; return rangemin_;
} }
inT32 max; int32_t max;
for (max = rangemax_ - rangemin_ - 1; max > 0 && buckets_[max] == 0; max--); for (max = rangemax_ - rangemin_ - 1; max > 0 && buckets_[max] == 0; max--);
return rangemin_ + max; return rangemin_ + max;
} }
@ -241,8 +241,8 @@ double STATS::median() const { //get median
double median = ile(0.5); double median = ile(0.5);
int median_pile = static_cast<int>(floor(median)); int median_pile = static_cast<int>(floor(median));
if ((total_count_ > 1) && (pile_count(median_pile) == 0)) { if ((total_count_ > 1) && (pile_count(median_pile) == 0)) {
inT32 min_pile; int32_t min_pile;
inT32 max_pile; int32_t max_pile;
/* Find preceding non zero pile */ /* Find preceding non zero pile */
for (min_pile = median_pile; pile_count(min_pile) == 0; min_pile--); for (min_pile = median_pile; pile_count(min_pile) == 0; min_pile--);
/* Find following non zero pile */ /* Find following non zero pile */
@ -257,14 +257,14 @@ double STATS::median() const { //get median
* *
* Return TRUE if this point is a local min. * Return TRUE if this point is a local min.
**********************************************************************/ **********************************************************************/
bool STATS::local_min(inT32 x) const { bool STATS::local_min(int32_t x) const {
if (buckets_ == NULL) { if (buckets_ == NULL) {
return false; return false;
} }
x = ClipToRange(x, rangemin_, rangemax_ - 1) - rangemin_; x = ClipToRange(x, rangemin_, rangemax_ - 1) - rangemin_;
if (buckets_[x] == 0) if (buckets_[x] == 0)
return true; return true;
inT32 index; // table index int32_t index; // table index
for (index = x - 1; index >= 0 && buckets_[index] == buckets_[x]; --index); for (index = x - 1; index >= 0 && buckets_[index] == buckets_[x]; --index);
if (index >= 0 && buckets_[index] < buckets_[x]) if (index >= 0 && buckets_[index] < buckets_[x])
return false; return false;
@ -284,7 +284,7 @@ bool STATS::local_min(inT32 x) const {
* The factor gives the height of the triangle, i.e. the weight of the * The factor gives the height of the triangle, i.e. the weight of the
* centre. * centre.
**********************************************************************/ **********************************************************************/
void STATS::smooth(inT32 factor) { void STATS::smooth(int32_t factor) {
if (buckets_ == NULL || factor < 2) { if (buckets_ == NULL || factor < 2) {
return; return;
} }
@ -315,22 +315,22 @@ void STATS::smooth(inT32 factor) {
* The return value is the current number of clusters. * The return value is the current number of clusters.
**********************************************************************/ **********************************************************************/
inT32 STATS::cluster(float lower, // thresholds int32_t STATS::cluster(float lower, // thresholds
float upper, float upper,
float multiple, // distance threshold float multiple, // distance threshold
inT32 max_clusters, // max no to make int32_t max_clusters, // max no to make
STATS *clusters) { // array of clusters STATS *clusters) { // array of clusters
BOOL8 new_cluster; // added one BOOL8 new_cluster; // added one
float *centres; // cluster centres float *centres; // cluster centres
inT32 entry; // bucket index int32_t entry; // bucket index
inT32 cluster; // cluster index int32_t cluster; // cluster index
inT32 best_cluster; // one to assign to int32_t best_cluster; // one to assign to
inT32 new_centre = 0; // residual mode int32_t new_centre = 0; // residual mode
inT32 new_mode; // pile count of new_centre int32_t new_mode; // pile count of new_centre
inT32 count; // pile to place int32_t count; // pile to place
float dist; // from cluster float dist; // from cluster
float min_dist; // from best_cluster float min_dist; // from best_cluster
inT32 cluster_count; // no of clusters int32_t cluster_count; // no of clusters
if (buckets_ == NULL || max_clusters < 1) if (buckets_ == NULL || max_clusters < 1)
return 0; return 0;
@ -375,7 +375,7 @@ inT32 STATS::cluster(float lower, // thresholds
count = buckets_[entry] - clusters[0].buckets_[entry]; count = buckets_[entry] - clusters[0].buckets_[entry];
//remaining pile //remaining pile
if (count > 0) { //any to handle if (count > 0) { //any to handle
min_dist = static_cast<float>(MAX_INT32); min_dist = static_cast<float>(INT32_MAX);
best_cluster = 0; best_cluster = 0;
for (cluster = 1; cluster <= cluster_count; cluster++) { for (cluster = 1; cluster <= cluster_count; cluster++) {
dist = entry + rangemin_ - centres[cluster]; dist = entry + rangemin_ - centres[cluster];
@ -533,8 +533,8 @@ void STATS::print() const {
if (buckets_ == NULL) { if (buckets_ == NULL) {
return; return;
} }
inT32 min = min_bucket() - rangemin_; int32_t min = min_bucket() - rangemin_;
inT32 max = max_bucket() - rangemin_; int32_t max = max_bucket() - rangemin_;
int num_printed = 0; int num_printed = 0;
for (int index = min; index <= max; index++) { for (int index = min; index <= max; index++) {
@ -559,8 +559,8 @@ void STATS::print_summary() const {
if (buckets_ == NULL) { if (buckets_ == NULL) {
return; return;
} }
inT32 min = min_bucket(); int32_t min = min_bucket();
inT32 max = max_bucket(); int32_t max = max_bucket();
tprintf("Total count=%d\n", total_count_); tprintf("Total count=%d\n", total_count_);
tprintf("Min=%.2f Really=%d\n", ile(0.0), min); tprintf("Min=%.2f Really=%d\n", ile(0.0), min);
tprintf("Lower quartile=%.2f\n", ile(0.25)); tprintf("Lower quartile=%.2f\n", ile(0.25));
@ -633,11 +633,11 @@ void STATS::plotline(ScrollView* window, // to draw in
* if the members were sorted, without actually sorting. * if the members were sorted, without actually sorting.
**********************************************************************/ **********************************************************************/
inT32 choose_nth_item(inT32 index, float *array, inT32 count) { int32_t choose_nth_item(int32_t index, float *array, int32_t count) {
inT32 next_sample; // next one to do int32_t next_sample; // next one to do
inT32 next_lesser; // space for new int32_t next_lesser; // space for new
inT32 prev_greater; // last one saved int32_t prev_greater; // last one saved
inT32 equal_count; // no of equal ones int32_t equal_count; // no of equal ones
float pivot; // proposed median float pivot; // proposed median
float sample; // current sample float sample; // current sample
@ -656,7 +656,7 @@ inT32 choose_nth_item(inT32 index, float *array, inT32 count) {
index = 0; // ensure legal index = 0; // ensure legal
else if (index >= count) else if (index >= count)
index = count - 1; index = count - 1;
equal_count = (inT32) (rand() % count); equal_count = (int32_t) (rand() % count);
pivot = array[equal_count]; pivot = array[equal_count];
// fill gap // fill gap
array[equal_count] = array[0]; array[equal_count] = array[0];
@ -700,14 +700,14 @@ inT32 choose_nth_item(inT32 index, float *array, inT32 count) {
* Returns the index of what would be the nth item in the array * Returns the index of what would be the nth item in the array
* if the members were sorted, without actually sorting. * if the members were sorted, without actually sorting.
**********************************************************************/ **********************************************************************/
inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size, int32_t choose_nth_item(int32_t index, void *array, int32_t count, size_t size,
int (*compar)(const void*, const void*)) { int (*compar)(const void*, const void*)) {
int result; // of compar int result; // of compar
inT32 next_sample; // next one to do int32_t next_sample; // next one to do
inT32 next_lesser; // space for new int32_t next_lesser; // space for new
inT32 prev_greater; // last one saved int32_t prev_greater; // last one saved
inT32 equal_count; // no of equal ones int32_t equal_count; // no of equal ones
inT32 pivot; // proposed median int32_t pivot; // proposed median
if (count <= 1) if (count <= 1)
return 0; return 0;
@ -723,7 +723,7 @@ inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size,
index = 0; // ensure legal index = 0; // ensure legal
else if (index >= count) else if (index >= count)
index = count - 1; index = count - 1;
pivot = (inT32) (rand () % count); pivot = (int32_t) (rand () % count);
swap_entries (array, size, pivot, 0); swap_entries (array, size, pivot, 0);
next_lesser = 0; next_lesser = 0;
prev_greater = count; prev_greater = count;
@ -763,8 +763,8 @@ inT32 choose_nth_item(inT32 index, void *array, inT32 count, size_t size,
**********************************************************************/ **********************************************************************/
void swap_entries(void *array, // array of entries void swap_entries(void *array, // array of entries
size_t size, // size of entry size_t size, // size of entry
inT32 index1, // entries to swap int32_t index1, // entries to swap
inT32 index2) { int32_t index2) {
char tmp; char tmp;
char *ptr1; // to entries char *ptr1; // to entries
char *ptr2; char *ptr2;

View File

@ -42,21 +42,21 @@ class STATS {
// max_bucket_value_plus_1 - min_bucket_value to the array size. // max_bucket_value_plus_1 - min_bucket_value to the array size.
// TODO(rays) This is ugly. Convert the second argument to // TODO(rays) This is ugly. Convert the second argument to
// max_bucket_value and all the code that uses it. // max_bucket_value and all the code that uses it.
STATS(inT32 min_bucket_value, inT32 max_bucket_value_plus_1); STATS(int32_t min_bucket_value, int32_t max_bucket_value_plus_1);
STATS(); // empty for arrays STATS(); // empty for arrays
~STATS(); ~STATS();
// (Re)Sets the range and clears the counts. // (Re)Sets the range and clears the counts.
// See the constructor for info on max and min values. // See the constructor for info on max and min values.
bool set_range(inT32 min_bucket_value, inT32 max_bucket_value_plus_1); bool set_range(int32_t min_bucket_value, int32_t max_bucket_value_plus_1);
void clear(); // empty buckets void clear(); // empty buckets
void add(inT32 value, inT32 count); void add(int32_t value, int32_t count);
// "Accessors" return various statistics on the data. // "Accessors" return various statistics on the data.
inT32 mode() const; // get mode of samples int32_t mode() const; // get mode of samples
double mean() const; // get mean of samples double mean() const; // get mean of samples
double sd() const; // standard deviation double sd() const; // standard deviation
// Returns the fractile value such that frac fraction (in [0,1]) of samples // Returns the fractile value such that frac fraction (in [0,1]) of samples
@ -65,17 +65,17 @@ class STATS {
// Returns the minimum used entry in the histogram (ie the minimum of the // Returns the minimum used entry in the histogram (ie the minimum of the
// data, NOT the minimum of the supplied range, nor is it an index.) // data, NOT the minimum of the supplied range, nor is it an index.)
// Would normally be called min(), but that is a reserved word in VC++. // Would normally be called min(), but that is a reserved word in VC++.
inT32 min_bucket() const; // Find min int32_t min_bucket() const; // Find min
// Returns the maximum used entry in the histogram (ie the maximum of the // Returns the maximum used entry in the histogram (ie the maximum of the
// data, NOT the maximum of the supplied range, nor is it an index.) // data, NOT the maximum of the supplied range, nor is it an index.)
inT32 max_bucket() const; // Find max int32_t max_bucket() const; // Find max
// Finds a more useful estimate of median than ile(0.5). // Finds a more useful estimate of median than ile(0.5).
// Overcomes a problem with ile() - if the samples are, for example, // Overcomes a problem with ile() - if the samples are, for example,
// 6,6,13,14 ile(0.5) return 7.0 - when a more useful value would be midway // 6,6,13,14 ile(0.5) return 7.0 - when a more useful value would be midway
// between 6 and 13 = 9.5 // between 6 and 13 = 9.5
double median() const; // get median of samples double median() const; // get median of samples
// Returns the count of the given value. // Returns the count of the given value.
inT32 pile_count(inT32 value ) const { int32_t pile_count(int32_t value ) const {
if (value <= rangemin_) if (value <= rangemin_)
return buckets_[0]; return buckets_[0];
if (value >= rangemax_ - 1) if (value >= rangemax_ - 1)
@ -83,27 +83,27 @@ class STATS {
return buckets_[value - rangemin_]; return buckets_[value - rangemin_];
} }
// Returns the total count of all buckets. // Returns the total count of all buckets.
inT32 get_total() const { int32_t get_total() const {
return total_count_; // total of all piles return total_count_; // total of all piles
} }
// Returns true if x is a local min. // Returns true if x is a local min.
bool local_min(inT32 x) const; bool local_min(int32_t x) const;
// Apply a triangular smoothing filter to the stats. // Apply a triangular smoothing filter to the stats.
// This makes the modes a bit more useful. // This makes the modes a bit more useful.
// The factor gives the height of the triangle, i.e. the weight of the // The factor gives the height of the triangle, i.e. the weight of the
// centre. // centre.
void smooth(inT32 factor); void smooth(int32_t factor);
// Cluster the samples into max_cluster clusters. // Cluster the samples into max_cluster clusters.
// Each call runs one iteration. The array of clusters must be // Each call runs one iteration. The array of clusters must be
// max_clusters+1 in size as cluster 0 is used to indicate which samples // max_clusters+1 in size as cluster 0 is used to indicate which samples
// have been used. // have been used.
// The return value is the current number of clusters. // The return value is the current number of clusters.
inT32 cluster(float lower, // thresholds int32_t cluster(float lower, // thresholds
float upper, float upper,
float multiple, // distance threshold float multiple, // distance threshold
inT32 max_clusters, // max no to make int32_t max_clusters, // max no to make
STATS *clusters); // array of clusters STATS *clusters); // array of clusters
// Finds (at most) the top max_modes modes, well actually the whole peak around // Finds (at most) the top max_modes modes, well actually the whole peak around
@ -141,29 +141,29 @@ class STATS {
#endif // GRAPHICS_DISABLED #endif // GRAPHICS_DISABLED
private: private:
inT32 rangemin_; // min of range int32_t rangemin_; // min of range
// rangemax_ is not well named as it is really one past the max. // rangemax_ is not well named as it is really one past the max.
inT32 rangemax_; // max of range int32_t rangemax_; // max of range
inT32 total_count_; // no of samples int32_t total_count_; // no of samples
inT32* buckets_; // array of cells int32_t* buckets_; // array of cells
}; };
// Returns the nth ordered item from the array, as if they were // Returns the nth ordered item from the array, as if they were
// ordered, but without ordering them, in linear time. // ordered, but without ordering them, in linear time.
// The array does get shuffled! // The array does get shuffled!
inT32 choose_nth_item(inT32 index, // index to choose int32_t choose_nth_item(int32_t index, // index to choose
float *array, // array of items float *array, // array of items
inT32 count); // no of items int32_t count); // no of items
// Generic version uses a defined comparator (with qsort semantics). // Generic version uses a defined comparator (with qsort semantics).
inT32 choose_nth_item(inT32 index, // index to choose int32_t choose_nth_item(int32_t index, // index to choose
void *array, // array of items void *array, // array of items
inT32 count, // no of items int32_t count, // no of items
size_t size, // element size size_t size, // element size
int (*compar)(const void*, const void*)); // comparator int (*compar)(const void*, const void*)); // comparator
// Swaps 2 entries in an array in-place. // Swaps 2 entries in an array in-place.
void swap_entries(void *array, // array of entries void swap_entries(void *array, // array of entries
size_t size, // size of entry size_t size, // size of entry
inT32 index1, // entries to swap int32_t index1, // entries to swap
inT32 index2); int32_t index2);
#endif // TESSERACT_CCSTRUCT_STATISTC_H_ #endif // TESSERACT_CCSTRUCT_STATISTC_H_

View File

@ -267,10 +267,10 @@ TBOX C_BLOB::bounding_box() const { // bounding box
* Return the area of the blob. * Return the area of the blob.
**********************************************************************/ **********************************************************************/
inT32 C_BLOB::area() { //area int32_t C_BLOB::area() { //area
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
C_OUTLINE_IT it = &outlines; //outlines of blob C_OUTLINE_IT it = &outlines; //outlines of blob
inT32 total; //total area int32_t total; //total area
total = 0; total = 0;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
@ -286,10 +286,10 @@ inT32 C_BLOB::area() { //area
* Return the perimeter of the top and 2nd level outlines. * Return the perimeter of the top and 2nd level outlines.
**********************************************************************/ **********************************************************************/
inT32 C_BLOB::perimeter() { int32_t C_BLOB::perimeter() {
C_OUTLINE *outline; // current outline C_OUTLINE *outline; // current outline
C_OUTLINE_IT it = &outlines; // outlines of blob C_OUTLINE_IT it = &outlines; // outlines of blob
inT32 total; // total perimeter int32_t total; // total perimeter
total = 0; total = 0;
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) { for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
@ -306,10 +306,10 @@ inT32 C_BLOB::perimeter() {
* Return the area of the blob. * Return the area of the blob.
**********************************************************************/ **********************************************************************/
inT32 C_BLOB::outer_area() { //area int32_t C_BLOB::outer_area() { //area
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
C_OUTLINE_IT it = &outlines; //outlines of blob C_OUTLINE_IT it = &outlines; //outlines of blob
inT32 total; //total area int32_t total; //total area
total = 0; total = 0;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
@ -327,12 +327,12 @@ inT32 C_BLOB::outer_area() { //area
* Chlid outlines are not counted. * Chlid outlines are not counted.
**********************************************************************/ **********************************************************************/
inT32 C_BLOB::count_transitions( //area int32_t C_BLOB::count_transitions( //area
inT32 threshold //on size int32_t threshold //on size
) { ) {
C_OUTLINE *outline; //current outline C_OUTLINE *outline; //current outline
C_OUTLINE_IT it = &outlines; //outlines of blob C_OUTLINE_IT it = &outlines; //outlines of blob
inT32 total; //total area int32_t total; //total area
total = 0; total = 0;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) { for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) {
@ -424,7 +424,7 @@ void C_BLOB::ComputeEdgeOffsets(int threshold, Pix* pix) {
// |- -| // |- -|
// | -| // | -|
// |---| <= Bottom of blob // |---| <= Bottom of blob
inT16 C_BLOB::EstimateBaselinePosition() { int16_t C_BLOB::EstimateBaselinePosition() {
TBOX box = bounding_box(); TBOX box = bounding_box();
int left = box.left(); int left = box.left();
int width = box.width(); int width = box.width();

View File

@ -66,11 +66,11 @@ class C_BLOB:public ELIST_LINK
} }
TBOX bounding_box() const; // compute bounding box TBOX bounding_box() const; // compute bounding box
inT32 area(); //compute area int32_t area(); //compute area
inT32 perimeter(); // Total perimeter of outlines and 1st level children. int32_t perimeter(); // Total perimeter of outlines and 1st level children.
inT32 outer_area(); //compute area int32_t outer_area(); //compute area
inT32 count_transitions( //count maxima int32_t count_transitions( //count maxima
inT32 threshold); //size threshold int32_t threshold); //size threshold
void move(const ICOORD vec); // repostion blob by vector void move(const ICOORD vec); // repostion blob by vector
void rotate(const FCOORD& rotation); // Rotate by given vector. void rotate(const FCOORD& rotation); // Rotate by given vector.
@ -81,7 +81,7 @@ class C_BLOB:public ELIST_LINK
// Estimates and returns the baseline position based on the shape of the // Estimates and returns the baseline position based on the shape of the
// outlines. // outlines.
inT16 EstimateBaselinePosition(); int16_t EstimateBaselinePosition();
// Returns a Pix rendering of the blob. pixDestroy after use. // Returns a Pix rendering of the blob. pixDestroy after use.
Pix* render(); Pix* render();

View File

@ -45,7 +45,7 @@ ELIST2IZE(WERD)
* blank_count blanks in front of the word * blank_count blanks in front of the word
* text correct text, outlives this WERD * text correct text, outlives this WERD
*/ */
WERD::WERD(C_BLOB_LIST *blob_list, uinT8 blank_count, const char *text) WERD::WERD(C_BLOB_LIST *blob_list, uint8_t blank_count, const char *text)
: blanks(blank_count), : blanks(blank_count),
flags(0), flags(0),
script_id_(0), script_id_(0),
@ -53,8 +53,8 @@ WERD::WERD(C_BLOB_LIST *blob_list, uinT8 blank_count, const char *text)
C_BLOB_IT start_it = &cblobs; C_BLOB_IT start_it = &cblobs;
C_BLOB_IT rej_cblob_it = &rej_cblobs; C_BLOB_IT rej_cblob_it = &rej_cblobs;
C_OUTLINE_IT c_outline_it; C_OUTLINE_IT c_outline_it;
inT16 inverted_vote = 0; int16_t inverted_vote = 0;
inT16 non_inverted_vote = 0; int16_t non_inverted_vote = 0;
// Move blob_list's elements into cblobs. // Move blob_list's elements into cblobs.
start_it.add_list_after(blob_list); start_it.add_list_after(blob_list);

View File

@ -64,7 +64,7 @@ class WERD : public ELIST2_LINK {
// blob_list - blobs of the word (we take this list's contents) // blob_list - blobs of the word (we take this list's contents)
// blanks - number of blanks before the word // blanks - number of blanks before the word
// text - correct text (outlives WERD) // text - correct text (outlives WERD)
WERD(C_BLOB_LIST *blob_list, uinT8 blanks, const char *text); WERD(C_BLOB_LIST *blob_list, uint8_t blanks, const char *text);
// WERD constructed from: // WERD constructed from:
// blob_list - blobs in the word // blob_list - blobs in the word
@ -101,10 +101,10 @@ class WERD : public ELIST2_LINK {
return &cblobs; return &cblobs;
} }
uinT8 space() { // access function uint8_t space() { // access function
return blanks; return blanks;
} }
void set_blanks(uinT8 new_blanks) { void set_blanks(uint8_t new_blanks) {
blanks = new_blanks; blanks = new_blanks;
} }
int script_id() const { int script_id() const {
@ -128,8 +128,8 @@ class WERD : public ELIST2_LINK {
BOOL8 flag(WERD_FLAGS mask) const { return flags.bit(mask); } BOOL8 flag(WERD_FLAGS mask) const { return flags.bit(mask); }
void set_flag(WERD_FLAGS mask, BOOL8 value) { flags.set_bit(mask, value); } void set_flag(WERD_FLAGS mask, BOOL8 value) { flags.set_bit(mask, value); }
BOOL8 display_flag(uinT8 flag) const { return disp_flags.bit(flag); } BOOL8 display_flag(uint8_t flag) const { return disp_flags.bit(flag); }
void set_display_flag(uinT8 flag, BOOL8 value) { void set_display_flag(uint8_t flag, BOOL8 value) {
disp_flags.set_bit(flag, value); disp_flags.set_bit(flag, value);
} }
@ -182,11 +182,11 @@ class WERD : public ELIST2_LINK {
bool *make_next_word_fuzzy); bool *make_next_word_fuzzy);
private: private:
uinT8 blanks; // no of blanks uint8_t blanks; // no of blanks
uinT8 dummy; // padding uint8_t dummy; // padding
BITS16 flags; // flags about word BITS16 flags; // flags about word
BITS16 disp_flags; // display flags BITS16 disp_flags; // display flags
inT16 script_id_; // From unicharset. int16_t script_id_; // From unicharset.
STRING correct; // correct text STRING correct; // correct text
C_BLOB_LIST cblobs; // compacted blobs C_BLOB_LIST cblobs; // compacted blobs
C_BLOB_LIST rej_cblobs; // DUFF blobs C_BLOB_LIST rej_cblobs; // DUFF blobs

View File

@ -24,6 +24,6 @@
* *
**********************************************************************/ **********************************************************************/
BITS16::BITS16( // constructor BITS16::BITS16( // constructor
uinT16 init) { // initial val uint16_t init) { // initial val
val = init; val = init;
} }

View File

@ -25,27 +25,27 @@
class DLLSYM BITS16 class DLLSYM BITS16
{ {
public: public:
uinT16 val; uint16_t val;
BITS16() { BITS16() {
val = 0; val = 0;
} // constructor } // constructor
BITS16( // constructor BITS16( // constructor
uinT16 init); // initial val uint16_t init); // initial val
void turn_on_bit( // flip specified bit void turn_on_bit( // flip specified bit
uinT8 bit_num) { // bit to flip 0..7 uint8_t bit_num) { // bit to flip 0..7
val = val | 01 << bit_num; val = val | 01 << bit_num;
} }
void turn_off_bit( // flip specified bit void turn_off_bit( // flip specified bit
uinT8 bit_num) { // bit to flip 0..7 uint8_t bit_num) { // bit to flip 0..7
val = val & ~(01 << bit_num); val = val & ~(01 << bit_num);
} }
void set_bit( // flip specified bit void set_bit( // flip specified bit
uinT8 bit_num, // bit to flip 0..7 uint8_t bit_num, // bit to flip 0..7
BOOL8 value) { // value to flip to BOOL8 value) { // value to flip to
if (value) if (value)
val = val | 01 << bit_num; val = val | 01 << bit_num;
@ -54,7 +54,7 @@ class DLLSYM BITS16
} }
BOOL8 bit( // access bit BOOL8 bit( // access bit
uinT8 bit_num) const { // bit to access uint8_t bit_num) const { // bit to access
return (val >> bit_num) & 01; return (val >> bit_num) & 01;
} }
}; };

View File

@ -29,7 +29,7 @@ namespace tesseract {
// Fast lookup table to get the first least significant set bit in a byte. // Fast lookup table to get the first least significant set bit in a byte.
// For zero, the table has 255, but since it is a special case, most code // For zero, the table has 255, but since it is a special case, most code
// that uses this table will check for zero before looking up lsb_index_. // that uses this table will check for zero before looking up lsb_index_.
const uinT8 BitVector::lsb_index_[256] = { const uint8_t BitVector::lsb_index_[256] = {
255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 255, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
@ -50,7 +50,7 @@ const uinT8 BitVector::lsb_index_[256] = {
// Fast lookup table to get the residual bits after zeroing the first (lowest) // Fast lookup table to get the residual bits after zeroing the first (lowest)
// set bit in a byte. // set bit in a byte.
const uinT8 BitVector::lsb_eroded_[256] = { const uint8_t BitVector::lsb_eroded_[256] = {
0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6, 0, 0, 0, 0x2, 0, 0x4, 0x4, 0x6,
0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e, 0, 0x8, 0x8, 0x0a, 0x08, 0x0c, 0x0c, 0x0e,
0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16, 0, 0x10, 0x10, 0x12, 0x10, 0x14, 0x14, 0x16,
@ -109,12 +109,12 @@ const int BitVector::hamming_table_[256] = {
BitVector::BitVector() : bit_size_(0), array_(NULL) {} BitVector::BitVector() : bit_size_(0), array_(NULL) {}
BitVector::BitVector(int length) : bit_size_(length) { BitVector::BitVector(int length) : bit_size_(length) {
array_ = new uinT32[WordLength()]; array_ = new uint32_t[WordLength()];
SetAllFalse(); SetAllFalse();
} }
BitVector::BitVector(const BitVector& src) : bit_size_(src.bit_size_) { BitVector::BitVector(const BitVector& src) : bit_size_(src.bit_size_) {
array_ = new uinT32[WordLength()]; array_ = new uint32_t[WordLength()];
memcpy(array_, src.array_, ByteLength()); memcpy(array_, src.array_, ByteLength());
} }
@ -146,7 +146,7 @@ bool BitVector::Serialize(FILE* fp) const {
// Reads from the given file. Returns false in case of error. // Reads from the given file. Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed. // If swap is true, assumes a big/little-endian swap is needed.
bool BitVector::DeSerialize(bool swap, FILE* fp) { bool BitVector::DeSerialize(bool swap, FILE* fp) {
uinT32 new_bit_size; uint32_t new_bit_size;
if (fread(&new_bit_size, sizeof(new_bit_size), 1, fp) != 1) return false; if (fread(&new_bit_size, sizeof(new_bit_size), 1, fp) != 1) return false;
if (swap) { if (swap) {
ReverseN(&new_bit_size, sizeof(new_bit_size)); ReverseN(&new_bit_size, sizeof(new_bit_size));
@ -179,8 +179,8 @@ int BitVector::NextSetBit(int prev_bit) const {
int next_word = WordIndex(next_bit); int next_word = WordIndex(next_bit);
int bit_index = next_word * kBitFactor; int bit_index = next_word * kBitFactor;
int word_end = bit_index + kBitFactor; int word_end = bit_index + kBitFactor;
uinT32 word = array_[next_word]; uint32_t word = array_[next_word];
uinT8 byte = word & 0xff; uint8_t byte = word & 0xff;
while (bit_index < word_end) { while (bit_index < word_end) {
if (bit_index + 8 > next_bit && byte != 0) { if (bit_index + 8 > next_bit && byte != 0) {
while (bit_index + lsb_index_[byte] < next_bit && byte != 0) while (bit_index + lsb_index_[byte] < next_bit && byte != 0)
@ -213,7 +213,7 @@ int BitVector::NumSetBits() const {
int wordlen = WordLength(); int wordlen = WordLength();
int total_bits = 0; int total_bits = 0;
for (int w = 0; w < wordlen; ++w) { for (int w = 0; w < wordlen; ++w) {
uinT32 word = array_[w]; uint32_t word = array_[w];
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
total_bits += hamming_table_[word & 0xff]; total_bits += hamming_table_[word & 0xff];
word >>= 8; word >>= 8;
@ -259,7 +259,7 @@ void BitVector::Alloc(int length) {
int new_wordlength = WordLength(); int new_wordlength = WordLength();
if (new_wordlength != initial_wordlength) { if (new_wordlength != initial_wordlength) {
delete [] array_; delete [] array_;
array_ = new uinT32[new_wordlength]; array_ = new uint32_t[new_wordlength];
} }
} }

View File

@ -35,10 +35,10 @@ class BitVector {
// Fast lookup table to get the first least significant set bit in a byte. // Fast lookup table to get the first least significant set bit in a byte.
// For zero, the table has 255, but since it is a special case, most code // For zero, the table has 255, but since it is a special case, most code
// that uses this table will check for zero before looking up lsb_index_. // that uses this table will check for zero before looking up lsb_index_.
static const uinT8 lsb_index_[256]; static const uint8_t lsb_index_[256];
// Fast lookup table to get the residual bits after zeroing the least // Fast lookup table to get the residual bits after zeroing the least
// significant set bit in a byte. // significant set bit in a byte.
static const uinT8 lsb_eroded_[256]; static const uint8_t lsb_eroded_[256];
// Fast lookup table to give the number of set bits in a byte. // Fast lookup table to give the number of set bits in a byte.
static const int hamming_table_[256]; static const int hamming_table_[256];
@ -114,7 +114,7 @@ class BitVector {
return index / kBitFactor; return index / kBitFactor;
} }
// Returns a mask to select the appropriate bit for the given index. // Returns a mask to select the appropriate bit for the given index.
uinT32 BitMask(int index) const { uint32_t BitMask(int index) const {
return 1 << (index & (kBitFactor - 1)); return 1 << (index & (kBitFactor - 1));
} }
// Returns the number of array elements needed to represent the current // Returns the number of array elements needed to represent the current
@ -128,13 +128,13 @@ class BitVector {
} }
// Number of bits in this BitVector. // Number of bits in this BitVector.
inT32 bit_size_; int32_t bit_size_;
// Array of words used to pack the bits. // Array of words used to pack the bits.
// Bits are stored little-endian by uinT32 word, ie by word first and then // Bits are stored little-endian by uint32_t word, ie by word first and then
// starting with the least significant bit in each word. // starting with the least significant bit in each word.
uinT32* array_; uint32_t* array_;
// Number of bits in an array_ element. // Number of bits in an array_ element.
static const int kBitFactor = sizeof(uinT32) * 8; static const int kBitFactor = sizeof(uint32_t) * 8;
}; };
} // namespace tesseract. } // namespace tesseract.

View File

@ -112,9 +112,9 @@ void CLIST::assign_to_sublist( //to this list
* Return count of elements on list * Return count of elements on list
**********************************************************************/ **********************************************************************/
inT32 CLIST::length() const { //count elements int32_t CLIST::length() const { //count elements
CLIST_ITERATOR it(const_cast<CLIST*>(this)); CLIST_ITERATOR it(const_cast<CLIST*>(this));
inT32 count = 0; int32_t count = 0;
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) for (it.mark_cycle_pt(); !it.cycled_list(); it.forward())
count++; count++;
@ -132,10 +132,10 @@ CLIST::sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
const void *, const void *)) { const void *, const void *)) {
CLIST_ITERATOR it(this); CLIST_ITERATOR it(this);
inT32 count; int32_t count;
void **base; //ptr array to sort void **base; //ptr array to sort
void **current; void **current;
inT32 i; int32_t i;
/* Allocate an array of pointers, one per list element */ /* Allocate an array of pointers, one per list element */
count = length (); count = length ();
@ -283,7 +283,7 @@ void *CLIST_ITERATOR::forward() {
**********************************************************************/ **********************************************************************/
void *CLIST_ITERATOR::data_relative( //get data + or - ... void *CLIST_ITERATOR::data_relative( //get data + or - ...
inT8 offset) { //offset from current int8_t offset) { //offset from current
CLIST_LINK *ptr; CLIST_LINK *ptr;
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -109,7 +109,7 @@ class DLLSYM CLIST
CLIST_ITERATOR *start_it, //from list start CLIST_ITERATOR *start_it, //from list start
CLIST_ITERATOR *end_it); //from list end CLIST_ITERATOR *end_it); //from list end
inT32 length() const; //# elements in list int32_t length() const; //# elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -202,7 +202,7 @@ class DLLSYM CLIST_ITERATOR
} }
void *data_relative( //get data + or - ... void *data_relative( //get data + or - ...
inT8 offset); //offset from current int8_t offset); //offset from current
void *forward(); //move to next element void *forward(); //move to next element
@ -238,7 +238,7 @@ class DLLSYM CLIST_ITERATOR
void exchange( //positions of 2 links void exchange( //positions of 2 links
CLIST_ITERATOR *other_it); //other iterator CLIST_ITERATOR *other_it); //other iterator
inT32 length(); //# elements in list int32_t length(); //# elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -705,7 +705,7 @@ inline BOOL8 CLIST_ITERATOR::cycled_list() {
* *
**********************************************************************/ **********************************************************************/
inline inT32 CLIST_ITERATOR::length() { inline int32_t CLIST_ITERATOR::length() {
#ifndef NDEBUG #ifndef NDEBUG
if (!list) if (!list)
NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL); NO_LIST.error ("CLIST_ITERATOR::length", ABORT, NULL);
@ -881,7 +881,7 @@ CLISTIZEH_C.
\ \
CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \ CLASSNAME *data() { return (CLASSNAME *)CLIST_ITERATOR::data(); } \
\ \
CLASSNAME *data_relative(inT8 offset) { \ CLASSNAME *data_relative(int8_t offset) { \
return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \ return (CLASSNAME *)CLIST_ITERATOR::data_relative(offset); \
} \ } \
\ \

View File

@ -87,9 +87,9 @@ void ELIST::assign_to_sublist( //to this list
* Return count of elements on list * Return count of elements on list
**********************************************************************/ **********************************************************************/
inT32 ELIST::length() const { // count elements int32_t ELIST::length() const { // count elements
ELIST_ITERATOR it(const_cast<ELIST*>(this)); ELIST_ITERATOR it(const_cast<ELIST*>(this));
inT32 count = 0; int32_t count = 0;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
count++; count++;
@ -109,10 +109,10 @@ ELIST::sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
const void *, const void *)) { const void *, const void *)) {
ELIST_ITERATOR it(this); ELIST_ITERATOR it(this);
inT32 count; int32_t count;
ELIST_LINK **base; //ptr array to sort ELIST_LINK **base; //ptr array to sort
ELIST_LINK **current; ELIST_LINK **current;
inT32 i; int32_t i;
/* Allocate an array of pointers, one per list element */ /* Allocate an array of pointers, one per list element */
count = length (); count = length ();
@ -231,7 +231,7 @@ ELIST_LINK *ELIST_ITERATOR::forward() {
**********************************************************************/ **********************************************************************/
ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ... ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ...
inT8 offset) { //offset from current int8_t offset) { //offset from current
ELIST_LINK *ptr; ELIST_LINK *ptr;
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -150,7 +150,7 @@ class DLLSYM ELIST
ELIST_ITERATOR *start_it, //from list start ELIST_ITERATOR *start_it, //from list start
ELIST_ITERATOR *end_it); //from list end ELIST_ITERATOR *end_it); //from list end
inT32 length() const; // # elements in list int32_t length() const; // # elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -243,7 +243,7 @@ class DLLSYM ELIST_ITERATOR
} }
ELIST_LINK *data_relative( //get data + or - ... ELIST_LINK *data_relative( //get data + or - ...
inT8 offset); //offset from current int8_t offset); //offset from current
ELIST_LINK *forward(); //move to next element ELIST_LINK *forward(); //move to next element
@ -279,7 +279,7 @@ class DLLSYM ELIST_ITERATOR
void exchange( //positions of 2 links void exchange( //positions of 2 links
ELIST_ITERATOR *other_it); //other iterator ELIST_ITERATOR *other_it); //other iterator
inT32 length(); //# elements in list int32_t length(); //# elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -746,7 +746,7 @@ inline bool ELIST_ITERATOR::cycled_list() {
* *
**********************************************************************/ **********************************************************************/
inline inT32 ELIST_ITERATOR::length() { inline int32_t ELIST_ITERATOR::length() {
#ifndef NDEBUG #ifndef NDEBUG
if (!list) if (!list)
NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL); NO_LIST.error ("ELIST_ITERATOR::length", ABORT, NULL);
@ -924,7 +924,7 @@ class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR { \
return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \ return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data()); \
} \ } \
\ \
CLASSNAME* data_relative(inT8 offset) { \ CLASSNAME* data_relative(int8_t offset) { \
return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\ return reinterpret_cast<CLASSNAME*>(ELIST_ITERATOR::data_relative(offset));\
} \ } \
\ \

View File

@ -88,9 +88,9 @@ void ELIST2::assign_to_sublist( //to this list
* Return count of elements on list * Return count of elements on list
**********************************************************************/ **********************************************************************/
inT32 ELIST2::length() const { // count elements int32_t ELIST2::length() const { // count elements
ELIST2_ITERATOR it(const_cast<ELIST2*>(this)); ELIST2_ITERATOR it(const_cast<ELIST2*>(this));
inT32 count = 0; int32_t count = 0;
for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ()) for (it.mark_cycle_pt (); !it.cycled_list (); it.forward ())
count++; count++;
@ -110,10 +110,10 @@ ELIST2::sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
const void *, const void *)) { const void *, const void *)) {
ELIST2_ITERATOR it(this); ELIST2_ITERATOR it(this);
inT32 count; int32_t count;
ELIST2_LINK **base; //ptr array to sort ELIST2_LINK **base; //ptr array to sort
ELIST2_LINK **current; ELIST2_LINK **current;
inT32 i; int32_t i;
/* Allocate an array of pointers, one per list element */ /* Allocate an array of pointers, one per list element */
count = length (); count = length ();
@ -268,7 +268,7 @@ ELIST2_LINK *ELIST2_ITERATOR::backward() {
**********************************************************************/ **********************************************************************/
ELIST2_LINK *ELIST2_ITERATOR::data_relative( //get data + or - .. ELIST2_LINK *ELIST2_ITERATOR::data_relative( //get data + or - ..
inT8 offset) { //offset from current int8_t offset) { //offset from current
ELIST2_LINK *ptr; ELIST2_LINK *ptr;
#ifndef NDEBUG #ifndef NDEBUG

View File

@ -125,7 +125,7 @@ class DLLSYM ELIST2
ELIST2_ITERATOR *start_it, //from list start ELIST2_ITERATOR *start_it, //from list start
ELIST2_ITERATOR *end_it); //from list end ELIST2_ITERATOR *end_it); //from list end
inT32 length() const; // # elements in list int32_t length() const; // # elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -208,7 +208,7 @@ class DLLSYM ELIST2_ITERATOR
} }
ELIST2_LINK *data_relative( //get data + or - ... ELIST2_LINK *data_relative( //get data + or - ...
inT8 offset); //offset from current int8_t offset); //offset from current
ELIST2_LINK *forward(); //move to next element ELIST2_LINK *forward(); //move to next element
@ -247,7 +247,7 @@ class DLLSYM ELIST2_ITERATOR
void exchange( //positions of 2 links void exchange( //positions of 2 links
ELIST2_ITERATOR *other_it); //other iterator ELIST2_ITERATOR *other_it); //other iterator
inT32 length(); //# elements in list int32_t length(); //# elements in list
void sort ( //sort elements void sort ( //sort elements
int comparator ( //comparison routine int comparator ( //comparison routine
@ -749,7 +749,7 @@ inline BOOL8 ELIST2_ITERATOR::cycled_list() {
* *
**********************************************************************/ **********************************************************************/
inline inT32 ELIST2_ITERATOR::length() { inline int32_t ELIST2_ITERATOR::length() {
#ifndef NDEBUG #ifndef NDEBUG
if (!list) if (!list)
NO_LIST.error ("ELIST2_ITERATOR::length", ABORT, NULL); NO_LIST.error ("ELIST2_ITERATOR::length", ABORT, NULL);
@ -928,7 +928,7 @@ ELIST2IZEH_C.
\ \
CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \ CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \
\ \
CLASSNAME *data_relative(inT8 offset) { \ CLASSNAME *data_relative(int8_t offset) { \
return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \ return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \
} \ } \
\ \

View File

@ -51,18 +51,18 @@ class TRand {
set_seed(static_cast<uint64_t>(hasher(str))); set_seed(static_cast<uint64_t>(hasher(str)));
} }
// Returns an integer in the range 0 to MAX_INT32. // Returns an integer in the range 0 to INT32_MAX.
int32_t IntRand() { int32_t IntRand() {
Iterate(); Iterate();
return seed_ >> 33; return seed_ >> 33;
} }
// Returns a floating point value in the range [-range, range]. // Returns a floating point value in the range [-range, range].
double SignedRand(double range) { double SignedRand(double range) {
return range * 2.0 * IntRand() / MAX_INT32 - range; return range * 2.0 * IntRand() / INT32_MAX - range;
} }
// Returns a floating point value in the range [0, range]. // Returns a floating point value in the range [0, range].
double UnsignedRand(double range) { double UnsignedRand(double range) {
return range * IntRand() / MAX_INT32; return range * IntRand() / INT32_MAX;
} }
private: private:

View File

@ -31,14 +31,6 @@
#include <cstdint> // int32_t, ... #include <cstdint> // int32_t, ...
// definitions of portable data types (numbers and characters) // definitions of portable data types (numbers and characters)
typedef int8_t inT8;
typedef uint8_t uinT8;
typedef int16_t inT16;
typedef uint16_t uinT16;
typedef int32_t inT32;
typedef uint32_t uinT32;
typedef int64_t inT64;
typedef uint64_t uinT64;
typedef float FLOAT32; typedef float FLOAT32;
typedef double FLOAT64; typedef double FLOAT64;
typedef unsigned char BOOL8; typedef unsigned char BOOL8;
@ -57,20 +49,8 @@ typedef unsigned char BOOL8;
#endif /* _WIN32 */ #endif /* _WIN32 */
#define MAX_INT8 0x7f
#define MAX_INT16 0x7fff
#define MAX_INT32 0x7fffffff
#define MAX_UINT8 0xff
#define MAX_UINT16 0xffff
#define MAX_UINT32 0xffffffff
#define MAX_FLOAT32 std::numeric_limits<float>::max() #define MAX_FLOAT32 std::numeric_limits<float>::max()
#define MIN_INT8 static_cast<int8_t>(0x80)
#define MIN_INT16 static_cast<int16_t>(0x8000)
#define MIN_INT32 static_cast<int32_t>(0x80000000)
#define MIN_UINT8 0x00
#define MIN_UINT16 0x0000
#define MIN_UINT32 0x00000000
// Minimum positive value ie 1e-37ish. // Minimum positive value ie 1e-37ish.
#define MIN_FLOAT32 std::numeric_limits<float>::min() #define MIN_FLOAT32 std::numeric_limits<float>::min()

View File

@ -41,7 +41,7 @@ void IndexMap::CopyFrom(const IndexMapBiDi& src) {
// Writes to the given file. Returns false in case of error. // Writes to the given file. Returns false in case of error.
bool IndexMap::Serialize(FILE* fp) const { bool IndexMap::Serialize(FILE* fp) const {
inT32 sparse_size = sparse_size_; int32_t sparse_size = sparse_size_;
if (fwrite(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false; if (fwrite(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false;
if (!compact_map_.Serialize(fp)) return false; if (!compact_map_.Serialize(fp)) return false;
return true; return true;
@ -50,7 +50,7 @@ bool IndexMap::Serialize(FILE* fp) const {
// Reads from the given file. Returns false in case of error. // Reads from the given file. Returns false in case of error.
// If swap is true, assumes a big/little-endian swap is needed. // If swap is true, assumes a big/little-endian swap is needed.
bool IndexMap::DeSerialize(bool swap, FILE* fp) { bool IndexMap::DeSerialize(bool swap, FILE* fp) {
inT32 sparse_size; int32_t sparse_size;
if (fread(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false; if (fread(&sparse_size, sizeof(sparse_size), 1, fp) != 1) return false;
if (swap) if (swap)
ReverseN(&sparse_size, sizeof(sparse_size)); ReverseN(&sparse_size, sizeof(sparse_size));
@ -169,7 +169,7 @@ void IndexMapBiDi::CompleteMerges() {
} }
// Compact the compact_map, leaving tmp_compact_map saying where each // Compact the compact_map, leaving tmp_compact_map saying where each
// index went to in the compacted map. // index went to in the compacted map.
GenericVector<inT32> tmp_compact_map; GenericVector<int32_t> tmp_compact_map;
tmp_compact_map.init_to_size(compact_size, -1); tmp_compact_map.init_to_size(compact_size, -1);
compact_size = 0; compact_size = 0;
for (int i = 0; i < compact_map_.size(); ++i) { for (int i = 0; i < compact_map_.size(); ++i) {
@ -193,7 +193,7 @@ bool IndexMapBiDi::Serialize(FILE* fp) const {
// Make a vector containing the rest of the map. If the map is many-to-one // Make a vector containing the rest of the map. If the map is many-to-one
// then each additional sparse entry needs to be stored. // then each additional sparse entry needs to be stored.
// Normally we store only the compact map to save space. // Normally we store only the compact map to save space.
GenericVector<inT32> remaining_pairs; GenericVector<int32_t> remaining_pairs;
for (int i = 0; i < sparse_map_.size(); ++i) { for (int i = 0; i < sparse_map_.size(); ++i) {
if (sparse_map_[i] >= 0 && compact_map_[sparse_map_[i]] != i) { if (sparse_map_[i] >= 0 && compact_map_[sparse_map_[i]] != i) {
remaining_pairs.push_back(i); remaining_pairs.push_back(i);
@ -208,7 +208,7 @@ bool IndexMapBiDi::Serialize(FILE* fp) const {
// If swap is true, assumes a big/little-endian swap is needed. // If swap is true, assumes a big/little-endian swap is needed.
bool IndexMapBiDi::DeSerialize(bool swap, FILE* fp) { bool IndexMapBiDi::DeSerialize(bool swap, FILE* fp) {
if (!IndexMap::DeSerialize(swap, fp)) return false; if (!IndexMap::DeSerialize(swap, fp)) return false;
GenericVector<inT32> remaining_pairs; GenericVector<int32_t> remaining_pairs;
if (!remaining_pairs.DeSerialize(swap, fp)) return false; if (!remaining_pairs.DeSerialize(swap, fp)) return false;
sparse_map_.init_to_size(sparse_size_, -1); sparse_map_.init_to_size(sparse_size_, -1);
for (int i = 0; i < compact_map_.size(); ++i) { for (int i = 0; i < compact_map_.size(); ++i) {

View File

@ -77,7 +77,7 @@ class IndexMap {
int sparse_size_; int sparse_size_;
// The compact space covers integers in the range [0, compact_map_.size()-1]. // The compact space covers integers in the range [0, compact_map_.size()-1].
// Each element contains the corresponding sparse index. // Each element contains the corresponding sparse index.
GenericVector<inT32> compact_map_; GenericVector<int32_t> compact_map_;
}; };
// Bidirectional many-to-one mapping between a sparse and a compact discrete // Bidirectional many-to-one mapping between a sparse and a compact discrete
@ -172,7 +172,7 @@ class IndexMapBiDi : public IndexMap {
} }
// Direct look-up of the compact index for each element in sparse space. // Direct look-up of the compact index for each element in sparse space.
GenericVector<inT32> sparse_map_; GenericVector<int32_t> sparse_map_;
}; };
} // namespace tesseract. } // namespace tesseract.

View File

@ -42,15 +42,15 @@ REALLY_DECLARE_MAIN(ARGC,ARGV)
* whitespace spaced string being an arg.\ * whitespace spaced string being an arg.\
**********************************************************************/\ **********************************************************************/\
\ \
inT32 parse_args( /*refine arg list*/\ int32_t parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\ int32_t argc, /*no of input args*/\
char *argv[], /*input args*/\ char *argv[], /*input args*/\
char *arglist[] /*output args*/\ char *arglist[] /*output args*/\
)\ )\
{\ {\
inT32 argcount; /*converted argc*/\ int32_t argcount; /*converted argc*/\
char *testchar; /*char in option string*/\ char *testchar; /*char in option string*/\
inT32 arg; /*current argument*/\ int32_t arg; /*current argument*/\
\ \
argcount=0; /*no of options*/\ argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\ for (arg=0;arg<argc;arg++)\
@ -80,17 +80,17 @@ char *arglist[] /*output args*/\
return argcount; /*new number of args*/\ return argcount; /*new number of args*/\
}\ }\
\ \
inT32 global_exit_code;\ int32_t global_exit_code;\
inT32 real_main(inT32,const char**);\ int32_t real_main(int32_t,const char**);\
\ \
inT32 run_main( /*the main thread*/\ int32_t run_main( /*the main thread*/\
CWinApp* theapp /*arguments*/\ CWinApp* theapp /*arguments*/\
)\ )\
{\ {\
char **argv;\ char **argv;\
char *argsin[2];\ char *argsin[2];\
inT32 argc;\ int32_t argc;\
inT32 exit_code;\ int32_t exit_code;\
\ \
argsin[0]=strdup(theapp->m_pszExeName);\ argsin[0]=strdup(theapp->m_pszExeName);\
argsin[1]=strdup(theapp->m_lpCmdLine);\ argsin[1]=strdup(theapp->m_lpCmdLine);\
@ -115,7 +115,7 @@ CWinApp* theapp /*arguments*/\
return exit_code;\ return exit_code;\
}\ }\
\ \
inT32 real_main(inT32 ARGC,const char* ARGV[])\ int32_t real_main(int32_t ARGC,const char* ARGV[])\
#else #else
@ -128,15 +128,15 @@ inT32 real_main(inT32 ARGC,const char* ARGV[])\
* whitespace spaced string being an arg.\ * whitespace spaced string being an arg.\
**********************************************************************/\ **********************************************************************/\
\ \
inT32 parse_args( /*refine arg list*/\ int32_t parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\ int32_t argc, /*no of input args*/\
char *argv[], /*input args*/\ char *argv[], /*input args*/\
char *arglist[] /*output args*/\ char *arglist[] /*output args*/\
)\ )\
{\ {\
inT32 argcount; /*converted argc*/\ int32_t argcount; /*converted argc*/\
char *testchar; /*char in option string*/\ char *testchar; /*char in option string*/\
inT32 arg; /*current argument*/\ int32_t arg; /*current argument*/\
\ \
argcount=0; /*no of options*/\ argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\ for (arg=0;arg<argc;arg++)\
@ -166,7 +166,7 @@ char *arglist[] /*output args*/\
return argcount; /*new number of args*/\ return argcount; /*new number of args*/\
}\ }\
\ \
inT32 main(inT32 ARGC,const char* ARGV[])\ int32_t main(int32_t ARGC,const char* ARGV[])\
#endif #endif

View File

@ -40,7 +40,7 @@ namespace tesseract {
bool ParamUtils::ReadParamsFile(const char *file, bool ParamUtils::ReadParamsFile(const char *file,
SetParamConstraint constraint, SetParamConstraint constraint,
ParamsVectors *member_params) { ParamsVectors *member_params) {
inT16 nameoffset; // offset for real name int16_t nameoffset; // offset for real name
if (*file == PLUS) { if (*file == PLUS) {
nameoffset = 1; nameoffset = 1;

View File

@ -76,9 +76,9 @@ class SortHelper {
// Returns the frequency of the most frequent value. // Returns the frequency of the most frequent value.
// If max_value is not NULL, returns the most frequent value. // If max_value is not NULL, returns the most frequent value.
// If the array is empty, returns -MAX_INT32 and max_value is unchanged. // If the array is empty, returns -INT32_MAX and max_value is unchanged.
int MaxCount(T* max_value) const { int MaxCount(T* max_value) const {
int best_count = -MAX_INT32; int best_count = -INT32_MAX;
for (int i = 0; i < counts_.size(); ++i) { for (int i = 0; i < counts_.size(); ++i) {
if (counts_[i].count > best_count) { if (counts_[i].count > best_count) {
best_count = counts_[i].count; best_count = counts_[i].count;

View File

@ -381,7 +381,7 @@ STRING & STRING::operator+=(const STRING& str) {
void STRING::add_str_int(const char* str, int number) { void STRING::add_str_int(const char* str, int number) {
if (str != NULL) if (str != NULL)
*this += str; *this += str;
// Allow space for the maximum possible length of inT64. // Allow space for the maximum possible length of int64_t.
char num_buffer[kMaxIntSize]; char num_buffer[kMaxIntSize];
snprintf(num_buffer, kMaxIntSize - 1, "%d", number); snprintf(num_buffer, kMaxIntSize - 1, "%d", number);
num_buffer[kMaxIntSize - 1] = '\0'; num_buffer[kMaxIntSize - 1] = '\0';

View File

@ -57,20 +57,20 @@ bool TessdataManager::LoadMemBuffer(const char *name, const char *data,
data_file_name_ = name; data_file_name_ = name;
TFile fp; TFile fp;
fp.Open(data, size); fp.Open(data, size);
inT32 num_entries = TESSDATA_NUM_ENTRIES; int32_t num_entries = TESSDATA_NUM_ENTRIES;
if (fp.FRead(&num_entries, sizeof(num_entries), 1) != 1) return false; if (fp.FRead(&num_entries, sizeof(num_entries), 1) != 1) return false;
swap_ = num_entries > kMaxNumTessdataEntries || num_entries < 0; swap_ = num_entries > kMaxNumTessdataEntries || num_entries < 0;
fp.set_swap(swap_); fp.set_swap(swap_);
if (swap_) ReverseN(&num_entries, sizeof(num_entries)); if (swap_) ReverseN(&num_entries, sizeof(num_entries));
if (num_entries > kMaxNumTessdataEntries || num_entries < 0) return false; if (num_entries > kMaxNumTessdataEntries || num_entries < 0) return false;
GenericVector<inT64> offset_table; GenericVector<int64_t> offset_table;
offset_table.resize_no_init(num_entries); offset_table.resize_no_init(num_entries);
if (fp.FReadEndian(&offset_table[0], sizeof(offset_table[0]), num_entries) != if (fp.FReadEndian(&offset_table[0], sizeof(offset_table[0]), num_entries) !=
num_entries) num_entries)
return false; return false;
for (int i = 0; i < num_entries && i < TESSDATA_NUM_ENTRIES; ++i) { for (int i = 0; i < num_entries && i < TESSDATA_NUM_ENTRIES; ++i) {
if (offset_table[i] >= 0) { if (offset_table[i] >= 0) {
inT64 entry_size = size - offset_table[i]; int64_t entry_size = size - offset_table[i];
int j = i + 1; int j = i + 1;
while (j < num_entries && offset_table[j] == -1) ++j; while (j < num_entries && offset_table[j] == -1) ++j;
if (j < num_entries) entry_size = offset_table[j] - offset_table[i]; if (j < num_entries) entry_size = offset_table[j] - offset_table[i];
@ -109,8 +109,8 @@ bool TessdataManager::SaveFile(const STRING &filename,
void TessdataManager::Serialize(GenericVector<char> *data) const { void TessdataManager::Serialize(GenericVector<char> *data) const {
ASSERT_HOST(is_loaded_); ASSERT_HOST(is_loaded_);
// Compute the offset_table and total size. // Compute the offset_table and total size.
inT64 offset_table[TESSDATA_NUM_ENTRIES]; int64_t offset_table[TESSDATA_NUM_ENTRIES];
inT64 offset = sizeof(inT32) + sizeof(offset_table); int64_t offset = sizeof(int32_t) + sizeof(offset_table);
for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) { for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) {
if (entries_[i].empty()) { if (entries_[i].empty()) {
offset_table[i] = -1; offset_table[i] = -1;
@ -120,7 +120,7 @@ void TessdataManager::Serialize(GenericVector<char> *data) const {
} }
} }
data->init_to_size(offset, 0); data->init_to_size(offset, 0);
inT32 num_entries = TESSDATA_NUM_ENTRIES; int32_t num_entries = TESSDATA_NUM_ENTRIES;
TFile fp; TFile fp;
fp.OpenWrite(data); fp.OpenWrite(data);
fp.FWrite(&num_entries, sizeof(num_entries), 1); fp.FWrite(&num_entries, sizeof(num_entries), 1);
@ -143,7 +143,7 @@ void TessdataManager::Clear() {
// Prints a directory of contents. // Prints a directory of contents.
void TessdataManager::Directory() const { void TessdataManager::Directory() const {
tprintf("Version string:%s\n", VersionString().c_str()); tprintf("Version string:%s\n", VersionString().c_str());
int offset = TESSDATA_NUM_ENTRIES * sizeof(inT64); int offset = TESSDATA_NUM_ENTRIES * sizeof(int64_t);
for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) { for (int i = 0; i < TESSDATA_NUM_ENTRIES; ++i) {
if (!entries_[i].empty()) { if (!entries_[i].empty()) {
tprintf("%d:%s:size=%d, offset=%d\n", i, kTessdataFileSuffixes[i], tprintf("%d:%s:size=%d, offset=%d\n", i, kTessdataFileSuffixes[i],

View File

@ -43,7 +43,7 @@ tprintf_internal( // Trace printf
va_list args; // variable args va_list args; // variable args
static FILE *debugfp = NULL; // debug file static FILE *debugfp = NULL; // debug file
// debug window // debug window
inT32 offset = 0; // into message int32_t offset = 0; // into message
static char msg[MAX_MSG_LEN + 1]; static char msg[MAX_MSG_LEN + 1];
va_start(args, format); // variable list va_start(args, format); // variable list

View File

@ -109,9 +109,9 @@ void UNICHARSET::UNICHAR_PROPERTIES::Init() {
// no useful values available. // no useful values available.
void UNICHARSET::UNICHAR_PROPERTIES::SetRangesOpen() { void UNICHARSET::UNICHAR_PROPERTIES::SetRangesOpen() {
min_bottom = 0; min_bottom = 0;
max_bottom = MAX_UINT8; max_bottom = UINT8_MAX;
min_top = 0; min_top = 0;
max_top = MAX_UINT8; max_top = UINT8_MAX;
width = 0.0f; width = 0.0f;
width_sd = 0.0f; width_sd = 0.0f;
bearing = 0.0f; bearing = 0.0f;
@ -122,9 +122,9 @@ void UNICHARSET::UNICHAR_PROPERTIES::SetRangesOpen() {
// Sets all ranges to empty. Used before expanding with font-based data. // Sets all ranges to empty. Used before expanding with font-based data.
void UNICHARSET::UNICHAR_PROPERTIES::SetRangesEmpty() { void UNICHARSET::UNICHAR_PROPERTIES::SetRangesEmpty() {
min_bottom = MAX_UINT8; min_bottom = UINT8_MAX;
max_bottom = 0; max_bottom = 0;
min_top = MAX_UINT8; min_top = UINT8_MAX;
max_top = 0; max_top = 0;
width = 0.0f; width = 0.0f;
width_sd = 0.0f; width_sd = 0.0f;
@ -805,9 +805,9 @@ bool UNICHARSET::load_via_fgets(
strcpy(script, null_script); strcpy(script, null_script);
int min_bottom = 0; int min_bottom = 0;
int max_bottom = MAX_UINT8; int max_bottom = UINT8_MAX;
int min_top = 0; int min_top = 0;
int max_top = MAX_UINT8; int max_top = UINT8_MAX;
float width = 0.0f; float width = 0.0f;
float width_sd = 0.0f; float width_sd = 0.0f;
float bearing = 0.0f; float bearing = 0.0f;
@ -900,9 +900,9 @@ void UNICHARSET::post_load_setup() {
top_bottom_set_ = false; top_bottom_set_ = false;
for (UNICHAR_ID id = 0; id < size_used; ++id) { for (UNICHAR_ID id = 0; id < size_used; ++id) {
int min_bottom = 0; int min_bottom = 0;
int max_bottom = MAX_UINT8; int max_bottom = UINT8_MAX;
int min_top = 0; int min_top = 0;
int max_top = MAX_UINT8; int max_top = UINT8_MAX;
get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top); get_top_bottom(id, &min_bottom, &max_bottom, &min_top, &max_top);
if (min_top > 0) if (min_top > 0)
top_bottom_set_ = true; top_bottom_set_ = true;

View File

@ -582,13 +582,13 @@ class UNICHARSET {
int min_bottom, int max_bottom, int min_bottom, int max_bottom,
int min_top, int max_top) { int min_top, int max_top) {
unichars[unichar_id].properties.min_bottom = unichars[unichar_id].properties.min_bottom =
static_cast<uint8_t>(ClipToRange(min_bottom, 0, MAX_UINT8)); ClipToRange<int>(min_bottom, 0, UINT8_MAX);
unichars[unichar_id].properties.max_bottom = unichars[unichar_id].properties.max_bottom =
static_cast<uint8_t>(ClipToRange(max_bottom, 0, MAX_UINT8)); ClipToRange<int>(max_bottom, 0, UINT8_MAX);
unichars[unichar_id].properties.min_top = unichars[unichar_id].properties.min_top =
static_cast<uint8_t>(ClipToRange(min_top, 0, MAX_UINT8)); ClipToRange<int>(min_top, 0, UINT8_MAX);
unichars[unichar_id].properties.max_top = unichars[unichar_id].properties.max_top =
static_cast<uint8_t>(ClipToRange(max_top, 0, MAX_UINT8)); ClipToRange<int>(max_top, 0, UINT8_MAX);
} }
// Returns the width stats (as mean, sd) of the given unichar relative to the // Returns the width stats (as mean, sd) of the given unichar relative to the
// median advance of all characters in the character set. // median advance of all characters in the character set.

View File

@ -185,7 +185,7 @@ ADAPT_TEMPLATES Classify::NewAdaptedTemplates(bool InitFromUnicharset) {
} /* NewAdaptedTemplates */ } /* NewAdaptedTemplates */
// Returns FontinfoId of the given config of the given adapted class. // Returns FontinfoId of the given config of the given adapted class.
int Classify::GetFontinfoId(ADAPT_CLASS Class, uinT8 ConfigId) { int Classify::GetFontinfoId(ADAPT_CLASS Class, uint8_t ConfigId) {
return (ConfigIsPermanent(Class, ConfigId) ? return (ConfigIsPermanent(Class, ConfigId) ?
PermConfigFor(Class, ConfigId)->FontinfoId : PermConfigFor(Class, ConfigId)->FontinfoId :
TempConfigFor(Class, ConfigId)->FontinfoId); TempConfigFor(Class, ConfigId)->FontinfoId);
@ -316,9 +316,9 @@ ADAPT_CLASS ReadAdaptedClass(TFile *fp) {
/* then read in the definitions of the permanent protos and configs */ /* then read in the definitions of the permanent protos and configs */
Class->PermProtos = NewBitVector (MAX_NUM_PROTOS); Class->PermProtos = NewBitVector (MAX_NUM_PROTOS);
Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS); Class->PermConfigs = NewBitVector (MAX_NUM_CONFIGS);
fp->FRead(Class->PermProtos, sizeof(uinT32), fp->FRead(Class->PermProtos, sizeof(uint32_t),
WordsInVectorOfSize(MAX_NUM_PROTOS)); WordsInVectorOfSize(MAX_NUM_PROTOS));
fp->FRead(Class->PermConfigs, sizeof(uinT32), fp->FRead(Class->PermConfigs, sizeof(uint32_t),
WordsInVectorOfSize(MAX_NUM_CONFIGS)); WordsInVectorOfSize(MAX_NUM_CONFIGS));
/* then read in the list of temporary protos */ /* then read in the list of temporary protos */
@ -391,8 +391,8 @@ ADAPT_TEMPLATES Classify::ReadAdaptedTemplates(TFile *fp) {
*/ */
PERM_CONFIG ReadPermConfig(TFile *fp) { PERM_CONFIG ReadPermConfig(TFile *fp) {
PERM_CONFIG Config = (PERM_CONFIG)malloc(sizeof(PERM_CONFIG_STRUCT)); PERM_CONFIG Config = (PERM_CONFIG)malloc(sizeof(PERM_CONFIG_STRUCT));
uinT8 NumAmbigs; uint8_t NumAmbigs;
fp->FRead(&NumAmbigs, sizeof(uinT8), 1); fp->FRead(&NumAmbigs, sizeof(NumAmbigs), 1);
Config->Ambigs = new UNICHAR_ID[NumAmbigs + 1]; Config->Ambigs = new UNICHAR_ID[NumAmbigs + 1];
fp->FRead(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs); fp->FRead(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs);
Config->Ambigs[NumAmbigs] = -1; Config->Ambigs[NumAmbigs] = -1;
@ -420,7 +420,7 @@ TEMP_CONFIG ReadTempConfig(TFile *fp) {
fp->FRead(Config, sizeof(TEMP_CONFIG_STRUCT), 1); fp->FRead(Config, sizeof(TEMP_CONFIG_STRUCT), 1);
Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG); Config->Protos = NewBitVector (Config->ProtoVectorSize * BITSINLONG);
fp->FRead(Config->Protos, sizeof(uinT32), Config->ProtoVectorSize); fp->FRead(Config->Protos, sizeof(uint32_t), Config->ProtoVectorSize);
return (Config); return (Config);
@ -449,9 +449,9 @@ void WriteAdaptedClass(FILE *File, ADAPT_CLASS Class, int NumConfigs) {
fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File); fwrite ((char *) Class, sizeof (ADAPT_CLASS_STRUCT), 1, File);
/* then write out the definitions of the permanent protos and configs */ /* then write out the definitions of the permanent protos and configs */
fwrite ((char *) Class->PermProtos, sizeof (uinT32), fwrite ((char *) Class->PermProtos, sizeof (uint32_t),
WordsInVectorOfSize (MAX_NUM_PROTOS), File); WordsInVectorOfSize (MAX_NUM_PROTOS), File);
fwrite ((char *) Class->PermConfigs, sizeof (uinT32), fwrite ((char *) Class->PermConfigs, sizeof (uint32_t),
WordsInVectorOfSize (MAX_NUM_CONFIGS), File); WordsInVectorOfSize (MAX_NUM_CONFIGS), File);
/* then write out the list of temporary protos */ /* then write out the list of temporary protos */
@ -517,12 +517,12 @@ void Classify::WriteAdaptedTemplates(FILE *File, ADAPT_TEMPLATES Templates) {
* @note History: Tue Mar 19 13:55:44 1991, DSJ, Created. * @note History: Tue Mar 19 13:55:44 1991, DSJ, Created.
*/ */
void WritePermConfig(FILE *File, PERM_CONFIG Config) { void WritePermConfig(FILE *File, PERM_CONFIG Config) {
uinT8 NumAmbigs = 0; uint8_t NumAmbigs = 0;
assert (Config != NULL); assert (Config != NULL);
while (Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs; while (Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
fwrite((char *) &NumAmbigs, sizeof(uinT8), 1, File); fwrite((char *) &NumAmbigs, sizeof(uint8_t), 1, File);
fwrite(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs, File); fwrite(Config->Ambigs, sizeof(UNICHAR_ID), NumAmbigs, File);
fwrite(&(Config->FontinfoId), sizeof(int), 1, File); fwrite(&(Config->FontinfoId), sizeof(int), 1, File);
} /* WritePermConfig */ } /* WritePermConfig */
@ -544,7 +544,7 @@ void WriteTempConfig(FILE *File, TEMP_CONFIG Config) {
assert (Config != NULL); assert (Config != NULL);
fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File); fwrite ((char *) Config, sizeof (TEMP_CONFIG_STRUCT), 1, File);
fwrite ((char *) Config->Protos, sizeof (uinT32), fwrite ((char *) Config->Protos, sizeof (uint32_t),
Config->ProtoVectorSize, File); Config->ProtoVectorSize, File);
} /* WriteTempConfig */ } /* WriteTempConfig */

View File

@ -27,8 +27,8 @@
typedef struct typedef struct
{ {
uinT16 ProtoId; uint16_t ProtoId;
uinT16 dummy; uint16_t dummy;
PROTO_STRUCT Proto; PROTO_STRUCT Proto;
} }
@ -38,8 +38,8 @@ typedef TEMP_PROTO_STRUCT *TEMP_PROTO;
typedef struct typedef struct
{ {
uinT8 NumTimesSeen; uint8_t NumTimesSeen;
uinT8 ProtoVectorSize; uint8_t ProtoVectorSize;
PROTO_ID MaxProtoId; PROTO_ID MaxProtoId;
BIT_VECTOR Protos; BIT_VECTOR Protos;
int FontinfoId; // font information inferred from pre-trained templates int FontinfoId; // font information inferred from pre-trained templates
@ -61,9 +61,9 @@ typedef union
typedef struct typedef struct
{ {
uinT8 NumPermConfigs; uint8_t NumPermConfigs;
uinT8 MaxNumTimesSeen; // maximum number of times any TEMP_CONFIG was seen uint8_t MaxNumTimesSeen; // maximum number of times any TEMP_CONFIG was seen
uinT8 dummy[2]; // (cut at matcher_min_examples_for_prototyping) uint8_t dummy[2]; // (cut at matcher_min_examples_for_prototyping)
BIT_VECTOR PermProtos; BIT_VECTOR PermProtos;
BIT_VECTOR PermConfigs; BIT_VECTOR PermConfigs;
LIST TempProtos; LIST TempProtos;
@ -75,8 +75,8 @@ typedef struct
{ {
INT_TEMPLATES Templates; INT_TEMPLATES Templates;
int NumNonEmptyClasses; int NumNonEmptyClasses;
uinT8 NumPermClasses; uint8_t NumPermClasses;
uinT8 dummy[3]; uint8_t dummy[3];
ADAPT_CLASS Class[MAX_NUM_CLASSES]; ADAPT_CLASS Class[MAX_NUM_CLASSES];
} ADAPT_TEMPLATES_STRUCT; } ADAPT_TEMPLATES_STRUCT;
typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES; typedef ADAPT_TEMPLATES_STRUCT *ADAPT_TEMPLATES;

View File

@ -80,7 +80,7 @@ using tesseract::UnicharRating;
using tesseract::ScoredFont; using tesseract::ScoredFont;
struct ADAPT_RESULTS { struct ADAPT_RESULTS {
inT32 BlobLength; int32_t BlobLength;
bool HasNonfragment; bool HasNonfragment;
UNICHAR_ID best_unichar_id; UNICHAR_ID best_unichar_id;
int best_match_index; int best_match_index;
@ -91,7 +91,7 @@ struct ADAPT_RESULTS {
/// Initializes data members to the default values. Sets the initial /// Initializes data members to the default values. Sets the initial
/// rating of each class to be the worst possible rating (1.0). /// rating of each class to be the worst possible rating (1.0).
inline void Initialize() { inline void Initialize() {
BlobLength = MAX_INT32; BlobLength = INT32_MAX;
HasNonfragment = false; HasNonfragment = false;
ComputeBest(); ComputeBest();
} }
@ -979,7 +979,7 @@ void Classify::DisplayAdaptedChar(TBLOB* blob, INT_CLASS_STRUCT* int_class) {
tprintf("Best match to temp config %d = %4.1f%%.\n", tprintf("Best match to temp config %d = %4.1f%%.\n",
int_result.config, int_result.rating * 100.0); int_result.config, int_result.rating * 100.0);
if (classify_learning_debug_level >= 2) { if (classify_learning_debug_level >= 2) {
uinT32 ConfigMask; uint32_t ConfigMask;
ConfigMask = 1 << int_result.config; ConfigMask = 1 << int_result.config;
ShowMatchDisplay(); ShowMatchDisplay();
im_.Match(int_class, AllProtosOn, (BIT_VECTOR)&ConfigMask, im_.Match(int_class, AllProtosOn, (BIT_VECTOR)&ConfigMask,
@ -1076,7 +1076,7 @@ void Classify::AmbigClassifier(
UNICHAR_ID *ambiguities, UNICHAR_ID *ambiguities,
ADAPT_RESULTS *results) { ADAPT_RESULTS *results) {
if (int_features.empty()) return; if (int_features.empty()) return;
uinT8* CharNormArray = new uinT8[unicharset.size()]; uint8_t* CharNormArray = new uint8_t[unicharset.size()];
UnicharRating int_result; UnicharRating int_result;
results->BlobLength = GetCharNormFeature(fx_info, templates, NULL, results->BlobLength = GetCharNormFeature(fx_info, templates, NULL,
@ -1111,9 +1111,9 @@ void Classify::AmbigClassifier(
/// Factored-out calls to IntegerMatcher based on class pruner results. /// Factored-out calls to IntegerMatcher based on class pruner results.
/// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure. /// Returns integer matcher results inside CLASS_PRUNER_RESULTS structure.
void Classify::MasterMatcher(INT_TEMPLATES templates, void Classify::MasterMatcher(INT_TEMPLATES templates,
inT16 num_features, int16_t num_features,
const INT_FEATURE_STRUCT* features, const INT_FEATURE_STRUCT* features,
const uinT8* norm_factors, const uint8_t* norm_factors,
ADAPT_CLASS* classes, ADAPT_CLASS* classes,
int debug, int debug,
int matcher_multiplier, int matcher_multiplier,
@ -1153,7 +1153,7 @@ void Classify::MasterMatcher(INT_TEMPLATES templates,
void Classify::ExpandShapesAndApplyCorrections( void Classify::ExpandShapesAndApplyCorrections(
ADAPT_CLASS* classes, bool debug, int class_id, int bottom, int top, ADAPT_CLASS* classes, bool debug, int class_id, int bottom, int top,
float cp_rating, int blob_length, int matcher_multiplier, float cp_rating, int blob_length, int matcher_multiplier,
const uinT8* cn_factors, const uint8_t* cn_factors,
UnicharRating* int_result, ADAPT_RESULTS* final_results) { UnicharRating* int_result, ADAPT_RESULTS* final_results) {
if (classes != NULL) { if (classes != NULL) {
// Adapted result. Convert configs to fontinfo_ids. // Adapted result. Convert configs to fontinfo_ids.
@ -1229,7 +1229,7 @@ double Classify::ComputeCorrectedRating(bool debug, int unichar_id,
int feature_misses, int feature_misses,
int bottom, int top, int bottom, int top,
int blob_length, int matcher_multiplier, int blob_length, int matcher_multiplier,
const uinT8* cn_factors) { const uint8_t* cn_factors) {
// Compute class feature corrections. // Compute class feature corrections.
double cn_corrected = im_.ApplyCNCorrection(1.0 - im_rating, blob_length, double cn_corrected = im_.ApplyCNCorrection(1.0 - im_rating, blob_length,
cn_factors[unichar_id], cn_factors[unichar_id],
@ -1294,7 +1294,7 @@ UNICHAR_ID *Classify::BaselineClassifier(
const INT_FX_RESULT_STRUCT& fx_info, const INT_FX_RESULT_STRUCT& fx_info,
ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results) { ADAPT_TEMPLATES Templates, ADAPT_RESULTS *Results) {
if (int_features.empty()) return NULL; if (int_features.empty()) return NULL;
uinT8* CharNormArray = new uinT8[unicharset.size()]; uint8_t* CharNormArray = new uint8_t[unicharset.size()];
ClearCharNormArray(CharNormArray); ClearCharNormArray(CharNormArray);
Results->BlobLength = IntCastRounded(fx_info.Length / kStandardFeatureLength); Results->BlobLength = IntCastRounded(fx_info.Length / kStandardFeatureLength);
@ -1371,10 +1371,10 @@ int Classify::CharNormTrainingSample(bool pruner_only,
sample.geo_feature(GeoTop), sample.geo_feature(GeoTop)); sample.geo_feature(GeoTop), sample.geo_feature(GeoTop));
// Compute the char_norm_array from the saved cn_feature. // Compute the char_norm_array from the saved cn_feature.
FEATURE norm_feature = sample.GetCNFeature(); FEATURE norm_feature = sample.GetCNFeature();
uinT8* char_norm_array = new uinT8[unicharset.size()]; uint8_t* char_norm_array = new uint8_t[unicharset.size()];
int num_pruner_classes = MAX(unicharset.size(), int num_pruner_classes = MAX(unicharset.size(),
PreTrainedTemplates->NumClasses); PreTrainedTemplates->NumClasses);
uinT8* pruner_norm_array = new uinT8[num_pruner_classes]; uint8_t* pruner_norm_array = new uint8_t[num_pruner_classes];
adapt_results->BlobLength = adapt_results->BlobLength =
static_cast<int>(ActualOutlineLength(norm_feature) * 20 + 0.5); static_cast<int>(ActualOutlineLength(norm_feature) * 20 + 0.5);
ComputeCharNormArrays(norm_feature, PreTrainedTemplates, char_norm_array, ComputeCharNormArrays(norm_feature, PreTrainedTemplates, char_norm_array,
@ -1713,8 +1713,8 @@ bool Classify::LooksLikeGarbage(TBLOB *blob) {
*/ */
int Classify::GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info, int Classify::GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info,
INT_TEMPLATES templates, INT_TEMPLATES templates,
uinT8* pruner_norm_array, uint8_t* pruner_norm_array,
uinT8* char_norm_array) { uint8_t* char_norm_array) {
FEATURE norm_feature = NewFeature(&CharNormDesc); FEATURE norm_feature = NewFeature(&CharNormDesc);
float baseline = kBlnBaselineOffset; float baseline = kBlnBaselineOffset;
float scale = MF_SCALE_FACTOR; float scale = MF_SCALE_FACTOR;
@ -1733,14 +1733,14 @@ int Classify::GetCharNormFeature(const INT_FX_RESULT_STRUCT& fx_info,
// pruner_array as appropriate according to the existence of the shape_table. // pruner_array as appropriate according to the existence of the shape_table.
void Classify::ComputeCharNormArrays(FEATURE_STRUCT* norm_feature, void Classify::ComputeCharNormArrays(FEATURE_STRUCT* norm_feature,
INT_TEMPLATES_STRUCT* templates, INT_TEMPLATES_STRUCT* templates,
uinT8* char_norm_array, uint8_t* char_norm_array,
uinT8* pruner_array) { uint8_t* pruner_array) {
ComputeIntCharNormArray(*norm_feature, char_norm_array); ComputeIntCharNormArray(*norm_feature, char_norm_array);
if (pruner_array != NULL) { if (pruner_array != NULL) {
if (shape_table_ == NULL) { if (shape_table_ == NULL) {
ComputeIntCharNormArray(*norm_feature, pruner_array); ComputeIntCharNormArray(*norm_feature, pruner_array);
} else { } else {
memset(pruner_array, MAX_UINT8, memset(pruner_array, UINT8_MAX,
templates->NumClasses * sizeof(pruner_array[0])); templates->NumClasses * sizeof(pruner_array[0]));
// Each entry in the pruner norm array is the MIN of all the entries of // Each entry in the pruner norm array is the MIN of all the entries of
// the corresponding unichars in the CharNormArray. // the corresponding unichars in the CharNormArray.
@ -2220,7 +2220,7 @@ void Classify::ShowBestMatchFor(int shape_id,
const INT_FEATURE_STRUCT* features, const INT_FEATURE_STRUCT* features,
int num_features) { int num_features) {
#ifndef GRAPHICS_DISABLED #ifndef GRAPHICS_DISABLED
uinT32 config_mask; uint32_t config_mask;
if (UnusedClassIdIn(PreTrainedTemplates, shape_id)) { if (UnusedClassIdIn(PreTrainedTemplates, shape_id)) {
tprintf("No built-in templates for class/shape %d\n", shape_id); tprintf("No built-in templates for class/shape %d\n", shape_id);
return; return;

Some files were not shown because too many files have changed in this diff Show More