if let (NACodecTypeInfo::Audio(_), Some(edata)) = (info.get_properties(), info.get_extradata()) {
validate!(edata.len() >= 12 + 24);
- let mut mr = MemoryReader::new_read(&edata);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&edata);
let len = br.read_u32be()? as usize;
validate!(len == 12 + 24);
let fcc = br.read_tag()?;
for data in pktbuf.chunks(PACKET_LEN * channels) {
for ch in 0..channels {
- let mut mr = MemoryReader::new_read(&data[PACKET_LEN * ch..][..PACKET_LEN]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&data[PACKET_LEN * ch..][..PACKET_LEN]);
let init = br.read_u16be()?;
let pred = (init as i16) & !0x7F;
}
impl Packet {
- fn read(br: &mut ByteReader) -> DecoderResult<Self> {
+ fn read(br: &mut dyn ByteIO) -> DecoderResult<Self> {
let id = br.read_byte()?;
let size = if (id & 0x80) == 0 { br.read_byte()? as usize } else { br.read_u16be()? as usize };
validate!(size <= (br.left() as usize));
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
if let Some(edata) = info.get_extradata() {
validate!(edata.len() >= 36);
- 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 size = br.read_u32be()? as usize;
validate!(size >= 36 && size <= edata.len());
let tag = br.read_tag()?;
let pktbuf = pkt.get_buffer();
validate!(pktbuf.len() == self.frm_bytes);
- let mut mr = MemoryReader::new_read(pktbuf.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(pktbuf.as_slice());
let hdr = Packet::read(&mut br)?;
let (is_intra, has_checksum) = match hdr.id {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
if let Some(edata) = info.get_extradata() {
validate!(edata.len() >= 36);
- 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 size = br.read_u32be()? as usize;
validate!(size >= 36 && size <= edata.len());
let tag = br.read_tag()?;
fn new() -> Self {
Self::default()
}
- fn decode_mono(&self, br: &mut ByteReader, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
+ fn decode_mono(&self, br: &mut dyn ByteIO, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
let mut has_skips = false;
let mut pix_buf = [0u8; 16];
let npixels = 16;
Ok(has_skips)
}
- fn decode_pal(&self, br: &mut ByteReader, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
+ fn decode_pal(&self, br: &mut dyn ByteIO, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
let mut has_skips = false;
let mut pix_buf = [0u8; 16];
let npixels = match self.depth {
Ok(has_skips)
}
- fn decode_16bit(&self, br: &mut ByteReader, frm: &mut NASimpleVideoFrame<u16>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
+ fn decode_16bit(&self, br: &mut dyn ByteIO, frm: &mut NASimpleVideoFrame<u16>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
let mut has_skips = false;
let stride = frm.stride[0];
Ok(has_skips)
}
- fn decode_24bit(&self, br: &mut ByteReader, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
+ fn decode_24bit(&self, br: &mut dyn ByteIO, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
let mut has_skips = false;
let mut rgb = [0u8; 3];
Ok(has_skips)
}
- fn decode_32bit(&self, br: &mut ByteReader, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
+ fn decode_32bit(&self, br: &mut dyn ByteIO, frm: &mut NASimpleVideoFrame<u8>, start_line: usize, end_line: usize) -> DecoderResult<bool> {
let mut has_skips = false;
let mut rgb = [0u8; 4];
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() >= 2);
- let mut mr = MemoryReader::new_read(src.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src.as_slice());
let id = br.read_byte()?;
validate!(id == 0x40 || id == 0x00);
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() >= 2);
- let mut mr = MemoryReader::new_read(src.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src.as_slice());
let id = br.read_byte()?;
validate!(id == 0xE1);
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() >= 2);
- let mut mr = MemoryReader::new_read(src.as_slice());
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src.as_slice());
let _flags = br.read_byte()?;
let length = br.read_u24be()? as usize;