@@ -330,7 +330,6 @@ static ds_status readProfileFromFile(ds_profile *profile,
330
330
const char *currentPosition;
331
331
const char *dataStart;
332
332
const char *dataEnd;
333
- size_t versionStringLength;
334
333
335
334
contentEnd = contentStart + contentSize;
336
335
currentPosition = contentStart;
@@ -349,8 +348,8 @@ static ds_status readProfileFromFile(ds_profile *profile,
349
348
goto cleanup;
350
349
}
351
350
352
- versionStringLength = strlen (profile->version );
353
- if (versionStringLength != ( dataEnd - dataStart) ||
351
+ size_t versionStringLength = strlen (profile->version );
352
+ if (versionStringLength + dataStart != dataEnd ||
354
353
strncmp (profile->version , dataStart, versionStringLength) != 0 ) {
355
354
// version mismatch
356
355
status = DS_PROFILE_FILE_ERROR;
@@ -439,8 +438,8 @@ static ds_status readProfileFromFile(ds_profile *profile,
439
438
440
439
actualDeviceNameLength = strlen (profile->devices [i].oclDeviceName );
441
440
driverVersionLength = strlen (profile->devices [i].oclDriverVersion );
442
- if (actualDeviceNameLength == ( deviceNameEnd - deviceNameStart) &&
443
- driverVersionLength == ( deviceDriverEnd - deviceDriverStart) &&
441
+ if (deviceNameStart + actualDeviceNameLength == deviceNameEnd &&
442
+ deviceDriverStart + driverVersionLength == deviceDriverEnd &&
444
443
strncmp (profile->devices [i].oclDeviceName , deviceNameStart,
445
444
actualDeviceNameLength) == 0 &&
446
445
strncmp (profile->devices [i].oclDriverVersion , deviceDriverStart,
@@ -586,7 +585,7 @@ static void legalizeFileName( char *fileName) {
586
585
const char *invalidChars =
587
586
" /\? :*\" ><| " ; // space is valid but can cause headaches
588
587
// for each invalid char
589
- for (int i = 0 ; i < strlen (invalidChars); i++) {
588
+ for (unsigned i = 0 ; i < strlen (invalidChars); i++) {
590
589
char invalidStr[4 ];
591
590
invalidStr[0 ] = invalidChars[i];
592
591
invalidStr[1 ] = ' \0 ' ;
@@ -1805,7 +1804,6 @@ int OpenclDevice::HistogramRectOCL(unsigned char *imageData,
1805
1804
static_cast <size_t >(block_size * kHistogramSize * bytes_per_pixel)};
1806
1805
1807
1806
/* map histogramAllChannels as write only */
1808
- int numBins = kHistogramSize * bytes_per_pixel * numWorkGroups;
1809
1807
1810
1808
cl_mem histogramBuffer = clCreateBuffer (
1811
1809
histKern.mpkContext , CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
@@ -2000,7 +1998,6 @@ int OpenclDevice::ThresholdRectToPixOCL(unsigned char *imageData,
2000
1998
/* set kernel arguments */
2001
1999
clStatus = clSetKernelArg (rEnv.mpkKernel , 0 , sizeof (cl_mem), &imageBuffer);
2002
2000
CHECK_OPENCL (clStatus, " clSetKernelArg imageBuffer" );
2003
- cl_uint numPixels = width * height;
2004
2001
clStatus = clSetKernelArg (rEnv.mpkKernel , 1 , sizeof (int ), &height);
2005
2002
CHECK_OPENCL (clStatus, " clSetKernelArg height" );
2006
2003
clStatus = clSetKernelArg (rEnv.mpkKernel , 2 , sizeof (int ), &width);
@@ -2197,9 +2194,6 @@ static double composeRGBPixelMicroBench(GPUEnv *env, TessScoreEvaluationInputDat
2197
2194
#endif
2198
2195
Pix *pix = pixCreate (input.width , input.height , 32 );
2199
2196
l_uint32 *pixData = pixGetData (pix);
2200
- int wpl = pixGetWpl (pix);
2201
- // l_uint32* output_gpu=pixReadFromTiffKernel(tiffdata,w,h,wpl,line);
2202
- // pixSetData(pix, output_gpu);
2203
2197
int i, j;
2204
2198
int idx = 0 ;
2205
2199
for (i = 0 ; i < input.height ; i++) {
@@ -2245,14 +2239,11 @@ static double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData
2245
2239
timespec time_funct_start, time_funct_end;
2246
2240
#endif
2247
2241
2248
- unsigned char pixelHi = (unsigned char )255 ;
2249
-
2250
2242
int left = 0 ;
2251
2243
int top = 0 ;
2252
2244
int kHistogramSize = 256 ;
2253
2245
int bytes_per_line = input.width *input.numChannels ;
2254
2246
int *histogramAllChannels = new int [kHistogramSize *input.numChannels ];
2255
- int retVal = 0 ;
2256
2247
// function call
2257
2248
if (type == DS_DEVICE_OPENCL_DEVICE) {
2258
2249
#if ON_WINDOWS
@@ -2264,8 +2255,7 @@ static double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData
2264
2255
#endif
2265
2256
2266
2257
OpenclDevice::gpuEnv = *env;
2267
- int wpl = pixGetWpl (input.pix );
2268
- retVal = OpenclDevice::HistogramRectOCL (
2258
+ int retVal = OpenclDevice::HistogramRectOCL (
2269
2259
input.imageData , input.numChannels , bytes_per_line, top, left,
2270
2260
input.width , input.height , kHistogramSize , histogramAllChannels);
2271
2261
@@ -2354,7 +2344,6 @@ static void ThresholdRectToPix_Native(const unsigned char* imagedata,
2354
2344
2355
2345
static double thresholdRectToPixMicroBench (GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2356
2346
double time ;
2357
- int retVal = 0 ;
2358
2347
#if ON_WINDOWS
2359
2348
LARGE_INTEGER freq, time_funct_start, time_funct_end;
2360
2349
QueryPerformanceFrequency (&freq);
@@ -2394,8 +2383,7 @@ static double thresholdRectToPixMicroBench(GPUEnv *env, TessScoreEvaluationInput
2394
2383
#endif
2395
2384
2396
2385
OpenclDevice::gpuEnv = *env;
2397
- int wpl = pixGetWpl (input.pix );
2398
- retVal = OpenclDevice::ThresholdRectToPixOCL (
2386
+ int retVal = OpenclDevice::ThresholdRectToPixOCL (
2399
2387
input.imageData , input.numChannels , bytes_per_line, thresholds,
2400
2388
hi_values, &input.pix , input.height , input.width , top, left);
2401
2389
@@ -2480,7 +2468,6 @@ static double getLineMasksMorphMicroBench(GPUEnv *env, TessScoreEvaluationInputD
2480
2468
#else
2481
2469
clock_gettime ( CLOCK_MONOTONIC, &time_funct_start );
2482
2470
#endif
2483
- Pix *src_pix = input.pix ;
2484
2471
OpenclDevice::gpuEnv = *env;
2485
2472
OpenclDevice::initMorphCLAllocations (wpl, input.height , input.pix );
2486
2473
Pix *pix_vline = nullptr , *pix_hline = nullptr , *pix_closed = nullptr ;
@@ -2677,12 +2664,12 @@ ds_device OpenclDevice::getDeviceSelection( ) {
2677
2664
// select fastest using custom Tesseract selection algorithm
2678
2665
float bestTime = FLT_MAX; // begin search with worst possible time
2679
2666
int bestDeviceIdx = -1 ;
2680
- for (int d = 0 ; d < profile->numDevices ; d++) {
2667
+ for (unsigned d = 0 ; d < profile->numDevices ; d++) {
2681
2668
ds_device device = profile->devices [d];
2682
2669
TessDeviceScore score = *(TessDeviceScore *)device.score ;
2683
2670
2684
2671
float time = score.time ;
2685
- printf (" [DS] Device[%i ] %i:%s score is %f\n " , d + 1 , device.type ,
2672
+ printf (" [DS] Device[%u ] %i:%s score is %f\n " , d + 1 , device.type ,
2686
2673
device.oclDeviceName , time );
2687
2674
if (time < bestTime) {
2688
2675
bestTime = time ;
0 commit comments