@@ -79,10 +79,10 @@ static struct tiff_transform tiff_orientation_transforms[] = {
79
79
80
80
static const l_int32 MAX_PAGES_IN_TIFF_FILE = 3000 ;
81
81
82
- cl_mem pixsCLBuffer, pixdCLBuffer, pixdCLIntermediate; // Morph operations buffers
83
- cl_mem pixThBuffer; // output from thresholdtopix calculation
84
- cl_int clStatus;
85
- KernelEnv rEnv;
82
+ static cl_mem pixsCLBuffer, pixdCLBuffer, pixdCLIntermediate; // Morph operations buffers
83
+ static cl_mem pixThBuffer; // output from thresholdtopix calculation
84
+ static cl_int clStatus;
85
+ static KernelEnv rEnv;
86
86
87
87
#define DS_TAG_VERSION " <version>"
88
88
#define DS_TAG_VERSION_END " </version>"
@@ -602,7 +602,7 @@ static ds_status writeProfileToFile(ds_profile *profile,
602
602
}
603
603
604
604
// substitute invalid characters in device name with _
605
- void legalizeFileName ( char *fileName) {
605
+ static void legalizeFileName ( char *fileName) {
606
606
// printf("fileName: %s\n", fileName);
607
607
const char *invalidChars =
608
608
" /\? :*\" ><| " ; // space is valid but can cause headaches
@@ -625,7 +625,7 @@ void legalizeFileName( char *fileName) {
625
625
}
626
626
}
627
627
628
- void populateGPUEnvFromDevice ( GPUEnv *gpuInfo, cl_device_id device ) {
628
+ static void populateGPUEnvFromDevice ( GPUEnv *gpuInfo, cl_device_id device ) {
629
629
// printf("[DS] populateGPUEnvFromDevice\n");
630
630
size_t size;
631
631
gpuInfo->mnIsUserCreated = 1 ;
@@ -682,14 +682,17 @@ int OpenclDevice::SetKernelEnv( KernelEnv *envInfo )
682
682
return 1 ;
683
683
}
684
684
685
- cl_mem allocateZeroCopyBuffer (KernelEnv rEnv, l_uint32 *hostbuffer, size_t nElements, cl_mem_flags flags, cl_int *pStatus)
685
+ static cl_mem allocateZeroCopyBuffer (KernelEnv rEnv, l_uint32 *hostbuffer,
686
+ size_t nElements, cl_mem_flags flags,
687
+ cl_int *pStatus)
686
688
{
687
689
cl_mem membuffer = clCreateBuffer ( rEnv.mpkContext , (cl_mem_flags) (flags),
688
690
nElements * sizeof (l_uint32), hostbuffer, pStatus);
689
691
690
692
return membuffer;
691
693
}
692
694
695
+ static
693
696
Pix *mapOutputCLBuffer (KernelEnv rEnv, cl_mem clbuffer, Pix *pixd, Pix *pixs,
694
697
int elements, cl_mem_flags flags, bool memcopy = false ,
695
698
bool sync = true ) {
@@ -724,7 +727,9 @@ Pix *mapOutputCLBuffer(KernelEnv rEnv, cl_mem clbuffer, Pix *pixd, Pix *pixs,
724
727
return pixd;
725
728
}
726
729
727
- cl_mem allocateIntBuffer ( KernelEnv rEnv, const l_uint32 *_pValues, size_t nElements, cl_int *pStatus , bool sync = false )
730
+ static cl_mem allocateIntBuffer (KernelEnv rEnv, const l_uint32 *_pValues,
731
+ size_t nElements, cl_int *pStatus,
732
+ bool sync = false )
728
733
{
729
734
cl_mem xValues =
730
735
clCreateBuffer (rEnv.mpkContext , (cl_mem_flags)(CL_MEM_READ_WRITE),
@@ -1297,8 +1302,7 @@ PERF_COUNT_END
1297
1302
}
1298
1303
1299
1304
// Morphology Dilate operation for 5x5 structuring element. Invokes the relevant OpenCL kernels
1300
- cl_int
1301
- pixDilateCL_55 (l_int32 wpl, l_int32 h)
1305
+ static cl_int pixDilateCL_55 (l_int32 wpl, l_int32 h)
1302
1306
{
1303
1307
size_t globalThreads[2 ];
1304
1308
cl_mem pixtemp;
@@ -1365,8 +1369,7 @@ pixDilateCL_55(l_int32 wpl, l_int32 h)
1365
1369
}
1366
1370
1367
1371
// Morphology Erode operation for 5x5 structuring element. Invokes the relevant OpenCL kernels
1368
- cl_int
1369
- pixErodeCL_55 (l_int32 wpl, l_int32 h)
1372
+ static cl_int pixErodeCL_55 (l_int32 wpl, l_int32 h)
1370
1373
{
1371
1374
size_t globalThreads[2 ];
1372
1375
cl_mem pixtemp;
@@ -1439,7 +1442,7 @@ pixErodeCL_55(l_int32 wpl, l_int32 h)
1439
1442
}
1440
1443
1441
1444
// Morphology Dilate operation. Invokes the relevant OpenCL kernels
1442
- cl_int
1445
+ static cl_int
1443
1446
pixDilateCL (l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1444
1447
{
1445
1448
l_int32 xp, yp, xn, yn ;
@@ -1546,7 +1549,7 @@ pixDilateCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1546
1549
}
1547
1550
1548
1551
// Morphology Erode operation. Invokes the relevant OpenCL kernels
1549
- cl_int pixErodeCL (l_int32 hsize, l_int32 vsize, l_uint32 wpl, l_uint32 h) {
1552
+ static cl_int pixErodeCL (l_int32 hsize, l_int32 vsize, l_uint32 wpl, l_uint32 h) {
1550
1553
l_int32 xp, yp, xn, yn ;
1551
1554
SEL *sel;
1552
1555
size_t globalThreads[2 ];
@@ -1653,8 +1656,7 @@ cl_int pixErodeCL(l_int32 hsize, l_int32 vsize, l_uint32 wpl, l_uint32 h) {
1653
1656
}
1654
1657
1655
1658
// Morphology Open operation. Invokes the relevant OpenCL kernels
1656
- cl_int
1657
- pixOpenCL (l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1659
+ static cl_int pixOpenCL (l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1658
1660
{
1659
1661
cl_int status;
1660
1662
cl_mem pixtemp;
@@ -1672,8 +1674,7 @@ pixOpenCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1672
1674
}
1673
1675
1674
1676
// Morphology Close operation. Invokes the relevant OpenCL kernels
1675
- cl_int
1676
- pixCloseCL (l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1677
+ static cl_int pixCloseCL (l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1677
1678
{
1678
1679
cl_int status;
1679
1680
cl_mem pixtemp;
@@ -1691,7 +1692,7 @@ pixCloseCL(l_int32 hsize, l_int32 vsize, l_int32 wpl, l_int32 h)
1691
1692
}
1692
1693
1693
1694
// pix OR operation: outbuffer = buffer1 | buffer2
1694
- cl_int
1695
+ static cl_int
1695
1696
pixORCL_work (l_uint32 wpl, l_uint32 h, cl_mem buffer1, cl_mem buffer2, cl_mem outbuffer)
1696
1697
{
1697
1698
cl_int status;
@@ -1729,6 +1730,7 @@ pixORCL_work(l_uint32 wpl, l_uint32 h, cl_mem buffer1, cl_mem buffer2, cl_mem ou
1729
1730
}
1730
1731
1731
1732
// output = buffer1 & ~(buffer2)
1733
+ static
1732
1734
cl_int pixSubtractCL_work (l_uint32 wpl, l_uint32 h, cl_mem buffer1,
1733
1735
cl_mem buffer2, cl_mem outBuffer = nullptr ) {
1734
1736
cl_int status;
@@ -2140,7 +2142,7 @@ typedef struct _TessScoreEvaluationInputData {
2140
2142
Pix *pix;
2141
2143
} TessScoreEvaluationInputData;
2142
2144
2143
- void populateTessScoreEvaluationInputData ( TessScoreEvaluationInputData *input ) {
2145
+ static void populateTessScoreEvaluationInputData (TessScoreEvaluationInputData *input) {
2144
2146
srand (1 );
2145
2147
// 8.5x11 inches @ 300dpi rounded to clean multiples
2146
2148
int height = 3328 ; // %256
@@ -2229,7 +2231,7 @@ typedef struct _TessDeviceScore {
2229
2231
* Micro Benchmarks for Device Selection
2230
2232
*****************************************************************************/
2231
2233
2232
- double composeRGBPixelMicroBench ( GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type ) {
2234
+ static double composeRGBPixelMicroBench (GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2233
2235
double time = 0 ;
2234
2236
#if ON_WINDOWS
2235
2237
LARGE_INTEGER freq, time_funct_start, time_funct_end;
@@ -2314,7 +2316,7 @@ double composeRGBPixelMicroBench( GPUEnv *env, TessScoreEvaluationInputData inpu
2314
2316
return time ;
2315
2317
}
2316
2318
2317
- double histogramRectMicroBench ( GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type ) {
2319
+ static double histogramRectMicroBench ( GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type ) {
2318
2320
double time ;
2319
2321
#if ON_WINDOWS
2320
2322
LARGE_INTEGER freq, time_funct_start, time_funct_end;
@@ -2397,7 +2399,7 @@ double histogramRectMicroBench( GPUEnv *env, TessScoreEvaluationInputData input,
2397
2399
}
2398
2400
2399
2401
// Reproducing the ThresholdRectToPix native version
2400
- void ThresholdRectToPix_Native (const unsigned char * imagedata,
2402
+ static void ThresholdRectToPix_Native (const unsigned char * imagedata,
2401
2403
int bytes_per_pixel,
2402
2404
int bytes_per_line,
2403
2405
const int * thresholds,
@@ -2434,7 +2436,7 @@ void ThresholdRectToPix_Native(const unsigned char* imagedata,
2434
2436
}
2435
2437
}
2436
2438
2437
- double thresholdRectToPixMicroBench ( GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type ) {
2439
+ static double thresholdRectToPixMicroBench (GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2438
2440
double time ;
2439
2441
int retVal = 0 ;
2440
2442
#if ON_WINDOWS
@@ -2530,7 +2532,7 @@ double thresholdRectToPixMicroBench( GPUEnv *env, TessScoreEvaluationInputData i
2530
2532
return time ;
2531
2533
}
2532
2534
2533
- double getLineMasksMorphMicroBench ( GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type ) {
2535
+ static double getLineMasksMorphMicroBench (GPUEnv *env, TessScoreEvaluationInputData input, ds_device_type type) {
2534
2536
2535
2537
double time = 0 ;
2536
2538
#if ON_WINDOWS
@@ -2628,28 +2630,28 @@ double getLineMasksMorphMicroBench( GPUEnv *env, TessScoreEvaluationInputData in
2628
2630
#include " stdlib.h"
2629
2631
2630
2632
// encode score object as byte string
2631
- ds_status serializeScore ( ds_device* device, void **serializedScore, unsigned int * serializedScoreSize ) {
2633
+ static ds_status serializeScore ( ds_device* device, void **serializedScore, unsigned int * serializedScoreSize ) {
2632
2634
*serializedScoreSize = sizeof (TessDeviceScore);
2633
2635
*serializedScore = new unsigned char [*serializedScoreSize];
2634
2636
memcpy (*serializedScore, device->score , *serializedScoreSize);
2635
2637
return DS_SUCCESS;
2636
2638
}
2637
2639
2638
2640
// parses byte string and stores in score object
2639
- ds_status deserializeScore ( ds_device* device, const unsigned char * serializedScore, unsigned int serializedScoreSize ) {
2641
+ static ds_status deserializeScore ( ds_device* device, const unsigned char * serializedScore, unsigned int serializedScoreSize ) {
2640
2642
// check that serializedScoreSize == sizeof(TessDeviceScore);
2641
2643
device->score = new TessDeviceScore;
2642
2644
memcpy (device->score , serializedScore, serializedScoreSize);
2643
2645
return DS_SUCCESS;
2644
2646
}
2645
2647
2646
- ds_status releaseScore (void *score) {
2648
+ static ds_status releaseScore (void *score) {
2647
2649
delete (TessDeviceScore *)score;
2648
2650
return DS_SUCCESS;
2649
2651
}
2650
2652
2651
2653
// evaluate devices
2652
- ds_status evaluateScoreForDevice ( ds_device *device, void *inputData) {
2654
+ static ds_status evaluateScoreForDevice ( ds_device *device, void *inputData) {
2653
2655
// overwrite statuc gpuEnv w/ current device
2654
2656
// so native opencl calls can be used; they use static gpuEnv
2655
2657
printf (" \n [DS] Device: \" %s\" (%s) evaluation...\n " , device->oclDeviceName , device->type ==DS_DEVICE_OPENCL_DEVICE ? " OpenCL" : " Native" );
0 commit comments