Ok(MV{ x, y })
}
-fn do_mc_16x16(dsp: &Box<dyn RV34DSP + Send>, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, mb_y: usize, mv: MV, avg: bool) {
+fn do_mc_16x16(dsp: &mut dyn RV34DSP, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, mb_y: usize, mv: MV, avg: bool) {
dsp.do_luma_mc (buf, prevbuf, mb_x * 16, mb_y * 16, mv, true, avg);
dsp.do_chroma_mc(buf, prevbuf, mb_x * 8, mb_y * 8, 1, mv, true, avg);
dsp.do_chroma_mc(buf, prevbuf, mb_x * 8, mb_y * 8, 2, mv, true, avg);
}
-fn do_mc_8x8(dsp: &Box<dyn RV34DSP + Send>, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, xoff: usize, mb_y: usize, yoff: usize, mv: MV, avg: bool) {
+fn do_mc_8x8(dsp: &mut dyn RV34DSP, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, xoff: usize, mb_y: usize, yoff: usize, mv: MV, avg: bool) {
dsp.do_luma_mc (buf, prevbuf, mb_x * 16 + xoff * 8, mb_y * 16 + yoff * 8, mv, false, avg);
dsp.do_chroma_mc(buf, prevbuf, mb_x * 8 + xoff * 4, mb_y * 8 + yoff * 4, 1, mv, false, avg);
dsp.do_chroma_mc(buf, prevbuf, mb_x * 8 + xoff * 4, mb_y * 8 + yoff * 4, 2, mv, false, avg);
MBType::MBP16x16 | MBType::MBP16x16Mix => {
if let Some(ref prevbuf) = self.ipbs.get_lastref() {
let mv = self.mvi.get_mv(mb_x, mb_y, 0, 0, true);
- do_mc_16x16(&self.dsp, buf, prevbuf, mb_x, mb_y, mv, false);
+ do_mc_16x16(self.dsp.as_mut(), buf, prevbuf, mb_x, mb_y, mv, false);
}
},
MBType::MBForward => {
if let Some(ref fwdbuf) = self.ipbs.get_b_fwdref() {
let mv = self.mvi.get_mv(mb_x, mb_y, 0, 0, true);
- do_mc_16x16(&self.dsp, buf, fwdbuf, mb_x, mb_y, mv, false);
+ do_mc_16x16(self.dsp.as_mut(), buf, fwdbuf, mb_x, mb_y, mv, false);
}
},
MBType::MBBackward => {
if let Some(ref bwdbuf) = self.ipbs.get_b_bwdref() {
let mv = self.mvi.get_mv(mb_x, mb_y, 0, 0, false);
- do_mc_16x16(&self.dsp, buf, bwdbuf, mb_x, mb_y, mv, false);
+ do_mc_16x16(self.dsp.as_mut(), buf, bwdbuf, mb_x, mb_y, mv, false);
}
},
MBType::MBP8x8 | MBType::MBP8x16 | MBType::MBP16x8 => {
for y in 0..2 {
for x in 0..2 {
let mv = self.mvi.get_mv(mb_x, mb_y, x, y, true);
- do_mc_8x8(&self.dsp, buf, prevbuf, mb_x, x, mb_y, y, mv, false);
+ do_mc_8x8(self.dsp.as_mut(), buf, prevbuf, mb_x, x, mb_y, y, mv, false);
}
}
}
},
MBType::MBSkip if !self.is_b => {
if let Some(ref prevbuf) = self.ipbs.get_lastref() {
- do_mc_16x16(&self.dsp, buf, prevbuf, mb_x, mb_y, ZERO_MV, false);
+ do_mc_16x16(self.dsp.as_mut(), buf, prevbuf, mb_x, mb_y, ZERO_MV, false);
}
},
MBType::MBSkip | MBType::MBDirect => {
for y in 0..2 {
for x in 0..2 {
let (mv_f, mv_b) = self.ref_mvi.get_mv(mb_x, mb_y, x, y, true).scale(sstate.trd, sstate.trb);
- do_mc_8x8(&self.dsp, buf, fwdbuf, mb_x, x, mb_y, y, mv_f, false);
- do_mc_8x8(&self.dsp, &mut self.avg_buf, bwdbuf, mb_x, x, mb_y, y, mv_b, true);
+ do_mc_8x8(self.dsp.as_mut(), buf, fwdbuf, mb_x, x, mb_y, y, mv_f, false);
+ do_mc_8x8(self.dsp.as_mut(), &mut self.avg_buf, bwdbuf, mb_x, x, mb_y, y, mv_b, true);
do_avg(&self.cdsp, buf, &self.avg_buf, mb_x, x, mb_y, y, 8, self.ratio1, self.ratio2);
}
}
if let (Some(ref fwdbuf), Some(ref bwdbuf)) = (self.ipbs.get_b_fwdref(), self.ipbs.get_b_bwdref()) {
let mv_f = self.mvi.get_mv(mb_x, mb_y, 0, 0, true);
let mv_b = self.mvi.get_mv(mb_x, mb_y, 0, 0, false);
- do_mc_16x16(&self.dsp, buf, fwdbuf, mb_x, mb_y, mv_f, false);
- do_mc_16x16(&self.dsp, &mut self.avg_buf, bwdbuf, mb_x, mb_y, mv_b, true);
+ do_mc_16x16(self.dsp.as_mut(), buf, fwdbuf, mb_x, mb_y, mv_f, false);
+ do_mc_16x16(self.dsp.as_mut(), &mut self.avg_buf, bwdbuf, mb_x, mb_y, mv_b, true);
do_avg(&self.cdsp, buf, &self.avg_buf, mb_x, 0, mb_y, 0, 16, self.ratio1, self.ratio2);
}
},
}
}
+ #[allow(clippy::cyclomatic_complexity)]
pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> {
let mut slice_offs: Vec<usize> = Vec::new();
parse_slice_offsets(src, &mut slice_offs)?;
});
}
+#[allow(clippy::cyclomatic_complexity)]
fn luma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, w: usize, h: usize, cx: usize, cy: usize) {
if (cx == 0) && (cy == 0) {
for _ in 0..h {
- for x in 0..w { dst[didx + x] = src[sidx + x]; }
+ dst[didx..][..w].copy_from_slice(&src[sidx..][..w]);
didx += dstride;
sidx += sstride;
}
fn chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, w: usize, h: usize, x: usize, y: usize) {
if (x == 0) && (y == 0) {
for _ in 0..h {
- for x in 0..w { dst[didx + x] = src[sidx + x]; }
+ dst[didx..][..w].copy_from_slice(&src[sidx..][..w]);
didx += dstride;
sidx += sstride;
}
let off = ((sum >> 5) + 32) as usize;
let frac = (sum & 0x1F) as u16;
if frac == 0 {
- for x in 0..size {
- dst[doff + x] = src[off + x];
- }
+ dst[doff..][..size].copy_from_slice(&src[off..][..size]);
} else {
for x in 0..size {
let a = src[off + x + 0] as u16;
sum += diff;
}
}
+ #[allow(clippy::cyclomatic_complexity)]
pub fn pred_angle(&self, dst: &mut [u8], mut doff: usize, dstride: usize, size: usize, angle: usize, filter: bool) {
let mut filtered1: [u8; 96] = [0; 96];
let mut filtered2: [u8; 96] = [0; 96];
Self::filter_bilin32(&mut filtered1[32..], self.t[1], self.t[33], 32);
}
for _ in 0..size {
- for x in 0..size {
- dst[doff + x] = filtered1[32 + x];
- }
+ dst[doff..][..size].copy_from_slice(&filtered1[32..][..size]);
doff += dstride;
}
if filter {
struct RMDemuxCommon {}
impl RMDemuxCommon {
- fn parse_stream_info(str_data: &mut CommonStreamData, strmgr: &mut StreamManager, stream_no: u32, edata: &Vec<u8>) -> DemuxerResult<bool> {
+ fn parse_stream_info(str_data: &mut CommonStreamData, strmgr: &mut StreamManager, stream_no: u32, edata: &[u8]) -> DemuxerResult<bool> {
let mut is_mlti = false;
- let mut mr = MemoryReader::new_read(edata.as_slice());
+ let mut mr = MemoryReader::new_read(edata);
let mut src = ByteReader::new(&mut mr);
let tag = src.read_u32be()?;
let tag2 = src.peek_u32be()?;
//println!("tag1 {:X} tag2 {:X}", tag, tag2);
if tag == mktag!('.', 'r', 'a', 0xFD) {
- Self::parse_audio_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata.as_slice())?;
+ Self::parse_audio_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata)?;
} else if ((tag2 == mktag!('V', 'I', 'D', 'O')) || (tag2 == mktag!('I', 'M', 'A', 'G'))) && ((tag as usize) <= edata.len()) {
- Self::parse_video_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata.as_slice(), tag2)?;
+ Self::parse_video_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata, tag2)?;
} else if tag == mktag!(b"LSD:") {
let extradata = Some(edata.to_owned());
Ok(last) => { if last { break; } },
Err(DemuxerError::IOError) => { break; },
Err(etype) => {
- if self.data_chunks.len() == 0 { // data is not found, report error
+ if self.data_chunks.is_empty() { // data is not found, report error
return Err(etype);
}
},
};
}
//println!("now @ {:X} / {}", self.src.tell(), self.data_pos);
- validate!(self.data_chunks.len() > 0);
+ validate!(!self.data_chunks.is_empty());
self.cur_data_chunk = 0;
let (pos, size, ver) = self.data_chunks[self.cur_data_chunk];
self.data_pos = pos;