aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-codec-support/src/vq/mod.rs
blob: 38ab9e3664c2ca144f8c4326eee8ff7835b60b91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Vector quantisation routines.
mod generic_elbg;
mod generic_mediancut;

pub trait VQElement: Sized+Copy+PartialEq {
    fn dist(&self, rval: Self) -> u32;
    fn min_cw() -> Self;
    fn max_cw() -> Self;
    fn min(&self, rval: Self) -> Self;
    fn max(&self, rval: Self) -> Self;
    fn num_components() -> usize;
    fn sort_by_component(arr: &mut [Self], component: usize);
    fn max_dist_component(min: &Self, max: &Self) -> usize;
}

pub trait VQElementSum<T: VQElement> {
    fn zero() -> Self;
    fn add(&mut self, rval: T, count: u64);
    fn get_centroid(&self) -> T;
}

pub use self::generic_elbg::ELBG;
pub use self::generic_mediancut::quantise_median_cut;