Skip to content

Commit

Permalink
Fix CID 1393661 (Arguments in wrong order)
Browse files Browse the repository at this point in the history
It did not cause a problem as both arguments were 0.

Update also the function prototype of HistogramRectOCL to
accept a void pointer which allows removing a type cast.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 1, 2018
1 parent 09da044 commit 5797044
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ccstruct/otsuthr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int OtsuThreshold(Pix* src_pix, int left, int top, int width, int height,
OpenclDevice od;
if (od.selectedDeviceIsOpenCL() && (num_channels == 1 || num_channels == 4) &&
top == 0 && left == 0) {
od.HistogramRectOCL((unsigned char*)pixGetData(src_pix), num_channels,
od.HistogramRectOCL(pixGetData(src_pix), num_channels,
pixGetWpl(src_pix) * 4, left, top, width, height,
kHistogramSize, histogramAllChannels);

Expand Down
8 changes: 4 additions & 4 deletions src/opencl/openclwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ void OpenclDevice::pixGetLinesCL(Pix* pixd, Pix* pixs, Pix** pix_vline,
* histogramAllChannels is laid out as all channel 0, then all channel 1...
* only supports 1 or 4 channels (bytes_per_pixel)
************************************************************************/
int OpenclDevice::HistogramRectOCL(unsigned char* imageData,
int OpenclDevice::HistogramRectOCL(void* imageData,
int bytes_per_pixel, int bytes_per_line,
int left, // always 0
int top, // always 0
Expand Down Expand Up @@ -2153,8 +2153,8 @@ static double histogramRectMicroBench(GPUEnv* env,
timespec time_funct_start, time_funct_end;
#endif

int left = 0;
int top = 0;
const int left = 0;
const int top = 0;
int kHistogramSize = 256;
int bytes_per_line = input.width * input.numChannels;
int* histogramAllChannels = new int[kHistogramSize * input.numChannels];
Expand All @@ -2170,7 +2170,7 @@ static double histogramRectMicroBench(GPUEnv* env,

OpenclDevice::gpuEnv = *env;
int retVal = OpenclDevice::HistogramRectOCL(
input.imageData, input.numChannels, bytes_per_line, top, left,
input.imageData, input.numChannels, bytes_per_line, left, top,
input.width, input.height, kHistogramSize, histogramAllChannels);

#if ON_WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion src/opencl/openclwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class OpenclDevice {
inline static int AddKernelConfig(int kCount, const char* kName);

/* for binarization */
static int HistogramRectOCL(unsigned char* imagedata, int bytes_per_pixel,
static int HistogramRectOCL(void* imagedata, int bytes_per_pixel,
int bytes_per_line, int left, int top, int width,
int height, int kHistogramSize,
int* histogramAllChannels);
Expand Down

0 comments on commit 5797044

Please sign in to comment.