Skip to content

Commit

Permalink
Big reworking with speed increasing
Browse files Browse the repository at this point in the history
  • Loading branch information
awxkee committed Oct 11, 2024
1 parent f7f98f4 commit 8bf71c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/jzazbz_to_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ fn jzazbz_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
.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.)
Expand Down Expand Up @@ -223,11 +223,11 @@ fn jzazbz_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
.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.)
Expand Down
12 changes: 6 additions & 6 deletions src/oklab_to_image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ fn oklab_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
.cast::<u16>();

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;
Expand Down Expand Up @@ -205,11 +205,11 @@ fn oklab_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
.cast::<u16>();

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;
Expand Down

0 comments on commit 8bf71c8

Please sign in to comment.