bsize: Vec::new(),
}
}
- fn decode_v1(&mut self, br: &mut ByteReader, data: &mut [u8], stride: usize) -> DecoderResult<bool> {
+ fn decode_v1(&mut self, br: &mut dyn ByteIO, data: &mut [u8], stride: usize) -> DecoderResult<bool> {
let mut is_intra = true;
for (yy, row) in data.chunks_mut(stride * self.block_h).enumerate() {
let cur_h = (self.h - yy * self.block_h).min(self.block_h);
}
Ok(is_intra)
}
- fn decode_v2(&mut self, br: &mut ByteReader, data: &mut [u8], stride: usize, keyframe: bool) -> DecoderResult<bool> {
+ fn decode_v2(&mut self, br: &mut dyn ByteIO, data: &mut [u8], stride: usize, keyframe: bool) -> DecoderResult<bool> {
let mut is_intra = !self.has_ifrm;
let bstride = (self.w + self.block_w - 1) / self.block_w;
for y in (0..self.h).step_by(self.block_h) {
}
},
2 => {
- let mut mr = MemoryReader::new_read(&self.tile[..src_len]);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&self.tile[..src_len]);
for line in dst.chunks_mut(stride).skip(start).take(height) {
for rgb in line.chunks_mut(3).take(cur_w) {
let b = br.read_byte()?;
let src = pkt.get_buffer();
validate!(src.len() > 4);
- let mut mr = MemoryReader::new_read(&src);
- let mut br = ByteReader::new(&mut mr);
+ let mut br = MemoryReader::new_read(&src);
let hdr0 = br.read_u16be()? as usize;
let hdr1 = br.read_u16be()? as usize;
const AVC_ID: u8 = 7;
struct FLVDemuxer<'a> {
- src: &'a mut ByteReader<'a>,
+ src: &'a mut dyn ByteIO,
vpkts: Vec<NAPacket>,
vtag: Option<u8>,
apkts: Vec<NAPacket>,
}
impl<'a> FLVDemuxer<'a> {
- fn new(io: &'a mut ByteReader<'a>) -> Self {
+ fn new(io: &'a mut dyn ByteIO) -> Self {
Self {
src: io,
vpkts: Vec::with_capacity(2),
pub struct FLVDemuxerCreator { }
impl DemuxerCreator for FLVDemuxerCreator {
- 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(FLVDemuxer::new(br))
}
fn get_name(&self) -> &'static str { "flv" }
#[test]
fn test_flv_demux() {
let mut file = File::open("assets/Flash/input.flv").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 = FLVDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
#[test]
fn test_flv_demux_back() {
let mut file = File::open("assets/Flash/input.flv").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 = FLVDemuxer::new(&mut br);
let mut sm = StreamManager::new();
let mut si = SeekIndex::new();
fn write_property_bool(&mut self, name: &str, val: bool) -> MuxerResult<()>;
}
-impl<'a> FLVPropertyWriter for ByteWriter<'a> {
+impl<T: ?Sized + ByteIO> FLVPropertyWriter for T {
fn write_property_num(&mut self, name: &str, val: f64) -> MuxerResult<()> {
self.write_u16be(name.len() as u16)?;
self.write_buf(name.as_bytes())?;
}
struct FLVMuxer<'a> {
- bw: &'a mut ByteWriter<'a>,
+ bw: &'a mut dyn ByteIO,
atag: u8,
ahdr: u8,
vtag: u8,
}
impl<'a> FLVMuxer<'a> {
- fn new(bw: &'a mut ByteWriter<'a>) -> Self {
+ fn new(bw: &'a mut dyn ByteIO) -> Self {
Self {
bw,
atag: NO_CODEC,
pub struct FLVMuxerCreator {}
impl MuxerCreator for FLVMuxerCreator {
- 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(FLVMuxer::new(bw))
}
fn get_name(&self) -> &'static str { "flv" }