Skip to content

Commit 9d5820f

Browse files
committed
Added color blending
1 parent 028787b commit 9d5820f

File tree

10 files changed

+1347
-34
lines changed

10 files changed

+1347
-34
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ workspace = { members = ["src/app"] }
22

33
[package]
44
name = "colorutils-rs"
5-
version = "0.5.4"
5+
version = "0.5.5"
66
edition = "2021"
77
description = "High performance utilities for color format handling and conversion."
88
readme = "README.md"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub mod planar_to_linear;
4646
mod rgb;
4747
mod rgb_expand;
4848
mod rgba;
49+
mod routines;
4950
mod sigmoidal;
5051
mod sigmoidal_to_image;
5152
#[cfg(all(

src/neon/image_to_oklab.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* // license that can be found in the LICENSE file.
66
*/
77
use crate::image::ImageConfiguration;
8+
use crate::image_to_oklab::OklabTarget;
89
use crate::neon::get_neon_linear_transfer;
910
use crate::neon::math::vcolorq_matrix_f32;
1011
use crate::{load_u8_and_deinterleave, TransferFunction, SRGB_TO_XYZ_D65};
1112
use erydanos::{vatan2q_f32, vcbrtq_fast_f32, vhypotq_fast_f32};
1213
use std::arch::aarch64::*;
13-
use crate::image_to_oklab::OklabTarget;
1414

1515
macro_rules! triple_to_oklab {
1616
($r: expr, $g: expr, $b: expr, $transfer: expr, $target: expr,
@@ -36,7 +36,8 @@ macro_rules! triple_to_oklab {
3636
let m_ = vcbrtq_fast_f32(l_m);
3737
let s_ = vcbrtq_fast_f32(l_s);
3838

39-
let (l, mut a, mut b) = vcolorq_matrix_f32(l_, m_, s_, $m0, $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8);
39+
let (l, mut a, mut b) =
40+
vcolorq_matrix_f32(l_, m_, s_, $m0, $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8);
4041

4142
if $target == OklabTarget::OKLCH {
4243
let c = vhypotq_fast_f32(a, b);
@@ -119,8 +120,8 @@ pub unsafe fn neon_image_to_oklab<const CHANNELS_CONFIGURATION: u8, const TARGET
119120
let b_low_low = vmovl_u16(vget_low_u16(b_low));
120121

121122
let (x_low_low, y_low_low, z_low_low) = triple_to_oklab!(
122-
r_low_low, g_low_low, b_low_low, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7, x8, c0, c1,
123-
c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
123+
r_low_low, g_low_low, b_low_low, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7, x8,
124+
c0, c1, c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
124125
);
125126

126127
let a_low = vmovl_u8(vget_low_u8(a_chan));
@@ -140,8 +141,8 @@ pub unsafe fn neon_image_to_oklab<const CHANNELS_CONFIGURATION: u8, const TARGET
140141
let b_low_high = vmovl_high_u16(b_low);
141142

142143
let (x_low_high, y_low_high, z_low_high) = triple_to_oklab!(
143-
r_low_high, g_low_high, b_low_high, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7, x8, c0,
144-
c1, c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
144+
r_low_high, g_low_high, b_low_high, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7,
145+
x8, c0, c1, c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
145146
);
146147

147148
if image_configuration.has_alpha() {
@@ -162,8 +163,8 @@ pub unsafe fn neon_image_to_oklab<const CHANNELS_CONFIGURATION: u8, const TARGET
162163
let b_high_low = vmovl_u16(vget_low_u16(b_high));
163164

164165
let (x_high_low, y_high_low, z_high_low) = triple_to_oklab!(
165-
r_high_low, g_high_low, b_high_low, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7, x8, c0,
166-
c1, c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
166+
r_high_low, g_high_low, b_high_low, &transfer, target, x0, x1, x2, x3, x4, x5, x6, x7,
167+
x8, c0, c1, c2, c3, c4, c5, c6, c7, c8, m0, m1, m2, m3, m4, m5, m6, m7, m8
167168
);
168169

169170
let a_high = vmovl_high_u8(a_chan);

src/neon/oklab_to_image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* // license that can be found in the LICENSE file.
66
*/
77
use crate::image::ImageConfiguration;
8+
use crate::image_to_oklab::OklabTarget;
89
use crate::neon::get_neon_gamma_transfer;
910
use crate::neon::math::vcolorq_matrix_f32;
1011
use crate::{load_f32_and_deinterleave, TransferFunction, XYZ_TO_SRGB_D65};
11-
use std::arch::aarch64::*;
1212
use erydanos::{vcosq_f32, vsinq_f32};
13-
use crate::image_to_oklab::OklabTarget;
13+
use std::arch::aarch64::*;
1414

1515
#[inline(always)]
1616
unsafe fn neon_oklab_gamma_vld<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(

src/neon/planar_to_linear.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ unsafe fn process_pixels(
4242
let r_high_high = vmovl_high_u16(r_high);
4343

4444
let x_high_high = neon_to_linear(r_high_high, &transfer);
45-
4645
let storing_row = float32x4x4_t(x_low_low, x_low_high, x_high_low, x_high_high);
4746
storing_row
4847
}

src/oklab_to_image.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
* // license that can be found in the LICENSE file.
66
*/
77
use crate::image::ImageConfiguration;
8+
use crate::image_to_oklab::OklabTarget;
89
#[cfg(all(
910
any(target_arch = "aarch64", target_arch = "arm"),
1011
target_feature = "neon"
1112
))]
1213
use crate::neon::neon_oklab_to_image;
14+
use crate::oklch::Oklch;
1315
#[cfg(all(
1416
any(target_arch = "x86_64", target_arch = "x86"),
1517
target_feature = "sse4.1"
1618
))]
1719
use crate::sse::sse_oklab_to_image;
1820
use crate::{Oklab, TransferFunction};
19-
use crate::image_to_oklab::OklabTarget;
20-
use crate::oklch::Oklch;
2121

2222
fn oklab_to_image<const CHANNELS_CONFIGURATION: u8, const TARGET: u8>(
2323
src: &[f32],
@@ -134,7 +134,7 @@ pub fn oklab_to_rgba(
134134
height: u32,
135135
transfer_function: TransferFunction,
136136
) {
137-
oklab_to_image::<{ ImageConfiguration::Rgba as u8 }, {OklabTarget::OKLAB as u8}>(
137+
oklab_to_image::<{ ImageConfiguration::Rgba as u8 }, { OklabTarget::OKLAB as u8 }>(
138138
src,
139139
src_stride,
140140
dst,
@@ -164,7 +164,7 @@ pub fn oklab_to_rgb(
164164
height: u32,
165165
transfer_function: TransferFunction,
166166
) {
167-
oklab_to_image::<{ ImageConfiguration::Rgb as u8 }, {OklabTarget::OKLAB as u8}>(
167+
oklab_to_image::<{ ImageConfiguration::Rgb as u8 }, { OklabTarget::OKLAB as u8 }>(
168168
src,
169169
src_stride,
170170
dst,
@@ -194,7 +194,7 @@ pub fn oklab_to_bgr(
194194
height: u32,
195195
transfer_function: TransferFunction,
196196
) {
197-
oklab_to_image::<{ ImageConfiguration::Bgr as u8 }, {OklabTarget::OKLAB as u8}>(
197+
oklab_to_image::<{ ImageConfiguration::Bgr as u8 }, { OklabTarget::OKLAB as u8 }>(
198198
src,
199199
src_stride,
200200
dst,
@@ -224,7 +224,7 @@ pub fn oklab_to_bgra(
224224
height: u32,
225225
transfer_function: TransferFunction,
226226
) {
227-
oklab_to_image::<{ ImageConfiguration::Bgra as u8 }, {OklabTarget::OKLAB as u8}>(
227+
oklab_to_image::<{ ImageConfiguration::Bgra as u8 }, { OklabTarget::OKLAB as u8 }>(
228228
src,
229229
src_stride,
230230
dst,
@@ -254,7 +254,7 @@ pub fn oklch_to_rgba(
254254
height: u32,
255255
transfer_function: TransferFunction,
256256
) {
257-
oklab_to_image::<{ ImageConfiguration::Rgba as u8 }, {OklabTarget::OKLCH as u8}>(
257+
oklab_to_image::<{ ImageConfiguration::Rgba as u8 }, { OklabTarget::OKLCH as u8 }>(
258258
src,
259259
src_stride,
260260
dst,
@@ -284,7 +284,7 @@ pub fn oklch_to_rgb(
284284
height: u32,
285285
transfer_function: TransferFunction,
286286
) {
287-
oklab_to_image::<{ ImageConfiguration::Rgb as u8 }, {OklabTarget::OKLCH as u8}>(
287+
oklab_to_image::<{ ImageConfiguration::Rgb as u8 }, { OklabTarget::OKLCH as u8 }>(
288288
src,
289289
src_stride,
290290
dst,
@@ -314,7 +314,7 @@ pub fn oklch_to_bgr(
314314
height: u32,
315315
transfer_function: TransferFunction,
316316
) {
317-
oklab_to_image::<{ ImageConfiguration::Bgr as u8 }, {OklabTarget::OKLCH as u8}>(
317+
oklab_to_image::<{ ImageConfiguration::Bgr as u8 }, { OklabTarget::OKLCH as u8 }>(
318318
src,
319319
src_stride,
320320
dst,
@@ -344,7 +344,7 @@ pub fn oklch_to_bgra(
344344
height: u32,
345345
transfer_function: TransferFunction,
346346
) {
347-
oklab_to_image::<{ ImageConfiguration::Bgra as u8 }, {OklabTarget::OKLCH as u8}>(
347+
oklab_to_image::<{ ImageConfiguration::Bgra as u8 }, { OklabTarget::OKLCH as u8 }>(
348348
src,
349349
src_stride,
350350
dst,

0 commit comments

Comments
 (0)