]> git.nihav.org Git - nihav.git/blobdiff - src/formats.rs
proper support for linesizes
[nihav.git] / src / formats.rs
index 03e6411bf107e4e5e12cb7a8d73738db8f205d37..180e9800433bfc297bd2e2015c3e6d223f17a52a 100644 (file)
@@ -59,7 +59,7 @@ impl fmt::Display for NASoniton {
     }
 }
 
-#[derive(Debug,Clone,Copy)]
+#[derive(Debug,Clone,Copy,PartialEq)]
 pub enum NAChannelType {
     C, L, R, Cs, Ls, Rs, Lss, Rss, LFE, Lc, Rc, Lh, Rh, Ch, LFE2, Lw, Rw, Ov, Lhs, Rhs, Chs, Ll, Rl, Cl, Lt, Rt, Lo, Ro
 }
@@ -142,6 +142,11 @@ impl NAChannelMap {
     pub fn add_channel(&mut self, ch: NAChannelType) {
         self.ids.push(ch);
     }
+    pub fn add_channels(&mut self, chs: &[NAChannelType]) {
+        for i in 0..chs.len() {
+            self.ids.push(chs[i]);
+        }
+    }
     pub fn num_channels(&self) -> usize {
         self.ids.len()
     }
@@ -325,7 +330,11 @@ impl NAPixelChromaton {
     }
     pub fn get_linesize(&self, width: usize) -> usize {
         let d = self.depth as usize;
-        (self.get_width(width) * d + d - 1) >> 3
+        if self.packed {
+            (self.get_width(width) * d + d - 1) >> 3
+        } else {
+            self.get_width(width)
+        }
     }
     pub fn get_data_size(&self, width: usize, height: usize) -> usize {
         let nh = (height + ((1 << self.v_ss) - 1)) >> self.v_ss;