@@ -691,6 +691,51 @@ void _capture_sharpen(dt_iop_module_t *self,
691
691
692
692
#if HAVE_OPENCL
693
693
694
+ int _capture_radius_cl (dt_iop_module_t * self ,
695
+ dt_dev_pixelpipe_iop_t * const piece ,
696
+ const cl_mem dev_in ,
697
+ const int width ,
698
+ const int height ,
699
+ const uint8_t (* const xtrans )[6 ],
700
+ const uint32_t filters )
701
+ {
702
+ dt_dev_pixelpipe_t * pipe = piece -> pipe ;
703
+ dt_iop_demosaic_data_t * d = piece -> data ;
704
+ dt_iop_demosaic_gui_data_t * g = self -> gui_data ;
705
+
706
+ if (!((g && g -> autoradius ) || d -> cs_radius < 0.01f ))
707
+ return CL_SUCCESS ;
708
+
709
+ const int devid = piece -> pipe -> devid ;
710
+ float * in = dt_iop_image_alloc (width , height , 1 );
711
+ if (!in ) return CL_MEM_OBJECT_ALLOCATION_FAILURE ;
712
+
713
+ cl_int err = dt_opencl_copy_device_to_host (devid , in , dev_in , width , height , sizeof (float ));
714
+ if (err == CL_SUCCESS )
715
+ {
716
+ const float radius = filters != 9u
717
+ ? _calcRadiusBayer (in , width , height , 0.01f , 1.0f , filters )
718
+ : _calcRadiusXtrans (in , width , height , 0.01f , 1.0f , xtrans );
719
+ const gboolean valid = radius > 0.1f && radius < 1.0f ;
720
+ dt_print_pipe (DT_DEBUG_PIPE , filters != 9u ? "bayer autoradius" : "xtrans autoradius" ,
721
+ pipe , self , devid , NULL , NULL , "autoradius=%.2f" , radius );
722
+
723
+ if (!feqf (radius , d -> cs_radius , 0.005f ) && valid )
724
+ {
725
+ if (g )
726
+ {
727
+ dt_control_log (_ ("calculated radius" ));
728
+ g -> autoradius = TRUE;
729
+ }
730
+ dt_iop_demosaic_params_t * p = self -> params ;
731
+ p -> cs_radius = d -> cs_radius = radius ;
732
+ }
733
+ else if (g ) g -> autoradius = FALSE;
734
+ }
735
+ dt_free_align (in );
736
+ return err ;
737
+ }
738
+
694
739
int _capture_sharpen_cl (dt_iop_module_t * self ,
695
740
dt_dev_pixelpipe_iop_t * const piece ,
696
741
const cl_mem dev_in ,
@@ -713,7 +758,6 @@ int _capture_sharpen_cl(dt_iop_module_t *self,
713
758
714
759
const dt_iop_demosaic_data_t * const d = piece -> data ;
715
760
dt_iop_demosaic_global_data_t * const gd = self -> global_data ;
716
- dt_iop_demosaic_gui_data_t * g = self -> gui_data ;
717
761
718
762
if (pipe -> type & DT_DEV_PIXELPIPE_THUMBNAIL )
719
763
{
@@ -730,42 +774,7 @@ int _capture_sharpen_cl(dt_iop_module_t *self,
730
774
wbon ? CAPTURE_CFACLIP * dsc -> temperature .coeffs [2 ] : CAPTURE_CFACLIP ,
731
775
0.0f };
732
776
733
- const gboolean fullpipe = pipe -> type & DT_DEV_PIXELPIPE_FULL ;
734
- const gboolean autoradius = fullpipe && g && g -> autoradius ;
735
- const float old_radius = d -> cs_radius ;
736
- float radius = old_radius ;
737
- if (autoradius || radius < 0.01f )
738
- {
739
- float * in = dt_alloc_align_float (pixels );
740
- if (in )
741
- {
742
- if (dt_opencl_copy_device_to_host (devid , in , dev_in , width , height , sizeof (float )) == CL_SUCCESS )
743
- {
744
- radius = filters != 9u
745
- ? _calcRadiusBayer (in , width , height , 0.01f , 1.0f , filters )
746
- : _calcRadiusXtrans (in , width , height , 0.01f , 1.0f , xtrans );
747
- const gboolean valid = radius > 0.1f && radius < 1.0f ;
748
- dt_print_pipe (DT_DEBUG_PIPE , filters != 9u ? "bayer autoradius" : "xtrans autoradius" ,
749
- pipe , self , devid , NULL , NULL , "autoradius=%.2f" , radius );
750
-
751
- if (!feqf (radius , old_radius , 0.005f ) && valid )
752
- {
753
- if (fullpipe )
754
- {
755
- if (g )
756
- {
757
- dt_control_log (_ ("calculated radius" ));
758
- g -> autoradius = TRUE;
759
- }
760
- dt_iop_demosaic_params_t * p = self -> params ;
761
- p -> cs_radius = radius ;
762
- }
763
- }
764
- else if (g ) g -> autoradius = FALSE;
765
- }
766
- dt_free_align (in );
767
- }
768
- }
777
+ const float radius = d -> cs_radius ;
769
778
770
779
cl_mem gcoeffs = NULL ;
771
780
cl_mem gauss_idx = NULL ;
0 commit comments