From: Kostya Shishkov Date: Thu, 23 Feb 2023 17:25:35 +0000 (+0100) Subject: cinepakenc: in hybrid VQ mode do not run ELBG refinement for < 256 entries X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=b790a725496c9d4385fa8a869af2b5cb6f3ffdd5;p=nihav.git cinepakenc: in hybrid VQ mode do not run ELBG refinement for < 256 entries --- diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs index 5ce22ee..3f999e7 100644 --- a/nihav-commonfmt/src/codecs/cinepakenc.rs +++ b/nihav-commonfmt/src/codecs/cinepakenc.rs @@ -618,12 +618,20 @@ impl CinepakEncoder { self.v4_len = elbg_v4.quantise(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]); }, QuantMode::Hybrid => { - quantise_median_cut::(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); - quantise_median_cut::(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]); - let mut elbg_v1: ELBG = ELBG::new(&self.v1_cur_cb[self.cur_strip]); - let mut elbg_v4: ELBG = ELBG::new(&self.v4_cur_cb[self.cur_strip]); - self.v1_len = elbg_v1.quantise(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); - self.v4_len = elbg_v4.quantise(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]); + let v1_len = quantise_median_cut::(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); + let v4_len = quantise_median_cut::(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]); + self.v1_len = if v1_len < 256 { + v1_len + } else { + let mut elbg_v1: ELBG = ELBG::new(&self.v1_cur_cb[self.cur_strip]); + elbg_v1.quantise(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]) + }; + self.v4_len = if v4_len < 256 { + v4_len + } else { + let mut elbg_v4: ELBG = ELBG::new(&self.v4_cur_cb[self.cur_strip]); + elbg_v4.quantise(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]) + }; }, QuantMode::MedianCut => { self.v1_len = quantise_median_cut::(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]);