fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(_ainfo) = info.get_properties() {
if let Some(buf) = info.get_extradata() {
- let mut mr = MemoryReader::new_read(&buf);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&buf);
let version = br.read_u16le()?;
let compression = br.read_u16le()?;
let _flags = br.read_u16le()?;
if let Some(buf) = info.get_extradata() {
validate!(buf.len() >= 22);
- let mut mr = MemoryReader::new_read(&buf);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&buf);
self.min_blk_size = br.read_u16be()? as usize;
self.max_blk_size = br.read_u16be()? as usize;
llaudio_register_all_demuxers(&mut dmx_reg);
let dmx_f = dmx_reg.find_demuxer("flac").unwrap();
let mut file = std::fs::File::open("assets/LLaudio/luckynight.flac").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 = create_demuxer(dmx_f, &mut br).unwrap();
let mut pkt_sizes = Vec::new();
if !check_crc(&buf) {
return Err(DecoderError::ChecksumError);
}
- let mut mr = MemoryReader::new_read(&buf);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&buf);
let tag = br.read_tag()?;
validate!(&tag == b"TTA1");
let afmt = br.read_u16le()?;
impl WVHeader {
#[allow(clippy::field_reassign_with_default)]
fn parse(src: &[u8]) -> DecoderResult<Self> {
- let mut mr = MemoryReader::new_read(src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src);
let tag = br.read_tag()?;
validate!(&tag == b"wvpk");
let mut hdr = Self::default();
dstate: DecorrState,
}
-fn get_subblock(br: &mut ByteReader) -> DecoderResult<(u8, usize)> {
+fn get_subblock(br: &mut dyn ByteIO) -> DecoderResult<(u8, usize)> {
let id1 = br.read_byte()?;
let id = id1 & 0x3F;
let mut len = 2 * if (id1 & 0x80) == 0 {
}
#[allow(clippy::cognitive_complexity)]
fn decode_block(&mut self, hdr: &WVHeader, src: &[u8], start_ch: usize, abuf: &mut NABufferType) -> DecoderResult<()> {
- let mut mr = MemoryReader::new_read(src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src);
let mut has_terms = false;
let mut has_weights = false;
let mut has_samples = false;
self.header = hdr;
off += WV_HEADER_SIZE;
let size = hdr.get_size();
- let mut mr = MemoryReader::new_read(&buf[off..][..size]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&buf[off..][..size]);
while br.left() > 0 {
let (id, len) = get_subblock(&mut br)?;
match id {
}
struct APEDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
cur_frame: usize,
frames: Vec<Frame>,
normal_blocks: u32,
}
impl<'a> APEDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
cur_frame: 0,
pub struct APEDemuxerCreator { }
impl DemuxerCreator for APEDemuxerCreator {
- 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(APEDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "ape" }
fn test_ape_demux() {
// sample: https://samples.mplayerhq.hu/A-codecs/lossless/luckynight.ape
let mut file = File::open("assets/LLaudio/ape/luckynight.ape").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 = APEDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
}
struct FLACDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
data_start: u64,
tot_samples: u64,
cur_samples: u64,
}
impl<'a> FLACDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
data_start: 0,
pub struct FLACDemuxerCreator { }
impl DemuxerCreator for FLACDemuxerCreator {
- 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(FLACDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "flac" }
fn test_flac_demux() {
// sample: https://samples.mplayerhq.hu/A-codecs/lossless/luckynight.flac
let mut file = File::open("assets/LLaudio/luckynight.flac").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 = FLACDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct FLACDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
data_start: u64,
tot_samples: u64,
cur_samples: u64,
}
impl<'a> FLACDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
data_start: 0,
pub struct FLACDemuxerCreator { }
impl RawDemuxerCreator for FLACDemuxerCreator {
- 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(FLACDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "flac" }
- fn check_format(&self, br: &mut ByteReader) -> bool {
+ fn check_format(&self, br: &mut dyn ByteIO) -> bool {
if br.seek(SeekFrom::Start(0)).is_err() {
return false;
}
fn test_flac_raw_demux() {
// sample: https://samples.mplayerhq.hu/A-codecs/lossless/luckynight.flac
let mut file = File::open("assets/LLaudio/luckynight.flac").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 = FLACDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::demuxers::*;
struct TTADemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
cur_frame: u32,
nframes: u32,
nsamples: u32,
}
impl<'a> TTADemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
cur_frame: 0,
pub struct TTADemuxerCreator { }
impl DemuxerCreator for TTADemuxerCreator {
- 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(TTADemuxer::new(br))
}
fn get_name(&self) -> &'static str { "tta" }
fn test_tta_demux() {
// sample: https://samples.mplayerhq.hu/A-codecs/lossless/luckynight.tta
let mut file = File::open("assets/LLaudio/luckynight.tta").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 = TTADemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
impl WVHeader {
#[allow(clippy::field_reassign_with_default)]
fn parse(src: &[u8]) -> DemuxerResult<Self> {
- let mut mr = MemoryReader::new_read(src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(src);
let tag = br.read_tag()?;
validate!(&tag == b"wvpk");
let mut hdr = Self::default();
}
struct WavPackDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
samplepos: u64,
nsamples: u64,
first_blocks: Option<(WVHeader, Vec<u8>)>,
}
impl<'a> WavPackDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
samplepos: 0,
pub struct WavPackDemuxerCreator { }
impl DemuxerCreator for WavPackDemuxerCreator {
- 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(WavPackDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "wavpack" }
fn test_wavpack_demux() {
// sample from the official WavPack test samples set
let mut file = File::open("assets/LLaudio/wv/false_stereo.wv").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 = WavPackDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
use nihav_core::muxers::*;
struct FLACMuxer<'a> {
- bw: &'a mut ByteWriter<'a>,
+ bw: &'a mut dyn ByteIO,
maxpkt: usize,
minpkt: usize,
duration: u64,
}
impl<'a> FLACMuxer<'a> {
- fn new(bw: &'a mut ByteWriter<'a>) -> Self {
+ fn new(bw: &'a mut dyn ByteIO) -> Self {
Self {
bw,
maxpkt: usize::MAX, minpkt: 0,
pub struct FLACMuxerCreator {}
impl MuxerCreator for FLACMuxerCreator {
- 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(FLACMuxer::new(bw))
}
fn get_name(&self) -> &'static str { "flac" }