use crate::dark_aq::DarkAqConfig;
use crate::quant_weights::DequantMatrices;
use crate::thread_pool::ThreadPool;
use crate::{
Speed, adaptive_quant, dct, enc_ac_strategy, enc_color_correlation, enc_group, enc_xyb,
inflated_cost,
};
pub(crate) struct EncodingContext {
pub(crate) thread_pool: ThreadPool,
pub(crate) speed: Speed,
pub(crate) boost: Option<DarkAqConfig>,
pub(crate) matrices: &'static DequantMatrices,
pub(crate) to_xyb_band: enc_xyb::ToXybBandFn,
pub(crate) fill_quant_field: adaptive_quant::FillQuantFieldFn,
pub(crate) sse_and_rate: inflated_cost::SseAndRateFn,
pub(crate) rate_log2_lut: &'static inflated_cost::RateLog2Lut,
pub(crate) quantize_block_ac: enc_group::QuantizeBlockAcFn,
pub(crate) apply_cfl: enc_ac_strategy::ApplyCflFn,
pub(crate) cfl_regression: enc_color_correlation::CflRegressionFn,
pub(crate) dct8x8: &'static dct::DctFn<8, 8, 64>,
pub(crate) dct8x16: &'static dct::DctFn<16, 8, 128>,
pub(crate) dct16x8: &'static dct::DctFn<8, 16, 128>,
pub(crate) dct16x16: &'static dct::DctFn<16, 16, 256>,
pub(crate) dct4x4: &'static dct::DctFn<8, 8, 64>,
pub(crate) dct4x8: &'static dct::DctFn<8, 8, 64>,
pub(crate) dct8x4: &'static dct::DctFn<8, 8, 64>,
pub(crate) dct32x32: &'static dct::DctFn<32, 32, 1024>,
pub(crate) dct32x16: &'static dct::DctFn<16, 32, 512>,
pub(crate) dct16x32: &'static dct::DctFn<32, 16, 512>,
}
impl EncodingContext {
pub(crate) fn new(
speed: Speed,
boost: Option<DarkAqConfig>,
distance: f32,
num_threads: usize,
) -> Self {
Self {
thread_pool: ThreadPool::new(num_threads),
speed,
boost,
matrices: DequantMatrices::new(distance),
to_xyb_band: enc_xyb::selected_to_xyb_band_fn(),
fill_quant_field: adaptive_quant::selected_fill_quant_field_fn(),
sse_and_rate: inflated_cost::selected_sse_and_rate_fn(),
rate_log2_lut: inflated_cost::rate_log2_lut(),
quantize_block_ac: enc_group::selected_quantize_block_ac_fn(),
apply_cfl: enc_ac_strategy::selected_apply_cfl_fn(),
cfl_regression: enc_color_correlation::selected_cfl_regression_fn(),
dct8x8: dct::selected_dct8x8(),
dct8x16: dct::selected_dct8x16(),
dct16x8: dct::selected_dct16x8(),
dct16x16: dct::selected_dct16x16(),
dct4x4: dct::selected_dct4x4(),
dct4x8: dct::selected_dct4x8(),
dct8x4: dct::selected_dct8x4(),
dct32x32: dct::selected_dct32x32(),
dct32x16: dct::selected_dct32x16(),
dct16x32: dct::selected_dct16x32(),
}
}
}
impl Default for EncodingContext {
#[inline]
fn default() -> Self {
Self::new(Speed::Fast, None, 1.0, 1)
}
}