]> git.nihav.org Git - nihav.git/commitdiff
try to fix tests
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 17 Jan 2019 15:17:15 +0000 (16:17 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 17 Jan 2019 15:17:26 +0000 (16:17 +0100)
nihav-commonfmt/src/codecs/aac.rs
nihav-commonfmt/src/codecs/atrac3.rs
nihav-commonfmt/src/codecs/clearvideo.rs
nihav-commonfmt/src/codecs/sipro.rs
nihav-commonfmt/src/codecs/ts102366.rs
nihav-core/src/lib.rs
nihav-core/src/test/dec_video.rs

index b81bdeefda194e39f50836a126e77ac81be71aca..02223c8a969fa0a5aeebb976b346a44ab87a1663 100644 (file)
@@ -1263,12 +1263,21 @@ pub fn get_decoder() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use crate::test::dec_video::*;
+    use nihav_core::codecs::RegisteredDecoders;
+    use nihav_core::demuxers::RegisteredDemuxers;
+    use nihav_core::test::dec_video::test_decode_audio;
+    use crate::codecs::generic_register_all_codecs;
+    use nihav_realmedia::demuxers::realmedia_register_all_demuxers;
     #[test]
     fn test_aac() {
+        let mut dmx_reg = RegisteredDemuxers::new();
+        realmedia_register_all_demuxers(&mut dmx_reg);
+        let mut dec_reg = RegisteredDecoders::new();
+        generic_register_all_codecs(&mut dec_reg);
+
 //        let file = "assets/RV/rv40_weighted_mc.rmvb";
         let file = "assets/RV/rv40_weighted_mc_2.rmvb";
-        test_decode_audio("realmedia", file, Some(12000), "aac");
+        test_decode_audio("realmedia", file, Some(12000), "aac", &dmx_reg, &dec_reg);
     }
 }
 
index 59e690bf3002ef7df26383b000dde3eaff4ef237..3170c00cad92cb1163ad82fab3646c88ad9c4117 100644 (file)
@@ -700,12 +700,21 @@ pub fn get_decoder() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use crate::test::dec_video::*;
+    use nihav_core::codecs::RegisteredDecoders;
+    use nihav_core::demuxers::RegisteredDemuxers;
+    use nihav_core::test::dec_video::test_decode_audio;
+    use crate::codecs::generic_register_all_codecs;
+    use nihav_realmedia::demuxers::realmedia_register_all_demuxers;
     #[test]
     fn test_atrac3() {
+        let mut dmx_reg = RegisteredDemuxers::new();
+        realmedia_register_all_demuxers(&mut dmx_reg);
+        let mut dec_reg = RegisteredDecoders::new();
+        generic_register_all_codecs(&mut dec_reg);
+
         let file = "assets/RV/rv30_atrc_384x208_realproducer_plus_8.51.rm";
 //        let file = "assets/RV/rv20_svt_atrc_640x352_realproducer_plus_8.51.rm";
-        test_decode_audio("realmedia", file, Some(12000), "atrac3");
+        test_decode_audio("realmedia", file, Some(12000), "atrac3", &dmx_reg, &dec_reg);
     }
 }
 
index 85431784dee3ef3ad039c7541346538497367e36..6b66dfac38cc0b1ff9276a1d770ed947ea57fab9 100644 (file)
@@ -774,10 +774,18 @@ pub fn get_decoder_rm() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use crate::test::dec_video::test_file_decoding;
+    use nihav_core::codecs::RegisteredDecoders;
+    use nihav_core::demuxers::RegisteredDemuxers;
+    use nihav_core::test::dec_video::test_file_decoding;
+    use crate::codecs::generic_register_all_codecs;
+    use crate::demuxers::generic_register_all_demuxers;
     #[test]
     fn test_clv() {
-         test_file_decoding("avi", "assets/TalkingHead_352x288.avi", Some(10), true, false, None/*Some("clv")*/);
+        let mut dmx_reg = RegisteredDemuxers::new();
+        generic_register_all_demuxers(&mut dmx_reg);
+        let mut dec_reg = RegisteredDecoders::new();
+        generic_register_all_codecs(&mut dec_reg);
+        test_file_decoding("avi", "assets/TalkingHead_352x288.avi", Some(10), true, false, None/*Some("clv")*/, &dmx_reg, &dec_reg);
 //         test_file_decoding("avi", "assets/basketball.avi", None/*Some(10)*/, true, false, Some("clv1"));
 //panic!("debug");
     }
index 4f6a86618b604a8ba7078a359ef09ac8752ad451..8820a011149d5d2ae5826c7b6e7087ed156f5f76 100644 (file)
@@ -741,11 +741,20 @@ pub fn get_decoder() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use crate::test::dec_video::*;
+    use nihav_core::codecs::RegisteredDecoders;
+    use nihav_core::demuxers::RegisteredDemuxers;
+    use nihav_core::test::dec_video::test_decode_audio;
+    use crate::codecs::generic_register_all_codecs;
+    use nihav_realmedia::demuxers::realmedia_register_all_demuxers;
     #[test]
     fn test_sipro() {
+        let mut dmx_reg = RegisteredDemuxers::new();
+        realmedia_register_all_demuxers(&mut dmx_reg);
+        let mut dec_reg = RegisteredDecoders::new();
+        generic_register_all_codecs(&mut dec_reg);
+
         let file = "assets/RV/autahi-vox.rm";
-        test_decode_audio("realmedia", file, Some(5000), "sipro");
+        test_decode_audio("realmedia", file, Some(5000), "sipro", &dmx_reg, &dec_reg);
     }
 }
 
index 9c2a0940b9b915ed78c4d3aafbeec701a0a23b53..12e0fe915d535a4436df4f4a2fa8ac5fe884ac58 100644 (file)
@@ -1247,11 +1247,20 @@ pub fn get_decoder() -> Box<NADecoder> {
 
 #[cfg(test)]
 mod test {
-    use crate::test::dec_video::*;
+    use nihav_core::codecs::RegisteredDecoders;
+    use nihav_core::demuxers::RegisteredDemuxers;
+    use nihav_core::test::dec_video::test_decode_audio;
+    use crate::codecs::generic_register_all_codecs;
+    use nihav_realmedia::demuxers::realmedia_register_all_demuxers;
     #[test]
     fn test_ts102366() {
+        let mut dmx_reg = RegisteredDemuxers::new();
+        realmedia_register_all_demuxers(&mut dmx_reg);
+        let mut dec_reg = RegisteredDecoders::new();
+        generic_register_all_codecs(&mut dec_reg);
+
         let file = "assets/RV/sp_sample1.rm";
-        test_decode_audio("realmedia", file, Some(12000), "ac3");
+        test_decode_audio("realmedia", file, Some(12000), "ac3", &dmx_reg, &dec_reg);
     }
 }
 
index 07c451e150004a94aa83212da02cceaa7331682c..05b7ad92cd8f0e9bd88efbc7a46d9bb6434b6e19 100644 (file)
@@ -13,5 +13,4 @@ pub mod detect;
 #[cfg(feature="dsp")]
 pub mod dsp;
 
-#[cfg(test)]
-mod test;
+pub mod test;
index 4a181917ebeae8b75c676f06aa133b7bf38ccc89..8dbc1839ae182dcf2e3fb9821b58647b9b2ec6ec 100644 (file)
@@ -103,8 +103,9 @@ fn write_palppm(pfx: &str, strno: usize, num: u64, frmref: NAFrameRef) {
 
 pub fn test_file_decoding(demuxer: &str, name: &str, limit: Option<u64>,
                           decode_video: bool, decode_audio: bool,
-                          video_pfx: Option<&str>) {
-    let dmx_f = find_demuxer(demuxer).unwrap();
+                          video_pfx: Option<&str>,
+                          dmx_reg: &RegisteredDemuxers, dec_reg: &RegisteredDecoders) {
+    let dmx_f = dmx_reg.find_demuxer(demuxer).unwrap();
     let mut file = File::open(name).unwrap();
     let mut fr = FileReader::new_read(&mut file);
     let mut br = ByteReader::new(&mut fr);
@@ -114,7 +115,7 @@ pub fn test_file_decoding(demuxer: &str, name: &str, limit: Option<u64>,
     for i in 0..dmx.get_num_streams() {
         let s = dmx.get_stream(i).unwrap();
         let info = s.get_info();
-        let decfunc = find_decoder(info.get_name());
+        let decfunc = dec_reg.find_decoder(info.get_name());
         if let Some(df) = decfunc {
             if (decode_video && info.is_video()) || (decode_audio && info.is_audio()) {
                 let mut dec = (df)();
@@ -154,8 +155,9 @@ pub fn test_file_decoding(demuxer: &str, name: &str, limit: Option<u64>,
     }
 }
 
-pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option<u64>, audio_pfx: &str) {
-    let dmx_f = find_demuxer(demuxer).unwrap();
+pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option<u64>, audio_pfx: &str,
+                         dmx_reg: &RegisteredDemuxers, dec_reg: &RegisteredDecoders) {
+    let dmx_f = dmx_reg.find_demuxer(demuxer).unwrap();
     let mut file = File::open(name).unwrap();
     let mut fr = FileReader::new_read(&mut file);
     let mut br = ByteReader::new(&mut fr);
@@ -165,7 +167,7 @@ pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option<u64>, audio_pf
     for i in 0..dmx.get_num_streams() {
         let s = dmx.get_stream(i).unwrap();
         let info = s.get_info();
-        let decfunc = find_decoder(info.get_name());
+        let decfunc = dec_reg.find_decoder(info.get_name());
         if let Some(df) = decfunc {
             if info.is_audio() {
                 let mut dec = (df)();