+macro_rules! idct {
+ ($src: expr, $sstep: expr, $dst: expr, $dstep: expr, $bias: expr, $shift: expr, $dtype: tt) => {
+ let s0 = $src[0] as i32;
+ let s1 = $src[$sstep] as i32;
+ let s2 = $src[$sstep * 2] as i32;
+ let s3 = $src[$sstep * 3] as i32;
+ let s4 = $src[$sstep * 4] as i32;
+ let s5 = $src[$sstep * 5] as i32;
+ let s6 = $src[$sstep * 6] as i32;
+ let s7 = $src[$sstep * 7] as i32;
+
+ let t0 = (s0 + s4).wrapping_mul(1448);
+ let t1 = (s0 - s4).wrapping_mul(1448);
+ let t2 = s2.wrapping_mul(1892) + s6.wrapping_mul(784);
+ let t3 = s2.wrapping_mul(784) - s6.wrapping_mul(1892);
+ let t4 = s1.wrapping_mul(2009) + s3.wrapping_mul(1703)
+ + s5.wrapping_mul(1138) + s7.wrapping_mul(400);
+ let t5 = s1.wrapping_mul(1703) - s3.wrapping_mul(400)
+ - s5.wrapping_mul(2009) - s7.wrapping_mul(1138);
+ let t6 = s1.wrapping_mul(1138) - s3.wrapping_mul(2009)
+ + s5.wrapping_mul(400) + s7.wrapping_mul(1703);
+ let t7 = s1.wrapping_mul(400) - s3.wrapping_mul(1138)
+ + s5.wrapping_mul(1703) - s7.wrapping_mul(2009);
+
+ let t8 = t0 + t2;
+ let t9 = t0 - t2;
+ let ta = t1 + t3;
+ let tb = t1 - t3;
+
+ $dst[0] = ((t8 + t4 + $bias) >> $shift) as $dtype;
+ $dst[$dstep] = ((ta + t5 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 2] = ((tb + t6 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 3] = ((t9 + t7 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 4] = ((t9 - t7 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 5] = ((tb - t6 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 6] = ((ta - t5 + $bias) >> $shift) as $dtype;
+ $dst[$dstep * 7] = ((t8 - t4 + $bias) >> $shift) as $dtype;
+ }
+}
+
+impl BlockDSP for RV20BlockDSP {
+ fn idct(&self, blk: &mut [i16; 64]) {
+ let mut tmp = [0i32; 64];
+ for (dst, src) in tmp.chunks_mut(8).zip(blk.chunks(8)) {
+ idct!(src, 1, dst, 1, 0, 4, i32);
+ }
+ for i in 0..8 {
+ idct!(&tmp[i..], 8, &mut blk[i..], 8, 1 << 19, 20, i16);
+ }
+ }
+ fn copy_blocks(&self, dst: &mut NAVideoBuffer<u8>, src: &NAVideoBuffer<u8>, xpos: usize, ypos: usize, w: usize, h: usize, mv: MV) {
+ let srcx = ((mv.x >> 1) as isize) + (xpos as isize);
+ let srcy = ((mv.y >> 1) as isize) + (ypos as isize);
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
+
+ blockdsp::copy_blocks(dst, src, xpos, ypos, srcx, srcy, w, h, 0, 1, mode, H263_INTERP_FUNCS);
+ }
+ fn avg_blocks(&self, dst: &mut NAVideoBuffer<u8>, src: &NAVideoBuffer<u8>, xpos: usize, ypos: usize, w: usize, h: usize, mv: MV) {
+ let srcx = ((mv.x >> 1) as isize) + (xpos as isize);
+ let srcy = ((mv.y >> 1) as isize) + (ypos as isize);
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
+
+ blockdsp::copy_blocks(dst, src, xpos, ypos, srcx, srcy, w, h, 0, 1, mode, H263_INTERP_AVG_FUNCS);
+ }
+ fn filter_row(&self, buf: &mut NAVideoBuffer<u8>, mb_y: usize, mb_w: usize, cbpi: &CBPInfo) {
+ h263_filter_row(buf, mb_y, mb_w, cbpi)
+ }
+}
+