core/formats: add NAPixelFormaton::get_total_depth()
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 21 May 2020 08:57:22 +0000 (10:57 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 21 May 2020 08:57:22 +0000 (10:57 +0200)
nihav-core/src/formats.rs

index 176f8d613f32a0fd782ea4569a1076c8343ebee7..2c2e717d93e3cd6bf35bf2fe2f5dafb3d0ede950 100644 (file)
@@ -659,6 +659,16 @@ impl NAPixelFormaton {
         }
         mdepth
     }
+    /// Returns the total amount of bits needed for components.
+    pub fn get_total_depth(&self) -> u8 {
+        let mut depth = 0;
+        for chr in self.comp_info.iter() {
+            if let Some(ref chromaton) = chr {
+                depth += chromaton.depth;
+            }
+        }
+        depth
+    }
     /// Returns the maximum component subsampling.
     pub fn get_max_subsampling(&self) -> u8 {
         let mut ssamp = 0;