@@ -32,7 +32,7 @@ __kernel void rcd_populate (__read_only image2d_t in, global float *cfa, global
3232 const int col = get_global_id (0 );
3333 const int row = get_global_id (1 );
3434 if (col >= w || row >= height ) return ;
35- const float val = scale * fmax (0.0f , readsingle (in , col , row ));
35+ const float val = scale * fmax (0.0f , Areadsingle (in , col , row ));
3636 const int color = FC (row , col , filters );
3737
3838 global float * rgbcol = rgb0 ;
@@ -51,7 +51,7 @@ __kernel void rcd_write_output (__write_only image2d_t out, global float *rgb0,
5151 if (!(col >= border && col < w - border && row >= border && row < height - border )) return ;
5252 const int idx = mad24 (row , w , col );
5353
54- write_imagef (out , (int2 )(col , row ), ( float4 )(fmax ( scale * rgb0 [idx ], 0.0f ), fmax ( scale * rgb1 [idx ], 0.0f ), fmax ( scale * rgb2 [idx ], 0.0f ), 0.0f ));
54+ write_imagef (out , (int2 )(col , row ), fmax ( 0.0f , ( float4 )(scale * rgb0 [idx ], scale * rgb1 [idx ], scale * rgb2 [idx ], 0.0f )));
5555}
5656
5757#define eps 1e-5f // Tolerance to avoid dividing by zero
@@ -278,8 +278,8 @@ __kernel void write_blended_dual(__read_only image2d_t high,
278278 const int row = get_global_id (1 );
279279 if ((col >= w ) || (row >= height )) return ;
280280
281- const float4 high_val = readpixel (high , col , row );
282- const float4 low_val = readpixel (low , col , row );
281+ const float4 high_val = Areadpixel (high , col , row );
282+ const float4 low_val = Areadpixel (low , col , row );
283283 const float4 blender = (float4 )clipf (mask [mad24 (row , w , col )]);
284284 float4 data = mix (low_val , high_val , blender );
285285 data .w = showmask ? blender .x : 0.0f ;
@@ -297,8 +297,8 @@ __kernel void calc_Y0_mask(global float *mask,
297297 if ((col >= w ) || (row >= height )) return ;
298298 const int idx = mad24 (row , w , col );
299299
300- const float4 pt = wb * fmax (0.0f , readpixel (in , col , row ));
301- mask [idx ] = dtcl_sqrt (0.33333333f * (pt .x + pt .y + pt .z ));
300+ const float4 pt = wb * fmax (0.0f , Areadpixel (in , col , row ));
301+ mask [idx ] = dtcl_sqrt ((pt .x + pt .y + pt .z ) / 3.0f );
302302}
303303
304304__kernel void calc_scharr_mask (global float * in , global float * out , const int w , const int height )
@@ -311,11 +311,7 @@ __kernel void calc_scharr_mask(global float *in, global float *out, const int w,
311311 const int incol = clamp (col , 1 , w - 2 );
312312 const int inrow = clamp (row , 1 , height - 2 );
313313 const int idx = mad24 (inrow , w , incol );
314- const float gx = 47.0f / 255.0f * (in [idx - w - 1 ] - in [idx - w + 1 ] + in [idx + w - 1 ] - in [idx + w + 1 ])
315- + 162.0f / 255.0f * (in [idx - 1 ] - in [idx + 1 ]);
316- const float gy = 47.0f / 255.0f * (in [idx - w - 1 ] - in [idx + w - 1 ] + in [idx - w + 1 ] - in [idx + w + 1 ])
317- + 162.0f / 255.0f * (in [idx - w ] - in [idx + w ]);
318- const float gradient_magnitude = dt_fast_hypot (gx , gy );
314+ const float gradient_magnitude = scharr_gradient (in , idx , w );
319315 out [oidx ] = clipf (gradient_magnitude / 16.0f );
320316}
321317
@@ -350,7 +346,7 @@ kernel void demosaic_box3(read_only image2d_t in,
350346 if (x >= 0 && y >= 0 && x < width && y < height )
351347 {
352348 const int color = fcol (y , x , filters , xtrans );
353- sum [color ] += fmax (0.0f , read_imagef (in , sampleri , ( int2 )( x , y )). x );
349+ sum [color ] += fmax (0.0f , Areadsingle (in , x , y ));
354350 cnt [color ] += 1.0f ;
355351 }
356352 }
0 commit comments