}
fn encode_residual(bw: &mut BitWriter, src: &[u32]) {
- let sum = src.iter().fold(0, |acc, &x| acc + x) / (src.len() as u32);
+ let sum = src.iter().sum::<u32>() / (src.len() as u32);
let k = (31 - sum.max(1).leading_zeros()) as u8;
if k < 16 {
ifilter: [i32; 32],
}
+#[allow(clippy::match_overlapping_arm)]
fn nsamples_code(nsamp: usize) -> u8 {
match nsamp {
192 => 1,
bw.write(1, 6);
bw.write0(); // no wasted bits
for &el in samp.iter() {
- bw.write_s(i32::from(el), samp_bits);
+ bw.write_s(el, samp_bits);
}
},
-1 | -2 | -3 | -4 => {
bw.write(8 | (order as u32), 6);
bw.write0(); // no wasted bits
for &el in samp[..order].iter() {
- bw.write_s(i32::from(el), samp_bits);
+ bw.write_s(el, samp_bits);
}
encode_residual(bw, &self.tmp[order..nsamples]);
},
bw.write(0x20 | ((order - 1) as u32), 6);
bw.write0(); // no wasted bits
for &el in samp[..order].iter() {
- bw.write_s(i32::from(el), samp_bits);
+ bw.write_s(el, samp_bits);
}
bw.write(filter_bits - 1, 4);
bw.write(filter_prec, 5);