More clang-tidy from previous commits

This commit is contained in:
Ray Smith 2016-12-06 13:45:49 -08:00
parent 025689fad6
commit d55f462c9c
9 changed files with 407 additions and 526 deletions

View File

@ -847,9 +847,7 @@ class TESS_API TessBaseAPI {
int** y1,
PAGE_RES* page_res);
TESS_LOCAL const PAGE_RES* GetPageRes() const {
return page_res_;
}
TESS_LOCAL const PAGE_RES* GetPageRes() const { return page_res_; }
/* @} */

View File

@ -268,10 +268,10 @@ void ImageThresholder::OtsuThresholdRectToPix(Pix* src_pix,
OpenclDevice od;
if ((num_channels == 4 || num_channels == 1) &&
od.selectedDeviceIsOpenCL() && rect_top_ == 0 && rect_left_ == 0 ) {
od.ThresholdRectToPixOCL((unsigned char*)pixGetData(src_pix),
num_channels, pixGetWpl(src_pix) * 4,
thresholds, hi_values, out_pix /*pix_OCL*/,
rect_height_, rect_width_, rect_top_, rect_left_);
od.ThresholdRectToPixOCL((unsigned char*)pixGetData(src_pix), num_channels,
pixGetWpl(src_pix) * 4, thresholds, hi_values,
out_pix /*pix_OCL*/, rect_height_, rect_width_,
rect_top_, rect_left_);
} else {
#endif
ThresholdRectToPix(src_pix, num_channels, thresholds, hi_values, out_pix);

View File

@ -147,9 +147,7 @@ class TESS_API STRING
}
// returns the string data part of storage
inline char* GetCStr() {
return ((char *)data_) + sizeof(STRING_HEADER);
}
inline char* GetCStr() { return ((char*)data_) + sizeof(STRING_HEADER); }
inline const char* GetCStr() const {
return ((const char *)data_) + sizeof(STRING_HEADER);

View File

@ -555,7 +555,8 @@ void LSTMTrainer::StartSubtrainer(STRING* log_msg) {
// Reduce learning rate so it doesn't diverge this time.
sub_trainer_->ReduceLearningRates(this, log_msg);
// If it fails again, we will wait twice as long before reverting again.
int stall_offset = learning_iteration() - sub_trainer_->learning_iteration();
int stall_offset =
learning_iteration() - sub_trainer_->learning_iteration();
stall_iteration_ = learning_iteration() + 2 * stall_offset;
sub_trainer_->stall_iteration_ = stall_iteration_;
// Re-save the best trainer with the new learning rates and stall iteration.

View File

@ -113,7 +113,8 @@ class LSTMTrainer : public LSTMRecognizer {
// previously setup UNICHARSET and UnicharCompress.
// ctc_mode controls how the truth text is mapped to the network targets.
// Note: Call before InitNetwork!
void InitCharSet(const UNICHARSET& unicharset, const UnicharCompress& recoder);
void InitCharSet(const UNICHARSET& unicharset,
const UnicharCompress& recoder);
// Initializes the trainer with a network_spec in the network description
// net_flags control network behavior according to the NetworkFlags enum.

View File

@ -68,8 +68,8 @@ typedef struct {
typedef ds_status (*ds_score_release)(void* score);
static ds_status releaseDSProfile(ds_profile* profile, ds_score_release sr) {
ds_status status = DS_SUCCESS;
if (profile!=nullptr) {
if (profile->devices!=nullptr && sr!=nullptr) {
if (profile != nullptr) {
if (profile->devices != nullptr && sr != nullptr) {
unsigned int i;
for (i = 0; i < profile->numDevices; i++) {
free(profile->devices[i].oclDeviceName);
@ -90,18 +90,16 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
int numDevices;
cl_uint numPlatforms;
cl_platform_id* platforms = nullptr;
cl_device_id* devices = nullptr;
cl_device_id* devices = nullptr;
ds_status status = DS_SUCCESS;
unsigned int next;
unsigned int i;
if (p == nullptr)
return DS_INVALID_PROFILE;
if (p == nullptr) return DS_INVALID_PROFILE;
ds_profile* profile = (ds_profile*)malloc(sizeof(ds_profile));
if (profile == nullptr)
return DS_MEMORY_ERROR;
if (profile == nullptr) return DS_MEMORY_ERROR;
memset(profile, 0, sizeof(ds_profile));
clGetPlatformIDs(0, nullptr, &numPlatforms);
@ -131,7 +129,8 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
}
profile->numDevices = numDevices+1; // +1 to numDevices to include the native CPU
profile->devices = (ds_device*)malloc(profile->numDevices*sizeof(ds_device));
profile->devices =
(ds_device*)malloc(profile->numDevices * sizeof(ds_device));
if (profile->devices == nullptr) {
profile->numDevices = 0;
status = DS_MEMORY_ERROR;
@ -151,14 +150,14 @@ static ds_status initDSProfile(ds_profile** p, const char* version) {
profile->devices[next].type = DS_DEVICE_OPENCL_DEVICE;
profile->devices[next].oclDeviceID = devices[j];
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DEVICE_NAME
, DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DEVICE_NAME,
DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
length = strlen(buffer);
profile->devices[next].oclDeviceName = (char*)malloc(length+1);
memcpy(profile->devices[next].oclDeviceName, buffer, length+1);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DRIVER_VERSION
, DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
clGetDeviceInfo(profile->devices[next].oclDeviceID, CL_DRIVER_VERSION,
DS_DEVICE_NAME_LENGTH, &buffer, nullptr);
length = strlen(buffer);
profile->devices[next].oclDriverVersion = (char*)malloc(length+1);
memcpy(profile->devices[next].oclDriverVersion, buffer, length+1);
@ -213,8 +212,7 @@ static ds_status profileDevices(ds_profile* profile,
switch (type) {
case DS_EVALUATE_NEW_ONLY:
if (profile->devices[i].score != nullptr)
break;
if (profile->devices[i].score != nullptr) break;
// else fall through
case DS_EVALUATE_ALL:
evaluatorStatus = evaluator(profile->devices+i, evaluatorData);
@ -260,11 +258,10 @@ static ds_status writeProfileToFile(ds_profile* profile,
const char* file) {
ds_status status = DS_SUCCESS;
if (profile == nullptr)
return DS_INVALID_PROFILE;
if (profile == nullptr) return DS_INVALID_PROFILE;
FILE* profileFile = fopen(file, "wb");
if (profileFile==nullptr) {
if (profileFile == nullptr) {
status = DS_FILE_ERROR;
}
else {
@ -327,7 +324,8 @@ static ds_status writeProfileToFile(ds_profile* profile,
fwrite(DS_TAG_SCORE, sizeof(char), strlen(DS_TAG_SCORE), profileFile);
status = serializer(profile->devices+i, &serializedScore,
&serializedScoreSize);
if (status == DS_SUCCESS && serializedScore!=nullptr && serializedScoreSize > 0) {
if (status == DS_SUCCESS && serializedScore != nullptr &&
serializedScoreSize > 0) {
fwrite(serializedScore, sizeof(char), serializedScoreSize, profileFile);
free(serializedScore);
}
@ -349,7 +347,7 @@ static ds_status readProFile(const char* fileName, char** content,
*content = nullptr;
FILE* input = fopen(fileName, "rb");
if(input == nullptr) {
if (input == nullptr) {
return DS_FILE_ERROR;
}
@ -357,7 +355,7 @@ static ds_status readProFile(const char* fileName, char** content,
size = ftell(input);
rewind(input);
char* binary = (char*)malloc(size);
if(binary == nullptr) {
if (binary == nullptr) {
fclose(input);
return DS_FILE_ERROR;
}
@ -403,8 +401,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
const char* contentEnd = nullptr;
size_t contentSize;
if (profile==nullptr)
return DS_INVALID_PROFILE;
if (profile == nullptr) return DS_INVALID_PROFILE;
status = readProFile(file, &contentStart, &contentSize);
if (status == DS_SUCCESS) {
@ -426,7 +423,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
dataStart += strlen(DS_TAG_VERSION);
dataEnd = findString(dataStart, contentEnd, DS_TAG_VERSION_END);
if (dataEnd==nullptr) {
if (dataEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
@ -458,27 +455,27 @@ static ds_status readProfileFromFile(ds_profile* profile,
const char* deviceDriverEnd;
dataStart = findString(currentPosition, contentEnd, DS_TAG_DEVICE);
if (dataStart==nullptr) {
if (dataStart == nullptr) {
// nothing useful remain, quit...
break;
}
dataStart+=strlen(DS_TAG_DEVICE);
dataEnd = findString(dataStart, contentEnd, DS_TAG_DEVICE_END);
if (dataEnd==nullptr) {
if (dataEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
// parse the device type
deviceTypeStart = findString(dataStart, contentEnd, DS_TAG_DEVICE_TYPE);
if (deviceTypeStart==nullptr) {
if (deviceTypeStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceTypeStart+=strlen(DS_TAG_DEVICE_TYPE);
deviceTypeEnd = findString(deviceTypeStart, contentEnd,
DS_TAG_DEVICE_TYPE_END);
if (deviceTypeEnd==nullptr) {
if (deviceTypeEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
@ -489,14 +486,14 @@ static ds_status readProfileFromFile(ds_profile* profile,
if (deviceType == DS_DEVICE_OPENCL_DEVICE) {
deviceNameStart = findString(dataStart, contentEnd, DS_TAG_DEVICE_NAME);
if (deviceNameStart==nullptr) {
if (deviceNameStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceNameStart+=strlen(DS_TAG_DEVICE_NAME);
deviceNameEnd = findString(deviceNameStart, contentEnd,
DS_TAG_DEVICE_NAME_END);
if (deviceNameEnd==nullptr) {
if (deviceNameEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
@ -504,14 +501,14 @@ static ds_status readProfileFromFile(ds_profile* profile,
deviceDriverStart = findString(dataStart, contentEnd,
DS_TAG_DEVICE_DRIVER_VERSION);
if (deviceDriverStart==nullptr) {
if (deviceDriverStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
deviceDriverStart+=strlen(DS_TAG_DEVICE_DRIVER_VERSION);
deviceDriverEnd = findString(deviceDriverStart, contentEnd,
DS_TAG_DEVICE_DRIVER_VERSION_END);
if (deviceDriverEnd ==nullptr) {
if (deviceDriverEnd == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
@ -532,7 +529,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
&& strncmp(profile->devices[i].oclDriverVersion, deviceDriverStart,
driverVersionLength)==0) {
deviceScoreStart = findString(dataStart, contentEnd, DS_TAG_SCORE);
if (deviceNameStart==nullptr) {
if (deviceNameStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}
@ -554,7 +551,7 @@ static ds_status readProfileFromFile(ds_profile* profile,
for (i = 0; i < profile->numDevices; i++) {
if (profile->devices[i].type == DS_DEVICE_NATIVE_CPU) {
deviceScoreStart = findString(dataStart, contentEnd, DS_TAG_SCORE);
if (deviceScoreStart==nullptr) {
if (deviceScoreStart == nullptr) {
status = DS_PROFILE_FILE_ERROR;
goto cleanup;
}

File diff suppressed because it is too large Load Diff

View File

@ -298,15 +298,14 @@ public:
inline static int AddKernelConfig( int kCount, const char *kName );
/* for binarization */
static int HistogramRectOCL(unsigned char *imagedata,
int bytes_per_pixel, int bytes_per_line,
int left, int top, int width, int height,
int kHistogramSize, int *histogramAllChannels);
static int HistogramRectOCL(unsigned char *imagedata, int bytes_per_pixel,
int bytes_per_line, int left, int top,
int width, int height, int kHistogramSize,
int *histogramAllChannels);
static int ThresholdRectToPixOCL(unsigned char *imagedata,
int bytes_per_pixel, int bytes_per_line,
int *thresholds,
int *hi_values, Pix **pix,
int *thresholds, int *hi_values, Pix **pix,
int rect_height, int rect_width,
int rect_top, int rect_left);

View File

@ -52,9 +52,8 @@ class REGION_OCC:public ELIST_LINK
float max_x; //Highest x in region
inT16 region_type; //Type of crossing
REGION_OCC() {
} //constructor used
//only in COPIER etc
REGION_OCC() {} // constructor used
// only in COPIER etc
REGION_OCC( //constructor
float min,
float max,