]> git.nihav.org Git - nihav.git/commitdiff
moviepak: obtain YUV422 formaton from string instead of hardcoding it
authorKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 2 Mar 2026 17:08:34 +0000 (18:08 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 2 Mar 2026 17:08:34 +0000 (18:08 +0100)
nihav-misc/src/codecs/moviepak.rs

index 86bb930c72152f9e2c61d90cc7754d4ece8b6df7..8c10dd9cdf17c23e2a7fa419dff982618a7a559e 100644 (file)
@@ -3,6 +3,7 @@
 use nihav_core::io::byteio::{ByteIO,MemoryReader};
 use nihav_core::codecs::*;
 use nihav_codec_support::codecs::jpeg::*;
+use std::str::FromStr;
 
 struct MoviePakDecoder {
     info:       NACodecInfoRef,
@@ -58,42 +59,7 @@ impl NADecoder for MoviePakDecoder {
             *el                 = i16::from(br.read_byte()?);
         }
 
-        let formaton = NAPixelFormaton {
-                model:      ColorModel::YUV(YUVSubmodel::YUVJ),
-                components: 3,
-                comp_info:  [
-                    Some(NAPixelChromaton {
-                        h_ss: 0, v_ss: 0,
-                        packed:     false,
-                        depth:      8,
-                        shift:      0,
-                        comp_offs:  0,
-                        next_elem:  1,
-                    }),
-                    Some(NAPixelChromaton {
-                        h_ss: 1, v_ss: 0,
-                        packed:     false,
-                        depth:      8,
-                        shift:      0,
-                        comp_offs:  1,
-                        next_elem:  1,
-                    }),
-                    Some(NAPixelChromaton {
-                        h_ss: 1, v_ss: 0,
-                        packed:     false,
-                        depth:      8,
-                        shift:      0,
-                        comp_offs:  2,
-                        next_elem:  1,
-                    }),
-                    None,
-                    None
-                ],
-                elem_size:  0,
-                be:         false,
-                alpha:      false,
-                palette:    false,
-            };
+        let formaton = NAPixelFormaton::from_str("yuv422p").unwrap();
         let vinfo = NAVideoInfo::new(self.jpeg.width, self.jpeg.height, false, formaton);
         let bufinfo = alloc_video_buffer(vinfo, 4)?;