]> git.nihav.org Git - nihav.git/blobdiff - nihav-commonfmt/src/codecs/cinepakenc.rs
cinepakenc: fix mask output optimisation
[nihav.git] / nihav-commonfmt / src / codecs / cinepakenc.rs
index 3269cf8ea7ef7de5fb111cdc5bce516b36306acc..4729cd6050fb3f4a228ad20064189f597f78dfa6 100644 (file)
@@ -883,7 +883,7 @@ impl CinepakEncoder {
             let mut skip = true;
             for mask in self.masks.masks.iter() {
                 bw.write_u32be(*mask)?;
-                if *mask == 0 { continue; }
+                if *mask == 0 && skip { continue; }
                 let mut bit = 1 << 31;
                 while bit > 0 {
                     if skip {
@@ -925,9 +925,10 @@ impl NAEncoder for CinepakEncoder {
     fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
         match encinfo.format {
             NACodecTypeInfo::None => {
-                let mut ofmt = EncodeParameters::default();
-                ofmt.format = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, true, YUV420_FORMAT));
-                Ok(ofmt)
+                Ok(EncodeParameters {
+                        format: NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, true, YUV420_FORMAT)),
+                        ..Default::default()
+                    })
             },
             NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
             NACodecTypeInfo::Video(vinfo) => {
@@ -1052,8 +1053,8 @@ impl NAOptionHandler for CinepakEncoder {
                             }
                         },
                         "quant_mode" => {
-                            if let NAValue::String(ref str) = option.value {
-                                match str.as_str() {
+                            if let NAValue::String(ref strval) = option.value {
+                                match strval.as_str() {
                                     "elbg"      => self.qmode = QuantMode::ELBG,
                                     "hybrid"    => self.qmode = QuantMode::Hybrid,
                                     "mediancut" => self.qmode = QuantMode::MedianCut,