]> git.nihav.org Git - nihav.git/commitdiff
zmbvenc: handle the situation when first frame in the stream is skip frame
authorKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 8 Apr 2025 17:09:55 +0000 (19:09 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Tue, 8 Apr 2025 17:09:55 +0000 (19:09 +0200)
nihav-commonfmt/src/codecs/zmbvenc.rs

index 1ea74d01585e3377058ff81b8fa2acff4cd87e9c..e112eb459db31e00e215668b25f64c3c421a3462 100644 (file)
@@ -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;