mirror of
https://github.com/Cykooz/fast_image_resize.git
synced 2026-10-07 17:01:09 +00:00
- Refactored support of no_std
- Added step in GitHub Action to check compilation for no_std.
This commit is contained in:
@@ -38,3 +38,7 @@ jobs:
|
||||
run: |
|
||||
cargo check --features rayon
|
||||
cargo test --features rayon
|
||||
|
||||
- name: Check compilation for no_std
|
||||
run: |
|
||||
cargo build --no-default-features --features=no_std
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
## [Unreleased] - ReleaseDate
|
||||
|
||||
### Added
|
||||
|
||||
- Added support of `no_std` environment ([#58](https://github.com/Cykooz/fast_image_resize/issues/58)).
|
||||
To use the crate in a such environment you must disable
|
||||
default features and enabled the `no_std` feature.
|
||||
|
||||
## [5.5.0] - 2026-01-02
|
||||
|
||||
### Added
|
||||
|
||||
Generated
+1
-1
@@ -580,7 +580,6 @@ dependencies = [
|
||||
"fast_image_resize",
|
||||
"image",
|
||||
"itertools 0.14.0",
|
||||
"libm",
|
||||
"libvips",
|
||||
"nix",
|
||||
"num-traits",
|
||||
@@ -1080,6 +1079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+9
-5
@@ -28,13 +28,17 @@ document-features = { version = "0.2.12", optional = true }
|
||||
image = { version = "0.25.6", optional = true, default-features = false }
|
||||
bytemuck = { version = "1.24", optional = true }
|
||||
rayon = { version = "1.11", optional = true }
|
||||
libm = "0.2.15"
|
||||
|
||||
|
||||
[features]
|
||||
# default = ["std"]
|
||||
## Whether or not to depend on the Rust `std`
|
||||
default = ["std"]
|
||||
## It must be enabled to use the crate in `std` environment.
|
||||
std = ["thiserror/std", "num-traits/std", "dep:document-features"]
|
||||
## This feature must be enabled to use the crate in `no_std` environment.
|
||||
## To prevent conflicts with the `std` feature it is not used for
|
||||
## conditional compilation. It just installs additional dependencies
|
||||
## or activates some features of existing dependencies.
|
||||
no_std = ["num-traits/libm"]
|
||||
## Enable this feature to implement traits [IntoImageView](crate::IntoImageView) and
|
||||
## [IntoImageViewMut](crate::IntoImageViewMut) for the
|
||||
## [DynamicImage](https://docs.rs/image/latest/image/enum.DynamicImage.html)
|
||||
@@ -44,10 +48,10 @@ std = ["thiserror/std", "num-traits/std", "dep:document-features"]
|
||||
image = ["std", "dep:image", "dep:bytemuck"]
|
||||
## Enable this feature to implement traits [bytemuck::Pod] and
|
||||
## [bytemuck::Zeroable] for the `Pixel` type.
|
||||
bytemuck = ["std", "dep:bytemuck"]
|
||||
bytemuck = ["dep:bytemuck"]
|
||||
## This feature enables image processing in the ` rayon ` thread pool.
|
||||
rayon = ["std", "dep:rayon", "resize/rayon", "image/rayon"]
|
||||
for_testing = ["image", "image/png", "bytemuck"]
|
||||
for_testing = ["std", "image", "image/png", "bytemuck"]
|
||||
only_u8x4 = [] # This can be used to experiment with the crate's code.
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,16 @@ that converts images from sRGB or gamma 2.2 into linear colorspace and back.
|
||||
You should enable `"rayon"` feature to turn on image processing in
|
||||
[rayon](https://docs.rs/rayon/latest/rayon/) thread pool.
|
||||
|
||||
## Use in a `no_std` environment
|
||||
|
||||
To use the crate in a `no_std` environment you must disable
|
||||
default features and enabled the `no_std` feature:
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
fast_image_resize = { version = "5.6", default-features = false, features = ["no_std"] }
|
||||
```
|
||||
|
||||
## Some benchmarks in single-threaded mode for x86_64
|
||||
|
||||
_All benchmarks:_
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::sse4;
|
||||
use crate::pixels::F32x2;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::sse4;
|
||||
|
||||
#[target_feature(enable = "avx2")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = F32x2>,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use super::AlphaMulDiv;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::F32x2;
|
||||
use crate::{ImageError, ImageView, ImageViewMut};
|
||||
|
||||
use super::AlphaMulDiv;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::F32x2;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
#[target_feature(enable = "sse4.1")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = F32x2>,
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::F32x4;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
#[target_feature(enable = "avx2")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = F32x4>,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use super::AlphaMulDiv;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::F32x4;
|
||||
use crate::{ImageError, ImageView, ImageViewMut};
|
||||
|
||||
use super::AlphaMulDiv;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::F32x4;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
#[target_feature(enable = "sse4.1")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = F32x4>,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use super::AlphaMulDiv;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::{CpuExtensions, ImageError, ImageView, ImageViewMut};
|
||||
|
||||
use super::AlphaMulDiv;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[target_feature(enable = "neon")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::wasm32::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U16x2>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = U16x2>,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use super::AlphaMulDiv;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::{CpuExtensions, ImageError, ImageView, ImageViewMut};
|
||||
|
||||
use super::AlphaMulDiv;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::neon_utils;
|
||||
use super::native;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[target_feature(enable = "neon")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
#[target_feature(enable = "sse4.1")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U16x4>,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::wasm32::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U16x4>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = U16x4>,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::sse4;
|
||||
use crate::pixels::U8x2;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
use super::sse4;
|
||||
|
||||
#[target_feature(enable = "avx2")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U8x2>,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use super::AlphaMulDiv;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::U8x2;
|
||||
use crate::{ImageError, ImageView, ImageViewMut};
|
||||
|
||||
use super::AlphaMulDiv;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::neon_utils;
|
||||
use super::native;
|
||||
use crate::pixels::U8x2;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[target_feature(enable = "neon")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::wasm32::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U8x2;
|
||||
use crate::wasm32_utils::u16x8_mul_add_shr16;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U8x2>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = U8x2>,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::pixels::U8x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::sse4;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[target_feature(enable = "avx2")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::neon_utils;
|
||||
use super::native;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[target_feature(enable = "neon")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::utils::foreach_with_pre_reading;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
#[target_feature(enable = "sse4.1")]
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U8x4>,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::wasm32::*;
|
||||
|
||||
use super::native;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::wasm32_utils::u16x8_mul_add_shr16;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) unsafe fn multiply_alpha(
|
||||
src_view: &impl ImageView<Pixel = U8x4>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = U8x4>,
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
use core::array::IntoIter;
|
||||
use core::iter::Take;
|
||||
use core::iter::{FusedIterator, Iterator};
|
||||
use core::iter::{FusedIterator, Iterator, Take};
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
/// An iterator over `N` elements of the iterator at a time.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use crate::float_ext::FloatExt;
|
||||
#[allow(unused_imports)]
|
||||
// It is used to implement floats in no_std
|
||||
use crate::compat::*;
|
||||
use crate::PixelComponentMapper;
|
||||
|
||||
fn gamma_into_linear(input: f32) -> f32 {
|
||||
|
||||
+1
-4
@@ -1,12 +1,9 @@
|
||||
//! Functions and structs for working with colorspace and gamma.
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::boxed::Box;
|
||||
|
||||
use num_traits::bounds::UpperBounded;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
use num_traits::Zero;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::pixels::{
|
||||
GetCount, InnerPixel, IntoPixelComponent, PixelComponent, PixelType, U16x2, U16x3, U16x4, U8x2,
|
||||
U8x3, U8x4, Values, U16, U8,
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//! This module is used as compatability layer to support `std` and `no_std`.
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
pub use std::boxed::Box;
|
||||
pub use std::{vec, vec::Vec};
|
||||
pub use std::borrow::ToOwned;
|
||||
} else {
|
||||
pub use alloc::boxed::Box;
|
||||
pub use alloc::{vec, vec::Vec};
|
||||
pub use alloc::borrow::ToOwned;
|
||||
|
||||
// `no_std` feature must be enabled
|
||||
pub use num_traits::Float;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
use super::{Coefficients, Convolution};
|
||||
use crate::convolution::vertical_f32::vert_convolution_f32;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::F32x2;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::{Coefficients, Convolution};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use super::{Coefficients, Convolution};
|
||||
use crate::convolution::vertical_f32::vert_convolution_f32;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::F32x3;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::{Coefficients, Convolution};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
use super::{Coefficients, Convolution};
|
||||
use crate::convolution::vertical_f32::vert_convolution_f32;
|
||||
use crate::cpu_extensions::CpuExtensions;
|
||||
use crate::pixels::F32x4;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
use super::{Coefficients, Convolution};
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
mod avx2;
|
||||
mod native;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use core::f64::consts::PI;
|
||||
use core::fmt::{Debug, Formatter};
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use crate::float_ext::FloatExt;
|
||||
#[allow(unused_imports)]
|
||||
// It is used to implement floats in no_std
|
||||
use crate::compat::*;
|
||||
|
||||
type FilterFn = fn(f64) -> f64;
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#[allow(unused_imports)]
|
||||
// It is used to implement floats in no_std
|
||||
use crate::compat::*;
|
||||
use crate::convolution::Coefficients;
|
||||
use crate::pixels::I32;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
pub(crate) fn horiz_convolution(
|
||||
src_view: &impl ImageView<Pixel = I32>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = I32>,
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
pub use filters::*;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{CpuExtensions, ImageView, ImageViewMut};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::borrow::ToOwned;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::Coefficients;
|
||||
|
||||
// This code is based on C-implementation from Pillow-SIMD package for Python
|
||||
// https://github.com/uploadcare/pillow-simd
|
||||
|
||||
@@ -256,6 +250,7 @@ macro_rules! try_process_in_threads_v {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::convolution::Bound;
|
||||
|
||||
fn get_coefficients(value: f64) -> Coefficients {
|
||||
Coefficients {
|
||||
values: vec![value],
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U16;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer32;
|
||||
use crate::pixels::U16;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer32;
|
||||
use crate::pixels::U16x2;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U16x3;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer32;
|
||||
use crate::pixels::U16x3;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer32;
|
||||
use crate::pixels::U16x4;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::borrow::ToOwned;
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U8;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::borrow::ToOwned;
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -2,8 +2,7 @@ use core::arch::wasm32::*;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8x2;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI16Chunk, Normalizer16};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U8x3;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -3,8 +3,7 @@ use core::mem::transmute;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8x3;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use core::arch::aarch64::*;
|
||||
|
||||
use crate::convolution::optimisations::{CoefficientsI16Chunk, Normalizer16};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -3,8 +3,7 @@ use core::mem::transmute;
|
||||
|
||||
use crate::convolution::optimisations::Normalizer16;
|
||||
use crate::pixels::U8x4;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn horiz_convolution(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::convolution::{Coefficients, CoefficientsChunk};
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) fn vert_convolution<T>(
|
||||
src_view: &impl ImageView<Pixel = T>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = T>,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
use core::arch::x86_64::*;
|
||||
|
||||
use super::native;
|
||||
use crate::convolution::{Coefficients, CoefficientsChunk};
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{simd_utils, ImageView, ImageViewMut};
|
||||
|
||||
use super::native;
|
||||
|
||||
pub(crate) fn vert_convolution<T>(
|
||||
src_view: &impl ImageView<Pixel = T>,
|
||||
dst_view: &mut impl ImageViewMut<Pixel = T>,
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{vec, vec::Vec};
|
||||
|
||||
use core::arch::aarch64::*;
|
||||
use core::mem::transmute;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
pub(crate) fn vert_convolution<T>(
|
||||
src_view: &impl ImageView<Pixel = T>,
|
||||
|
||||
@@ -3,8 +3,7 @@ use core::arch::wasm32::*;
|
||||
use crate::convolution::optimisations::{CoefficientsI32Chunk, Normalizer32};
|
||||
use crate::convolution::vertical_u16::native::convolution_by_u16;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
pub(crate) fn vert_convolution<T: InnerPixel<Component = u16>>(
|
||||
src_view: &impl ImageView<Pixel = T>,
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{vec, vec::Vec};
|
||||
|
||||
use core::arch::aarch64::*;
|
||||
use core::mem::transmute;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::optimisations::{CoefficientsI16Chunk, Normalizer16};
|
||||
use crate::neon_utils;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{neon_utils, ImageView, ImageViewMut};
|
||||
|
||||
pub(crate) fn vert_convolution<T>(
|
||||
src_view: &impl ImageView<Pixel = T>,
|
||||
|
||||
@@ -3,8 +3,7 @@ use core::arch::wasm32::*;
|
||||
use crate::convolution::optimisations::{CoefficientsI16Chunk, Normalizer16};
|
||||
use crate::convolution::vertical_u8::native;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::wasm32_utils;
|
||||
use crate::{ImageView, ImageViewMut};
|
||||
use crate::{wasm32_utils, ImageView, ImageViewMut};
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn vert_convolution<T: InnerPixel<Component = u8>>(
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
pub trait FloatExt {
|
||||
fn sin(self) -> Self;
|
||||
fn cos(self) -> Self;
|
||||
fn sqrt(self) -> Self;
|
||||
fn exp(self) -> Self;
|
||||
fn powf(self, exp: Self) -> Self;
|
||||
}
|
||||
|
||||
impl FloatExt for f32 {
|
||||
fn sin(self) -> Self {
|
||||
libm::sinf(self)
|
||||
}
|
||||
fn cos(self) -> Self {
|
||||
libm::cosf(self)
|
||||
}
|
||||
fn sqrt(self) -> Self {
|
||||
libm::sqrtf(self)
|
||||
}
|
||||
fn exp(self) -> Self {
|
||||
libm::expf(self)
|
||||
}
|
||||
fn powf(self, exp: f32) -> Self {
|
||||
libm::powf(self, exp)
|
||||
}
|
||||
}
|
||||
|
||||
impl FloatExt for f64 {
|
||||
fn sin(self) -> Self {
|
||||
libm::sin(self)
|
||||
}
|
||||
fn cos(self) -> Self {
|
||||
libm::cos(self)
|
||||
}
|
||||
fn sqrt(self) -> Self {
|
||||
libm::sqrt(self)
|
||||
}
|
||||
fn exp(self) -> Self {
|
||||
libm::exp(self)
|
||||
}
|
||||
fn powf(self, exp: f64) -> Self {
|
||||
libm::pow(self, exp)
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -1,14 +1,10 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
use core::num::NonZeroU32;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::images::{TypedCroppedImage, TypedCroppedImageMut, UnsafeImageMut};
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{ArrayChunks, ImageError, PixelTrait, PixelType};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
/// A trait for getting access to image data.
|
||||
///
|
||||
/// # Safety
|
||||
|
||||
+1
-3
@@ -1,6 +1,4 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{vec, vec::Vec};
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::images::{BufferContainer, TypedImage, TypedImageRef};
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
use core::ops::DerefMut;
|
||||
|
||||
use crate::image_view::try_pixel_type;
|
||||
use crate::images::{TypedImage, TypedImageRef};
|
||||
use crate::{ImageView, ImageViewMut, IntoImageView, IntoImageViewMut, PixelTrait, PixelType};
|
||||
use bytemuck::cast_slice_mut;
|
||||
use image::{
|
||||
DynamicImage, GrayAlphaImage, GrayImage, ImageBuffer, Luma, LumaA, Rgb, Rgb32FImage, RgbImage,
|
||||
Rgba, Rgba32FImage, RgbaImage,
|
||||
};
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::image_view::try_pixel_type;
|
||||
use crate::images::{TypedImage, TypedImageRef};
|
||||
use crate::{ImageView, ImageViewMut, IntoImageView, IntoImageViewMut, PixelTrait, PixelType};
|
||||
|
||||
impl IntoImageView for DynamicImage {
|
||||
fn pixel_type(&self) -> Option<PixelType> {
|
||||
match self {
|
||||
|
||||
+2
-2
@@ -1,6 +1,4 @@
|
||||
//! Contains different types of images and wrappers for them.
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
use core::fmt::Debug;
|
||||
|
||||
pub use cropped_image::*;
|
||||
@@ -9,6 +7,8 @@ pub use typed_cropped_image::*;
|
||||
pub use typed_image::*;
|
||||
pub(crate) use unsafe_image::UnsafeImageMut;
|
||||
|
||||
use crate::compat::*;
|
||||
|
||||
mod cropped_image;
|
||||
mod image;
|
||||
mod typed_cropped_image;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
use core::num::NonZeroU32;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::images::{View, ViewMut};
|
||||
use crate::{CropBoxError, ImageView, ImageViewMut};
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{vec, vec::Vec};
|
||||
use core::fmt::Debug;
|
||||
use core::num::NonZeroU32;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::images::BufferContainer;
|
||||
use crate::pixels::InnerPixel;
|
||||
use crate::{ImageBufferError, ImageView, ImageViewMut, InvalidPixelsSize};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
/// Generic reference to image data that provides [ImageView].
|
||||
#[derive(Debug)]
|
||||
pub struct TypedImageRef<'a, P> {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
use core::marker::PhantomData;
|
||||
use core::num::NonZeroU32;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::{ArrayChunks, ImageView, ImageViewMut};
|
||||
|
||||
#[derive(Copy)]
|
||||
|
||||
+10
-4
@@ -1,12 +1,17 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![no_std]
|
||||
#![doc = include_str!("../README.md")]
|
||||
|
||||
//!
|
||||
//! ## Feature flags
|
||||
#![cfg_attr(feature = "std", doc = document_features::document_features!())]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
extern crate std;
|
||||
} else {
|
||||
extern crate alloc;
|
||||
}
|
||||
}
|
||||
|
||||
pub use alpha::errors::*;
|
||||
pub use array_chunks::*;
|
||||
@@ -27,6 +32,8 @@ use crate::alpha::AlphaMulDiv;
|
||||
#[macro_use]
|
||||
mod utils;
|
||||
|
||||
mod compat;
|
||||
|
||||
mod alpha;
|
||||
mod array_chunks;
|
||||
mod change_components_type;
|
||||
@@ -35,7 +42,6 @@ mod convolution;
|
||||
mod cpu_extensions;
|
||||
mod crop_box;
|
||||
mod errors;
|
||||
mod float_ext;
|
||||
mod image_view;
|
||||
pub mod images;
|
||||
mod mul_div;
|
||||
|
||||
+3
-2
@@ -4,8 +4,9 @@ use core::marker::PhantomData;
|
||||
use core::mem::size_of;
|
||||
use core::slice;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
#[allow(unused_imports)]
|
||||
// It is used to implement floats in no_std
|
||||
use crate::compat::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
|
||||
+1
-6
@@ -1,6 +1,4 @@
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::compat::*;
|
||||
use crate::convolution::{self, FilterType};
|
||||
use crate::crop_box::CroppedSrcImageView;
|
||||
use crate::image_view::{try_pixel_type, ImageView, ImageViewMut, IntoImageView, IntoImageViewMut};
|
||||
@@ -10,9 +8,6 @@ use crate::{
|
||||
CpuExtensions, CropBox, DifferentDimensionsError, MulDiv, PixelTrait, PixelType, ResizeError,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum ResizeAlg {
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
use std::cell::RefCell;
|
||||
use core::cell::RefCell;
|
||||
use std::string::{String, ToString};
|
||||
use std::thread_local;
|
||||
use std::vec::Vec;
|
||||
|
||||
thread_local!(static TEST_LOGS: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user