]> git.nihav.org Git - nihav.git/commitdiff
formats: add some helper functions and make formaton and chromaton fields public
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 10 Feb 2019 17:45:04 +0000 (18:45 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 10 Feb 2019 17:45:04 +0000 (18:45 +0100)
nihav-core/src/formats.rs

index 952e4c042953272be35bb17a9969fda202b987ed..0cc24a1033933203c7cdb3446ef4d2ee75e5de73 100644 (file)
@@ -297,6 +297,18 @@ impl ColorModel {
             _                => 3,
         }
     }
+    pub fn is_rgb(&self) -> bool {
+        match *self {
+            ColorModel::RGB(_) => true,
+            _ => false,
+        }
+    }
+    pub fn is_yuv(&self) -> bool {
+        match *self {
+            ColorModel::YUV(_) => true,
+            _ => false,
+        }
+    }
 }
 
 impl fmt::Display for ColorModel {
@@ -315,13 +327,13 @@ impl fmt::Display for ColorModel {
 
 #[derive(Clone,Copy,PartialEq)]
 pub struct NAPixelChromaton {
-    h_ss:           u8,
-    v_ss:           u8,
-    packed:         bool,
-    depth:          u8,
-    shift:          u8,
-    comp_offs:      u8,
-    next_elem:      u8,
+    pub h_ss:           u8,
+    pub v_ss:           u8,
+    pub packed:         bool,
+    pub depth:          u8,
+    pub shift:          u8,
+    pub comp_offs:      u8,
+    pub next_elem:      u8,
 }
 
 pub const FORMATON_FLAG_BE      :u32 = 0x01;
@@ -331,13 +343,13 @@ pub const FORMATON_FLAG_PALETTE :u32 = 0x04;
 
 #[derive(Clone,Copy,PartialEq)]
 pub struct NAPixelFormaton {
-    model:      ColorModel,
-    components: u8,
-    comp_info:  [Option<NAPixelChromaton>; 5],
-    elem_size:  u8,
-    be:         bool,
-    alpha:      bool,
-    palette:    bool,
+    pub model:      ColorModel,
+    pub components: u8,
+    pub comp_info:  [Option<NAPixelChromaton>; 5],
+    pub elem_size:  u8,
+    pub be:         bool,
+    pub alpha:      bool,
+    pub palette:    bool,
 }
 
 macro_rules! chromaton {