From: Kostya Shishkov Date: Mon, 15 Jun 2020 16:45:11 +0000 (+0200) Subject: codec_support/vq: do not move empty group centroid X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=4347bba10cf40229706ee48a8a868a35c82cd4c0;p=nihav.git codec_support/vq: do not move empty group centroid --- diff --git a/nihav-codec-support/src/vq/generic_elbg.rs b/nihav-codec-support/src/vq/generic_elbg.rs index b2c838d..3c3e3c0 100644 --- a/nihav-codec-support/src/vq/generic_elbg.rs +++ b/nihav-codec-support/src/vq/generic_elbg.rs @@ -51,7 +51,9 @@ impl> Cluster { self.dist += u64::from(self.centroid.dist(entry.val)) * entry.count; } fn calc_centroid(&mut self) { - self.centroid = self.sum.get_centroid(); + if self.count > 0 { + self.centroid = self.sum.get_centroid(); + } } fn calc_dist(&mut self) { if self.count != 0 {