From 8bf71c8c42e2e0b18fb4a472d515227503d8817e Mon Sep 17 00:00:00 2001 From: awxkee Date: Fri, 11 Oct 2024 09:09:46 +0100 Subject: [PATCH] Big reworking with speed increasing --- src/jzazbz_to_image.rs | 12 ++++++------ src/oklab_to_image.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/jzazbz_to_image.rs b/src/jzazbz_to_image.rs index 850c038..1a37dc1 100644 --- a/src/jzazbz_to_image.rs +++ b/src/jzazbz_to_image.rs @@ -132,11 +132,11 @@ fn jzazbz_to_image( .round(); dst_chunk[image_configuration.get_r_channel_offset()] = - *lut_table.get_unchecked(r_cast as usize); + *lut_table.get_unchecked((r_cast as usize).min(2048)); dst_chunk[image_configuration.get_g_channel_offset()] = - *lut_table.get_unchecked(g_cast as usize); + *lut_table.get_unchecked((g_cast as usize).min(2048)); dst_chunk[image_configuration.get_b_channel_offset()] = - *lut_table.get_unchecked(b_cast as usize); + *lut_table.get_unchecked((b_cast as usize).min(2048)); if image_configuration.has_alpha() { let a_cast = (src_chunks[image_configuration.get_a_channel_offset()] * 255.) @@ -223,11 +223,11 @@ fn jzazbz_to_image( .round(); dst_chunk[image_configuration.get_r_channel_offset()] = - *lut_table.get_unchecked(r_cast as usize); + *lut_table.get_unchecked((r_cast as usize).min(2048)); dst_chunk[image_configuration.get_g_channel_offset()] = - *lut_table.get_unchecked(g_cast as usize); + *lut_table.get_unchecked((g_cast as usize).min(2048)); dst_chunk[image_configuration.get_b_channel_offset()] = - *lut_table.get_unchecked(b_cast as usize); + *lut_table.get_unchecked((b_cast as usize).min(2048)); if image_configuration.has_alpha() { let a_cast = (src_chunks[image_configuration.get_a_channel_offset()] * 255.) diff --git a/src/oklab_to_image.rs b/src/oklab_to_image.rs index ac8f0ab..77318ab 100644 --- a/src/oklab_to_image.rs +++ b/src/oklab_to_image.rs @@ -129,11 +129,11 @@ fn oklab_to_image( .cast::(); dst_chunks[image_configuration.get_r_channel_offset()] = - *lut_table.get_unchecked(rgb.r as usize); + *lut_table.get_unchecked((rgb.r as usize).min(2048)); dst_chunks[image_configuration.get_g_channel_offset()] = - *lut_table.get_unchecked(rgb.g as usize); + *lut_table.get_unchecked((rgb.g as usize).min(2048)); dst_chunks[image_configuration.get_b_channel_offset()] = - *lut_table.get_unchecked(rgb.b as usize); + *lut_table.get_unchecked((rgb.b as usize).min(2048)); if image_configuration.has_alpha() { let a_lin = (src_chunks[3] * 255f32).round() as u8; dst_chunks[image_configuration.get_a_channel_offset()] = a_lin; @@ -205,11 +205,11 @@ fn oklab_to_image( .cast::(); dst_chunks[image_configuration.get_r_channel_offset()] = - *lut_table.get_unchecked(rgb.r as usize); + *lut_table.get_unchecked((rgb.r as usize).min(2048)); dst_chunks[image_configuration.get_g_channel_offset()] = - *lut_table.get_unchecked(rgb.g as usize); + *lut_table.get_unchecked((rgb.g as usize).min(2048)); dst_chunks[image_configuration.get_b_channel_offset()] = - *lut_table.get_unchecked(rgb.b as usize); + *lut_table.get_unchecked((rgb.b as usize).min(2048)); if image_configuration.has_alpha() { let a_lin = (src_chunks[3] * 255f32).round() as u8; dst_chunks[image_configuration.get_a_channel_offset()] = a_lin;