use crate::convolution::{
ColumnFilter, ConvolutionOptions, HorizontalFilterPass, RowFilter, VerticalConvolutionPass,
};
use crate::factory::plane_u16::default_u16_column_plan;
use crate::filter_weights::FilterWeights;
use crate::plan::HorizontalFiltering;
use crate::{ImageStore, ThreadingPolicy};
use std::sync::Arc;
impl HorizontalFilterPass<u16, f32, 2> for ImageStore<'_, u16, 2> {
fn horizontal_plan(
filter_weights: FilterWeights<f32>,
threading_policy: ThreadingPolicy,
options: ConvolutionOptions,
) -> Arc<dyn RowFilter<u16, 2> + Send + Sync> {
if options.bit_depth <= 12 {
let approx =
filter_weights.numerical_approximation_i16::<{ crate::support::PRECISION }>(0);
#[cfg(all(target_arch = "aarch64", feature = "neon"))]
{
use crate::neon::{
convolve_horizontal_gray_alpha_neon_rows_4_lb_u16,
convolve_horizontal_gray_alpha_neon_u16_lb_row,
};
return Arc::new(HorizontalFiltering {
filter_weights: approx,
filter_4_rows: Some(convolve_horizontal_gray_alpha_neon_rows_4_lb_u16),
filter_row: convolve_horizontal_gray_alpha_neon_u16_lb_row,
threading_policy,
});
}
#[cfg(not(all(target_arch = "aarch64", feature = "neon")))]
{
use crate::fixed_point_horizontal::{
convolve_row_handler_fixed_point, convolve_row_handler_fixed_point_4,
};
return Arc::new(HorizontalFiltering {
filter_weights: approx,
filter_4_rows: Some(convolve_row_handler_fixed_point_4::<u16, i32, 2>),
filter_row: convolve_row_handler_fixed_point::<u16, i32, 2>,
threading_policy,
});
}
}
#[cfg(all(target_arch = "aarch64", feature = "neon"))]
{
use crate::neon::{
convolve_horizontal_cbcr_neon_f32_u16_row,
convolve_horizontal_cbcr_neon_rows_4_f32_u16,
};
Arc::new(HorizontalFiltering {
filter_weights,
filter_4_rows: Some(convolve_horizontal_cbcr_neon_rows_4_f32_u16),
filter_row: convolve_horizontal_cbcr_neon_f32_u16_row,
threading_policy,
})
}
#[cfg(not(all(target_arch = "aarch64", feature = "neon")))]
{
use crate::floating_point_horizontal::{
convolve_row_handler_floating_point, convolve_row_handler_floating_point_4,
};
Arc::new(HorizontalFiltering {
filter_weights,
filter_4_rows: Some(convolve_row_handler_floating_point_4::<u16, f32, f32, 2>),
filter_row: convolve_row_handler_floating_point::<u16, f32, f32, 2>,
threading_policy,
})
}
}
}
impl VerticalConvolutionPass<u16, f32, 2> for ImageStore<'_, u16, 2> {
fn vertical_plan(
filter_weights: FilterWeights<f32>,
threading_policy: ThreadingPolicy,
options: ConvolutionOptions,
) -> Arc<dyn ColumnFilter<u16, 2> + Send + Sync> {
default_u16_column_plan::<2>(filter_weights, threading_policy, options)
}
}