mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 14:41:36 +08:00
Clean use of qsort function sort_floats
It is only used in textord/topitch.cpp, so move it into that file. Remove also the inline attribute as it has not effect here and update the type casts to fix some compiler warnings from clang. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
e4b9cfffcb
commit
69a111a739
@ -101,18 +101,6 @@ template<typename T> inline void Swap(T* p1, T* p2) {
|
||||
*p1 = tmp;
|
||||
}
|
||||
|
||||
// qsort function to sort 2 floats.
|
||||
inline int sort_floats(const void *arg1, const void *arg2) {
|
||||
float diff = *((float *) arg1) - *((float *) arg2);
|
||||
if (diff > 0) {
|
||||
return 1;
|
||||
} else if (diff < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// return the smallest multiple of block_size greater than or equal to n.
|
||||
inline int RoundUp(int n, int block_size) {
|
||||
return block_size * ((n + block_size - 1) / block_size);
|
||||
|
@ -60,6 +60,19 @@ EXTERN double_VAR (textord_balance_factor, 1.0,
|
||||
#define BLOCK_STATS_CLUSTERS 10
|
||||
#define MAX_ALLOWED_PITCH 100 //max pixel pitch.
|
||||
|
||||
// qsort function to sort 2 floats.
|
||||
static int sort_floats(const void *arg1, const void *arg2) {
|
||||
float diff = *reinterpret_cast<const float*>(arg1) -
|
||||
*reinterpret_cast<const float*>(arg2);
|
||||
if (diff > 0) {
|
||||
return 1;
|
||||
} else if (diff < 0) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* compute_fixed_pitch
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user