let mut doff = $xpos + $ypos * 256;
for _y in 0..$h {
for x in 0..$w {
- $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $ydelta).max(0).min(255) as u8;
+ $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $ydelta).clamp(0, 255) as u8;
}
soff += 256;
doff += 256;
let mut doff = CHROMA_OFF + $xpos / 2 + $ypos / 2 * 256;
for _y in 0..$h / 2 {
for x in 0..$w / 2 {
- $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $udelta).max(0).min(255) as u8;
- $bufs[$dst_id][doff + x + 128] = (i32::from($bufs[$src_id][soff + x + 128]) + $vdelta).max(0).min(255) as u8;
+ $bufs[$dst_id][doff + x] = (i32::from($bufs[$src_id][soff + x]) + $udelta).clamp(0, 255) as u8;
+ $bufs[$dst_id][doff + x + 128] = (i32::from($bufs[$src_id][soff + x + 128]) + $vdelta).clamp(0, 255) as u8;
}
soff += 256;
doff += 256;
for (dline, row) in dst.chunks_mut(256).zip(blk.chunks_mut(4)) {
transform!(row[0], row[1], row[2], row[3], 1, 1);
for (out, coef) in dline.iter_mut().zip(row.iter_mut()) {
- *out = (i32::from(*out) + ((*coef + 0x20) >> 6)).max(0).min(255) as u8;
+ *out = (i32::from(*out) + ((*coef + 0x20) >> 6)).clamp(0, 255) as u8;
}
}
}
if num_zero > 0 && coef_left > 0 {
let run = if num_zero < 7 {
br.read_cb(&codebooks.zero_run_cb[num_zero as usize - 1])?
+ } else if br.peek(3) != 0 {
+ 7 - (br.read(3)? as u8)
} else {
- if br.peek(3) != 0 {
- 7 - (br.read(3)? as u8)
- } else {
- (br.read_unary()? as u8) + 4
- }
+ (br.read_unary()? as u8) + 4
};
validate!(run <= num_zero);
idx -= run;
self.decode_block(br, xpos, ypos + hh, w, hh)?;
},
3 => { self.do_mc_bias(br, xpos, ypos, w, h)?; },
- 4 | 5 | 6 => {
+ 4..=6 => {
let ref_id = (mode - 4) as usize;
self.do_mc(br, xpos, ypos, w, h, ref_id)?;
},
self.intra_pred4x4(br, xpos, ypos, w, h)?;
}
},
- 16 | 17 | 18 => {
+ 16..=18 => {
let ref_id = (mode - 16) as usize;
self.do_mc(br, xpos, ypos, w, h, ref_id)?;
self.decode_residue(br, xpos, ypos, w, h)?;
self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
if let Some(edata) = info.get_extradata() {
- validate!(edata.len() > 0);
+ validate!(!edata.is_empty());
let fps = edata[0] as usize;
validate!(fps <= 60);
let base = &QUANTISERS[(fps % 6) * 8..][..8];
let mut cell4 = [0; 20];
match mode {
- 0 | 1 | 2 => {
+ 0..=2 => {
for y in (0..self.cell.get_height()).step_by(4) {
for x in (0..self.cell.get_width()).step_by(4) {
Self::get_cell4(&self.buf, x, y, stride, &mut cell4);
let mut ccell4 = [0; 20];
let mut pcell4 = [0; 20];
match mode {
- 0 | 1 | 2 => {
+ 0..=2 => {
for y in (0..self.cell.get_height()).step_by(4) {
for x in (0..self.cell.get_width()).step_by(4) {
Self::get_cell4(&self.buf, x, y, stride, &mut ccell4);