diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-02-08 17:36:49 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2023-02-08 17:36:49 +0100 |
commit | 991233445f09055823cdca1211cd19d87a2d56ab (patch) | |
tree | 625afd0b1e19a3b5263daa82d79911030818aa8c | |
parent | 608a923fdacd068d33f904a5181691bbae221b94 (diff) | |
download | nihav-991233445f09055823cdca1211cd19d87a2d56ab.tar.gz |
msvideo1enc: handle skip frames
-rw-r--r-- | nihav-ms/src/codecs/msvideo1enc.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index 3c89f7a..b927dc8 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -873,6 +873,31 @@ impl NAEncoder for MSVideo1Encoder { } fn encode(&mut self, frm: &NAFrame) -> EncoderResult<()> { let buf = frm.get_buffer(); + if frm.frame_type == FrameType::Skip { + if let Some(ref stream) = self.stream { + let mut dbuf = Vec::with_capacity(4); + let mut gw = GrowableMemoryWriter::new_write(&mut dbuf); + let mut bw = ByteWriter::new(&mut gw); + + let vinfo = stream.get_info().get_properties().get_video_info().unwrap(); + let mut nskips = ((vinfo.get_width() + 3) / 4) * ((vinfo.get_height() + 3) / 4); + while nskips >= 1023 { + Self::write_skips(&mut bw, 1023)?; + nskips -= 1023; + } + if nskips > 0 { + Self::write_skips(&mut bw, nskips)?; + } + self.pkt = Some(NAPacket::new(self.stream.clone().unwrap(), frm.ts, false, dbuf)); + self.frmcount += 1; + if self.frmcount == self.key_int { + self.frmcount = 0; + } + return Ok(()); + } else { + return Err(EncoderError::Bug); + } + } if let Some(ref vbuf) = buf.get_vbuf16() { if self.pal_mode { return Err(EncoderError::InvalidParameters); |