mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-22 01:30:49 +08:00
Allow inlining of function TruncateParam
It is only used locally in intproto.cpp, so defining it before the first use and adding the static attribute allows the compiler to inline it. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
93cfffeb87
commit
380466e0d3
@ -165,8 +165,6 @@ void RenderIntProto(ScrollView *window,
|
||||
ScrollView::Color color);
|
||||
#endif // GRAPHICS_DISABLED
|
||||
|
||||
int TruncateParam(float Param, int Min, int Max);
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Global Data Definitions and Declarations
|
||||
-----------------------------------------------------------------------------*/
|
||||
@ -198,6 +196,27 @@ static double_VAR(classify_pp_angle_pad, 45.0, "Proto Pruner Angle Pad");
|
||||
static double_VAR(classify_pp_end_pad, 0.5, "Proto Prune End Pad");
|
||||
static double_VAR(classify_pp_side_pad, 2.5, "Proto Pruner Side Pad");
|
||||
|
||||
/**
|
||||
* This routine truncates Param to lie within the range
|
||||
* of Min-Max inclusive.
|
||||
*
|
||||
* @param Param parameter value to be truncated
|
||||
* @param Min, Max parameter limits (inclusive)
|
||||
*
|
||||
* @return Truncated parameter.
|
||||
*/
|
||||
static int TruncateParam(float Param, int Min, int Max) {
|
||||
int result;
|
||||
if (Param < Min) {
|
||||
result = Min;
|
||||
} else if (Param > Max) {
|
||||
result = Max;
|
||||
} else {
|
||||
result = static_cast<int>(std::floor(Param));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Public Code
|
||||
-----------------------------------------------------------------------------*/
|
||||
@ -486,14 +505,11 @@ namespace tesseract {
|
||||
* @param Class integer class to add converted proto to
|
||||
*/
|
||||
void Classify::ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class) {
|
||||
INT_PROTO P;
|
||||
float Param;
|
||||
|
||||
assert(ProtoId < Class->NumProtos);
|
||||
|
||||
P = ProtoForProtoId(Class, ProtoId);
|
||||
INT_PROTO P = ProtoForProtoId(Class, ProtoId);
|
||||
|
||||
Param = Proto->A * 128;
|
||||
float Param = Proto->A * 128;
|
||||
P->A = TruncateParam(Param, -128, 127);
|
||||
|
||||
Param = -Proto->B * 256;
|
||||
@ -1687,25 +1703,6 @@ void RenderIntProto(ScrollView *window,
|
||||
} /* RenderIntProto */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This routine truncates Param to lie within the range
|
||||
* of Min-Max inclusive.
|
||||
*
|
||||
* @param Param parameter value to be truncated
|
||||
* @param Min, Max parameter limits (inclusive)
|
||||
*
|
||||
* @return Truncated parameter.
|
||||
*/
|
||||
int TruncateParam(float Param, int Min, int Max) {
|
||||
if (Param < Min) {
|
||||
Param = Min;
|
||||
} else if (Param > Max) {
|
||||
Param = Max;
|
||||
}
|
||||
return static_cast<int>(std::floor(Param));
|
||||
} /* TruncateParam */
|
||||
|
||||
|
||||
#ifndef GRAPHICS_DISABLED
|
||||
/**
|
||||
* Initializes the int matcher window if it is not already
|
||||
|
Loading…
Reference in New Issue
Block a user