From b09ecc095508e73b170333ff85d25f64bd8394db Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 8 Aug 2021 12:55:53 +0200 Subject: [PATCH] make encoder test functions accept encoder-specific options --- nihav-codec-support/src/test/enc_video.rs | 6 ++++-- nihav-commonfmt/src/codecs/cinepakenc.rs | 4 ++-- nihav-commonfmt/src/codecs/zmbvenc.rs | 20 ++++++++++++-------- nihav-ms/src/codecs/msadpcm.rs | 2 +- nihav-ms/src/codecs/msvideo1enc.rs | 4 ++-- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/nihav-codec-support/src/test/enc_video.rs b/nihav-codec-support/src/test/enc_video.rs index e9fcf1f..16ea415 100644 --- a/nihav-codec-support/src/test/enc_video.rs +++ b/nihav-codec-support/src/test/enc_video.rs @@ -210,7 +210,7 @@ pub fn test_remuxing_md5(dec_config: &DecoderTestParams, muxer: &str, mux_reg: & } /// Tests an encoder by decoding a stream from input file, feeding it to the encoder and muxing the result into output file. -pub fn test_encoding_to_file(dec_config: &DecoderTestParams, enc_config: &EncoderTestParams, mut enc_params: EncodeParameters) { +pub fn test_encoding_to_file(dec_config: &DecoderTestParams, enc_config: &EncoderTestParams, mut enc_params: EncodeParameters, enc_options: &[NAOption]) { let dmx_f = dec_config.dmx_reg.find_demuxer(dec_config.demuxer).unwrap(); let mut file = File::open(dec_config.in_name).unwrap(); let mut fr = FileReader::new_read(&mut file); @@ -256,6 +256,7 @@ pub fn test_encoding_to_file(dec_config: &DecoderTestParams, enc_config: &Encode let encfunc = enc_config.enc_reg.find_encoder(enc_config.enc_name).unwrap(); let mut encoder = (encfunc)(); + encoder.set_options(enc_options); let out_str = encoder.init(0, enc_params).unwrap(); out_sm.add_stream(NAStream::clone(&out_str)); @@ -318,7 +319,7 @@ pub fn test_encoding_to_file(dec_config: &DecoderTestParams, enc_config: &Encode } /// Tests an encoder by decoding a stream from input file, feeding it to the encoder and calculating the hash of codec information and packet data. -pub fn test_encoding_md5(dec_config: &DecoderTestParams, enc_config: &EncoderTestParams, mut enc_params: EncodeParameters, ref_hash: &[u32; 4]) { +pub fn test_encoding_md5(dec_config: &DecoderTestParams, enc_config: &EncoderTestParams, mut enc_params: EncodeParameters, enc_options: &[NAOption], ref_hash: &[u32; 4]) { let dmx_f = dec_config.dmx_reg.find_demuxer(dec_config.demuxer).unwrap(); let mut file = File::open(dec_config.in_name).unwrap(); let mut fr = FileReader::new_read(&mut file); @@ -363,6 +364,7 @@ pub fn test_encoding_md5(dec_config: &DecoderTestParams, enc_config: &EncoderTes let encfunc = enc_config.enc_reg.find_encoder(enc_config.enc_name).unwrap(); let mut encoder = (encfunc)(); + encoder.set_options(enc_options); let out_str = encoder.init(0, enc_params).unwrap(); let mut md5 = MD5::new(); diff --git a/nihav-commonfmt/src/codecs/cinepakenc.rs b/nihav-commonfmt/src/codecs/cinepakenc.rs index 38f7cec..01e5714 100644 --- a/nihav-commonfmt/src/codecs/cinepakenc.rs +++ b/nihav-commonfmt/src/codecs/cinepakenc.rs @@ -1128,8 +1128,8 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + //test_encoding_to_file(&dec_config, &enc_config, enc_params, &[]); + test_encoding_md5(&dec_config, &enc_config, enc_params, &[], &[0xd73cb3c7, 0x30d59f90, 0x1d6e0e28, 0x5b72cc0c]); } } diff --git a/nihav-commonfmt/src/codecs/zmbvenc.rs b/nihav-commonfmt/src/codecs/zmbvenc.rs index 0d5c1af..7de6c23 100644 --- a/nihav-commonfmt/src/codecs/zmbvenc.rs +++ b/nihav-commonfmt/src/codecs/zmbvenc.rs @@ -588,8 +588,9 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + let enc_options = &[]; + //test_encoding_to_file(&dec_config, &enc_config, enc_params, enc_options); + test_encoding_md5(&dec_config, &enc_config, enc_params, enc_options, &[0x50df10e2, 0x606f3268, 0xdd4bc2ff, 0x844e7d87]); } @@ -632,8 +633,9 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + let enc_options = &[]; + //test_encoding_to_file(&dec_config, &enc_config, enc_params, enc_options); + test_encoding_md5(&dec_config, &enc_config, enc_params, enc_options, &[0x0b4cb528, 0x66c91f6c, 0x1c2187a5, 0x2723a08d]); } @@ -676,8 +678,9 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + let enc_options = &[]; + //test_encoding_to_file(&dec_config, &enc_config, enc_params, enc_options); + test_encoding_md5(&dec_config, &enc_config, enc_params, enc_options, &[0x1a522743, 0x6c320a6e, 0xd08539e1, 0x03fc17ea]); } @@ -720,8 +723,9 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + let enc_options = &[]; + //test_encoding_to_file(&dec_config, &enc_config, enc_params, enc_options); + test_encoding_md5(&dec_config, &enc_config, enc_params, enc_options, &[0x3880e045, 0xe6c88dc7, 0x21066058, 0xc789f1e9]); } } diff --git a/nihav-ms/src/codecs/msadpcm.rs b/nihav-ms/src/codecs/msadpcm.rs index 5010c03..dfcf640 100644 --- a/nihav-ms/src/codecs/msadpcm.rs +++ b/nihav-ms/src/codecs/msadpcm.rs @@ -464,7 +464,7 @@ mod test { tb_den: 0, flags: 0, }; - test_encoding_md5(&dec_config, &enc_config, enc_params, + test_encoding_md5(&dec_config, &enc_config, enc_params, &[], &[0xe1591a1e, 0x816d0239, 0x4cc42291, 0x4e6b69cb]); } } diff --git a/nihav-ms/src/codecs/msvideo1enc.rs b/nihav-ms/src/codecs/msvideo1enc.rs index d2e5c34..89b4b22 100644 --- a/nihav-ms/src/codecs/msvideo1enc.rs +++ b/nihav-ms/src/codecs/msvideo1enc.rs @@ -610,8 +610,8 @@ mod test { tb_den: 0, flags: 0, }; - //test_encoding_to_file(&dec_config, &enc_config, enc_params); - test_encoding_md5(&dec_config, &enc_config, enc_params, + //test_encoding_to_file(&dec_config, &enc_config, enc_params, &[]); + test_encoding_md5(&dec_config, &enc_config, enc_params, &[], &[0x4339421d, 0x6393f1b6, 0x653d6cd2, 0x3a184382]); } } -- 2.30.2