/*fn open_wav_out(pfx: &str, strno: usize) -> WavWriter {
let name = format!("assets/{}out{:02}.wav", pfx, strno);
let mut file = File::create(name).unwrap();
- let mut fw = FileWriter::new_write(&mut file);
- let mut wr = ByteWriter::new(&mut fw);
+ let mut wr = FileWriter::new_write(&mut file);
WavWriter::new(&mut wr)
}*/
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);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mut decs: Vec<PossibleDecoder> = Vec::new();
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);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mut decs: Vec<PossibleDecoder> = Vec::new();
if let Some(audio_pfx) = audio_pfx {
let name = format!("{}/{}out.wav", OUTPUT_PREFIX, audio_pfx);
let file = File::create(name).unwrap();
- let mut fw = FileWriter::new_write(file);
- let mut wr = ByteWriter::new(&mut fw);
+ let mut wr = FileWriter::new_write(file);
let mut wwr = WavWriter::new(&mut wr);
let mut wrote_header = false;
test: ExpectedTestResult) {
let dmx_f = dmx_reg.find_demuxer(demuxer).unwrap();
let mut file = File::open(filename).unwrap();
- let mut fr = FileReader::new_read(&mut file);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mut decs: Vec<PossibleDecoder> = Vec::new();
dec_reg: &RegisteredDecoders, test: ExpectedTestResult) {
let dmx_f = dmx_reg.find_demuxer(demuxer).unwrap();
let mut file = File::open(filename).unwrap();
- let mut fr = FileReader::new_read(&mut file);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_raw_demuxer(dmx_f, &mut br).unwrap();
let mut decs: Vec<Option<(Box<dyn NAPacketiser>, Box<NADecoderSupport>, Box<dyn NADecoder>)>> = Vec::new();
let dmx_f = dmx_reg.find_demuxer(demuxer).expect("demuxer is not found");
let mut file = File::open(filename).expect("input file should be present");
- let mut fr = FileReader::new_read(&mut file);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).expect("demuxer can't be created");
let mut decs: Vec<Option<(Box<NADecoderSupport>, Box<dyn NADecoderMT>)>> = Vec::new();
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);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mut decs: Vec<PossibleDecoder> = Vec::new();
pub fn test_remuxing(dec_config: &DecoderTestParams, enc_config: &EncoderTestParams) {
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);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mux_f = enc_config.mux_reg.find_muxer(enc_config.muxer).unwrap();
let out_name = "assets/test_out/".to_owned() + enc_config.out_name;
let file = File::create(&out_name).unwrap();
- let mut fw = FileWriter::new_write(file);
- let mut bw = ByteWriter::new(&mut fw);
+ let mut bw = FileWriter::new_write(file);
let mut out_sm = StreamManager::new();
let mux_caps = mux_f.get_capabilities();
let mut stream_map: Vec<Option<usize>> = Vec::new();
pub fn test_remuxing_md5(dec_config: &DecoderTestParams, muxer: &str, mux_reg: &RegisteredMuxers, md5_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);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let mux_f = mux_reg.find_muxer(muxer).unwrap();
let mut dst = Vec::with_capacity(1 << 10);
- let mut gw = GrowableMemoryWriter::new_write(&mut dst);
- let mut bw = ByteWriter::new(&mut gw);
+ let mut bw = GrowableMemoryWriter::new_write(&mut dst);
let mut out_sm = StreamManager::new();
let mux_caps = mux_f.get_capabilities();
let mut stream_map: Vec<Option<usize>> = Vec::new();
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);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let in_stream = dmx.get_streams().find(|strm| strm.get_media_type() == dec_config.stream_type).unwrap();
let mux_f = enc_config.mux_reg.find_muxer(enc_config.muxer).unwrap();
let out_name = "assets/test_out/".to_owned() + enc_config.out_name;
let file = File::create(&out_name).unwrap();
- let mut fw = FileWriter::new_write(file);
- let mut bw = ByteWriter::new(&mut fw);
+ let mut bw = FileWriter::new_write(file);
let mut mux = create_muxer(mux_f, out_sm, &mut bw).unwrap();
let (mut ifmt, dst_vinfo) = if let NACodecTypeInfo::Video(vinfo) = enc_params.format {
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);
- let mut br = ByteReader::new(&mut fr);
+ let mut br = FileReader::new_read(&mut file);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
let in_stream = dmx.get_streams().find(|strm| strm.get_media_type() == dec_config.stream_type).unwrap();
/// WAVE output writer.
pub struct WavWriter<'a> {
- io: &'a mut ByteWriter<'a>,
+ io: &'a mut dyn ByteIO,
data_pos: u64,
}
-fn write_byte(wr: &mut ByteWriter, sample: u8) -> ByteIOResult<()> {
+fn write_byte(wr: &mut dyn ByteIO, sample: u8) -> ByteIOResult<()> {
wr.write_byte(sample)
}
-fn write_s16(wr: &mut ByteWriter, sample: i16) -> ByteIOResult<()> {
+fn write_s16(wr: &mut dyn ByteIO, sample: i16) -> ByteIOResult<()> {
wr.write_u16le(sample as u16)
}
-fn write_s32(wr: &mut ByteWriter, sample: i32) -> ByteIOResult<()> {
+fn write_s32(wr: &mut dyn ByteIO, sample: i32) -> ByteIOResult<()> {
wr.write_u16le((sample >> 16) as u16)
}
-fn write_f32(wr: &mut ByteWriter, sample: f32) -> ByteIOResult<()> {
+fn write_f32(wr: &mut dyn ByteIO, sample: f32) -> ByteIOResult<()> {
let mut out = (sample * 32768.0) as i32;
if out < -32768 { out = -32768; }
if out > 32767 { out = 32767; }
impl<'a> WavWriter<'a> {
/// Constructs a new `WavWriter` instance.
- pub fn new(io: &'a mut ByteWriter<'a>) -> Self {
+ pub fn new(io: &'a mut dyn ByteIO) -> Self {
WavWriter { io, data_pos: 0 }
}
/// Writes audio format information to the file header.