diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-02-23 18:25:35 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-02-23 18:25:35 +0100 |
commit | b790a725496c9d4385fa8a869af2b5cb6f3ffdd5 (patch) | |
tree | 661021dd101c7f6e2819ea089c04585c6b7d56ef /nihav-commonfmt | |
parent | 9f7faaf36e8a2c7d51cfd415d92ae5ebfb4983e4 (diff) | |
download | nihav-b790a725496c9d4385fa8a869af2b5cb6f3ffdd5.tar.gz |
cinepakenc: in hybrid VQ mode do not run ELBG refinement for < 256 entries
Diffstat (limited to 'nihav-commonfmt')
-rw-r--r-- | nihav-commonfmt/src/codecs/cinepakenc.rs | 20 |
1 files changed, 14 insertions, 6 deletions
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::<YUVCode, YUVCodeSum>(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); - quantise_median_cut::<YUVCode, YUVCodeSum>(&self.v4_entries, &mut self.v4_cur_cb[self.cur_strip]); - let mut elbg_v1: ELBG<YUVCode, YUVCodeSum> = ELBG::new(&self.v1_cur_cb[self.cur_strip]); - let mut elbg_v4: ELBG<YUVCode, YUVCodeSum> = 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::<YUVCode, YUVCodeSum>(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); + let v4_len = quantise_median_cut::<YUVCode, YUVCodeSum>(&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<YUVCode, YUVCodeSum> = 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<YUVCode, YUVCodeSum> = 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::<YUVCode, YUVCodeSum>(&self.v1_entries, &mut self.v1_cur_cb[self.cur_strip]); |