let coded0 = cbpi.is_coded(mb_x, 0);
let coded1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
- if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, str, coff); }
- if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, str, coff + 8); }
+ if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, strength, coff); }
+ if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, strength, coff + 8); }
}
let coff = off + 8 * stride;
if cbpi.is_coded(mb_x, 2) && coded0 { deblock_hor(buf, 0, q, coff); }
let ccur0 = cbpi.is_coded(mb_x, 0);
let ccur1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
let coff = off - 8 * stride;
let qtop = cbpi.get_q(mb_x);
if leftt && ctop0 { deblock_ver(buf, 0, strtop, coff); }
if ctop0 && ctop1 { deblock_ver(buf, 0, strtop, coff + 8); }
}
- if leftc && ccur0 { deblock_ver(buf, 0, str, off); }
- if ccur0 && ccur1 { deblock_ver(buf, 0, str, off + 8); }
+ if leftc && ccur0 { deblock_ver(buf, 0, strength, off); }
+ if ccur0 && ccur1 { deblock_ver(buf, 0, strength, off + 8); }
leftt = ctop1;
leftc = ccur1;
off += 16;
let ctv = cbpi.is_coded_top(mb_x, 5);
let ccv = cbpi.is_coded(mb_x, 5);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
- if ctu && ccu { deblock_hor(buf, 1, str, offu + mb_x * 8); }
- if ctv && ccv { deblock_hor(buf, 2, str, offv + mb_x * 8); }
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ if ctu && ccu { deblock_hor(buf, 1, strength, offu + mb_x * 8); }
+ if ctv && ccv { deblock_hor(buf, 2, strength, offv + mb_x * 8); }
}
let mut leftu = false;
let mut leftv = false;
}
continue;
}
- let str = strmgr.get_stream(stream_no as usize);
- if str.is_none() {
+ let stream = strmgr.get_stream(stream_no as usize);
+ if stream.is_none() {
self.src.read_skip(size)?;
self.movi_size -= size + 8;
continue;
}
- let stream = str.unwrap();
+ let stream = stream.unwrap();
if size == 0 {
self.movi_size -= 8;
if self.movi_size == 0 {
} else {
track.cur_ts = None;
}
- let str = strmgr.get_stream(track.track_str_id);
- if str.is_none() { return Err(DemuxerError::InvalidData); }
- let stream = str.unwrap();
+ let stream = strmgr.get_stream(track.track_str_id);
+ if stream.is_none() { return Err(DemuxerError::InvalidData); }
+ let stream = stream.unwrap();
src.seek(SeekFrom::Start(offset))?;
let mut pkt = src.read_packet(stream, pts, false, size)?;
if let Some(ref pal) = track.pal {
validate!(self.mdat_pos > 0);
validate!(!self.tracks.is_empty());
for track in self.tracks.iter_mut() {
- let mut str = None;
- std::mem::swap(&mut track.stream, &mut str);
- if let Some(stream) = str {
+ let mut strm = None;
+ std::mem::swap(&mut track.stream, &mut strm);
+ if let Some(stream) = strm {
let str_id = strmgr.add_stream(stream).unwrap();
track.track_str_id = str_id;
}
if self.src.tell() >= self.data_end {
return Err(DemuxerError::EOF);
}
- let str = strmgr.get_stream(0);
- if str.is_none() { return Err(InvalidData); }
- let stream = str.unwrap();
+ let strm = strmgr.get_stream(0);
+ if strm.is_none() { return Err(InvalidData); }
+ let stream = strm.unwrap();
let pts = if self.avg_bytes != 0 {
let pos = self.src.tell() - self.data_pos;
Some(pos * u64::from(self.srate) / u64::from(self.avg_bytes))
if self.data_pos == 0 {
return Err(MuxerError::NotCreated);
}
- let str = pkt.get_stream();
- let str_num = str.get_num();
+ let stream = pkt.get_stream();
+ let str_num = stream.get_num();
if str_num > 99 || str_num >= self.stream_info.len() {
return Err(MuxerError::UnsupportedFormat);
}
self.stream_info[str_num].max_size = self.stream_info[str_num].max_size.max(chunk_len);
self.index.push(IdxEntry {
stream: str_num as u32,
- stype: str.get_media_type(),
+ stype: stream.get_media_type(),
key: pkt.keyframe,
pos: self.bw.tell() as u32,
len: chunk_len });
- write_chunk_hdr(self.bw, str.get_media_type(), str_num as u32)?;
+ write_chunk_hdr(self.bw, stream.get_media_type(), str_num as u32)?;
self.bw.write_u32le(chunk_len)?;
self.bw.write_buf(pkt.get_buffer().as_slice())?;
if (self.bw.tell() & 1) != 0 {
/// Adds a new stream.
pub fn add_stream(&mut self, stream: NAStream) -> Option<usize> {
let stream_num = self.streams.len();
- let mut str = stream;
- str.set_num(stream_num);
- self.streams.push(str.into_ref());
+ let mut stream = stream;
+ stream.set_num(stream_num);
+ self.streams.push(stream.into_ref());
self.ignored.push(false);
Some(stream_num)
}
}
/// Returns stream reference for provided stream ID.
pub fn get_stream_index(&mut self, id: u32) -> Option<&mut StreamSeekInfo> {
- for str in self.seek_info.iter_mut() {
- if str.id == id {
- return Some(str);
+ for stream in self.seek_info.iter_mut() {
+ if stream.id == id {
+ return Some(stream);
}
}
None
/// Searches for a seek position before requested time.
pub fn find_pos(&self, time: NATimePoint) -> Option<SeekIndexResult> {
let mut cand = None;
- for str in self.seek_info.iter() {
- if !str.filled { continue; }
- let res = str.find_pos(time);
+ for stream in self.seek_info.iter() {
+ if !stream.filled { continue; }
+ let res = stream.find_pos(time);
if res.is_none() { continue; }
let res = res.unwrap();
if cand.is_none() {
- cand = Some(SeekIndexResult { pts: res.pts, pos: res.pos, str_id: str.id });
+ cand = Some(SeekIndexResult { pts: res.pts, pos: res.pos, str_id: stream.id });
} else if let Some(entry) = cand {
if res.pos < entry.pos {
- cand = Some(SeekIndexResult { pts: res.pts, pos: res.pos, str_id: str.id });
+ cand = Some(SeekIndexResult { pts: res.pts, pos: res.pos, str_id: stream.id });
}
}
}
/// Creates demuxer for a provided bytestream.
pub fn create_demuxer<'a>(dmxcr: &dyn DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult<Demuxer<'a>> {
let mut dmx = dmxcr.new_demuxer(br);
- let mut str = StreamManager::new();
+ let mut strmgr = StreamManager::new();
let mut seek_idx = SeekIndex::new();
- dmx.open(&mut str, &mut seek_idx)?;
- Ok(Demuxer::new(dmx, str, seek_idx))
+ dmx.open(&mut strmgr, &mut seek_idx)?;
+ Ok(Demuxer::new(dmx, strmgr, seek_idx))
}
/// List of registered demuxers.
/// Creates raw data demuxer for a provided bytestream.
pub fn create_raw_demuxer<'a>(dmxcr: &dyn RawDemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult<RawDemuxer<'a>> {
let mut dmx = dmxcr.new_demuxer(br);
- let mut str = StreamManager::new();
+ let mut strmgr = StreamManager::new();
let mut seek_idx = SeekIndex::new();
- dmx.open(&mut str, &mut seek_idx)?;
- Ok(RawDemuxer::new(dmx, str, seek_idx))
+ dmx.open(&mut strmgr, &mut seek_idx)?;
+ Ok(RawDemuxer::new(dmx, strmgr, seek_idx))
}
/// List of registered demuxers.
let end = if self.be { "BE" } else { "LE" };
let palstr = if self.palette { "palette " } else { "" };
let astr = if self.alpha { "alpha " } else { "" };
- let mut str = format!("Formaton for {} ({}{}elem {} size {}): ", self.model, palstr, astr,end, self.elem_size);
+ let mut string = format!("Formaton for {} ({}{}elem {} size {}): ", self.model, palstr, astr,end, self.elem_size);
for i in 0..self.comp_info.len() {
if let Some(chr) = self.comp_info[i] {
- str = format!("{} {}", str, chr);
+ string = format!("{} {}", string, chr);
}
}
- write!(f, "[{}]", str)
+ write!(f, "[{}]", string)
}
}
},
NAValue::String(ref cur_str) => {
if let NAOptionDefinitionType::String(Some(strings)) = self.opt_type {
- for str in strings.iter() {
- if cur_str == str {
+ for string in strings.iter() {
+ if cur_str == string {
return Ok(());
}
}
let magic = br.read_u32be()?;
validate!(magic == 0x100 || magic == 0x101);
br.read_skip(36)?;
- for str in self.streams.iter_mut() {
- str.read_header(&src, &mut br)?;
+ for stream in self.streams.iter_mut() {
+ stream.read_header(&src, &mut br)?;
}
let myinfo = NAVideoInfo::new(self.width, self.height, false, RGB24_FORMAT);
let nblocks = self.src.peek_byte()?;
asize = (nblocks as usize) * 65 + 1;
validate!(asize < size);
- let str = strmgr.get_stream(self.aud_id).unwrap();
- let ts = str.make_ts(Some(self.apos), None, None);
- let apkt = self.src.read_packet(str, ts, false, asize)?;
+ let stream = strmgr.get_stream(self.aud_id).unwrap();
+ let ts = stream.make_ts(Some(self.apos), None, None);
+ let apkt = self.src.read_packet(stream, ts, false, asize)?;
self.apos += u64::from(nblocks) * 32;
self.pkt_buf.push(apkt);
} else {
buf[0] = ctype;
self.src.read_buf(&mut buf[1..])?;
- let str = strmgr.get_stream(self.vid_id).unwrap();
- let ts = str.make_ts(Some(self.vpos), None, None);
- let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf);
+ let stream = strmgr.get_stream(self.vid_id).unwrap();
+ let ts = stream.make_ts(Some(self.vpos), None, None);
+ let pkt = NAPacket::new(stream, ts, (ctype & 3) == 3, buf);
self.vpos += 1;
return Ok(pkt);
buf[0] = (self.src.tell() & 1) as u8;
self.src.read_buf(&mut buf[1..])?;
- let str = strmgr.get_stream(self.aud_id).unwrap();
- let ts = str.make_ts(Some(self.apos), None, None);
- let apkt = NAPacket::new(str, ts, false, buf);
+ let stream = strmgr.get_stream(self.aud_id).unwrap();
+ let ts = stream.make_ts(Some(self.apos), None, None);
+ let apkt = NAPacket::new(stream, ts, false, buf);
self.apos += (asize as u64) / 41 * 32;
self.pkt_buf.push(apkt);
buf[0] = ctype;
self.src.read_buf(&mut buf[1..])?;
- let str = strmgr.get_stream(self.vid_id).unwrap();
- let ts = str.make_ts(Some(self.vpos), None, None);
- let pkt = NAPacket::new(str, ts, (ctype & 3) == 3, buf);
+ let stream = strmgr.get_stream(self.vid_id).unwrap();
+ let ts = stream.make_ts(Some(self.vpos), None, None);
+ let pkt = NAPacket::new(stream, ts, (ctype & 3) == 3, buf);
self.vpos += 1;
return Ok(pkt);
self.cur_frame += 1;
}
- let str = strmgr.get_stream(id).unwrap();
- let ts = str.make_ts(Some(pts), None, None);
- self.src.read_packet(str, ts, true, size)
+ let stream = strmgr.get_stream(id).unwrap();
+ let ts = stream.make_ts(Some(pts), None, None);
+ self.src.read_packet(stream, ts, true, size)
}
fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> {
let size = (self.end - self.src.tell()).min(0x2000) as usize;
let pts = (self.src.tell() - 14) * 2;
- let str = strmgr.get_stream(self.a_id).unwrap();
- let ts = str.make_ts(Some(pts), None, None);
- self.src.read_packet(str, ts, true, size)
+ let stream = strmgr.get_stream(self.a_id).unwrap();
+ let ts = stream.make_ts(Some(pts), None, None);
+ self.src.read_packet(stream, ts, true, size)
}
fn seek(&mut self, _time: NATimePoint, _seek_index: &SeekIndex) -> DemuxerResult<()> {
fn read_achunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
self.state = GDVState::AudioRead;
- let str = strmgr.get_stream(self.a_id.unwrap()).unwrap();
- let ts = str.make_ts(Some(u64::from(self.cur_frame)), None, None);
- self.src.read_packet(str, ts, true, self.asize)
+ let stream = strmgr.get_stream(self.a_id.unwrap()).unwrap();
+ let ts = stream.make_ts(Some(u64::from(self.cur_frame)), None, None);
+ self.src.read_packet(stream, ts, true, self.asize)
}
fn read_vchunk(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
- let str = strmgr.get_stream(self.v_id.unwrap()).unwrap();
+ let stream = strmgr.get_stream(self.v_id.unwrap()).unwrap();
let src = &mut self.src;
let magic = src.read_u16be()?;
if magic != 0x0513 { return Err(DemuxerError::InvalidData); }
let flags = (tmp & 0xFF) as usize;
self.state = GDVState::NewFrame;
self.cur_frame += 1;
- let ts = str.make_ts(Some(u64::from(self.cur_frame - 1)), None, None);
- src.read_packet(str, ts, (flags & 64) != 0, size)
+ let ts = stream.make_ts(Some(u64::from(self.cur_frame - 1)), None, None);
+ src.read_packet(stream, ts, (flags & 64) != 0, size)
}
}
match ftype {
0xAA97 => {
- let str = strmgr.get_stream(self.v_id).unwrap();
- let ts = str.make_ts(Some(self.cur_frame), None, None);
+ let stream = strmgr.get_stream(self.v_id).unwrap();
+ let ts = stream.make_ts(Some(self.cur_frame), None, None);
self.cur_frame += 1;
- let mut pkt = self.src.read_packet(str, ts, true, fsize)?;
+ let mut pkt = self.src.read_packet(stream, ts, true, fsize)?;
pkt.add_side_data(NASideData::Palette(self.pal_change, self.pal.clone()));
self.pal_change = false;
return Ok(pkt);
self.pal_change = true;
},
0xAA99 => {
- let str = strmgr.get_stream(self.a_id).unwrap();
- let ts = str.make_ts(Some(self.apos), None, None);
+ let stream = strmgr.get_stream(self.a_id).unwrap();
+ let ts = stream.make_ts(Some(self.apos), None, None);
self.apos += fsize as u64;
- return self.src.read_packet(str, ts, true, fsize);
+ return self.src.read_packet(stream, ts, true, fsize);
},
0xAAFF => return Err(DemuxerError::EOF),
_ => return Err(DemuxerError::InvalidData),
0xFFFF => return Err(DemuxerError::EOF),
0 => {
if let Some(a_id) = self.a_id {
- let str = strmgr.get_stream(a_id).unwrap();
- let ts = str.make_ts(Some(self.apts), None, None);
+ let stream = strmgr.get_stream(a_id).unwrap();
+ let ts = stream.make_ts(Some(self.apts), None, None);
self.apts += (size / self.bps) as u64;
- return self.src.read_packet(str, ts, true, size);
+ return self.src.read_packet(stream, ts, true, size);
} else {
self.src.read_skip(size)?;
}
},
2 | 3 | 4 | 11 => {
validate!(self.v_id.is_some());
- let str = strmgr.get_stream(self.v_id.unwrap_or(0)).unwrap();
- let ts = str.make_ts(Some(self.vpts), None, None);
+ let stream = strmgr.get_stream(self.v_id.unwrap_or(0)).unwrap();
+ let ts = stream.make_ts(Some(self.vpts), None, None);
self.vpts += 1;
let cur_len = self.side_data.len();
}
let mut buf = Vec::new();
std::mem::swap(&mut buf, &mut self.side_data);
- return Ok(NAPacket::new(str, ts, self.vpts == 1, buf));
+ return Ok(NAPacket::new(stream, ts, self.vpts == 1, buf));
},
5 => {
validate!(size <= 256);
self.fno += 1;
let str_id = if is_video { self.vid_id } else { self.aud_id };
- let str = strmgr.get_stream(str_id).unwrap();
- let ts = str.make_ts(Some(u64::from(cur_frame.ts)), None, None);
- let pkt = NAPacket::new(str, ts, false, buf);
+ let stream = strmgr.get_stream(str_id).unwrap();
+ let ts = stream.make_ts(Some(u64::from(cur_frame.ts)), None, None);
+ let pkt = NAPacket::new(stream, ts, false, buf);
Ok(pkt)
}
let coded0 = cbpi.is_coded(mb_x, 0);
let coded1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
- if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, str, coff); }
- if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, str, coff + 8); }
+ if coded0 && cbpi.is_coded_top(mb_x, 0) { deblock_hor(buf, 0, strength, coff); }
+ if coded1 && cbpi.is_coded_top(mb_x, 1) { deblock_hor(buf, 0, strength, coff + 8); }
}
let coff = off + 8 * stride;
if cbpi.is_coded(mb_x, 2) && coded0 { deblock_hor(buf, 0, q, coff); }
let ccur0 = cbpi.is_coded(mb_x, 0);
let ccur1 = cbpi.is_coded(mb_x, 1);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
if mb_y != 0 {
let coff = off - 8 * stride;
let qtop = cbpi.get_q(mb_x);
if leftt && ctop0 { deblock_ver(buf, 0, strtop, coff); }
if ctop0 && ctop1 { deblock_ver(buf, 0, strtop, coff + 8); }
}
- if leftc && ccur0 { deblock_ver(buf, 0, str, off); }
- if ccur0 && ccur1 { deblock_ver(buf, 0, str, off + 8); }
+ if leftc && ccur0 { deblock_ver(buf, 0, strength, off); }
+ if ccur0 && ccur1 { deblock_ver(buf, 0, strength, off + 8); }
leftt = ctop1;
leftc = ccur1;
off += 16;
let ctv = cbpi.is_coded_top(mb_x, 5);
let ccv = cbpi.is_coded(mb_x, 5);
let q = cbpi.get_q(mb_w + mb_x);
- let str = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
- if ctu && ccu { deblock_hor(buf, 1, str, offu + mb_x * 8); }
- if ctv && ccv { deblock_hor(buf, 2, str, offv + mb_x * 8); }
+ let strength = if q < 32 { FILTER_STRENGTH[q as usize] } else { 0 };
+ if ctu && ccu { deblock_hor(buf, 1, strength, offu + mb_x * 8); }
+ if ctv && ccv { deblock_hor(buf, 2, strength, offv + mb_x * 8); }
}
let mut leftu = false;
let mut leftv = false;
let q1 = el!(pix, off + step);
let q2 = el!(pix, off + 2*step);
- let str;
+ let strength;
if filter_p1 && filter_q1 {
- str = (t << 2) + (p1 - q1);
+ strength = (t << 2) + (p1 - q1);
} else {
- str = t << 2;
+ strength = t << 2;
}
- let diff = clip_symm((str + 4) >> 3, lim_p0q0);
+ let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
pix[off - step] = clip8(p0 + diff);
pix[off ] = clip8(q0 - diff);
let q1 = el!(ch, 3 + 1);
let q2 = el!(ch, 3 + 2);
- let str;
+ let strength;
if filter_p1 && filter_q1 {
- str = (t << 2) + (p1 - q1);
+ strength = (t << 2) + (p1 - q1);
} else {
- str = t << 2;
+ strength = t << 2;
}
- let diff = clip_symm((str + 4) >> 3, lim_p0q0);
+ let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
ch[3 - 1] = clip8(p0 + diff);
ch[3 ] = clip8(q0 - diff);
let c = src.read_byte()?;
vec.push(c);
}
- let str = String::from_utf8(vec);
- if let Ok(res) = str {
+ if let Ok(res) = String::from_utf8(vec) {
Ok(res)
} else {
Ok(String::new())
enum IVRRecord {
Invalid(u8),
StreamProperties(usize),
- Packet { ts: u32, str: u32, flags: u32, len: usize, checksum: u32 },
+ Packet { ts: u32, strm: u32, flags: u32, len: usize, checksum: u32 },
IntValue(Vec<u8>, u32),
BinaryData(Vec<u8>, Vec<u8>),
StringData(Vec<u8>, Vec<u8>),
},
2 => {
let ts = src.read_u32be()?;
- let str = src.read_u16be()? as u32;
+ let strm = src.read_u16be()? as u32;
let flags = src.read_u32be()?;
let len = src.read_u32be()? as usize;
let chk = src.read_u32be()?;
validate!((len > 0) && (len < (1 << 24)));
- Ok(IVRRecord::Packet { ts, str, flags, len, checksum: chk })
+ Ok(IVRRecord::Packet { ts, strm, flags, len, checksum: chk })
},
3 => {
let name = Self::read_string(src)?;
IVRRecord::Invalid(typ) => write!(f, "Invalid({:02X})", typ),
IVRRecord::StreamProperties(num) =>
write!(f, "({} stream properties)", num),
- IVRRecord::Packet { ts, str, flags, len, checksum } =>
- write!(f, "paket({}, {}, {:X}, {}, {})", ts, str, flags, len, checksum),
+ IVRRecord::Packet { ts, strm, flags, len, checksum } =>
+ write!(f, "paket({}, {}, {:X}, {}, {})", ts, strm, flags, len, checksum),
IVRRecord::IntValue(ref name, val) =>
write!(f, "({} = {})", String::from_utf8_lossy(name), val),
IVRRecord::BinaryData(ref name, ref val) =>
loop {
let rec = IVRRecord::read(src)?;
match rec {
- IVRRecord::Packet { ts, str, flags, len, .. } => {
+ IVRRecord::Packet { ts, strm, flags, len, .. } => {
let payload_size = len;
- let sr = self.remap_ids.iter().position(|x| *x == str);
+ let sr = self.remap_ids.iter().position(|x| *x == strm);
validate!(sr.is_some());
let str_no = self.start_str + (sr.unwrap() as u32);
let pkt_grp = ((flags >> 8) & 0xFF) as u16;