Skip to content

Commit

Permalink
Merge pull request #30 from awxkee/dev
Browse files Browse the repository at this point in the history
Added ubs for RGB8/RGBA8
  • Loading branch information
awxkee authored Jan 7, 2025
2 parents b2b9568 + 625c197 commit 69cf1f1
Show file tree
Hide file tree
Showing 10 changed files with 455 additions and 280 deletions.
2 changes: 1 addition & 1 deletion app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
image = { version = "0.25.5", features = ["default"] }
#image = { path= "../../../RustroverProjects/image", features = ["default", "avif", "avif-native"] }
pic-scale = { path = "..", features = ["half", "nightly_i8mm"], default-features = true }
pic-scale = { path = "..", features = ["half"], default-features = true }
fast_image_resize = { version = "5.0.0", features = [] }
half = { version = "2.4.1", default-features = true }

Expand Down
12 changes: 6 additions & 6 deletions app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() {
.decode()
.unwrap();
let dimensions = img.dimensions();
let transient = img.to_rgb8();
let transient = img.to_rgba8();
let mut bytes = Vec::from(transient.as_bytes());

let mut scaler = Scaler::new(ResamplingFunction::Lanczos3);
Expand All @@ -60,7 +60,7 @@ fn main() {

//
let store =
ImageStore::<u8, 3>::from_slice(&bytes, dimensions.0 as usize, dimensions.1 as usize)
ImageStore::<u8, 4>::from_slice(&bytes, dimensions.0 as usize, dimensions.1 as usize)
.unwrap();

let dst_size = ImageSize::new(dimensions.0 as usize / 4, dimensions.1 as usize / 4);
Expand All @@ -75,15 +75,15 @@ fn main() {
// )
// .unwrap();

let mut dst_store = ImageStoreMut::<u8, 3>::alloc_with_depth(
dimensions.0 as usize / 3,
dimensions.1 as usize / 3,
let mut dst_store = ImageStoreMut::<u8, 4>::alloc_with_depth(
dimensions.0 as usize / 4,
dimensions.1 as usize / 4,
10,
);

// for i in 0..25 {
let start_time = Instant::now();
scaler.resize_rgb(&store, &mut dst_store).unwrap();
scaler.resize_rgba(&store, &mut dst_store, false).unwrap();

let elapsed_time = start_time.elapsed();
// Print the elapsed time in milliseconds
Expand Down
6 changes: 4 additions & 2 deletions src/avx2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ mod alpha_u16;
mod alpha_u8;
mod check_alpha;
mod rgb_u8;
#[cfg(feature = "nightly_avx512")]
mod rgb_u8_dot_i8;
#[cfg(feature = "half")]
mod rgba_f16;
mod rgba_f32;
mod rgba_u8_dot_lp;
mod rgba_u8_lb;
pub(crate) mod utils;
#[cfg(feature = "half")]
Expand All @@ -48,6 +48,9 @@ mod vertical_u16_lb;
mod vertical_u8;
mod vertical_u8_lp;

pub(crate) use crate::avx2::rgba_u8_dot_lp::{
convolve_horizontal_rgba_row_dot, convolve_horizontal_rgba_rows_4_dot,
};
#[cfg(feature = "half")]
pub(crate) use alpha_f16::{avx_premultiply_alpha_rgba_f16, avx_unpremultiply_alpha_rgba_f16};
pub(crate) use alpha_f32::avx_premultiply_alpha_rgba_f32;
Expand All @@ -59,7 +62,6 @@ pub(crate) use check_alpha::{
avx_has_non_constant_cap_alpha_rgba16, avx_has_non_constant_cap_alpha_rgba8,
};
pub(crate) use rgb_u8::{convolve_horizontal_rgb_avx_row_one, convolve_horizontal_rgb_avx_rows_4};
#[cfg(feature = "nightly_avx512")]
pub(crate) use rgb_u8_dot_i8::{
convolve_horizontal_rgb_avx_row_i8_one, convolve_horizontal_rgb_avx_rows_4_i8,
};
Expand Down
Loading

0 comments on commit 69cf1f1

Please sign in to comment.