use nihav_core::codecs::*;
-use nihav_core::codecs::blockdsp::*;
+use nihav_codec_support::codecs::blockdsp;
+use nihav_codec_support::codecs::blockdsp::*;
+
+pub const VP_YUVA420_FORMAT: NAPixelFormaton = NAPixelFormaton{
+ model: ColorModel::YUV(YUVSubmodel::YUVJ),
+ components: 4,
+ comp_info: [
+ Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 0, next_elem: 1}),
+ Some(NAPixelChromaton{ h_ss: 1, v_ss: 1, packed: false, depth: 8, shift: 0, comp_offs: 1, next_elem: 1}),
+ Some(NAPixelChromaton{ h_ss: 1, v_ss: 1, packed: false, depth: 8, shift: 0, comp_offs: 2, next_elem: 1}),
+ Some(NAPixelChromaton{ h_ss: 0, v_ss: 0, packed: false, depth: 8, shift: 0, comp_offs: 3, next_elem: 1}),
+ None ],
+ elem_size: 0,
+ be: false,
+ alpha: true,
+ palette: false
+ };
#[derive(Clone,Copy,Debug,PartialEq)]
#[allow(dead_code)]
None
}
}
+ pub fn has_refs(&self) -> bool {
+ self.lastframe.is_some()
+ }
}
pub const VP56_COEF_BASE: [i16; 6] = [ 5, 7, 11, 19, 35, 67 ];
}
val
}
+ pub fn read_byte(&mut self) -> u8 {
+ let mut val = 0u8;
+ for _ in 0..8 {
+ val = (val << 1) | (self.read_prob(128) as u8);
+ }
+ val
+ }
+ pub fn read_sbits(&mut self, bits: u8) -> i32 {
+ let mut val = if self.read_prob(128) { -1i32 } else { 0i32 };
+ for _ in 1..bits {
+ val = (val << 1) | (self.read_prob(128) as i32);
+ }
+ val
+ }
pub fn read_probability(&mut self) -> u8 {
let val = self.read_bits(7) as u8;
if val == 0 {
((((prob as i32) * (weights[0] as i32) + 128) >> 8) + (weights[1] as i32)).min(maxval).max(1) as u8
}
-#[macro_export]
macro_rules! vp_tree {
($bc: expr, $prob: expr, $node1: expr, $node2: expr) => {
if !$bc.read_prob($prob) {
let src_x = sx - (pre as isize);
let src_y = sy - (pre as isize);
{
- let mut tmp_buf = NASimpleVideoFrame::from_video_buf(&mut mc_buf).unwrap();
- copy_block(&mut tmp_buf, src, comp, 0, 0, src_x as i16, src_y as i16,
- bsize, bsize, 0, 0, 0, interp);
- if (sy & 7) != 0 {
- let foff = (8 - (sy & 7)) as usize;
- let off = (pre + foff) * tmp_buf.stride[comp];
- vp31_loop_filter(tmp_buf.data, off, tmp_buf.stride[comp], 1, bsize, loop_str);
- }
+ let tmp_buf = NASimpleVideoFrame::from_video_buf(&mut mc_buf).unwrap();
+ edge_emu(src.as_ref(), src_x, src_y, bsize, bsize, &mut tmp_buf.data[tmp_buf.offset[comp]..], tmp_buf.stride[comp], comp, 0);
+// copy_block(&mut tmp_buf, src, comp, 0, 0, src_x as i16, src_y as i16,
+// bsize, bsize, 0, 0, 0, interp);
if (sx & 7) != 0 {
let foff = (8 - (sx & 7)) as usize;
- let off = pre + foff;
+ let off = pre + foff + tmp_buf.offset[comp];
vp31_loop_filter(tmp_buf.data, off, 1, tmp_buf.stride[comp], bsize, loop_str);
}
+ if (sy & 7) != 0 {
+ let foff = (8 - (sy & 7)) as usize;
+ let off = (pre + foff) * tmp_buf.stride[comp] + tmp_buf.offset[comp];
+ vp31_loop_filter(tmp_buf.data, off, tmp_buf.stride[comp], 1, bsize, loop_str);
+ }
}
let dxoff = (pre as i16) - (dx as i16);
let dyoff = (pre as i16) - (dy as i16);
- copy_block(dst, mc_buf, comp, dx, dy, dxoff, dyoff, 8, 8, preborder, postborder, 0/* mode*/, interp);
+ copy_block(dst, mc_buf, comp, dx, dy, dxoff, dyoff, 8, 8, preborder, postborder, mode, interp);
}
fn vp3_interp00(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw: usize, bh: usize)
}
}
-fn vp3_interp11(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw: usize, bh: usize)
+fn vp3_interp1x(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw: usize, bh: usize)
{
let mut didx = 0;
let mut sidx = 0;
for _ in 0..bh {
for x in 0..bw {
dst[didx + x] = (((src[sidx + x] as u16) +
- (src[sidx + x + 1] as u16) +
- (src[sidx + x + sstride] as u16) +
- (src[sidx + x + sstride + 1] as u16)) >> 2) as u8;
+ (src[sidx + x + sstride + 1] as u16)) >> 1) as u8;
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+}
+
+fn vp3_interp1y(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw: usize, bh: usize)
+{
+ let mut didx = 0;
+ let mut sidx = 0;
+ for _ in 0..bh {
+ for x in 0..bw {
+ dst[didx + x] = (((src[sidx + x + 1] as u16) +
+ (src[sidx + x + sstride] as u16)) >> 1) as u8;
}
didx += dstride;
sidx += sstride;
}
}
-pub const VP3_INTERP_FUNCS: &[blockdsp::BlkInterpFunc] = &[ vp3_interp00, vp3_interp01, vp3_interp10, vp3_interp11 ];
+pub const VP3_INTERP_FUNCS: &[blockdsp::BlkInterpFunc] = &[ vp3_interp00, vp3_interp01, vp3_interp10, vp3_interp1x, vp3_interp1y ];