From 4347bba10cf40229706ee48a8a868a35c82cd4c0 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 15 Jun 2020 18:45:11 +0200 Subject: [PATCH] codec_support/vq: do not move empty group centroid --- nihav-codec-support/src/vq/generic_elbg.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 { -- 2.39.5