ypos: 0,
}
}
- fn decode_cu_line(&mut self, buf: &mut NAVideoBuffer<u8>, hdr: &FrameHeader, src: &[u8], cu_y: usize) -> DecoderResult<()> {
+ fn decode_cu_line(&mut self, buf: &mut NASimpleVideoFrame<u8>, hdr: &FrameHeader, src: &[u8], cu_y: usize) -> DecoderResult<()> {
let mut br = BitReader::new(src, src.len(), BitReaderMode::BE);
let cu_w = hdr.get_width_cu();
let dqp = hdr.read_line_qp_offset(&mut br)?;
}
Ok(())
}
- fn decode_cb_tree(&mut self, buf: &mut NAVideoBuffer<u8>, hdr: &FrameHeader, br: &mut BitReader, xpos: usize, ypos: usize, log_size: u8) -> DecoderResult<()> {
+ fn decode_cb_tree(&mut self, buf: &mut NASimpleVideoFrame<u8>, hdr: &FrameHeader, br: &mut BitReader, xpos: usize, ypos: usize, log_size: u8) -> DecoderResult<()> {
if (xpos >= hdr.width) || (ypos >= hdr.height) { return Ok(()); }
let size = 1 << log_size;
CUType::Intra => {
let itype = self.blk_info[self.blk_pos].imode;
if !split_i4x4 {
- let dstride = buf.get_stride(0);
+ let dstride = buf.stride[0];
let off = xpos + ypos * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let dst = &mut data;
+ let dst = &mut buf.data;
self.populate_ipred(hdr, dst, 0, dstride, 0, 0, size, true);
self.ipred.pred_angle(dst, off, dstride, size, itype as usize, true);
}
for comp in 1..3 {
- let dstride = buf.get_stride(comp);
- let soff = buf.get_offset(comp);
+ let dstride = buf.stride[comp];
+ let soff = buf.offset[comp];
let off = soff + (xpos >> 1) + (ypos >> 1) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.populate_ipred(hdr, dst, soff, dstride, 0, 0, size >> 1, false);
self.ipred.pred_angle(&mut dst, off, dstride, size >> 1, itype as usize, false);
}
validate!(hdr.ftype == FrameType::B);
if let (Some(ref prevbuf), Some(ref nextbuf)) = (self.ipbs.get_b_fwdref(), self.ipbs.get_b_bwdref()) {
self.dsp.do_mc(buf, prevbuf, bx, by, bw, bh, mv.f_mv, false);
- self.dsp.do_mc(&mut self.avg_buf, nextbuf, bx, by, bw, bh, mv.b_mv, true);
+ {
+ let mut avg_buf = NASimpleVideoFrame::from_video_buf(&mut self.avg_buf).unwrap();
+ self.dsp.do_mc(&mut avg_buf, nextbuf, bx, by, bw, bh, mv.b_mv, true);
+ }
self.dsp.do_avg(buf, &self.avg_buf, bx, by, bw, bh);
}
},
let i = x + y * 4;
if ((cbp16 >> i) & 1) != 0 {
self.dsp.transform4x4(&mut self.y_coeffs[i * 16..][..16]);
- let dstride = buf.get_stride(0);
+ let dstride = buf.stride[0];
let off = xpos + x * 4 + (ypos + y * 4) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs[i*16..][..16], 4);
}
}
let yoff = (ypos >> 1) + y * 4;
if ((cbp16 >> (16 + i)) & 1) != 0 {
self.dsp.transform4x4(&mut self.u_coeffs[i * 16..][..16]);
- let dstride = buf.get_stride(1);
- let off = buf.get_offset(1) + xoff + yoff * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let dstride = buf.stride[1];
+ let off = buf.offset[1] + xoff + yoff * dstride;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs[i * 16..][..16], 4);
}
if ((cbp16 >> (20 + i)) & 1) != 0 {
self.dsp.transform4x4(&mut self.v_coeffs[i * 16..][..16]);
- let dstride = buf.get_stride(2);
- let off = buf.get_offset(2) + xoff + yoff * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let dstride = buf.stride[2];
+ let off = buf.offset[2] + xoff + yoff * dstride;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs[i * 16..][..16], 4);
}
}
let xoff = (i & 1) * 4;
let yoff = (i & 2) * 2;
if split_i4x4 {
- let dstride = buf.get_stride(0);
+ let dstride = buf.stride[0];
let off = xpos + xoff + (ypos + yoff) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.populate_ipred(hdr, dst, 0, dstride, xoff, yoff, 4, true);
let itype = self.blk_info[self.blk_pos + (i & 1) + (i >> 1) * self.blk_stride].imode;
self.ipred.pred_angle(&mut dst, off, dstride, 4, itype as usize, false);
if ((cbp8 >> i) & 1) != 0 {
let blk = &mut self.y_coeffs[i * 16..][..16];
self.dsp.transform4x4(blk);
- let dstride = buf.get_stride(0);
- let soff = buf.get_offset(0);
+ let dstride = buf.stride[0];
+ let soff = buf.offset[0];
let off = soff + xpos + xoff + (ypos + yoff) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, blk, 4);
}
}
if ((cbp8 >> 4) & 1) != 0 {
self.dsp.transform4x4(&mut self.u_coeffs);
- let dstride = buf.get_stride(1);
- let soff = buf.get_offset(1);
+ let dstride = buf.stride[1];
+ let soff = buf.offset[1];
let off = soff + (xpos >> 1) + (ypos >> 1) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 4);
}
if ((cbp8 >> 5) & 1) != 0 {
self.dsp.transform4x4(&mut self.v_coeffs);
- let dstride = buf.get_stride(2);
- let soff = buf.get_offset(2);
+ let dstride = buf.stride[2];
+ let soff = buf.offset[2];
let off = soff + (xpos >> 1) + (ypos >> 1) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 4);
}
}
rv6_decode_cu_8x8(br, &self.cbs, is_intra, self.qp, self.sel_qp, &mut self.y_coeffs, &mut self.u_coeffs, &mut self.v_coeffs, cbp8, false)?;
if (cbp8 & 0xF) != 0 {
self.dsp.transform8x8(&mut self.y_coeffs);
- let dstride = buf.get_stride(0);
+ let dstride = buf.stride[0];
let off = xpos + ypos * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs, 8);
}
if ((cbp8 >> 4) & 1) != 0 {
self.dsp.transform4x4(&mut self.u_coeffs);
- let dstride = buf.get_stride(1);
- let soff = buf.get_offset(1);
+ let dstride = buf.stride[1];
+ let soff = buf.offset[1];
let off = soff + (xpos >> 1) + (ypos >> 1) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 4);
}
if ((cbp8 >> 5) & 1) != 0 {
self.dsp.transform4x4(&mut self.v_coeffs);
- let dstride = buf.get_stride(2);
- let soff = buf.get_offset(2);
+ let dstride = buf.stride[2];
+ let soff = buf.offset[2];
let off = soff + (xpos >> 1) + (ypos >> 1) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 4);
}
}
rv6_decode_cu_16x16(br, &self.cbs, is_intra, self.qp, self.sel_qp, &mut self.y_coeffs, &mut self.u_coeffs, &mut self.v_coeffs, super_cbp)?;
if (super_cbp & 0xFFFF) != 0 {
self.dsp.transform16x16(&mut self.y_coeffs);
- let dstride = buf.get_stride(0);
+ let dstride = buf.stride[0];
let off = xpos + x * 16 + (ypos + y * 16) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.y_coeffs, 16);
}
if ((super_cbp >> 16) & 0xF) != 0 {
self.dsp.transform8x8(&mut self.u_coeffs);
- let dstride = buf.get_stride(1);
- let soff = buf.get_offset(1);
+ let dstride = buf.stride[1];
+ let soff = buf.offset[1];
let off = soff + (xpos >> 1) + x * 8 + ((ypos >> 1) + y * 8) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.u_coeffs, 8);
}
if ((super_cbp >> 20) & 0xF) != 0 {
self.dsp.transform8x8(&mut self.v_coeffs);
- let dstride = buf.get_stride(2);
- let soff = buf.get_offset(2);
+ let dstride = buf.stride[2];
+ let soff = buf.offset[2];
let off = soff + (xpos >> 1) + x * 8 + ((ypos >> 1) + y * 8) * dstride;
- let mut data = buf.get_data_mut().unwrap();
- let mut dst = &mut data;
+ let mut dst = &mut buf.data;
self.dsp.add_block(&mut dst, off, dstride, &self.v_coeffs, 8);
}
}
skip_cand.list[i] = MVInfo { f_mv: ZERO_MV, b_mv: ZERO_MV, mvref: MVRef::Ref0 };
}
}
- fn deblock_cb_tree(&mut self, buf: &mut NAVideoBuffer<u8>, hdr: &FrameHeader, xpos: usize, ypos: usize, log_size: u8) {
+ fn deblock_cb_tree(&mut self, buf: &mut NASimpleVideoFrame<u8>, hdr: &FrameHeader, xpos: usize, ypos: usize, log_size: u8) {
if (xpos >= hdr.width) || (ypos >= hdr.height) { return; }
let split = (log_size > 3) && self.cu_splits.pop().unwrap();
if split {
self.dblk.reinit(hdr.width, hdr.height);
}
let mut off = hsize + ((br.tell() >> 3) as usize);
+ let mut dframe = NASimpleVideoFrame::from_video_buf(&mut buf).unwrap();
for (cu_y, size) in slices.into_iter().enumerate() {
- self.decode_cu_line(&mut buf, &hdr, &src[off..][..size], cu_y)?;
+ self.decode_cu_line(&mut dframe, &hdr, &src[off..][..size], cu_y)?;
off += size;
}
if (hdr.ftype == FrameType::I) || (hdr.ftype == FrameType::P) {
-use nihav_core::frame::NAVideoBuffer;
+use nihav_core::frame::{NAVideoBuffer, NASimpleVideoFrame};
use nihav_core::codecs::MV;
use nihav_core::codecs::blockdsp::edge_emu;
sidx += sstride;
}
}
- pub fn do_avg(&self, frame: &mut NAVideoBuffer<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, w: usize, h: usize) {
+ pub fn do_avg(&self, frame: &mut NASimpleVideoFrame<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, w: usize, h: usize) {
for comp in 0..3 {
- let dstride = frame.get_stride(comp);
+ let dstride = frame.stride[comp];
let sstride = prev_frame.get_stride(comp);
- let doff = if comp == 0 { x + y * dstride } else { frame.get_offset(comp) + (x >> 1) + (y >> 1) * dstride };
+ let doff = if comp == 0 { x + y * dstride } else { frame.offset[comp] + (x >> 1) + (y >> 1) * dstride };
let soff = prev_frame.get_offset(comp);
- let ddata = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = ddata.as_mut_slice();
+ let dst = &mut frame.data;
let sdata = prev_frame.get_data();
let src: &[u8] = sdata.as_slice();
}
}
}
- pub fn do_mc(&self, frame: &mut NAVideoBuffer<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, w: usize, h: usize, mv: MV, avg: bool) {
+ pub fn do_mc(&self, frame: &mut NASimpleVideoFrame<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, w: usize, h: usize, mv: MV, avg: bool) {
{ // luma
- let dstride = frame.get_stride(0);
- let doffset = frame.get_offset(0) + (if !avg { x + y * dstride } else { 0 });
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
+ let dstride = frame.stride[0];
+ let doffset = frame.offset[0] + (if !avg { x + y * dstride } else { 0 });
+ let dst = &mut frame.data;
let (w_, h_) = prev_frame.get_dimensions(0);
let fw = (w_ + 15) & !15;
let ch = h >> 1;
for comp in 1..3 { // chroma
- let dstride = frame.get_stride(comp);
- let doffset = frame.get_offset(comp) + (if !avg { (x >> 1) + (y >> 1) * dstride } else { 0 });
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
+ let dstride = frame.stride[comp];
+ let doffset = frame.offset[comp] + (if !avg { (x >> 1) + (y >> 1) * dstride } else { 0 });
if check_pos(x >> 1, y >> 1, cw, ch, fw, fh, dx, dy, 0, 1, 0, 1) {
let sstride = prev_frame.get_stride(comp);
let mut soffset = prev_frame.get_offset(comp) + (x >> 1) + (y >> 1) * sstride;
let data = prev_frame.get_data();
let src: &[u8] = data.as_slice();
soffset = ((soffset as isize) + (dx as isize) + (dy as isize) * (sstride as isize)) as usize;
- chroma_mc(dst, doffset, dstride, src, soffset, sstride, cw, ch, cx, cy);
+ chroma_mc(frame.data, doffset, dstride, src, soffset, sstride, cw, ch, cx, cy);
} else {
let mut ebuf: [u8; 40*40] = [0; 40*40];
edge_emu(prev_frame, ((x >> 1) as isize) + (dx as isize), ((y >> 1) as isize) + (dy as isize), cw+1, ch+1, &mut ebuf, 40, comp);
- chroma_mc(dst, doffset, dstride, &ebuf, 0, 40, cw, ch, cx, cy);
+ chroma_mc(frame.data, doffset, dstride, &ebuf, 0, 40, cw, ch, cx, cy);
}
}
}
- fn deblock_edge4_ver(&self, frame: &mut NAVideoBuffer<u8>, xpos: usize, ypos: usize,
+ fn deblock_edge4_ver(&self, frame: &mut NASimpleVideoFrame<u8>, xpos: usize, ypos: usize,
dblk_l: u8, dblk_r: u8, deblock_chroma: bool) {
let qp_l = dblk_l >> 2;
let str_l = dblk_l & 3;
let lim1 = dl_r[2] as i16;
let lim2 = (dl_r[3] * 4) as i16;
{
- let stride = frame.get_stride(0);
- let offset = frame.get_offset(0) + xpos + ypos * stride;
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
- filter_luma_edge(dst, offset, 1, stride, mode_l, mode_r, lim1, lim2);
+ let stride = frame.stride[0];
+ let offset = frame.offset[0] + xpos + ypos * stride;
+ filter_luma_edge(frame.data, offset, 1, stride, mode_l, mode_r, lim1, lim2);
}
if ((str_l | str_r) >= 2) && deblock_chroma {
for comp in 1..2 {
- let stride = frame.get_stride(comp);
- let offset = frame.get_offset(comp) + (xpos >> 1) + (ypos >> 1) * stride;
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
- filter_chroma_edge(dst, offset, 1, stride, mode_l, mode_r, lim1, lim2);
+ let stride = frame.stride[comp];
+ let offset = frame.offset[comp] + (xpos >> 1) + (ypos >> 1) * stride;
+ filter_chroma_edge(frame.data, offset, 1, stride, mode_l, mode_r, lim1, lim2);
}
}
}
- fn deblock_edge4_hor(&self, frame: &mut NAVideoBuffer<u8>, xpos: usize, ypos: usize,
+ fn deblock_edge4_hor(&self, frame: &mut NASimpleVideoFrame<u8>, xpos: usize, ypos: usize,
dblk_t: u8, dblk_d: u8, deblock_chroma: bool) {
let qp_t = dblk_t >> 2;
let str_t = dblk_t & 3;
let lim1 = dl_d[2] as i16;
let lim2 = (dl_d[3] * 4) as i16;
{
- let stride = frame.get_stride(0);
- let offset = frame.get_offset(0) + xpos + ypos * stride;
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
- filter_luma_edge(dst, offset, stride, 1, mode_t, mode_d, lim1, lim2);
+ let stride = frame.stride[0];
+ let offset = frame.offset[0] + xpos + ypos * stride;
+ filter_luma_edge(frame.data, offset, stride, 1, mode_t, mode_d, lim1, lim2);
}
if ((str_t | str_d) >= 2) && deblock_chroma {
for comp in 1..2 {
- let stride = frame.get_stride(comp);
- let offset = frame.get_offset(comp) + (xpos >> 1) + (ypos >> 1) * stride;
- let data = frame.get_data_mut().unwrap();
- let dst: &mut [u8] = data.as_mut_slice();
- filter_chroma_edge(dst, offset, stride, 1, mode_t, mode_d, lim1, lim2);
+ let stride = frame.stride[comp];
+ let offset = frame.offset[comp] + (xpos >> 1) + (ypos >> 1) * stride;
+ filter_chroma_edge(frame.data, offset, stride, 1, mode_t, mode_d, lim1, lim2);
}
}
}
- fn deblock8x8(&self, dparams: &RV60DeblockParams, frame: &mut NAVideoBuffer<u8>,
+ fn deblock8x8(&self, dparams: &RV60DeblockParams, frame: &mut NASimpleVideoFrame<u8>,
xpos: usize, ypos: usize, top_str: &[u8], left_str: &[u8], dblkpos: usize) {
if xpos > 0 {
if ypos > 0 {
}
}
}
- pub fn do_deblock(&self, dparams: &RV60DeblockParams, frame: &mut NAVideoBuffer<u8>,
+ pub fn do_deblock(&self, dparams: &RV60DeblockParams, frame: &mut NASimpleVideoFrame<u8>,
xpos: usize, ypos: usize, size: usize, top_str: &[u8], left_str: &[u8], dpos: usize) {
for x in 0..(size >> 3) {
self.deblock8x8(dparams, frame, xpos + x * 8, ypos,