Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace = { members = ["app/accelerate", "app"], exclude = ["fuzz"] }

[package]
name = "libblur"
version = "0.23.2"
version = "0.23.3"
edition = "2021"
description = "Fast image blurring in pure Rust"
readme = "./README.md"
Expand Down
40 changes: 20 additions & 20 deletions app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ fn main() {
// FastBlurChannels::Channels4,
// );

let mut z0 = v_vec
.iter()
.map(|&x| (x as f32 * (1. / 255.)))
.collect::<Vec<_>>();
let mut cvt = BlurImageMut::borrow(
&mut z0,
// let mut z0 = v_vec
// .iter()
// .map(|&x| (x as f32 * (1. / 255.)))
// .collect::<Vec<_>>();
let mut cvt = BlurImage::borrow(
&mut v_vec,
dyn_image.width(),
dyn_image.height(),
FastBlurChannels::Channels3,
Expand All @@ -148,7 +148,7 @@ fn main() {
let gaussian_kernel = gaussian_kernel_2d(500., 500 / 2);
// let gaussian_kernel = complex_gaussian_kernel(500., 0.75, 5.);

// let mut dst_image = BlurImageMut::default(); //cvt.clone_as_mut();
let mut dst_image = BlurImageMut::default(); //cvt.clone_as_mut();

// gaussian_blur(
// &cvt,
Expand All @@ -160,17 +160,17 @@ fn main() {
// )
// .unwrap();
//
// gaussian_blur(
// &cvt,
// &mut dst_image,
// GaussianBlurParams::new_from_sigma(500.),
// EdgeMode::Reflect.as_2d(),
// ThreadingPolicy::Single,
// ConvolutionMode::Exact,
// )
// .unwrap();
gaussian_blur(
&cvt,
&mut dst_image,
GaussianBlurParams::new_from_sigma(31.),
EdgeMode::Reflect.as_2d(),
ThreadingPolicy::Single,
ConvolutionMode::Exact,
)
.unwrap();

stack_blur_f32(&mut cvt, AnisotropicRadius::new(8), ThreadingPolicy::Single).unwrap();
// stack_blur_f32(&mut cvt, AnisotropicRadius::new(8), ThreadingPolicy::Single).unwrap();

// filter_2d_rgb_fft::<u8, f32>(
// &cvt,
Expand Down Expand Up @@ -238,12 +238,12 @@ fn main() {

// dst_image = vzd.gamma8(TransferFunction::Srgb, false).unwrap();
//
dst_bytes = cvt
dst_bytes = dst_image
.data
.borrow_mut()
.iter()
// .map(|&x| x)
.map(|&x| (x * 255f32).round() as u8)
.map(|&x| x)
// .map(|&x| (x * 255f32).round() as u8)
// .map(|&x| (x >> 8) as u8)
.collect::<Vec<u8>>();

Expand Down
12 changes: 6 additions & 6 deletions src/filter1d/avx/filter_column_symm_approx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(

let coeff = _mm256_set1_epi32(*v_prepared.get_unchecked(half_len));

while cx + 128 < image_width {
while cx + 128 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm256_load_pack_x4(v_src.as_ptr());
Expand Down Expand Up @@ -146,7 +146,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(
cx += 128;
}

while cx + 64 < image_width {
while cx + 64 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm256_load_pack_x2(v_src.as_ptr());
Expand Down Expand Up @@ -176,7 +176,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(
cx += 64;
}

while cx + 32 < image_width {
while cx + 32 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm256_loadu_si256(v_src.as_ptr() as *const __m256i);
Expand All @@ -202,7 +202,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(
cx += 32;
}

while cx + 16 < image_width {
while cx + 16 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm_loadu_si128(v_src.as_ptr() as *const __m128i);
Expand All @@ -228,7 +228,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(
cx += 16;
}

while cx + 8 < image_width {
while cx + 8 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm_loadu_si64(v_src.as_ptr() as *const _);
Expand All @@ -254,7 +254,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl(
cx += 8;
}

while cx + 4 < image_width {
while cx + 4 <= image_width {
let v_src = ref0.get_unchecked(cx..);

let source = _mm_loadu_si32(v_src.as_ptr() as *const _);
Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/filter_column_symm_approx_x2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl_x2(

let coeff = _mm256_set1_epi32(*v_prepared.get_unchecked(half_len));

while cx + 64 < image_width {
while cx + 64 <= image_width {
let v_src0 = ref0.get_unchecked(cx..);
let v_src1 = ref1.get_unchecked(cx..);

Expand Down Expand Up @@ -153,7 +153,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl_x2(
cx += 64;
}

while cx + 32 < image_width {
while cx + 32 <= image_width {
let v_src0 = ref0.get_unchecked(cx..);
let v_src1 = ref1.get_unchecked(cx..);

Expand Down Expand Up @@ -231,7 +231,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl_x2(
cx += 16;
}

while cx + 8 < image_width {
while cx + 8 <= image_width {
let v_src0 = ref0.get_unchecked(cx..);
let v_src1 = ref1.get_unchecked(cx..);

Expand Down Expand Up @@ -269,7 +269,7 @@ unsafe fn filter_column_avx_symm_u8_i32_impl_x2(
cx += 8;
}

while cx + 4 < image_width {
while cx + 4 <= image_width {
let v_src0 = ref0.get_unchecked(cx..);
let v_src1 = ref1.get_unchecked(cx..);

Expand Down
10 changes: 5 additions & 5 deletions src/filter1d/avx/filter_row_symm_u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl<const FMA: bool, const N: usize> RowSymmExecutionUnit<FMA, N> {

let coeff = _mm256_set1_ps(scanned_kernel.get_unchecked(half_len).weight);

while cx + 64 < max_width {
while cx + 64 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand Down Expand Up @@ -184,7 +184,7 @@ impl<const FMA: bool, const N: usize> RowSymmExecutionUnit<FMA, N> {
cx += 64;
}

while cx + 32 < max_width {
while cx + 32 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand Down Expand Up @@ -212,7 +212,7 @@ impl<const FMA: bool, const N: usize> RowSymmExecutionUnit<FMA, N> {
cx += 32;
}

while cx + 16 < max_width {
while cx + 16 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand All @@ -235,7 +235,7 @@ impl<const FMA: bool, const N: usize> RowSymmExecutionUnit<FMA, N> {
cx += 16;
}

while cx + 8 < max_width {
while cx + 8 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand All @@ -258,7 +258,7 @@ impl<const FMA: bool, const N: usize> RowSymmExecutionUnit<FMA, N> {
cx += 8;
}

while cx + 4 < max_width {
while cx + 4 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/filter_row_symm_uq15_u16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ unsafe fn filter_row_avx_symm_uq15_u16_impl<const N: usize>(

let coeff = _mm256_set1_epi32(scanned_kernel.get_unchecked(half_len).weight as i32);

while cx + 64 < max_width {
while cx + 64 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand Down Expand Up @@ -123,7 +123,7 @@ unsafe fn filter_row_avx_symm_uq15_u16_impl<const N: usize>(
cx += 64;
}

while cx + 32 < max_width {
while cx + 32 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand Down Expand Up @@ -177,7 +177,7 @@ unsafe fn filter_row_avx_symm_uq15_u16_impl<const N: usize>(
cx += 16;
}

while cx + 8 < max_width {
while cx + 8 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source =
Expand All @@ -199,7 +199,7 @@ unsafe fn filter_row_avx_symm_uq15_u16_impl<const N: usize>(
cx += 8;
}

while cx + 4 < max_width {
while cx + 4 <= max_width {
let shifted_src = local_src.get_unchecked(cx..);

let source = _mm_loadu_si64(shifted_src.get_unchecked(half_len * N..).as_ptr() as *const _);
Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/row_symm_approx_binter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<const N: usize> ExecutionUnit<N> {

let coeff = _mm256_set1_epi32(*v_prepared.get_unchecked(half_len));

while m_cx + 32 < max_width {
while m_cx + 32 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand All @@ -158,7 +158,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 32;
}

while m_cx + 16 < max_width {
while m_cx + 16 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand All @@ -182,7 +182,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 16;
}

while m_cx + 8 < max_width {
while m_cx + 8 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand All @@ -206,7 +206,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 8;
}

while m_cx + 4 < max_width {
while m_cx + 4 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/row_symm_approx_binter3_uq0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<const N: usize> ExecutionUnit<N> {
let m_right = width.saturating_sub(half_len);
let max_width = m_right * N;

while m_cx + 32 < max_width {
while m_cx + 32 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -158,7 +158,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 32;
}

while m_cx + 16 < max_width {
while m_cx + 16 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -206,7 +206,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 16;
}

while m_cx + 8 < max_width {
while m_cx + 8 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -241,7 +241,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 8;
}

while m_cx + 4 < max_width {
while m_cx + 4 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/row_symm_approx_binter5_uq0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<const N: usize> ExecutionUnit<N> {
let m_right = width.saturating_sub(half_len);
let max_width = m_right * N;

while m_cx + 32 < max_width {
while m_cx + 32 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -179,7 +179,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 32;
}

while m_cx + 16 < max_width {
while m_cx + 16 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -247,7 +247,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 16;
}

while m_cx + 8 < max_width {
while m_cx + 8 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -295,7 +295,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 8;
}

while m_cx + 4 < max_width {
while m_cx + 4 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down
8 changes: 4 additions & 4 deletions src/filter1d/avx/row_symm_approx_binter_uq0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl<const N: usize> ExecutionUnit<N> {
let coeff = _mm256_set1_epi32(*v_prepared.get_unchecked(half_len));
let rnd = _mm256_set1_epi16(1 << 6);

while m_cx + 32 < max_width {
while m_cx + 32 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -193,7 +193,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 32;
}

while m_cx + 16 < max_width {
while m_cx + 16 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -240,7 +240,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 16;
}

while m_cx + 8 < max_width {
while m_cx + 8 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down Expand Up @@ -278,7 +278,7 @@ impl<const N: usize> ExecutionUnit<N> {
m_cx += 8;
}

while m_cx + 4 < max_width {
while m_cx + 4 <= max_width {
let cx = m_cx - s_half;
let shifted_src = src.get_unchecked(cx..);

Expand Down
Loading