From: Kostya Shishkov Date: Sun, 7 Jun 2020 12:48:03 +0000 (+0200) Subject: add declared bitdepth to NAVideoInfo X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=30940e7459d0fa54e1831bb9825b1b91787ac3d7;p=nihav.git add declared bitdepth to NAVideoInfo --- diff --git a/nihav-codec-support/src/test/enc_video.rs b/nihav-codec-support/src/test/enc_video.rs index 4a258de..bde9e78 100644 --- a/nihav-codec-support/src/test/enc_video.rs +++ b/nihav-codec-support/src/test/enc_video.rs @@ -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(); diff --git a/nihav-commonfmt/src/demuxers/avi.rs b/nihav-commonfmt/src/demuxers/avi.rs index cf1b5bf..11f0bce 100644 --- a/nihav-commonfmt/src/demuxers/avi.rs +++ b/nihav-commonfmt/src/demuxers/avi.rs @@ -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 { diff --git a/nihav-core/src/frame.rs b/nihav-core/src/frame.rs index 26e8640..6386d6f 100644 --- a/nihav-core/src/frame.rs +++ b/nihav-core/src/frame.rs @@ -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 } diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index 5b130ff..c6e4e8d 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -559,6 +559,7 @@ mod test { height: 0, format: RGB555_FORMAT, flipped: true, + bits: 16, }; let enc_params = EncodeParameters { format: NACodecTypeInfo::Video(dst_vinfo),