max_last_poc: u32,
poc_base: u32,
avg_pool: NAVideoBufferPool<u8>,
+ disp_w: usize,
+ disp_h: usize,
}
impl H264MTDecoder {
max_last_poc: 0,
poc_base: 0,
avg_pool: NAVideoBufferPool::new(8),
+ disp_w: 0,
+ disp_h: 0,
}
}
fn handle_nal(&mut self, src: Vec<u8>, supp: &mut NADecoderSupport, skip_decoding: bool, user_id: u32, time: NATimeInfo) -> DecoderResult<()> {
}
let cur_vinfo = supp.pool_u8.get_info();
- let tmp_vinfo = NAVideoInfo::new(width, height, false, YUV420_FORMAT);
+ let (w, h) = if ((self.disp_w + 15) & !15) == width && ((self.disp_h + 15) & !15) == height {
+ (self.disp_w, self.disp_h)
+ } else {
+ (width, height)
+ };
+ let tmp_vinfo = NAVideoInfo::new(w, h, false, YUV420_FORMAT);
if cur_vinfo != Some(tmp_vinfo) {
supp.pool_u8.reset();
supp.pool_u8.prealloc_video(tmp_vinfo, 4)?;
let mut width = vinfo.get_width();
let mut height = vinfo.get_height();
+ self.disp_w = width;
+ self.disp_h = height;
if (width == 0 || height == 0) && !self.sps.is_empty() {
width = self.sps[0].pic_width_in_mbs * 16;
info: NACodecInfoRef,
width: usize,
height: usize,
+ disp_w: usize,
+ disp_h: usize,
num_mbs: usize,
nal_len: u8,
sps: Vec<Arc<SeqParameterSet>>,
info: NACodecInfoRef::default(),
width: 0,
height: 0,
+ disp_w: 0,
+ disp_h: 0,
num_mbs: 0,
nal_len: 0,
sps: Vec::with_capacity(1),
if ret.is_none() {
return Err(DecoderError::AllocError);
}
- let tmp_vinfo = NAVideoInfo::new(self.width, self.height, false, YUV420_FORMAT);
+ let (w, h) = if ((self.disp_w + 15) & !15) == self.width && ((self.disp_h + 15) & !15) == self.height {
+ (self.disp_w, self.disp_h)
+ } else {
+ (self.width, self.height)
+ };
+ let tmp_vinfo = NAVideoInfo::new(w, h, false, YUV420_FORMAT);
let mut buf = ret.unwrap();
if buf.get_info() != tmp_vinfo {
supp.pool_u8.reset();
self.width = vinfo.get_width();
self.height = vinfo.get_height();
+ self.disp_w = self.width;
+ self.disp_h = self.height;
if (self.width == 0 || self.height == 0) && !self.sps.is_empty() {
self.width = self.sps[0].pic_width_in_mbs * 16;