self.decode_frame_intra(&mut br, &mut buf, vinfo.get_width(), vinfo.get_height())?;
extend_edges(&mut buf, 1 << self.tsize);
} else {
- let mut prev = self.frmmgr.clone_ref().unwrap();
+ let pref = self.frmmgr.clone_ref();
+ if pref.is_none() { return Err(DecoderError::MissingReference); }
+ let mut prev = pref.unwrap();
extend_edges(&mut prev, 1 << self.tsize);
self.decode_frame_inter(&mut br, &mut buf, &mut prev, vinfo.get_width(), vinfo.get_height())?;
extend_edges(&mut buf, 1 << self.tsize);
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();
if hdr.is_intra {
self.shuf.clear();
+ } else {
+ if !self.shuf.has_refs() {
+ return Err(DecoderError::MissingReference);
+ }
}
let mut cr;
self.set_dimensions(width, height);
self.dstate.reset();
+ } else {
+ if !self.shuf.has_refs() {
+ return Err(DecoderError::MissingReference);
+ }
}
self.read_features(&mut bc)?;
None
}
}
+ pub fn has_refs(&self) -> bool {
+ self.lastframe.is_some()
+ }
}
pub const VP56_COEF_BASE: [i16; 6] = [ 5, 7, 11, 19, 35, 67 ];
self.base_ts += 1 << 13;
}
}
+ match hdr0.ftype {
+ FrameType::P => {
+ if self.ipbs.get_lastref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ },
+ FrameType::B => {
+ if self.ipbs.get_lastref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ if self.ipbs.get_nextref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ },
+ _ => {},
+ };
let ts_diff = (self.next_ts << 3).wrapping_sub(hdr0.pts << 3) >> 3;
let ts = self.base_ts + (self.next_ts as u64) - (ts_diff as u64);
sstate.trd = (self.next_ts << 3).wrapping_sub(self.last_ts << 3) >> 3;
let hdr = FrameHeader::read(&mut br)?;
let mut slices: Vec<usize> = Vec::new();
hdr.parse_slice_sizes(&mut br, &mut slices)?;
+ match hdr.ftype {
+ FrameType::P => {
+ if self.ipbs.get_lastref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ },
+ FrameType::B => {
+ if self.ipbs.get_lastref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ if self.ipbs.get_nextref().is_none() {
+ return Err(DecoderError::MissingReference);
+ }
+ },
+ _ => {},
+ };
let tmp_vinfo = NAVideoInfo::new(hdr.width, hdr.height, false, YUV420_FORMAT);
let ret = supp.pool_u8.get_free();