From: Kostya Shishkov Date: Thu, 17 Jan 2019 15:17:15 +0000 (+0100) Subject: try to fix tests X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=4f6124ac474e05ab343505444cdbb69b67829e2c;p=nihav.git try to fix tests --- diff --git a/nihav-commonfmt/src/codecs/aac.rs b/nihav-commonfmt/src/codecs/aac.rs index b81bdee..02223c8 100644 --- a/nihav-commonfmt/src/codecs/aac.rs +++ b/nihav-commonfmt/src/codecs/aac.rs @@ -1263,12 +1263,21 @@ pub fn get_decoder() -> Box { #[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); } } diff --git a/nihav-commonfmt/src/codecs/atrac3.rs b/nihav-commonfmt/src/codecs/atrac3.rs index 59e690b..3170c00 100644 --- a/nihav-commonfmt/src/codecs/atrac3.rs +++ b/nihav-commonfmt/src/codecs/atrac3.rs @@ -700,12 +700,21 @@ pub fn get_decoder() -> Box { #[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); } } diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 8543178..6b66dfa 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -774,10 +774,18 @@ pub fn get_decoder_rm() -> Box { #[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"); } diff --git a/nihav-commonfmt/src/codecs/sipro.rs b/nihav-commonfmt/src/codecs/sipro.rs index 4f6a866..8820a01 100644 --- a/nihav-commonfmt/src/codecs/sipro.rs +++ b/nihav-commonfmt/src/codecs/sipro.rs @@ -741,11 +741,20 @@ pub fn get_decoder() -> Box { #[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); } } diff --git a/nihav-commonfmt/src/codecs/ts102366.rs b/nihav-commonfmt/src/codecs/ts102366.rs index 9c2a094..12e0fe9 100644 --- a/nihav-commonfmt/src/codecs/ts102366.rs +++ b/nihav-commonfmt/src/codecs/ts102366.rs @@ -1247,11 +1247,20 @@ pub fn get_decoder() -> Box { #[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); } } diff --git a/nihav-core/src/lib.rs b/nihav-core/src/lib.rs index 07c451e..05b7ad9 100644 --- a/nihav-core/src/lib.rs +++ b/nihav-core/src/lib.rs @@ -13,5 +13,4 @@ pub mod detect; #[cfg(feature="dsp")] pub mod dsp; -#[cfg(test)] -mod test; +pub mod test; diff --git a/nihav-core/src/test/dec_video.rs b/nihav-core/src/test/dec_video.rs index 4a18191..8dbc183 100644 --- a/nihav-core/src/test/dec_video.rs +++ b/nihav-core/src/test/dec_video.rs @@ -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, 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, 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, } } -pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option, audio_pfx: &str) { - let dmx_f = find_demuxer(demuxer).unwrap(); +pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option, 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, 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)();