};
}
-fn vp3_interp00(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]; }
- didx += dstride;
- sidx += sstride;
- }
-}
-
-fn vp3_interp01(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)) >> 1) as u8; }
- didx += dstride;
- sidx += sstride;
- }
-}
-
-fn vp3_interp10(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 + sstride] as u16)) >> 1) as u8; }
- didx += dstride;
- sidx += sstride;
- }
-}
-
-fn vp3_interp11(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;
- }
- didx += dstride;
- sidx += sstride;
- }
-}
-
fn vp31_loop_filter_v(frm: &mut NASimpleVideoFrame<u8>, x: usize, y: usize, plane: usize, loop_str: i16) {
let off = frm.offset[plane] + x + y * frm.stride[plane];
vp31_loop_filter(frm.data, off, 1, frm.stride[plane], 8, loop_str);
vp31_loop_filter(frm.data, off, frm.stride[plane], 1, 8, loop_str);
}
-pub const VP3_INTERP_FUNCS: &[blockdsp::BlkInterpFunc] = &[ vp3_interp00, vp3_interp01, vp3_interp10, vp3_interp11 ];
-
impl VP34Decoder {
fn new(version: u8) -> Self {
let vt = alloc_video_buffer(NAVideoInfo::new(24, 24, false, YUV420_FORMAT), 4).unwrap();
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), true, fmt));
self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
supp.pool_u8.set_dec_bufs(3);
- supp.pool_u8.prealloc_video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), false, fmt), 4)?;
+ supp.pool_u8.prealloc_video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), true, fmt), 4)?;
self.generate_block_addr();
if self.version == 4 {
self.parse_header(&mut br)?;
if self.is_intra {
self.shuf.clear();
+ } else {
+ if !self.shuf.has_refs() {
+ return Err(DecoderError::MissingReference);
+ }
}
let ret = supp.pool_u8.get_free();
frm.set_frame_type(if self.is_intra { FrameType::I } else { FrameType::P });
Ok(frm.into_ref())
}
+ fn flush(&mut self) {
+ self.shuf.clear();
+ }
}
-pub fn get_decoder_vp3() -> Box<NADecoder> {
+pub fn get_decoder_vp3() -> Box<NADecoder + Send> {
Box::new(VP34Decoder::new(3))
}
-pub fn get_decoder_vp4() -> Box<NADecoder> {
+pub fn get_decoder_vp4() -> Box<NADecoder + Send> {
Box::new(VP34Decoder::new(4))
}