From: Kostya Shishkov Date: Tue, 8 Apr 2025 17:09:55 +0000 (+0200) Subject: zmbvenc: handle the situation when first frame in the stream is skip frame X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=69b9f356fe75435b1c33a4c44aa7400076a8a9b8;p=nihav.git zmbvenc: handle the situation when first frame in the stream is skip frame --- diff --git a/nihav-commonfmt/src/codecs/zmbvenc.rs b/nihav-commonfmt/src/codecs/zmbvenc.rs index 1ea74d0..e112eb4 100644 --- a/nihav-commonfmt/src/codecs/zmbvenc.rs +++ b/nihav-commonfmt/src/codecs/zmbvenc.rs @@ -145,7 +145,21 @@ impl ZMBVEncoder { if let NABufferType::None = buf { if self.bpp == 0 { - return Err(EncoderError::FormatError); + println!("First frame is skip frame, pretending it's a black frame and hoping for the best"); + if let Some(ref stream) = self.stream { + if let Some(vinfo) = stream.get_info().get_properties().get_video_info() { + let in_bpp = if vinfo.format.is_paletted() { + 8 + } else { vinfo.format.get_total_depth() }; + if !matches!(in_bpp, 8 | 15 | 16 | 24) { + return Err(EncoderError::FormatError); + } + self.bpp = in_bpp; + } + } + if self.bpp == 0 { + return Err(EncoderError::FormatError); + } } self.frm1.copy_from_slice(&self.frm2); bpp = self.bpp;