// 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", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(12000), None/*Some("aac")*/, &dmx_reg, &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", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(12000), None/*Some("atrac3")*/, &dmx_reg, &dec_reg);
}
}
generic_register_all_codecs(&mut dec_reg);
let file = "assets/RV/autahi-vox.rm";
- test_decode_audio("realmedia", file, Some(5000), "sipro", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(5000), None/*Some("sipro")*/, &dmx_reg, &dec_reg);
}
}
generic_register_all_codecs(&mut dec_reg);
let file = "assets/RV/sp_sample1.rm";
- test_decode_audio("realmedia", file, Some(12000), "ac3", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(12000), None/*Some("ac3")*/, &dmx_reg, &dec_reg);
}
}
}
}
-pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option<u64>, audio_pfx: &str,
+pub fn test_decode_audio(demuxer: &str, name: &str, limit: Option<u64>, audio_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 name = format!("assets/{}out.wav", audio_pfx);
- let file = File::create(name).unwrap();
- let mut fw = FileWriter::new_write(file);
- let mut wr = ByteWriter::new(&mut fw);
- let mut wwr = WavWriter::new(&mut wr);
- let mut wrote_header = false;
+ if let Some(audio_pfx) = audio_pfx {
+ let name = format!("assets/{}out.wav", audio_pfx);
+ let file = File::create(name).unwrap();
+ let mut fw = FileWriter::new_write(file);
+ let mut wr = ByteWriter::new(&mut fw);
+ let mut wwr = WavWriter::new(&mut wr);
+ let mut wrote_header = false;
- loop {
- let pktres = dmx.get_frame();
- if let Err(e) = pktres {
- if e == DemuxerError::EOF { break; }
- panic!("error");
- }
- let pkt = pktres.unwrap();
- if limit.is_some() && pkt.get_pts().is_some() && pkt.get_pts().unwrap() > limit.unwrap() {
- break;
- }
- let streamno = pkt.get_stream().get_id() as usize;
- if let Some((ref mut dsupp, ref mut dec)) = decs[streamno] {
- let frm = dec.decode(dsupp, &pkt).unwrap();
- if frm.get_info().is_audio() {
- if !wrote_header {
- wwr.write_header(frm.get_info().as_ref().get_properties().get_audio_info().unwrap()).unwrap();
- wrote_header = true;
+ loop {
+ let pktres = dmx.get_frame();
+ if let Err(e) = pktres {
+ if e == DemuxerError::EOF { break; }
+ panic!("error");
+ }
+ let pkt = pktres.unwrap();
+ if limit.is_some() && pkt.get_pts().is_some() && pkt.get_pts().unwrap() > limit.unwrap() {
+ break;
+ }
+ let streamno = pkt.get_stream().get_id() as usize;
+ if let Some((ref mut dsupp, ref mut dec)) = decs[streamno] {
+ let frm = dec.decode(dsupp, &pkt).unwrap();
+ if frm.get_info().is_audio() {
+ if !wrote_header {
+ wwr.write_header(frm.get_info().as_ref().get_properties().get_audio_info().unwrap()).unwrap();
+ wrote_header = true;
+ }
+ wwr.write_frame(frm.get_buffer()).unwrap();
}
- wwr.write_frame(frm.get_buffer()).unwrap();
+ }
+ }
+ } else {
+ loop {
+ let pktres = dmx.get_frame();
+ if let Err(e) = pktres {
+ if e == DemuxerError::EOF { break; }
+ panic!("error");
+ }
+ let pkt = pktres.unwrap();
+ if limit.is_some() && pkt.get_pts().is_some() && pkt.get_pts().unwrap() > limit.unwrap() {
+ break;
+ }
+ let streamno = pkt.get_stream().get_id() as usize;
+ if let Some((ref mut dsupp, ref mut dec)) = decs[streamno] {
+ let _ = dec.decode(dsupp, &pkt).unwrap();
}
}
}
duck_register_all_codecs(&mut dec_reg);
let file = "assets/Duck/AVI-DUCK-dk3.duk";
- test_decode_audio("avi", file, Some(100), "dk3", &dmx_reg, &dec_reg);
+ test_decode_audio("avi", file, Some(100), None/*Some("dk3")*/, &dmx_reg, &dec_reg);
}
#[test]
fn test_dk4() {
duck_register_all_codecs(&mut dec_reg);
let file = "assets/Duck/virtuafighter2-opening1.avi";
- test_decode_audio("avi", file, Some(100), "dk4", &dmx_reg, &dec_reg);
+ test_decode_audio("avi", file, Some(100), None/*Some("dk4")*/, &dmx_reg, &dec_reg);
}
}
//let file = "assets/Duck/Cell-140.vp5";
//let file = "assets/Duck/Chocolat-500.vp5";
let file = "assets/Duck/potter-500.vp7";
- test_decode_audio("avi", file, Some(1500), "avc", &dmx_reg, &dec_reg);
+ test_decode_audio("avi", file, Some(1500), None/*Some("avc")*/, &dmx_reg, &dec_reg);
}
}
let file = "assets/Game/PERFECT.BMV";
// let file = "assets/Game/DW2-MOUSE.BMV";
// let file = "assets/Game/WILDCAT.BMV";
- test_decode_audio("bmv", file, None, "bmv", &dmx_reg, &dec_reg);
+ test_decode_audio("bmv", file, None, None/*Some("bmv")*/, &dmx_reg, &dec_reg);
}
}
game_register_all_codecs(&mut dec_reg);
let file = "assets/Game/DW3-Loffnote.bmv";
- test_decode_audio("bmv3", file, None, "bmv3", &dmx_reg, &dec_reg);
+ test_decode_audio("bmv3", file, None, None/*Some("bmv3")*/, &dmx_reg, &dec_reg);
}
}
let file = "assets/Game/128.vmd";
// let file = "assets/Game/1000.VMD";
// let file = "assets/Game/235.VMD";
- test_decode_audio("vmd", file, None, "vmd", &dmx_reg, &dec_reg);
+ test_decode_audio("vmd", file, None, None/*Some("vmd")*/, &dmx_reg, &dec_reg);
}
}
let file = "assets/Indeo/IMC/8khz.avi";
// let file = "assets/Indeo/STsKlassFist-1a.avi";
// let file = "assets/Indeo/IMC/Angel Bday.avi";
- test_decode_audio("avi", file, None, "imc", &dmx_reg, &dec_reg);
+ test_decode_audio("avi", file, None, None/*Some("imc")*/, &dmx_reg, &dec_reg);
//test_file_decoding("avi", file, None, false, true, None);
}
}
// let file = "assets/RAD/Snd0a110c51.dee";
// let file = "assets/RAD/NEW.BIK";
// let file = "assets/RAD/ge_video_86l.bk2";
- test_decode_audio("bink", file, None, "bink", &dmx_reg, &dec_reg);
+ test_decode_audio("bink", file, None, None/*Some("bink")*/, &dmx_reg, &dec_reg);
}
}
//let file = "assets/RAD/20130507_audio-distortion.smk";
let file = "assets/RAD/wetlogo.smk";
- test_decode_audio("smacker", file, None, "smk", &dmx_reg, &dec_reg);
+ test_decode_audio("smacker", file, None, None/*Some("smk")*/, &dmx_reg, &dec_reg);
}
}
// let file = "assets/RV/rv30_weighted_mc.rm";
let file = "assets/RV/multichannel.rma";
- test_decode_audio("realmedia", file, Some(2000), "cook", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(2000), None/*Some("cook")*/, &dmx_reg, &dec_reg);
}
}
realmedia_register_all_codecs(&mut dec_reg);
let file = "assets/RV/ra3_in_rm_file.rm";
- test_decode_audio("realmedia", file, Some(5000), "ra14.4", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(5000), None/*Some("ra14.4")*/, &dmx_reg, &dec_reg);
}
}
realmedia_register_all_codecs(&mut dec_reg);
let file = "assets/RV/A0000044.rm";
- test_decode_audio("realmedia", file, Some(5000), "ra28.8", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(5000), None/*Some("ra28.8")*/, &dmx_reg, &dec_reg);
}
}
realmedia_register_all_codecs(&mut dec_reg);
let file = "assets/RV/rv40_ralf.rmvb";
- test_decode_audio("realmedia", file, Some(2000), "ralf", &dmx_reg, &dec_reg);
+ test_decode_audio("realmedia", file, Some(2000), None/*Some("ralf")*/, &dmx_reg, &dec_reg);
//panic!("end");
}
}