add declared bitdepth to NAVideoInfo
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 7 Jun 2020 12:48:03 +0000 (14:48 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 7 Jun 2020 12:48:03 +0000 (14:48 +0200)
nihav-codec-support/src/test/enc_video.rs
nihav-commonfmt/src/demuxers/avi.rs
nihav-core/src/frame.rs
nihav-ms/src/codecs/msvideo1enc.rs

index 4a258de07863ef7f185647ad16c8e55f413fd6a1..bde9e7874e46fbd969fd0a05f321b468398de1ee 100644 (file)
@@ -271,7 +271,7 @@ pub fn test_encoding_to_file(dec_config: &DecoderTestParams, enc_config: &Encode
              vinfo)
         } else {
             (ScaleInfo { fmt: YUV420_FORMAT, width: 2, height: 2 },
-             NAVideoInfo { width: 2, height: 2, format: YUV420_FORMAT, flipped: false })
+             NAVideoInfo { width: 2, height: 2, format: YUV420_FORMAT, flipped: false, bits: 12 })
         };
     let ofmt = ifmt;
     let mut scaler = NAScale::new(ifmt, ofmt).unwrap();
index cf1b5bfa5fb1b7ebf4f5aa1c80e53faac5244839..11f0bce5d1dfcb55c84e6022982ba2b5e42fd83b 100644 (file)
@@ -415,7 +415,8 @@ fn parse_strf_vids(dmx: &mut AVIDemuxer, strmgr: &mut StreamManager, size: usize
 
     let flip = height < 0;
     let format = if bitcount > 8 { RGB24_FORMAT } else { PAL8_FORMAT };
-    let vhdr = NAVideoInfo::new(width as usize, if flip { -height as usize } else { height as usize}, flip, format);
+    let mut vhdr = NAVideoInfo::new(width as usize, if flip { -height as usize } else { height as usize}, flip, format);
+    vhdr.bits = (planes as u8) * (bitcount as u8);
     let vci = NACodecTypeInfo::Video(vhdr);
     let edata = dmx.read_extradata(size - 40)?;
     if colors > 0 {
index 26e8640aa5dc236ee7ba605cf2126e91c333a957..6386d6f80902c7b2c7ba9e72487e9b2c396dc029 100644 (file)
@@ -53,12 +53,15 @@ pub struct NAVideoInfo {
     pub flipped:    bool,
     /// Picture pixel format.
     pub format:     NAPixelFormaton,
+    /// Declared bits per sample.
+    pub bits:       u8,
 }
 
 impl NAVideoInfo {
     /// Constructs a new `NAVideoInfo` instance.
     pub fn new(w: usize, h: usize, flip: bool, fmt: NAPixelFormaton) -> Self {
-        NAVideoInfo { width: w, height: h, flipped: flip, format: fmt }
+        let bits = fmt.get_total_depth();
+        NAVideoInfo { width: w, height: h, flipped: flip, format: fmt, bits }
     }
     /// Returns picture width.
     pub fn get_width(&self)  -> usize { self.width as usize }
index 5b130ff3c25e52f1f8ac157ce4807136671e3335..c6e4e8d24a4e2496ea8ed2b0aafc579478dc0f80 100644 (file)
@@ -559,6 +559,7 @@ mod test {
                 height:  0,
                 format:  RGB555_FORMAT,
                 flipped: true,
+                bits:    16,
             };
         let enc_params = EncodeParameters {
                 format:  NACodecTypeInfo::Video(dst_vinfo),