diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-05-30 12:07:17 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-05-30 12:07:17 +0200 |
commit | 971ae3066382f416b074c24df6b3213431856b81 (patch) | |
tree | 75dfcd8050ab883cf80f9946033aeb6847e67ee7 /nihav-codec-support/src/vq/mod.rs | |
parent | f0081142878786d1a07c61e4df2d2a318609b478 (diff) | |
download | nihav-971ae3066382f416b074c24df6b3213431856b81.tar.gz |
codec_support: add module for generic vector quantisation
Diffstat (limited to 'nihav-codec-support/src/vq/mod.rs')
-rw-r--r-- | nihav-codec-support/src/vq/mod.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nihav-codec-support/src/vq/mod.rs b/nihav-codec-support/src/vq/mod.rs new file mode 100644 index 0000000..38ab9e3 --- /dev/null +++ b/nihav-codec-support/src/vq/mod.rs @@ -0,0 +1,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; |