Skip to content

Commit 16c218d

Browse files
committed
Enable conditional build of SIMD features
The packed_simd features enables SIMD. If the feature isn't enabled, ssimd is used, which uses plain structs to emulate simd vectors. When optimizations are enabled and the target architecture supports it, the compiler should still emit SIMD instructions for the ssimd code.
1 parent feeac4e commit 16c218d

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ exclude = ["tests/*"]
1313
[dependencies]
1414
byteorder = "1.0"
1515
rayon = { version = "1.0", optional = true }
16-
packed_simd = "0.3"
16+
ssimd = { git = "https://github.com/lovasoa/ssimd.git" }
17+
packed_simd = { version = "0.3", optional = true }
1718

1819
[dev-dependencies]
1920
png = "0.16"

src/idct.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
use crate::parser::Dimensions;
55
use std::num::Wrapping;
66

7-
use packed_simd::{
7+
#[cfg(feature = "packed_simd")]
8+
extern crate packed_simd;
9+
10+
#[cfg(feature = "packed_simd")]
11+
use self::packed_simd as simd;
12+
13+
#[cfg(not(feature = "packed_simd"))]
14+
extern crate ssimd;
15+
16+
#[cfg(not(feature = "packed_simd"))]
17+
use self::ssimd as simd;
18+
19+
use self::simd::{
820
i32x8, i16x8, u16x8, u8x8,
921
i32x4, i16x4, u16x4, u8x4,
1022
FromCast,

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
extern crate byteorder;
3333
#[cfg(feature="rayon")]
3434
extern crate rayon;
35-
extern crate packed_simd;
3635

3736
pub use decoder::{Decoder, ImageInfo, PixelFormat};
3837
pub use error::{Error, UnsupportedFeature};

0 commit comments

Comments
 (0)