fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
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 codec_id = br.read_u32le()?;
validate!(codec_id == 0x102);
let vsize = br.read_u32le()? as usize;
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
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 codec_id = br.read_u32le()?;
validate!(codec_id == 0x100 + 22);
let vsize = br.read_u32le()? as usize;
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() > 2 && (src.len() & 1) == 0);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut is_intra = true;
let mut dpos = 0;
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() > 2 && (src.len() & 1) == 0);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut is_intra = true;
let mut dpos = 0;
let bufinfo = alloc_video_buffer(self.info.get_properties().get_video_info().unwrap(), 0)?;
match self.codec_id {
2 => {
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let mut buf = bufinfo.get_vbuf16().unwrap();
let stride = buf.get_stride(0);
fn read_string(&mut self) -> DemuxerResult<Vec<u8>>;
}
-impl<'a> ReadString for ByteReader<'a> {
+impl<T: ?Sized + ByteIO> ReadString for T {
fn read_string(&mut self) -> DemuxerResult<Vec<u8>> {
let mut res = Vec::new();
loop {
}
struct ARMovieDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
chunk_offs: Vec<ChunkInfo>,
cur_chunk: usize,
state: ReadState,
}
impl<'a> ARMovieDemuxer<'a> {
- fn new(src: &'a mut ByteReader<'a>) -> Self {
+ fn new(src: &'a mut dyn ByteIO) -> Self {
Self {
src,
chunk_offs: Vec::new(),
pub struct ARMovieDemuxerCreator { }
impl RawDemuxerCreator for ARMovieDemuxerCreator {
- fn new_demuxer<'a>(&self, br: &'a mut ByteReader<'a>) -> Box<dyn RawDemuxCore<'a> + 'a> {
+ fn new_demuxer<'a>(&self, br: &'a mut dyn ByteIO) -> Box<dyn RawDemuxCore<'a> + 'a> {
Box::new(ARMovieDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "armovie" }
- fn check_format(&self, br: &mut ByteReader) -> bool {
+ fn check_format(&self, br: &mut dyn ByteIO) -> bool {
let mut hdr = [0; 8];
br.read_buf(&mut hdr).is_ok() && &hdr == b"ARMovie\n"
}
fn test_armovie_demux() {
// a sample from Acorn Replay Demonstration Disc 2
let mut file = File::open("assets/Acorn/CHEMSET2").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 = ARMovieDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn test_armovie_tca_demux() {
// a sample from All About Planes
let mut file = File::open("assets/Acorn/wessex").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 = ARMovieDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct TCADemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
tca: TCACoreDemuxer,
}
impl<'a> TCADemuxer<'a> {
- fn new(src: &'a mut ByteReader<'a>) -> Self {
+ fn new(src: &'a mut dyn ByteIO) -> Self {
Self {
src,
tca: TCACoreDemuxer::default()
pub struct TCADemuxerCreator { }
impl DemuxerCreator for TCADemuxerCreator {
- 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(TCADemuxer::new(br))
}
fn get_name(&self) -> &'static str { "tca" }
}
impl TCACoreDemuxer {
- pub(crate) fn open(&mut self, src: &mut ByteReader, strmgr: &mut StreamManager, mut tb_num: u32, mut tb_den: u32) -> DemuxerResult<()> {
+ pub(crate) fn open(&mut self, src: &mut dyn ByteIO, strmgr: &mut StreamManager, mut tb_num: u32, mut tb_den: u32) -> DemuxerResult<()> {
let start_pos = src.tell();
let tag = src.peek_tag()?;
let is_acef = &tag == b"ACEF";
Ok(())
}
- pub(crate) fn get_frame(&mut self, src: &mut ByteReader, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
+ pub(crate) fn get_frame(&mut self, src: &mut dyn ByteIO, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
let has_video = self.video_pos + 4 < self.data_end;
let has_audio = self.audio && self.sound_pos < self.sound_end;
}
}
- pub(crate) fn get_frame_raw(&mut self, src: &mut ByteReader, strmgr: &mut StreamManager) -> DemuxerResult<NARawData> {
+ pub(crate) fn get_frame_raw(&mut self, src: &mut dyn ByteIO, strmgr: &mut StreamManager) -> DemuxerResult<NARawData> {
let pkt = self.get_frame(src, strmgr)?;
Ok(NARawData::new_from_refbuf(pkt.get_stream(), pkt.get_buffer()))
}
fn test_tca_demux() {
// a sample from RISC DISC 3
let mut file = File::open("assets/Acorn/JUMPER").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 = TCADemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();