]> git.nihav.org Git - nihav.git/blobdiff - nihav-flash/src/codecs/flashsv.rs
Acorn Super Moving Blocks Decoder
[nihav.git] / nihav-flash / src / codecs / flashsv.rs
index 26e0eb4e201d9bac69f448b0ab491a47a82001fd..9e577d1499c5b1cfe8edb8af58fbb42ac57f10d8 100644 (file)
@@ -33,16 +33,10 @@ impl FSVShuffler {
     }
     fn has_last_frame(&self) -> bool { self.lastframe.is_some() }
     fn get_key_frame(&mut self) -> Option<NAVideoBufferRef<u8>> {
-        match self.keyframe {
-            Some(ref frm) => Some(frm.clone()),
-            None => None,
-        }
+        self.keyframe.as_ref().cloned()
     }
     fn get_last_frame(&mut self) -> Option<NAVideoBufferRef<u8>> {
-        match self.lastframe {
-            Some(ref frm) => Some(frm.clone()),
-            None => None,
-        }
+        self.lastframe.as_ref().cloned()
     }
 }
 
@@ -235,7 +229,7 @@ impl NADecoder for FSVDecoder {
         if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
             let w = vinfo.get_width();
             let h = vinfo.get_height();
-            let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, true, RGB24_FORMAT));
+            let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, true, BGR24_FORMAT));
             self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
 
             Ok(())
@@ -347,6 +341,7 @@ mod test {
         let mut dec_reg = RegisteredDecoders::new();
         flash_register_all_decoders(&mut dec_reg);
 
+        // sample: https://samples.mplayerhq.hu/FLV/flash_screen/screen.flv
         test_decoding("flv", "flashsv", "assets/Flash/screen.flv",
                       Some(3000), &dmx_reg, &dec_reg, ExpectedTestResult::MD5Frames(vec![
                             [0xb45b899e, 0x417b17d5, 0x7bfe898b, 0x026b289f],
@@ -367,6 +362,7 @@ mod test {
         let mut dec_reg = RegisteredDecoders::new();
         flash_register_all_decoders(&mut dec_reg);
 
+        // sample created from https://samples.mplayerhq.hu/FLV/flash_screen/screen.flv by recoding
         test_decoding("flv", "flashsv2", "assets/Flash/screen2.flv",
                       Some(4700), &dmx_reg, &dec_reg, ExpectedTestResult::MD5Frames(vec![
                             [0x55522afa, 0x9c7dd794, 0xdd67aa2e, 0x8b8c525e],
@@ -388,7 +384,7 @@ mod test {
 }
 
 const DEFAULT_PAL: [u8; 128 * 3] = [
-     0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x99, 0x99, 0x99,
+    0x00, 0x00, 0x00, 0x33, 0x33, 0x33, 0x66, 0x66, 0x66, 0x99, 0x99, 0x99,
     0xCC, 0xCC, 0xCC, 0xFF, 0xFF, 0xFF, 0x33, 0x00, 0x00, 0x66, 0x00, 0x00,
     0x99, 0x00, 0x00, 0xCC, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x33, 0x00,
     0x00, 0x66, 0x00, 0x00, 0x99, 0x00, 0x00, 0xCC, 0x00, 0x00, 0xFF, 0x00,
@@ -421,3 +417,16 @@ const DEFAULT_PAL: [u8; 128 * 3] = [
     0x11, 0x11, 0x11, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x55, 0x55, 0x55,
     0xAA, 0xAA, 0xAA, 0xBB, 0xBB, 0xBB, 0xDD, 0xDD, 0xDD, 0xEE, 0xEE, 0xEE
 ];
+
+const BGR24_FORMAT: NAPixelFormaton = NAPixelFormaton {
+        model: ColorModel::RGB(RGBSubmodel::RGB), components: 3,
+        comp_info: [
+            Some(NAPixelChromaton{
+                h_ss: 0, v_ss: 0, packed: true, depth: 8, shift: 0, comp_offs: 2, next_elem: 3 }),
+            Some(NAPixelChromaton{
+                h_ss: 0, v_ss: 0, packed: true, depth: 8, shift: 0, comp_offs: 1, next_elem: 3 }),
+            Some(NAPixelChromaton{
+                h_ss: 0, v_ss: 0, packed: true, depth: 8, shift: 0, comp_offs: 0, next_elem: 3 }),
+            None, None],
+        elem_size: 3, be: false, alpha: false, palette: false
+};