Skip to content

Commit f46dfdc

Browse files
mwoottonzdenop
authored andcommitted
Fix a padding problem in ThresholdRectToPixOCL
1 parent 5db7602 commit f46dfdc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

opencl/oclkernels.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,6 @@ void kernel_ThresholdRectToPix(
10661066
__global int *pix) {
10671067

10681068
// declare variables
1069-
uint pad = PIXELS_PER_WORD * wpl - width;//number of padding bits at the end of each output line
10701069
int pThresholds[NUM_CHANNELS];
10711070
int pHi_Values[NUM_CHANNELS];
10721071
for ( int i = 0; i < NUM_CHANNELS; i++) {
@@ -1077,15 +1076,16 @@ void kernel_ThresholdRectToPix(
10771076
// for each word (32 pixels) in output image
10781077
for ( uint w = get_global_id(0); w < wpl*height; w += get_global_size(0) ) {
10791078
unsigned int word = 0; // all bits start at zero
1080-
//decrease the pixel index for the padding at the end of each output line (=number of lines * padding)
1081-
uint pxIdxOffset = ( w / wpl) * pad;// = ( ( PIXELS_PER_WORD * w) / ( width + pad)) * pad;
10821079
// for each burst in word
10831080
for ( int b = 0; b < BURSTS_PER_WORD; b++) {
10841081
// load burst
10851082
charVec pixels;
1086-
for ( int i = 0; i < (PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH; i++ ) {
1087-
pixels.v[i] = imageData[w*(BURSTS_PER_WORD*(PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH) + b*((PIXELS_PER_BURST*NUM_CHANNELS)/CHAR_VEC_WIDTH) + i - pxIdxOffset];
1088-
}
1083+
int offset = (w / wpl) * width;
1084+
offset += (w % wpl) * PIXELS_PER_WORD;
1085+
offset += b * PIXELS_PER_BURST;
1086+
1087+
for (int i = 0; i < PIXELS_PER_BURST; ++i)
1088+
pixels.v[i] = imageData[offset + i];
10891089

10901090
// for each pixel in burst
10911091
for ( int p = 0; p < PIXELS_PER_BURST; p++) {

0 commit comments

Comments
 (0)