fast_image_resize/convolution/f32x3/
mod.rs1use crate::convolution::vertical_f32::vert_convolution_f32;
2use crate::cpu_extensions::CpuExtensions;
3use crate::pixels::F32x3;
4use crate::{ImageView, ImageViewMut};
5
6use super::{Coefficients, Convolution};
7
8#[cfg(target_arch = "x86_64")]
9mod avx2;
10mod native;
11#[cfg(target_arch = "x86_64")]
14mod sse4;
15type P = F32x3;
19
20impl Convolution for P {
21 fn horiz_convolution(
22 src_view: &impl ImageView<Pixel = Self>,
23 dst_view: &mut impl ImageViewMut<Pixel = Self>,
24 offset: u32,
25 coeffs: Coefficients,
26 cpu_extensions: CpuExtensions,
27 ) {
28 debug_assert!(src_view.height() - offset >= dst_view.height());
29 let coeffs_ref = &coeffs;
30
31 try_process_in_threads_h! {
32 horiz_convolution(
33 src_view,
34 dst_view,
35 offset,
36 coeffs_ref,
37 cpu_extensions,
38 );
39 }
40 }
41
42 fn vert_convolution(
43 src_view: &impl ImageView<Pixel = Self>,
44 dst_view: &mut impl ImageViewMut<Pixel = Self>,
45 offset: u32,
46 coeffs: Coefficients,
47 cpu_extensions: CpuExtensions,
48 ) {
49 debug_assert!(src_view.width() - offset >= dst_view.width());
50
51 let coeffs_ref = &coeffs;
52
53 try_process_in_threads_v! {
54 vert_convolution(
55 src_view,
56 dst_view,
57 offset,
58 coeffs_ref,
59 cpu_extensions,
60 );
61 }
62 }
63}
64
65fn horiz_convolution(
66 src_view: &impl ImageView<Pixel = P>,
67 dst_view: &mut impl ImageViewMut<Pixel = P>,
68 offset: u32,
69 coeffs: &Coefficients,
70 cpu_extensions: CpuExtensions,
71) {
72 match cpu_extensions {
73 #[cfg(target_arch = "x86_64")]
74 CpuExtensions::Avx2 => avx2::horiz_convolution(src_view, dst_view, offset, coeffs),
75 #[cfg(target_arch = "x86_64")]
76 CpuExtensions::Sse4_1 => sse4::horiz_convolution(src_view, dst_view, offset, coeffs),
77 _ => native::horiz_convolution(src_view, dst_view, offset, coeffs),
82 }
83}
84
85fn vert_convolution(
86 src_view: &impl ImageView<Pixel = P>,
87 dst_view: &mut impl ImageViewMut<Pixel = P>,
88 offset: u32,
89 coeffs: &Coefficients,
90 cpu_extensions: CpuExtensions,
91) {
92 vert_convolution_f32(src_view, dst_view, offset, coeffs, cpu_extensions);
93}