@@ -990,9 +990,9 @@ static inline void _compress_into_gamut(dt_aligned_pixel_t pixel_in_out)
990990 + rgb_offset [2 ] * luminance_coeffs [2 ];
991991 y_new = max_inverse_rgb_offset - y_inverse_rgb_offset + y_new ;
992992
993- // Compensate the intensity to match the original luminance
993+ // Compensate the intensity to match the original luminance; avoid div by 0 or tiny number
994994 const float luminance_ratio =
995- y_new > y_compensate_negative
995+ ( y_new > y_compensate_negative && y_new > _epsilon )
996996 ? y_compensate_negative / y_new
997997 : 1.f ;
998998
@@ -1119,7 +1119,7 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_par
11191119 // toe
11201120 tone_mapping_params .target_black =
11211121 powf (p -> curve_target_display_black_ratio , 1.f / tone_mapping_params .curve_gamma );
1122- tone_mapping_params .toe_power = p -> curve_toe_power ;
1122+ tone_mapping_params .toe_power = fmaxf ( 0.01f , p -> curve_toe_power ) ;
11231123
11241124 const float remaining_y_below_pivot = tone_mapping_params .pivot_y - tone_mapping_params .target_black ;
11251125 const float toe_length_y = remaining_y_below_pivot * p -> curve_linear_ratio_below_pivot ;
@@ -1181,7 +1181,7 @@ static tone_mapping_params_t _calculate_tone_mapping_params(const dt_iop_agx_par
11811181
11821182 const float shoulder_dy_above_pivot = tone_mapping_params .slope * dx_linear_above_pivot ;
11831183 tone_mapping_params .shoulder_transition_y = tone_mapping_params .pivot_y + shoulder_dy_above_pivot ;
1184- tone_mapping_params .shoulder_power = p -> curve_shoulder_power ;
1184+ tone_mapping_params .shoulder_power = fmaxf ( 0.01f , p -> curve_shoulder_power ) ;
11851185
11861186 const float shoulder_limit_x = 1.f ;
11871187 tone_mapping_params .shoulder_scale = _scale (shoulder_limit_x ,
@@ -2885,7 +2885,7 @@ int process_cl(dt_iop_module_t *self,
28852885{
28862886 if (!dt_iop_have_required_input_format (4 , self , piece -> colors , (void * )dev_in , (void * )dev_out , roi_in , roi_out ))
28872887 {
2888- return CL_INVALID_IMAGE_FORMAT_DESCRIPTOR ;
2888+ return DT_OPENCL_PROCESS_CL ;
28892889 }
28902890
28912891 const dt_iop_agx_global_data_t * gd = self -> global_data ;
@@ -2906,7 +2906,7 @@ int process_cl(dt_iop_module_t *self,
29062906 {
29072907 dt_print (DT_DEBUG_ALWAYS ,
29082908 "[agx process_cl] Failed to obtain a valid base profile. Module will not run correctly." );
2909- return CL_INVALID_CONTEXT ;
2909+ return DT_OPENCL_PROCESS_CL ;
29102910 }
29112911
29122912 dt_colormatrix_t pipe_to_base ;
0 commit comments