aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2023-05-20 17:07:13 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2023-05-20 17:07:13 +0200
commit8c3f822a3224477463989f8be27c46d70e257579 (patch)
tree98577b519b298d75917843a396bd46ab80dede64
parente5ee9a29f58a41bae17bfb3657b2698bd54efb63 (diff)
downloadnihav-8c3f822a3224477463989f8be27c46d70e257579.tar.gz
cinepakenc: try to calculate the number of strips automatically if requested
-rw-r--r--nihav-commonfmt/src/codecs/cinepakenc.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs
index f4ac9b2..8273de0 100644
--- a/nihav-commonfmt/src/codecs/cinepakenc.rs
+++ b/nihav-commonfmt/src/codecs/cinepakenc.rs
@@ -1000,6 +1000,12 @@ impl NAEncoder for CinepakEncoder {
fn encode(&mut self, frm: &NAFrame) -> EncoderResult<()> {
let buf = frm.get_buffer();
if let Some(ref vbuf) = buf.get_vbuf() {
+ if self.nstrips == 0 {
+ let (w, h) = vbuf.get_dimensions(0);
+ self.nstrips = ((((w * h) >> 4) + 1200) / 2400).max(1).min(3);
+ let strip_h = ((h + self.nstrips - 1) / self.nstrips + 3) & !3;
+ self.nstrips = (h + strip_h - 1) / strip_h;
+ }
let cur_strips = self.v1_cb.len();
if cur_strips != self.nstrips {
self.frmcount = 0;