let mut br = ByteReader::new(&mut fr);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
- let in_stream = dmx.get_streams().find(|str| str.get_media_type() == dec_config.stream_type).unwrap();
+ let in_stream = dmx.get_streams().find(|strm| strm.get_media_type() == dec_config.stream_type).unwrap();
let in_stream_id = in_stream.id;
let decfunc = dec_config.dec_reg.find_decoder(in_stream.get_info().get_name()).unwrap();
let mut dec = (decfunc)();
let mut br = ByteReader::new(&mut fr);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
- let in_stream = dmx.get_streams().find(|str| str.get_media_type() == dec_config.stream_type).unwrap();
+ let in_stream = dmx.get_streams().find(|strm| strm.get_media_type() == dec_config.stream_type).unwrap();
let in_stream_id = in_stream.id;
let decfunc = dec_config.dec_reg.find_decoder(in_stream.get_info().get_name()).unwrap();
let mut dec = (decfunc)();
}
},
"quant_mode" => {
- if let NAValue::String(ref str) = option.value {
- match str.as_str() {
+ if let NAValue::String(ref strval) = option.value {
+ match strval.as_str() {
"elbg" => self.qmode = QuantMode::ELBG,
"hybrid" => self.qmode = QuantMode::Hybrid,
"mediancut" => self.qmode = QuantMode::MedianCut,
if strmgr.get_num_streams() > 99 {
return Err(MuxerError::UnsupportedFormat);
}
- for (str_no, str) in strmgr.iter().enumerate() {
- if str.get_media_type() == StreamType::Video {
+ for (str_no, strm) in strmgr.iter().enumerate() {
+ if strm.get_media_type() == StreamType::Video {
self.video_str = Some(str_no);
- self.video_id = str.id;
+ self.video_id = strm.id;
break;
}
}
self.pal_pos.clear();
self.pal_pos.resize(strmgr.get_num_streams(), 0);
- for (strno, str) in strmgr.iter().enumerate() {
+ for (strno, strm) in strmgr.iter().enumerate() {
let strl_pos = self.bw.tell() + 8;
self.bw.write_buf(b"LIST\0\0\0\0strlstrh")?;
self.bw.write_u32le(56)?; // strh size
- match str.get_media_type() {
+ match strm.get_media_type() {
StreamType::Video => {
self.bw.write_buf(b"vids")?;
- let fcc = find_avi_fourcc(str.get_info().get_name());
+ let fcc = find_avi_fourcc(strm.get_info().get_name());
if fcc.is_none() {
return Err(MuxerError::UnsupportedFormat);
}
self.bw.write_buf(&fcc.unwrap_or([0; 4]))?;
- let vinfo = str.get_info().get_properties().get_video_info().unwrap();
+ let vinfo = strm.get_info().get_properties().get_video_info().unwrap();
if vinfo.width >= (1 << 16) || vinfo.height >= (1 << 16) {
return Err(MuxerError::UnsupportedFormat);
}
};
self.stream_info.push(AVIStream {
strh_pos: self.bw.tell(),
- is_video: str.get_media_type() == StreamType::Video,
+ is_video: strm.get_media_type() == StreamType::Video,
nframes: 0,
max_size: 0,
});
self.bw.write_u16le(0)?; // priority
self.bw.write_u16le(0)?; // language
self.bw.write_u32le(0)?; // initial frames
- self.bw.write_u32le(str.tb_num)?;
- self.bw.write_u32le(str.tb_den)?;
+ self.bw.write_u32le(strm.tb_num)?;
+ self.bw.write_u32le(strm.tb_den)?;
self.bw.write_u32le(0)?; // start
self.bw.write_u32le(0)?; // length
self.bw.write_u32le(0)?; // suggested buffer size
self.bw.write_buf(b"strf")?;
self.bw.write_u32le(0)?;
let strf_pos = self.bw.tell();
- match str.get_media_type() {
+ match strm.get_media_type() {
StreamType::Video => {
- let vinfo = str.get_info().get_properties().get_video_info().unwrap();
+ let vinfo = strm.get_info().get_properties().get_video_info().unwrap();
let hdr_pos = self.bw.tell();
self.bw.write_u32le(0)?;
self.bw.write_u32le(vinfo.width as u32)?;
self.bw.write_u16le(1)?;
self.bw.write_u16le(8)?;
}
- let fcc = find_avi_fourcc(str.get_info().get_name());
+ let fcc = find_avi_fourcc(strm.get_info().get_name());
if fcc.is_none() {
return Err(MuxerError::UnsupportedFormat);
}
self.bw.write_u32le(0)?; // total colors
self.bw.write_u32le(0)?; // important colors
}
- if let Some(ref edata) = str.get_info().get_extradata() {
+ if let Some(ref edata) = strm.get_info().get_extradata() {
self.bw.write_buf(edata.as_slice())?;
}
let bisize = self.bw.tell() - hdr_pos;
self.bw.seek(SeekFrom::End(0))?;
},
StreamType::Audio => {
- let ainfo = str.get_info().get_properties().get_audio_info().unwrap();
- let twocc = find_wav_twocc(str.get_info().get_name());
+ let ainfo = strm.get_info().get_properties().get_audio_info().unwrap();
+ let twocc = find_wav_twocc(strm.get_info().get_name());
if twocc.is_none() {
return Err(MuxerError::UnsupportedFormat);
}
self.bw.write_u32le(0)?; // avg bytes per second
self.bw.write_u16le(ainfo.block_len as u16)?;
self.bw.write_u16le(ainfo.format.bits as u16)?;
- if let Some(ref edata) = str.get_info().get_extradata() {
+ if let Some(ref edata) = strm.get_info().get_extradata() {
self.bw.write_buf(edata.as_slice())?;
}
},
StreamType::Subtitles => {
- if let Some(ref edata) = str.get_info().get_extradata() {
+ if let Some(ref edata) = strm.get_info().get_extradata() {
self.bw.write_buf(edata.as_slice())?;
}
},
/// An auxiliary trait to make bytestream reader read packet data.
pub trait NAPacketReader {
/// Reads input and constructs a packet containing it.
- fn read_packet(&mut self, str: NAStreamRef, ts: NATimeInfo, keyframe: bool, size: usize) -> DemuxerResult<NAPacket>;
+ fn read_packet(&mut self, strm: NAStreamRef, ts: NATimeInfo, keyframe: bool, size: usize) -> DemuxerResult<NAPacket>;
/// Reads input into already existing packet.
fn fill_packet(&mut self, pkt: &mut NAPacket) -> DemuxerResult<()>;
}
impl<'a> NAPacketReader for ByteReader<'a> {
- fn read_packet(&mut self, str: NAStreamRef, ts: NATimeInfo, kf: bool, size: usize) -> DemuxerResult<NAPacket> {
+ fn read_packet(&mut self, strm: NAStreamRef, ts: NATimeInfo, kf: bool, size: usize) -> DemuxerResult<NAPacket> {
let mut buf: Vec<u8> = Vec::with_capacity(size);
if buf.capacity() < size { return Err(DemuxerError::MemoryError); }
buf.resize(size, 0);
self.read_buf(buf.as_mut_slice())?;
- let pkt = NAPacket::new(str, ts, kf, buf);
+ let pkt = NAPacket::new(strm, ts, kf, buf);
Ok(pkt)
}
fn fill_packet(&mut self, pkt: &mut NAPacket) -> DemuxerResult<()> {
}
/// Adds a new stream to the index.
pub fn stream_id_to_index(&self, id: u32) -> Option<usize> {
- for (idx, str) in self.seek_info.iter().enumerate() {
- if str.id == id {
+ for (idx, strm) in self.seek_info.iter().enumerate() {
+ if strm.id == id {
return Some(idx);
}
}
impl<'a> Demuxer<'a> {
/// Constructs a new `Demuxer` instance.
- fn new(dmx: Box<dyn DemuxCore<'a> + 'a>, str: StreamManager, seek_idx: SeekIndex) -> Self {
+ fn new(dmx: Box<dyn DemuxCore<'a> + 'a>, strmgr: StreamManager, seek_idx: SeekIndex) -> Self {
Demuxer {
dmx,
- streams: str,
+ streams: strmgr,
seek_idx,
}
}
impl NAPacket {
/// Constructs a new `NAPacket` instance.
- pub fn new(str: NAStreamRef, ts: NATimeInfo, kf: bool, vec: Vec<u8>) -> Self {
+ pub fn new(stream: NAStreamRef, ts: NATimeInfo, kf: bool, vec: Vec<u8>) -> Self {
// let mut vec: Vec<u8> = Vec::new();
// vec.resize(size, 0);
- NAPacket { stream: str, ts, keyframe: kf, buffer: NABufferRef::new(vec), side_data: Vec::new() }
+ NAPacket { stream, ts, keyframe: kf, buffer: NABufferRef::new(vec), side_data: Vec::new() }
}
/// Constructs a new `NAPacket` instance reusing a buffer reference.
- pub fn new_from_refbuf(str: NAStreamRef, ts: NATimeInfo, kf: bool, buffer: NABufferRef<Vec<u8>>) -> Self {
- NAPacket { stream: str, ts, keyframe: kf, buffer, side_data: Vec::new() }
+ pub fn new_from_refbuf(stream: NAStreamRef, ts: NATimeInfo, kf: bool, buffer: NABufferRef<Vec<u8>>) -> Self {
+ NAPacket { stream, ts, keyframe: kf, buffer, side_data: Vec::new() }
}
/// Returns information about the stream packet belongs to.
pub fn get_stream(&self) -> NAStreamRef { self.stream.clone() }
/// Adds side data for a packet.
pub fn add_side_data(&mut self, side_data: NASideData) { self.side_data.push(side_data); }
/// Assigns packet to a new stream.
- pub fn reassign(&mut self, str: NAStreamRef, ts: NATimeInfo) {
- self.stream = str;
+ pub fn reassign(&mut self, stream: NAStreamRef, ts: NATimeInfo) {
+ self.stream = stream;
self.ts = ts;
}
}
impl<'a> Muxer<'a> {
/// Constructs a new `Muxer` instance.
- fn new(mux: Box<dyn MuxCore<'a> + 'a>, str: StreamManager) -> Self {
+ fn new(mux: Box<dyn MuxCore<'a> + 'a>, strmgr: StreamManager) -> Self {
Muxer {
mux,
- streams: str,
+ streams: strmgr,
}
}
/// Returns a stream reference by its number.
}
/// Creates muxer for a provided bytestream writer.
-pub fn create_muxer<'a>(mxcr: &dyn MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
+pub fn create_muxer<'a>(mxcr: &dyn MuxerCreator, strmgr: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
let mut mux = mxcr.new_muxer(bw);
- mux.create(&str)?;
- Ok(Muxer::new(mux, str))
+ mux.create(&strmgr)?;
+ Ok(Muxer::new(mux, strmgr))
}
/// List of registered muxers.
NAOptionDefinitionType::None => Ok((NAOption { name: self.name, value: NAValue::None }, 1)),
NAOptionDefinitionType::Bool => Ok((NAOption { name: self.name, value: NAValue::Bool(true) }, 1)),
NAOptionDefinitionType::Int(_, _) => {
- if let Some(str) = value {
- let ret = str.parse::<i64>();
+ if let Some(strval) = value {
+ let ret = strval.parse::<i64>();
if let Ok(val) = ret {
let opt = NAOption { name: self.name, value: NAValue::Int(val) };
self.check(&opt)?;
}
},
NAOptionDefinitionType::Float(_, _) => {
- if let Some(str) = value {
- let ret = str.parse::<f64>();
+ if let Some(strval) = value {
+ let ret = strval.parse::<f64>();
if let Ok(val) = ret {
let opt = NAOption { name: self.name, value: NAValue::Float(val) };
self.check(&opt)?;
}
},
NAOptionDefinitionType::String(_) => {
- if let Some(str) = value {
- let opt = NAOption { name: self.name, value: NAValue::String(str.to_string()) };
+ if let Some(strval) = value {
+ let opt = NAOption { name: self.name, value: NAValue::String(strval.to_string()) };
self.check(&opt)?;
Ok((opt, 2))
} else {
for opt_def in DECODER_OPTIONS.iter() {
if opt_def.check(option).is_ok() {
match (option.name, &option.value) {
- (FRAME_SKIP_OPTION, NAValue::String(ref str)) => {
- if let Ok(smode) = FrameSkipMode::from_str(str) {
+ (FRAME_SKIP_OPTION, NAValue::String(ref strval)) => {
+ if let Ok(smode) = FrameSkipMode::from_str(strval) {
self.skip_mode = smode;
}
},
fn get_left_strength(&self, pos: usize) -> u8 {
self.left_str[pos] & 3
}
- fn set_top_strength(&mut self, pos: usize, str: u8) {
- self.top_str[pos] |= str;
+ fn set_top_strength(&mut self, pos: usize, strength: u8) {
+ self.top_str[pos] |= strength;
}
- fn set_left_strength(&mut self, pos: usize, str: u8) {
- self.left_str[pos] |= str;
+ fn set_left_strength(&mut self, pos: usize, strength: u8) {
+ self.left_str[pos] |= strength;
}
}
for opt_def in DECODER_OPTIONS.iter() {
if opt_def.check(option).is_ok() {
match (option.name, &option.value) {
- (FRAME_SKIP_OPTION, NAValue::String(ref str)) => {
- if let Ok(smode) = FrameSkipMode::from_str(str) {
+ (FRAME_SKIP_OPTION, NAValue::String(ref strval)) => {
+ if let Ok(smode) = FrameSkipMode::from_str(strval) {
self.skip_mode = smode;
}
},
CC::Le(ref arg) => { arg.le(src) },
CC::Gt(ref arg) => { arg.gt(src) },
CC::Ge(ref arg) => { arg.ge(src) },
- CC::Str(str) => {
- let mut val: Vec<u8> = vec![0; str.len()];
+ CC::Str(strng) => {
+ let mut val: Vec<u8> = vec![0; strng.len()];
let res = src.peek_buf(val.as_mut_slice());
if res.is_err() { return false; }
- val == str
+ val == strng
}
}
}