@@ -1581,17 +1581,24 @@ void process(dt_iop_module_t *self,
15811581 for (size_t k = 0 ; k < 4 * n_pixels ; k += 4 )
15821582 {
15831583 const float * const restrict pix_in = in + k ;
1584+ dt_aligned_pixel_t sanitised_in = { 0.f };
1585+ for_each_channel (c )
1586+ {
1587+ const float component = pix_in [c ];
1588+ // allow about 22.5 EV above mid-grey, including out-of-gamut pixels, getting rid of NaNs
1589+ sanitised_in [c ] = isnan (component ) ? 0.f : CLAMPF (component , -1e6f , 1e6f );
1590+ }
15841591 float * const restrict pix_out = out + k ;
15851592
15861593 // Convert from pipe working space to base space
15871594 dt_aligned_pixel_t base_rgb = { 0.f };
15881595 if (base_working_same_profile )
15891596 {
1590- copy_pixel (base_rgb , pix_in );
1597+ copy_pixel (base_rgb , sanitised_in );
15911598 }
15921599 else
15931600 {
1594- dt_apply_transposed_color_matrix (pix_in , pipe_to_base_transposed , base_rgb );
1601+ dt_apply_transposed_color_matrix (sanitised_in , pipe_to_base_transposed , base_rgb );
15951602 }
15961603
15971604 _compress_into_gamut (base_rgb );
@@ -1607,7 +1614,7 @@ void process(dt_iop_module_t *self,
16071614 dt_apply_transposed_color_matrix (rendering_rgb , rendering_to_pipe_transposed , pix_out );
16081615
16091616 // Copy over the alpha channel
1610- pix_out [3 ] = pix_in [3 ];
1617+ pix_out [3 ] = sanitised_in [3 ];
16111618 }
16121619}
16131620
0 commit comments