11/*
22 This file is part of darktable,
3- copyright (c ) 2009--2010 johannes hanika .
3+ Copyright (C ) 2009-2025 darktable developers .
44
55 darktable is free software: you can redistribute it and/or modify
66 it under the terms of the GNU General Public License as published by
@@ -36,8 +36,13 @@ backtransformf (float2 p, const int r_x, const int r_y, const int r_wd, const in
3636}
3737
3838kernel void
39- green_equilibration_lavg (read_only image2d_t in , write_only image2d_t out , const int width , const int height , const unsigned int filters ,
40- const int r_x , const int r_y , const float thr , local float * buffer )
39+ green_equilibration_lavg (read_only image2d_t in ,
40+ write_only image2d_t out ,
41+ const int width ,
42+ const int height ,
43+ const unsigned int filters ,
44+ const float thr ,
45+ local float * buffer )
4146{
4247 const int x = get_global_id (0 );
4348 const int y = get_global_id (1 );
@@ -79,11 +84,11 @@ green_equilibration_lavg(read_only image2d_t in, write_only image2d_t out, const
7984
8085 if (x >= width || y >= height ) return ;
8186
82- const int c = FC (y + r_y , x + r_x , filters );
87+ const int c = FC (y , x , filters );
8388 const float maximum = 1.0f ;
8489 float o = buffer [0 ];
8590
86- if (c == 1 && (( y + r_y ) & 1 ))
91+ if (c == 1 && (y & 1 ))
8792 {
8893 const float o1_1 = buffer [-1 * stride - 1 ];
8994 const float o1_2 = buffer [-1 * stride + 1 ];
@@ -112,8 +117,12 @@ green_equilibration_lavg(read_only image2d_t in, write_only image2d_t out, const
112117
113118
114119kernel void
115- green_equilibration_favg_reduce_first (read_only image2d_t in , const int width , const int height ,
116- global float2 * accu , const unsigned int filters , const int r_x , const int r_y , local float2 * buffer )
120+ green_equilibration_favg_reduce_first (read_only image2d_t in ,
121+ const int width ,
122+ const int height ,
123+ global float2 * accu ,
124+ const unsigned int filters ,
125+ local float2 * buffer )
117126{
118127 const int x = get_global_id (0 );
119128 const int y = get_global_id (1 );
@@ -124,11 +133,11 @@ green_equilibration_favg_reduce_first(read_only image2d_t in, const int width, c
124133
125134 const int l = mad24 (ylid , xlsz , xlid );
126135
127- const int c = FC (y + r_y , x + r_x , filters );
136+ const int c = FC (y , x , filters );
128137
129138 const int isinimage = (x < 2 * (width / 2 ) && y < 2 * (height / 2 ));
130- const int isgreen1 = (c == 1 && !(( y + r_y ) & 1 ));
131- const int isgreen2 = (c == 1 && (( y + r_y ) & 1 ));
139+ const int isgreen1 = (c == 1 && !(y & 1 ));
140+ const int isgreen2 = (c == 1 && (y & 1 ));
132141
133142 float pixel = read_imagef (in , sampleri , (int2 )(x , y )).x ;
134143
@@ -194,8 +203,12 @@ green_equilibration_favg_reduce_second(const global float2* input, global float2
194203
195204
196205kernel void
197- green_equilibration_favg_apply (read_only image2d_t in , write_only image2d_t out , const int width , const int height , const unsigned int filters ,
198- const int r_x , const int r_y , const float gr_ratio )
206+ green_equilibration_favg_apply (read_only image2d_t in ,
207+ write_only image2d_t out ,
208+ const int width ,
209+ const int height ,
210+ const unsigned int filters ,
211+ const float gr_ratio )
199212{
200213 const int x = get_global_id (0 );
201214 const int y = get_global_id (1 );
@@ -204,9 +217,9 @@ green_equilibration_favg_apply(read_only image2d_t in, write_only image2d_t out,
204217
205218 float pixel = read_imagef (in , sampleri , (int2 )(x , y )).x ;
206219
207- const int c = FC (y + r_y , x + r_x , filters );
220+ const int c = FC (y , x , filters );
208221
209- const int isgreen1 = (c == 1 && !(( y + r_y ) & 1 ));
222+ const int isgreen1 = (c == 1 && !(y & 1 ));
210223
211224 pixel *= (isgreen1 ? gr_ratio : 1.0f );
212225
@@ -461,8 +474,14 @@ clip_and_zoom(read_only image2d_t in, write_only image2d_t out, const int width,
461474 * resamping is done via rank-1 lattices and demosaicing using half-size interpolation.
462475 */
463476__kernel void
464- clip_and_zoom_demosaic_half_size (__read_only image2d_t in , __write_only image2d_t out , const int width , const int height ,
465- const int r_x , const int r_y , const int rin_wd , const int rin_ht , const float r_scale , const unsigned int filters )
477+ clip_and_zoom_demosaic_half_size (__read_only image2d_t in ,
478+ __write_only image2d_t out ,
479+ const int width ,
480+ const int height ,
481+ const int rin_wd ,
482+ const int rin_ht ,
483+ const float r_scale ,
484+ const unsigned int filters )
466485{
467486 // global id is pixel in output image (float4)
468487 const int x = get_global_id (0 );
@@ -490,7 +509,7 @@ clip_and_zoom_demosaic_half_size(__read_only image2d_t in, __write_only image2d_
490509
491510
492511 // upper left corner:
493- const float2 f = (float2 )(( x + r_x ) * px_footprint , ( y + r_y ) * px_footprint );
512+ const float2 f = (float2 )(x * px_footprint , y * px_footprint );
494513 int2 p = (int2 )((int )f .x & ~1 , (int )f .y & ~1 );
495514 const float2 d = (float2 )((f .x - p .x )/2.0f , (f .y - p .y )/2.0f );
496515
@@ -504,14 +523,14 @@ clip_and_zoom_demosaic_half_size(__read_only image2d_t in, __write_only image2d_
504523
505524 if (xx + 1 >= rin_wd || yy + 1 >= rin_ht ) continue ;
506525
507- float xfilter = (i == 0 ) ? 1.0f - d .x : ((i == samples + 1 ) ? d .x : 1.0f );
508- float yfilter = (j == 0 ) ? 1.0f - d .y : ((j == samples + 1 ) ? d .y : 1.0f );
526+ const float xfilter = (i == 0 ) ? 1.0f - d .x : ((i == samples + 1 ) ? d .x : 1.0f );
527+ const float yfilter = (j == 0 ) ? 1.0f - d .y : ((j == samples + 1 ) ? d .y : 1.0f );
509528
510529 // get four mosaic pattern uint16:
511- float p1 = read_imagef (in , sampleri , (int2 )(xx , yy )).x ;
512- float p2 = read_imagef (in , sampleri , (int2 )(xx + 1 , yy )).x ;
513- float p3 = read_imagef (in , sampleri , (int2 )(xx , yy + 1 )).x ;
514- float p4 = read_imagef (in , sampleri , (int2 )(xx + 1 , yy + 1 )).x ;
530+ const float p1 = read_imagef (in , sampleri , (int2 )(xx , yy )).x ;
531+ const float p2 = read_imagef (in , sampleri , (int2 )(xx + 1 , yy )).x ;
532+ const float p3 = read_imagef (in , sampleri , (int2 )(xx , yy + 1 )).x ;
533+ const float p4 = read_imagef (in , sampleri , (int2 )(xx + 1 , yy + 1 )).x ;
515534 color += yfilter * xfilter * (float4 )(p1 , (p2 + p3 )* 0.5f , p4 , 0.0f );
516535 weight += yfilter * xfilter ;
517536 }
@@ -679,7 +698,7 @@ ppg_demosaic_redblue (read_only image2d_t in, write_only image2d_t out, const in
679698 float4 color = buffer [0 ];
680699 if (x == 0 || y == 0 || x == (width - 1 ) || y == (height - 1 ))
681700 {
682- write_imagef (out , (int2 )(x , y ), fmax (color , 0.0f ));
701+ write_imagef (out , (int2 )(x , y ), fmax (color , 0.0f ));
683702 return ;
684703 }
685704
0 commit comments