let src = pkt.get_buffer();
validate!(src.len() > 1);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let flags = br.read_byte()?;
if (flags & BMV_COMMAND) != 0 {
fn new() -> Self {
Self { nib: 0, has_nib: false }
}
- fn get_nib(&mut self, br: &mut ByteReader) -> DecoderResult<u8> {
+ fn get_nib(&mut self, br: &mut dyn ByteIO) -> DecoderResult<u8> {
if self.has_nib {
self.has_nib = false;
Ok(self.nib)
Ok(b & 0xF)
}
}
- fn get_length(&mut self, br: &mut ByteReader, mut len: usize, mut shift: u8) -> DecoderResult<usize> {
+ fn get_length(&mut self, br: &mut dyn ByteIO, mut len: usize, mut shift: u8) -> DecoderResult<usize> {
loop {
let nib = self.get_nib(br)? as usize;
len |= nib << shift;
}
}
#[allow(clippy::identity_op)]
- fn decode_frame(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_frame(&mut self, br: &mut dyn ByteIO) -> DecoderResult<()> {
let mut idx = 0;
loop {
let op = br.read_byte()?;
self.mode = BMV3Mode::Copy;
Ok(())
}
- fn pixfunc(&mut self, br: &mut ByteReader, len: usize) -> DecoderResult<()> {
+ fn pixfunc(&mut self, br: &mut dyn ByteIO, len: usize) -> DecoderResult<()> {
validate!(len <= self.end - self.pos);
for _ in 0..len {
let op = BMV_PIXFUNCS_MAP[br.read_byte()? as usize];
Ok(())
}
- fn decode_normal(&mut self, br: &mut ByteReader, op: u8) -> DecoderResult<()> {
+ fn decode_normal(&mut self, br: &mut dyn ByteIO, op: u8) -> DecoderResult<()> {
if op < 0x40 {
let mode = op & 1;
let len = ((op >> 1) & 0x7) as usize;
}
Ok(())
}
- fn decode_copy(&mut self, br: &mut ByteReader, op: u8) -> DecoderResult<()> {
+ fn decode_copy(&mut self, br: &mut dyn ByteIO, op: u8) -> DecoderResult<()> {
if op < 0x40 {
let len = ((op >> 1) & 0x7) as usize;
if len < 2 {
}
Ok(())
}
- fn decode_mode4(&mut self, br: &mut ByteReader, op: u8) -> DecoderResult<()> {
+ fn decode_mode4(&mut self, br: &mut dyn ByteIO, op: u8) -> DecoderResult<()> {
if (op & 0xF) < 4 {
let mut len = ((op & 3) * 2) as usize;
if (op & 0xF0) >= 0x20 {
}
Ok(())
}
- fn decode_mode5c(&mut self, br: &mut ByteReader, op: u8) -> DecoderResult<()> {
+ fn decode_mode5c(&mut self, br: &mut dyn ByteIO, op: u8) -> DecoderResult<()> {
if (op & 0xF) < 4 {
let mut len = ((op & 3) * 2) as usize;
if (op & 0xF0) >= 0x20 {
let src = pkt.get_buffer();
validate!(src.len() > 1);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let flags = br.read_byte()?;
if (flags & BMV_COMMAND) != 0 {
impl Bits8 {
fn new() -> Self { Bits8 { queue: 0, fill: 0 } }
- fn read_2bits(&mut self, br: &mut ByteReader) -> ByteIOResult<u8> {
+ fn read_2bits(&mut self, br: &mut dyn ByteIO) -> ByteIOResult<u8> {
if self.fill == 0 {
self.queue = br.read_byte()?;
self.fill += 8;
impl Bits32 {
fn new() -> Self { Bits32 { queue: 0, fill: 0 } }
- fn fill(&mut self, br: &mut ByteReader) -> ByteIOResult<()> {
+ fn fill(&mut self, br: &mut dyn ByteIO) -> ByteIOResult<()> {
self.queue = br.read_u32le()?;
self.fill = 32;
Ok(())
}
- fn read_bits(&mut self, br: &mut ByteReader, nbits: u8) -> ByteIOResult<u32> {
+ fn read_bits(&mut self, br: &mut dyn ByteIO, nbits: u8) -> ByteIOResult<u32> {
let res = self.queue & ((1 << nbits) - 1);
self.queue >>= nbits;
self.fill -= nbits;
}
}
- fn decode_method2(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_method2(&mut self, br: &mut dyn ByteIO) -> DecoderResult<()> {
let mut bits = Bits8::new();
let mut size = self.info.get_properties().get_video_info().unwrap().get_width() *
Ok(())
}
- fn decode_method2_16bit(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_method2_16bit(&mut self, br: &mut dyn ByteIO) -> DecoderResult<()> {
let mut bits = Bits8::new();
if self.frame16[8] != 64 {
Ok(())
}
- fn decode_method5(&mut self, br: &mut ByteReader, skip: usize) -> DecoderResult<()> {
+ fn decode_method5(&mut self, br: &mut dyn ByteIO, skip: usize) -> DecoderResult<()> {
let mut bits = Bits8::new();
let mut size = self.info.get_properties().get_video_info().unwrap().get_width() *
}
#[allow(clippy::identity_op)]
- fn decode_method68(&mut self, br: &mut ByteReader,
+ fn decode_method68(&mut self, br: &mut dyn ByteIO,
skip: usize, use8: bool) -> DecoderResult<()> {
let mut bits = Bits32::new();
}
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let flags = br.read_u32le()?;
let w = self.info.get_properties().get_video_info().unwrap().get_width();
let h = self.info.get_properties().get_video_info().unwrap().get_height();
}
}
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let header = br.read_byte()?;
let method = header & 0xF;
validate!(src.len() > idx_start);
let src1 = if num_vec > 256 { &src[idx_start + (nblocks + 7)/8..] } else { &src[idx_start..] };
- let mut mr = MemoryReader::new_read(src1);
- let mut idx_br = ByteReader::new(&mut mr);
- let mut mr = MemoryReader::new_read(&src[idx_start..]);
- let mut idx9_br = ByteReader::new(&mut mr);
+ let mut idx_br = MemoryReader::new_read(src1);
+ let mut idx9_br = MemoryReader::new_read(&src[idx_start..]);
let mut hi9 = 0u8;
let mut bits = 0u8;
for y in (0..height).step_by(2) {
let src = pkt.get_buffer();
validate!(src.len() > FRAME_HEADER);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let width = br.read_u16le()? as usize;
let height = br.read_u16le()? as usize;
},
1 | 11 => {
validate!(!opcodes.is_empty());
- let mut mr = MemoryReader::new_read(opcodes);
- let mut ops = ByteReader::new(&mut mr);
- let mut mr = MemoryReader::new_read(clr_data);
- let mut clr = ByteReader::new(&mut mr);
+ let mut ops = MemoryReader::new_read(opcodes);
+ let mut clr = MemoryReader::new_read(clr_data);
let mut x = xoff;
let mut y = yoff;
height: 0,
}
}
- fn decode_81(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_81(&mut self, br: &mut dyn ByteIO) -> DecoderResult<()> {
let mut pat = [0; 8];
let mut cur_clr = [0; 16];
let mut off = 0;
Ok(())
}
fn decode_85(&mut self, clr_src: &[u8], op_src: &[u8]) -> DecoderResult<()> {
- let mut mr = MemoryReader::new_read(clr_src);
- let mut clrs = ByteReader::new(&mut mr);
- let mut mr = MemoryReader::new_read(op_src);
- let mut ops = ByteReader::new(&mut mr);
+ let mut clrs = MemoryReader::new_read(clr_src);
+ let mut ops = MemoryReader::new_read(op_src);
let mut pat = [0; 8];
let mut cur_clr = [0; 16];
match self.subtype {
0x81 | 0x8A => {
validate!(src.len() > 12);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let stype = br.read_byte()?;
validate!(stype == 0x81 || stype == 0x8A);
br.read_byte()?;
},
0x85 | 0x86 | 0x89 => {
validate!(src.len() > 6);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let pal_offset = usize::from(br.read_u16be()?);
let pal_size = usize::from(br.read_u16be()?);
}
let _left = read_u32le(&src[14..])?;
let offset = if self.tot_size == 0 {
- let mut mr = MemoryReader::new_read(&src[18..]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src[18..]);
let tag = br.read_tag()?;
if &tag == b"iMUS" {
self.tot_size = br.read_u32be()?;
}
let nsamples = (match self.bits {
_ if self.old => {
- let mut mr = MemoryReader::new_read(&self.queued);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&self.queued);
let mut nblocks = 0;
while br.left() > 0 {
let len = br.read_u16be()? as usize;
let adata = adata.get_data_mut().unwrap();
match self.bits {
_ if self.old => {
- let mut mr = MemoryReader::new_read(&self.queued);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&self.queued);
for dst in adata.chunks_exact_mut(1024 * 2) {
let len = br.read_u16be()? as usize;
let end = br.tell() + (len as u64);
}
}
}
- fn read_additional(&mut self, br: &mut ByteReader, add: u16) -> DecoderResult<()> {
+ fn read_additional(&mut self, br: &mut dyn ByteIO, add: u16) -> DecoderResult<()> {
if add > 0 {
validate!(add <= 256);
let mut gbuf = [0; 8];
}
#[allow(clippy::too_many_arguments)]
-fn do_block47(br: &mut ByteReader, dst: &mut [u8], frm1: &[u8], frm2: &[u8], x: usize, y: usize, stride: usize, bsize: usize, clr: &[u8; 6], glyphs: &Glyphs) -> DecoderResult<()> {
+fn do_block47(br: &mut dyn ByteIO, dst: &mut [u8], frm1: &[u8], frm2: &[u8], x: usize, y: usize, stride: usize, bsize: usize, clr: &[u8; 6], glyphs: &Glyphs) -> DecoderResult<()> {
let op = br.read_byte()?;
match op {
0xFF if bsize > 2 => {
}
}
- fn decode_rle(br: &mut ByteReader, dst: &mut [u8], w: usize, h: usize, stride: usize) -> DecoderResult<()> {
+ fn decode_rle(br: &mut dyn ByteIO, dst: &mut [u8], w: usize, h: usize, stride: usize) -> DecoderResult<()> {
let mut x = 0;
let mut y = 0;
let mut len = 0;
Ok(())
}
- fn decode_1(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize, transparent: bool) -> DecoderResult<()> {
+ fn decode_1(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize, transparent: bool) -> DecoderResult<()> {
for yy in 0..h {
let len = u64::from(br.read_u16le()?);
let end = br.tell() + len;
Ok(())
}
- fn decode_2(&mut self, br: &mut ByteReader, x: i16, y: i16, _w: usize, _h: usize, len: usize) -> DecoderResult<()> {
+ fn decode_2(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, _w: usize, _h: usize, len: usize) -> DecoderResult<()> {
validate!((len & 3) == 0);
let mut xpos = x;
Ok(())
}
#[allow(clippy::too_many_arguments)]
- fn decode_4(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize, mode: u8, add: u16) -> DecoderResult<()> {
+ fn decode_4(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize, mode: u8, add: u16) -> DecoderResult<()> {
self.glyphs.make_glyphs_4(mode);
self.glyphs.read_additional(br, add)?;
Ok(())
}
#[allow(clippy::too_many_arguments)]
- fn decode_5(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize, mode: u8, add: u16) -> DecoderResult<()> {
+ fn decode_5(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize, mode: u8, add: u16) -> DecoderResult<()> {
self.glyphs.make_glyphs_5(mode);
self.glyphs.read_additional(br, add)?;
Ok(())
}
- fn decode_21(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize, size: usize) -> DecoderResult<()> {
+ fn decode_21(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize, size: usize) -> DecoderResult<()> {
let end = br.tell() + (size as u64);
for yy in 0..h {
if br.tell() >= end { break; }
Ok(())
}
#[allow(clippy::too_many_arguments)]
- fn decode_23(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize, bias: u8, add: u16, old: bool) -> DecoderResult<()> {
+ fn decode_23(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize, bias: u8, add: u16, old: bool) -> DecoderResult<()> {
let mut lut = [0; 256];
if old {
for (i, el) in lut.iter_mut().enumerate() {
Ok(())
}
- fn decode_37(&mut self, br: &mut ByteReader, x: i16, y: i16, mut w: usize, mut h: usize) -> DecoderResult<()> {
+ fn decode_37(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, mut w: usize, mut h: usize) -> DecoderResult<()> {
let compr = br.read_byte()?;
let mv_off = br.read_byte()? as usize;
validate!(mv_off <= 2);
Ok(())
}
- fn decode_47(&mut self, br: &mut ByteReader, x: i16, y: i16, w: usize, h: usize) -> DecoderResult<()> {
+ fn decode_47(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, w: usize, h: usize) -> DecoderResult<()> {
let seq = br.read_u16le()?;
let compr = br.read_byte()?;
let reorder = br.read_byte()?;
Ok(())
}
- fn decode_48(&mut self, br: &mut ByteReader, x: i16, y: i16, mut w: usize, mut h: usize) -> DecoderResult<()> {
+ fn decode_48(&mut self, br: &mut dyn ByteIO, x: i16, y: i16, mut w: usize, mut h: usize) -> DecoderResult<()> {
let compr = br.read_byte()?;
let mvsel = br.read_byte()? as usize;
validate!(mvsel < 2);
let src = pkt.get_buffer();
validate!(src.len() > 8);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut store = false;
while br.left() > 0 {
37 => {
let start = br.tell() as usize;
let end = start + size - 14;
- let mut mr = MemoryReader::new_read(&src[start..end]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src[start..end]);
self.decode_37(&mut br, x, y, w, h)?;
},
47 => {
let start = br.tell() as usize;
let end = start + size - 14;
- let mut mr = MemoryReader::new_read(&src[start..end]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src[start..end]);
self.decode_47(&mut br, x, y, w, h)?;
},
48 => {
let start = br.tell() as usize;
let end = start + size - 14;
- let mut mr = MemoryReader::new_read(&src[start..end]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src[start..end]);
self.decode_48(&mut br, x, y, w, h)?;
},
_ => return Err(DecoderError::NotImplemented),
}
}
-fn decode_rle(br: &mut ByteReader, dst: &mut [u8]) -> DecoderResult<()> {
+fn decode_rle(br: &mut dyn ByteIO, dst: &mut [u8]) -> DecoderResult<()> {
let mut len = 0;
let mut clr = 0;
let mut run = false;
}
}
-fn do_block2(br: &mut ByteReader, dst: &mut [u16], x: usize, y: usize, bsize: usize, bdata: &BlockData) -> DecoderResult<()> {
+fn do_block2(br: &mut dyn ByteIO, dst: &mut [u16], x: usize, y: usize, bsize: usize, bdata: &BlockData) -> DecoderResult<()> {
let stride = bdata.stride;
let op = br.read_byte()?;
match op {
let src = pkt.get_buffer();
validate!(src.len() > 8);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut reorder = 0;
while br.left() > 0 {
validate!(br.tell() < tend);
let start = br.tell() as usize;
br.seek(SeekFrom::Start(tend))?;
- let mut mr = MemoryReader::new_read(&src[start..(tend as usize)]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src[start..(tend as usize)]);
if seq == 0 {
for el in self.pic.frm1.iter_mut() {
$off = ($off + 1) & 0xFFF;
};
}
-fn lz_unpack(br: &mut ByteReader, dst: &mut [u8]) -> DecoderResult<()> {
+fn lz_unpack(br: &mut dyn ByteIO, dst: &mut [u8]) -> DecoderResult<()> {
let mut window: [u8; 0x1000] = [0x20; 0x1000];
let dst_size = br.read_u32le()? as usize;
Ok(())
}
-fn rle_unpack(br: &mut ByteReader, len: usize, dst: &mut [u8]) -> DecoderResult<()> {
+fn rle_unpack(br: &mut dyn ByteIO, len: usize, dst: &mut [u8]) -> DecoderResult<()> {
let end = br.tell() + (len as u64);
let mut dpos = 0;
if (len & 1) != 0 {
Ok(())
}
-fn decode_frame_data(br: &mut ByteReader, dst: &mut [u8], mut dpos: usize, stride: usize, w: usize, h: usize, method: u8) -> DecoderResult<bool> {
+fn decode_frame_data(br: &mut dyn ByteIO, dst: &mut [u8], mut dpos: usize, stride: usize, w: usize, h: usize, method: u8) -> DecoderResult<bool> {
match method {
1 => {
for _ in 0..h {
ver2: 0,
}
}
- fn decode_frame(&mut self, br: &mut ByteReader) -> DecoderResult<bool> {
+ fn decode_frame(&mut self, br: &mut dyn ByteIO) -> DecoderResult<bool> {
let frame_x = br.read_u16le()? as usize;
let frame_y = br.read_u16le()? as usize;
let frame_r = br.read_u16le()? as usize;
let is_intra = if (method & 0x80) != 0 {
validate!(!self.buf.is_empty());
lz_unpack(br, &mut self.buf)?;
- let mut mr = MemoryReader::new_read(&self.buf);
- let mut buf_br = ByteReader::new(&mut mr);
+ let mut buf_br = MemoryReader::new_read(&self.buf);
decode_frame_data(&mut buf_br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?
} else {
decode_frame_data(br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?
let src = pkt.get_buffer();
validate!(src.len() >= 10);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let is_intra = self.decode_frame(&mut br)?;
ch: 0,
}
}
- fn decode_16bit(&self, dst: &mut [i16], off1: usize, br: &mut ByteReader, nblocks: usize, mut mask: u32) -> DecoderResult<()> {
+ fn decode_16bit(&self, dst: &mut [i16], off1: usize, br: &mut dyn ByteIO, nblocks: usize, mut mask: u32) -> DecoderResult<()> {
let channels = self.chmap.num_channels();
let mut off = [0, off1];
for _ in 0..nblocks {
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
validate!(pktbuf.len() >= 6);
- let mut mr = MemoryReader::new_read(&pktbuf);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&pktbuf);
let blk_type = br.read_byte()?;
br.read_skip(9)?;
let mask;
use nihav_core::demuxers::*;
struct BMVDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
vid_id: usize,
aud_id: usize,
vpos: u64,
}
impl<'a> BMVDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
vid_id: 0,
pub struct BMVDemuxerCreator { }
impl DemuxerCreator for BMVDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(BMVDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "bmv" }
}
struct BMV3Demuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
vid_id: usize,
aud_id: usize,
vpos: u64,
}
impl<'a> BMV3Demuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
vid_id: 0,
pub struct BMV3DemuxerCreator { }
impl DemuxerCreator for BMV3DemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(BMV3Demuxer::new(br))
}
fn get_name(&self) -> &'static str { "bmv3" }
#[test]
fn test_bmv_demux() {
let mut file = File::open("assets/Game/DW2-MOUSE.BMV").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 = BMVDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
#[test]
fn test_bmv3_demux() {
let mut file = File::open("assets/Game/DW3-Loffnote.bmv").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 = BMV3Demuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
}
struct GremlinVideoDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
frames: u16,
cur_frame: u16,
asize: usize,
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl<'a> GremlinVideoDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
GremlinVideoDemuxer {
cur_frame: 0,
frames: 0,
pub struct GDVDemuxerCreator { }
impl DemuxerCreator for GDVDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(GremlinVideoDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "gdv" }
fn test_gdv_demux() {
// sample from Normality game
let mut file = File::open("assets/Game/intro1.gdv").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 = GremlinVideoDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct SequenceDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
nframes: usize,
frame_no: usize,
}
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl<'a> SequenceDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
SequenceDemuxer {
src: io,
frame_no: 0,
pub struct SequenceDemuxerCreator { }
impl DemuxerCreator for SequenceDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(SequenceDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "sierra-seq" }
#[test]
fn test_seq() {
let mut file = File::open("assets/Game/sierra/FS1.SEQ").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 = SequenceDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
None, None],
elem_size: 2, be: false, alpha: false, palette: false };
struct SGADemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
subtype: u8,
apts: u64,
abuf: Vec<u8>,
}
impl<'a> SGADemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
subtype: 0,
Ok(tot_sec * if ntsc { 60 } else { 30 } + u64::from(frame))
}
-fn get_smpte_time(src: &mut ByteReader, ntsc: bool) -> DemuxerResult<u64> {
+fn get_smpte_time(src: &mut dyn ByteIO, ntsc: bool) -> DemuxerResult<u64> {
let mut buf = [0; 4];
src.read_buf(&mut buf)?;
parse_smpte_time(&buf, ntsc)
pub struct SGADemuxerCreator { }
impl DemuxerCreator for SGADemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(SGADemuxer::new(br))
}
fn get_name(&self) -> &'static str { "sga" }
fn test_sga_demux(name: &str) {
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 = SGADemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct SmushDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
old: bool,
size: u64,
asize: u64,
}
-fn parse_iact(br: &mut ByteReader, end: u64, arate: &mut u32, abits: &mut u8, chans: &mut u8, mcmp: bool) -> DemuxerResult<()> {
+fn parse_iact(br: &mut dyn ByteIO, end: u64, arate: &mut u32, abits: &mut u8, chans: &mut u8, mcmp: bool) -> DemuxerResult<()> {
if !mcmp {
br.read_skip(14)?;
}
}
impl<'a> SmushDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
SmushDemuxer {
src: io,
let opcode = src.read_u16le()?;
let flags = src.read_u16le()?;
if (opcode == 8) && (flags == 0x2E) {
- if parse_iact(src, end, &mut arate, &mut abits, &mut chans, false).is_ok() {
+ if parse_iact(*src, end, &mut arate, &mut abits, &mut chans, false).is_ok() {
aname = "smush-iact";
}
validate!(src.tell() <= end);
pub struct SmushDemuxerCreator { }
impl DemuxerCreator for SmushDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(SmushDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "smush" }
struct MCMPDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
cur_frame: usize,
offsets: Vec<u64>,
}
impl<'a> MCMPDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
MCMPDemuxer {
src: io,
cur_frame: 0,
arate = self.src.read_u32le()?;
validate!(arate > 0);
} else {
- parse_iact(self.src, data_start, &mut arate, &mut abits, &mut chans, true)?;
+ parse_iact(&mut *self.src, data_start, &mut arate, &mut abits, &mut chans, true)?;
}
if chans == 2 {
for (samp, pts) in self.samples.iter_mut().zip(self.pts.iter_mut()) {
pub struct MCMPDemuxerCreator { }
impl DemuxerCreator for MCMPDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(MCMPDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "smush-mcmp" }
fn test_smush_demux_anim_v1() {
// sample from Rebel Assault game
let mut file = File::open("assets/Game/smush/c1block.anm").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 = SmushDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn test_smush_demux_anim_v2() {
// sample from The Dig
let mut file = File::open("assets/Game/smush/PIGOUT.SAN").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 = SmushDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn test_smush_demux_sanm() {
// sample from Grim Fandango
let mut file = File::open("assets/Game/smush/lol.snm").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 = SmushDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn test_mcmp_demux_imus() {
// sample from Grim Fandango
let mut file = File::open("assets/Game/smush/1104 - Lupe.IMC").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 = MCMPDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn test_mcmp_demux_wav() {
// sample from Grim Fandango
let mut file = File::open("assets/Game/smush/breadpor.WAV").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 = MCMPDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
}
struct VMDDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
vid_id: usize,
aud_id: usize,
fno: usize,
}
impl<'a> VMDDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
vid_id: 0,
pub struct VMDDemuxerCreator { }
impl DemuxerCreator for VMDDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn DemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn DemuxCore<'a> + 'a> {
Box::new(VMDDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "vmd" }
// sample: https://samples.mplayerhq.hu/game-formats/sierra-vmd/Lighthouse/128.vmd
let mut file = File::open("assets/Game/sierra/128.vmd").unwrap();
//let mut file = File::open("assets/Game/1491.VMD").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 = VMDDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::muxers::*;
struct EAMuxer<'a> {
- bw: &'a mut ByteWriter<'a>,
+ bw: &'a mut dyn ByteIO,
has_alpha: bool,
nframes: u32,
max_size: [u32; 2],
}
impl<'a> EAMuxer<'a> {
- fn new(bw: &'a mut ByteWriter<'a>) -> Self {
+ fn new(bw: &'a mut dyn ByteIO) -> Self {
Self {
bw,
has_alpha: false,
pub struct EAMuxerCreator {}
impl MuxerCreator for EAMuxerCreator {
- fn new_muxer<'a>(&self, bw: &'a mut ByteWriter<'a>) -> Box<dyn MuxCore<'a> + 'a> {
+ fn new_muxer<'a>(&self, bw: &'a mut dyn ByteIO) -> Box<dyn MuxCore<'a> + 'a> {
Box::new(EAMuxer::new(bw))
}
fn get_name(&self) -> &'static str { "ea" }