projects
/
nihav.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
msvideo1enc: get rid of small repeated allocation
[nihav.git]
/
nihav-ms
/
src
/
codecs
/
msvideo1enc.rs
diff --git
a/nihav-ms/src/codecs/msvideo1enc.rs
b/nihav-ms/src/codecs/msvideo1enc.rs
index cdad0ce2aa49a2e9b50f624b85d1efe2bda85fcc..8a6281d6217718985cb00bbe8ba41586abce1a6e 100644
(file)
--- a/
nihav-ms/src/codecs/msvideo1enc.rs
+++ b/
nihav-ms/src/codecs/msvideo1enc.rs
@@
-50,7
+50,8
@@
impl VQElement for Pixel16 {
for i in 0..31 {
offs[i + 1] = offs[i] + counts[i];
}
for i in 0..31 {
offs[i + 1] = offs[i] + counts[i];
}
- let mut dst = vec![Pixel16(0); arr.len()];
+ let mut dst = [Pixel16(0); 16];
+ assert!(dst.len() >= arr.len());
for pix in arr.iter() {
let (r, g, b) = pix.unpack();
let idx = match component {
for pix in arr.iter() {
let (r, g, b) = pix.unpack();
let idx = match component {
@@
-61,7
+62,8
@@
impl VQElement for Pixel16 {
dst[offs[idx]] = *pix;
offs[idx] += 1;
}
dst[offs[idx]] = *pix;
offs[idx] += 1;
}
- arr.copy_from_slice(dst.as_slice());
+ let len = arr.len();
+ arr.copy_from_slice(&dst[..len]);
}
fn max_dist_component(min: &Self, max: &Self) -> usize {
let (r0, g0, b0) = max.unpack();
}
fn max_dist_component(min: &Self, max: &Self) -> usize {
let (r0, g0, b0) = max.unpack();