-use nihav_core::io::byteio::{ByteReader,MemoryReader};
+use nihav_core::io::byteio::{ByteIO,MemoryReader};
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::codecs::*;
if let NACodecTypeInfo::Video(_vinfo) = info.get_properties() {
if let Some(edata) = info.get_extradata() {
validate!(edata.len() >= 64);
- let mut mr = MemoryReader::new_read(edata.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(edata.as_slice());
let len = br.read_u32be()? as usize;
validate!(edata.len() == len);
let _ = br.read_u32be()?; //always 7?
// Somewhat simplified JPEG decoder
// TODO: move common JPEG decoding into codec-support
-use nihav_core::io::byteio::{ByteReader,MemoryReader};
+use nihav_core::io::byteio::{ByteIO,MemoryReader};
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::codecs::*;
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
if src.len() < 2048 { return Err(DecoderError::ShortData); }
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let _size_v0 = br.read_u32be()? as usize;
let field2_size = br.read_u32be()? as usize;
if field2_size != 0 {
self.stride = (w + tile_size - 1) / tile_size * tile_size;
self.frame = vec![0; self.stride * ((h + tile_size - 1) / tile_size * tile_size)];
}
- fn decode_tile_intra(&mut self, xpos: usize, ypos: usize, tsize: usize, flags: &mut ByteReader, pixels: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_tile_intra(&mut self, xpos: usize, ypos: usize, tsize: usize, flags: &mut dyn ByteIO, pixels: &mut dyn ByteIO) -> DecoderResult<()> {
let mut flg = flags.read_u16le()?;
for yoff in (0..tsize).step_by(tsize / 4) {
for xoff in (0..tsize).step_by(tsize / 4) {
}
Ok(())
}
- fn decode_intra(&mut self, flags: &mut ByteReader, pixels: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_intra(&mut self, flags: &mut dyn ByteIO, pixels: &mut dyn ByteIO) -> DecoderResult<()> {
for y in (0..self.height).step_by(self.tile_size) {
for x in (0..self.width).step_by(self.tile_size) {
self.decode_tile_intra(x, y, self.tile_size, flags, pixels)?;
Ok(())
}
- fn decode_tile_inter(&mut self, xpos: usize, ypos: usize, tsize: usize, flags: &mut ByteReader, pixels: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_tile_inter(&mut self, xpos: usize, ypos: usize, tsize: usize, flags: &mut dyn ByteIO, pixels: &mut dyn ByteIO) -> DecoderResult<()> {
let mut flg = flags.read_u16le()?;
for yoff in (0..tsize).step_by(tsize / 4) {
for xoff in (0..tsize).step_by(tsize / 4) {
}
Ok(())
}
- fn decode_inter(&mut self, flags: &mut ByteReader, pixels: &mut ByteReader) -> DecoderResult<()> {
+ fn decode_inter(&mut self, flags: &mut dyn ByteIO, pixels: &mut dyn ByteIO) -> DecoderResult<()> {
for y in (0..self.height).step_by(self.tile_size) {
for x in (0..self.width).step_by(self.tile_size) {
self.decode_tile_inter(x, y, self.tile_size, flags, pixels)?;
&self.ubuf
};
- let mut mr = MemoryReader::new_read(tree_flags);
- let mut flags = ByteReader::new(&mut mr);
-
- let mut mr = MemoryReader::new_read(pixel_data);
- let mut pixels = ByteReader::new(&mut mr);
+ let mut flags = MemoryReader::new_read(tree_flags);
+ let mut pixels = MemoryReader::new_read(pixel_data);
let is_intra = (frame_flags & 1) == 0;
-use nihav_core::io::byteio::{ByteReader,MemoryReader};
+use nihav_core::io::byteio::{ByteIO,MemoryReader};
use nihav_core::codecs::*;
struct DVCDecoder {
}
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 mut pos = 0;
let mut is_intra = true;
-use nihav_core::io::byteio::{ByteReader,MemoryReader};
+use nihav_core::io::byteio::{ByteIO,MemoryReader};
use nihav_core::codecs::*;
use nihav_codec_support::codecs::imaadpcm::*;
}
impl FrameContext {
- fn decode_block2(&mut self, br: &mut ByteReader, dst: &mut [u8], xpos: usize, ypos: usize) -> DecoderResult<()> {
+ fn decode_block2(&mut self, br: &mut dyn ByteIO, dst: &mut [u8], xpos: usize, ypos: usize) -> DecoderResult<()> {
let op = if self.sub2op_run > 0 {
self.sub2op_run -= 1;
self.sub2op_val
}
Ok(())
}
- fn decode_block4(&mut self, br: &mut ByteReader, dst: &mut [u8], xpos: usize, ypos: usize, split: bool) -> DecoderResult<()> {
+ fn decode_block4(&mut self, br: &mut dyn ByteIO, dst: &mut [u8], xpos: usize, ypos: usize, split: bool) -> DecoderResult<()> {
let op = if split {
0xFF
} else if self.subop_run > 0 {
}
Ok(())
}
- fn unpack_frame(&mut self, br: &mut ByteReader, dst: &mut [u8]) -> DecoderResult<()> {
+ fn unpack_frame(&mut self, br: &mut dyn ByteIO, dst: &mut [u8]) -> DecoderResult<()> {
self.op_run = 0;
self.op_val = 0;
self.subop_run = 0;
self.frame = vec![0; self.fctx.width * self.fctx.height];
self.fctx.pframe = vec![0; self.fctx.width * self.fctx.height];
}
- fn load_raw_frame(&mut self, br: &mut ByteReader) -> DecoderResult<()> {
+ fn load_raw_frame(&mut self, br: &mut dyn ByteIO) -> DecoderResult<()> {
if self.fctx.width == 160 {
br.read_buf(&mut self.frame)?;
} else {
}
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 frm_type = br.read_u16be()?;
let _is_last = (br.read_u16be()? & 1) == 0;
use nihav_core::demuxers::*;
struct MVIDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
is_large: bool,
vpacket: Option<NAPacket>,
aframe: usize,
}
impl<'a> MVIDemuxer<'a> {
- fn new(src: &'a mut ByteReader<'a>) -> Self {
+ fn new(src: &'a mut dyn ByteIO) -> Self {
MVIDemuxer {
src,
is_large: false,
pub struct MVIDemuxerCreator { }
impl DemuxerCreator for MVIDemuxerCreator {
- 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(MVIDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "mvi" }
fn test_mvi_demux() {
// sample from AD&D Core Rules CD
let mut file = File::open("assets/Misc/MP/avtest.mvi").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 = MVIDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct QPEGDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
frameno: u32,
}
impl<'a> QPEGDemuxer<'a> {
- fn new(src: &'a mut ByteReader<'a>) -> Self {
+ fn new(src: &'a mut dyn ByteIO) -> Self {
QPEGDemuxer {
src,
frameno: 0,
pub struct QPEGDemuxerCreator { }
impl DemuxerCreator for QPEGDemuxerCreator {
- 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(QPEGDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "qpeg" }
fn test_qpeg_demux() {
// sample from Inside Multimedia 1994 October
let mut file = File::open("assets/Misc/club01.dvc").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 = QPEGDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct TealMovieDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
frameno: usize,
offsets: Vec<u32>,
afrm_start: usize,
}
impl<'a> TealMovieDemuxer<'a> {
- fn new(src: &'a mut ByteReader<'a>) -> Self {
+ fn new(src: &'a mut dyn ByteIO) -> Self {
TealMovieDemuxer {
src,
frameno: 0,
height: 0,
}
}
- fn skip_block2(br: &mut ByteReader, b2_run: &mut usize, b2_type: &mut u8) -> DemuxerResult<()> {
+ fn skip_block2(br: &mut dyn ByteIO, b2_run: &mut usize, b2_type: &mut u8) -> DemuxerResult<()> {
let op = if *b2_run > 0 {
*b2_run -= 1;
*b2_type
}
Ok(())
}
- fn skip_block4(br: &mut ByteReader, split: bool, b4_run: &mut usize, b4_type: &mut u8, b2_run: &mut usize, b2_type: &mut u8) -> DemuxerResult<()> {
+ fn skip_block4(br: &mut dyn ByteIO, split: bool, b4_run: &mut usize, b4_type: &mut u8, b2_run: &mut usize, b2_type: &mut u8) -> DemuxerResult<()> {
let op = if split {
0xFF
} else if *b4_run > 0 {
}
Ok(())
}
- fn find_type2_size(br: &mut ByteReader, width: usize, height: usize) -> DemuxerResult<usize> {
+ fn find_type2_size(br: &mut dyn ByteIO, width: usize, height: usize) -> DemuxerResult<usize> {
let mut b8_type = 0;
let mut b8_run = 0;
let mut b4_type = 0;
Ok(br.tell() as usize)
}
fn parse_frame(&mut self) -> DemuxerResult<(bool, Vec<u8>)> {
- let mut mr = MemoryReader::new_read(&self.buf[self.ppos..]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&self.buf[self.ppos..]);
let ftype = br.read_u16be()?;
let flags = br.read_u16be()?;
if (flags & 1) == 0 {
pub struct TealMovieDemuxerCreator { }
impl DemuxerCreator for TealMovieDemuxerCreator {
- 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(TealMovieDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "tealmov" }
fn test_teal_movie_demux() {
// sample bundled with TealMovie software
let mut file = File::open("assets/Misc/ASTRONUT.PDB").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 = TealMovieDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();