diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2024-08-06 18:09:47 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2024-08-06 18:09:47 +0200 |
commit | 25f6045bcf6624e5175c46373c7356fd365f48e4 (patch) | |
tree | 9f08f6d91a0a6e17d3b282f7d6814108b4b6b62c /nihav-itu | |
parent | 511f5e91f17edc3520a6c83a3b9150c2b3db6a63 (diff) | |
download | nihav-25f6045bcf6624e5175c46373c7356fd365f48e4.tar.gz |
h264: koda
Diffstat (limited to 'nihav-itu')
-rw-r--r-- | nihav-itu/src/codecs/h264/decoder_mt.rs | 13 | ||||
-rw-r--r-- | nihav-itu/src/codecs/h264/decoder_st.rs | 13 |
2 files changed, 24 insertions, 2 deletions
diff --git a/nihav-itu/src/codecs/h264/decoder_mt.rs b/nihav-itu/src/codecs/h264/decoder_mt.rs index cdddfec..6ffb446 100644 --- a/nihav-itu/src/codecs/h264/decoder_mt.rs +++ b/nihav-itu/src/codecs/h264/decoder_mt.rs @@ -489,6 +489,8 @@ struct H264MTDecoder { max_last_poc: u32, poc_base: u32, avg_pool: NAVideoBufferPool<u8>, + disp_w: usize, + disp_h: usize, } impl H264MTDecoder { @@ -509,6 +511,8 @@ 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<()> { @@ -597,7 +601,12 @@ impl H264MTDecoder { } 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)?; @@ -796,6 +805,8 @@ impl NADecoderMT for H264MTDecoder { 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; diff --git a/nihav-itu/src/codecs/h264/decoder_st.rs b/nihav-itu/src/codecs/h264/decoder_st.rs index fad0dd9..4cb4e92 100644 --- a/nihav-itu/src/codecs/h264/decoder_st.rs +++ b/nihav-itu/src/codecs/h264/decoder_st.rs @@ -9,6 +9,8 @@ struct H264Decoder { info: NACodecInfoRef, width: usize, height: usize, + disp_w: usize, + disp_h: usize, num_mbs: usize, nal_len: u8, sps: Vec<Arc<SeqParameterSet>>, @@ -51,6 +53,8 @@ impl H264Decoder { info: NACodecInfoRef::default(), width: 0, height: 0, + disp_w: 0, + disp_h: 0, num_mbs: 0, nal_len: 0, sps: Vec::with_capacity(1), @@ -189,7 +193,12 @@ println!("PAFF?"); 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(); @@ -783,6 +792,8 @@ impl NADecoder for H264Decoder { 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; |