}
pub fn get_dimensions(&self) -> (usize, usize) { (self.w, self.h) }
- fn decode_intra_mb(&mut self, bd: &mut BlockDecoder, bdsp: &BlockDSP, mb_pos: usize, binfo: &BlockInfo, sstate: &SliceState, apply_acpred: bool) -> DecoderResult<()> {
+ fn decode_intra_mb(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP, mb_pos: usize, binfo: &BlockInfo, sstate: &SliceState, apply_acpred: bool) -> DecoderResult<()> {
for i in 0..6 {
bd.decode_block_intra(&binfo, &sstate, binfo.get_q(), i, (binfo.cbp & (1 << (5 - i))) != 0, &mut self.blk[i])?;
if apply_acpred && (binfo.acpred != ACPredMode::None) {
}
Ok(())
}
- fn decode_inter_mb(&mut self, bd: &mut BlockDecoder, bdsp: &BlockDSP, binfo: &BlockInfo, sstate: &SliceState) -> DecoderResult<()> {
+ fn decode_inter_mb(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP, binfo: &BlockInfo, sstate: &SliceState) -> DecoderResult<()> {
for i in 0..6 {
bd.decode_block_inter(&binfo, &sstate, binfo.get_q(), i, ((binfo.cbp >> (5 - i)) & 1) != 0, &mut self.blk[i])?;
bdsp.idct(&mut self.blk[i]);
mb_pos
}
#[allow(clippy::cyclomatic_complexity)]
- pub fn parse_frame(&mut self, bd: &mut BlockDecoder, bdsp: &BlockDSP) -> DecoderResult<NABufferType> {
+ pub fn parse_frame(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP) -> DecoderResult<NABufferType> {
let pinfo = bd.decode_pichdr()?;
let mut mvi = MVInfo::new();
let mut mvi2 = MVInfo::new();
self.ipbs.clear();
}
- pub fn get_bframe(&mut self, bdsp: &BlockDSP) -> DecoderResult<NABufferType> {
+ pub fn get_bframe(&mut self, bdsp: &dyn BlockDSP) -> DecoderResult<NABufferType> {
if !self.has_b || self.ipbs.get_lastref().is_none() || self.ipbs.get_nextref().is_none() {
return Err(DecoderError::MissingReference);
}
}
}
-fn recon_b_mb(buf: &mut NAVideoBuffer<u8>, ipbs: &mut IPBShuffler, bdsp: &BlockDSP, mvi: &mut MVInfo, mvi2: &mut MVInfo, mb_pos: usize, mb_w: usize, sstate: &SliceState, binfo: &BlockInfo, mv_data: &[BlockMVInfo], bsdiff: u16, tsdiff: u16) {
+fn recon_b_mb(buf: &mut NAVideoBuffer<u8>, ipbs: &mut IPBShuffler, bdsp: &dyn BlockDSP, mvi: &mut MVInfo, mvi2: &mut MVInfo, mb_pos: usize, mb_w: usize, sstate: &SliceState, binfo: &BlockInfo, mv_data: &[BlockMVInfo], bsdiff: u16, tsdiff: u16) {
let mb_x = mb_pos % mb_w;
let mb_y = mb_pos / mb_w;
}
fn recon_b_frame(mut b_buf: NAVideoBufferRef<u8>, bck_buf: NAVideoBufferRef<u8>, fwd_buf: NAVideoBufferRef<u8>,
- mb_w: usize, mb_h: usize, b_data: &[BMB], bdsp: &BlockDSP) {
+ mb_w: usize, mb_h: usize, b_data: &[BMB], bdsp: &dyn BlockDSP) {
let mut cbpi = CBPInfo::new();
let mut cur_mb = 0;
cbpi.reset(mb_w);
#[cfg(feature="demuxer_wav")]
mod wav;
-const DEMUXERS: &[&DemuxerCreator] = &[
+const DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_avi")]
&avi::AVIDemuxerCreator {},
#[cfg(feature="demuxer_mov")]
fn open(&mut self, strmgr: &mut StreamManager, seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let riff = self.src.read_u32be()?;
let riff_size = self.src.read_u32le()? as usize;
- let riff_end = self.src.tell() + if riff_size > 0 { (riff_size as u64) } else { u64::from(std::u32::MAX) };
+ let riff_end = self.src.tell() + if riff_size > 0 { riff_size as u64 } else { u64::from(std::u32::MAX) };
let wave = self.src.read_u32be()?;
validate!(riff == mktag!(b"RIFF"));
validate!(wave == mktag!(b"WAVE"));
#[cfg(feature="muxer_wav")]
mod wav;
-const MUXERS: &[&MuxerCreator] = &[
+const MUXERS: &[&dyn MuxerCreator] = &[
#[cfg(feature="muxer_avi")]
&avi::AVIMuxerCreator {},
#[cfg(feature="muxer_wav")]
/// Adds a new stream.
pub fn add_stream(&mut self, stream: NAStream) -> Option<usize> {
let stream_num = self.streams.len();
- let mut str = stream.clone();
+ let mut str = stream;
str.set_num(stream_num);
self.streams.push(str.into_ref());
self.ignored.push(false);
}
/// Creates demuxer for a provided bytestream.
-pub fn create_demuxer<'a>(dmxcr: &DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult<Demuxer<'a>> {
+pub fn create_demuxer<'a>(dmxcr: &dyn DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult<Demuxer<'a>> {
let mut dmx = dmxcr.new_demuxer(br);
let mut str = StreamManager::new();
let mut seek_idx = SeekIndex::new();
/// List of registered demuxers.
#[derive(Default)]
pub struct RegisteredDemuxers {
- dmxs: Vec<&'static DemuxerCreator>,
+ dmxs: Vec<&'static dyn DemuxerCreator>,
}
impl RegisteredDemuxers {
Self { dmxs: Vec::new() }
}
/// Registers a new demuxer.
- pub fn add_demuxer(&mut self, dmx: &'static DemuxerCreator) {
+ pub fn add_demuxer(&mut self, dmx: &'static dyn DemuxerCreator) {
self.dmxs.push(dmx);
}
/// Searches for a demuxer that supports requested container format.
- pub fn find_demuxer(&self, name: &str) -> Option<&DemuxerCreator> {
+ pub fn find_demuxer(&self, name: &str) -> Option<&dyn DemuxerCreator> {
for &dmx in self.dmxs.iter() {
if dmx.get_name() == name {
return Some(dmx);
None
}
/// Provides an iterator over currently registered demuxers.
- pub fn iter(&self) -> std::slice::Iter<&DemuxerCreator> {
+ pub fn iter(&self) -> std::slice::Iter<&dyn DemuxerCreator> {
self.dmxs.iter()
}
}
/// [`MemoryReader`]: ./struct.MemoryReader.html
#[allow(dead_code)]
pub struct ByteReader<'a> {
- io: &'a mut ByteIO,
+ io: &'a mut dyn ByteIO,
}
/// Bytestream reader from memory.
/// # Ok(())
/// # }
/// ````
- pub fn new(io: &'a mut ByteIO) -> Self { ByteReader { io } }
+ pub fn new(io: &'a mut dyn ByteIO) -> Self { ByteReader { io } }
/// Reads data into provided buffer. Partial read is treated as success.
pub fn read_buf(&mut self, buf: &mut [u8]) -> ByteIOResult<usize> {
/// [`MemoryWriter`]: ./struct.MemoryWriter.html
#[allow(dead_code)]
pub struct ByteWriter<'a> {
- io: &'a mut ByteIO,
+ io: &'a mut dyn ByteIO,
}
/// Bytestream writer to memory.
impl<'a> ByteWriter<'a> {
/// Constructs a new instance of `ByteWriter`.
- pub fn new(io: &'a mut ByteIO) -> Self { ByteWriter { io } }
+ pub fn new(io: &'a mut dyn ByteIO) -> Self { ByteWriter { io } }
/// Writes byte array to the output.
pub fn write_buf(&mut self, buf: &[u8]) -> ByteIOResult<()> {
impl<S: Copy> Codebook<S> {
/// Constructs a new `Codebook` instance using provided codebook description and mode.
- pub fn new(cb: &mut CodebookDescReader<S>, mode: CodebookMode) -> CodebookResult<Self> {
+ pub fn new(cb: &mut dyn CodebookDescReader<S>, mode: CodebookMode) -> CodebookResult<Self> {
let mut maxbits = 0;
let mut nnz = 0;
let mut escape_list: EscapeCodes = HashMap::new();
}
/// Creates muxer for a provided bytestream writer.
-pub fn create_muxer<'a>(mxcr: &MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
+pub fn create_muxer<'a>(mxcr: &dyn MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult<Muxer<'a>> {
let mut mux = mxcr.new_muxer(bw);
mux.create(&str)?;
Ok(Muxer::new(mux, str))
/// List of registered muxers.
#[derive(Default)]
pub struct RegisteredMuxers {
- muxes: Vec<&'static MuxerCreator>,
+ muxes: Vec<&'static dyn MuxerCreator>,
}
impl RegisteredMuxers {
Self { muxes: Vec::new() }
}
/// Registers a new muxer.
- pub fn add_muxer(&mut self, mux: &'static MuxerCreator) {
+ pub fn add_muxer(&mut self, mux: &'static dyn MuxerCreator) {
self.muxes.push(mux);
}
/// Searches for a muxer that supports requested container format.
- pub fn find_muxer(&self, name: &str) -> Option<&MuxerCreator> {
+ pub fn find_muxer(&self, name: &str) -> Option<&dyn MuxerCreator> {
for &mux in self.muxes.iter() {
if mux.get_name() == name {
return Some(mux);
None
}
/// Provides an iterator over currently registered muxers.
- pub fn iter(&self) -> std::slice::Iter<&MuxerCreator> {
+ pub fn iter(&self) -> std::slice::Iter<&dyn MuxerCreator> {
self.muxes.iter()
}
}
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
-pub fn get_decoder_vp3() -> Box<NADecoder + Send> {
+pub fn get_decoder_vp3() -> Box<dyn NADecoder + Send> {
Box::new(VP34Decoder::new(3))
}
-pub fn get_decoder_vp4() -> Box<NADecoder + Send> {
+pub fn get_decoder_vp4() -> Box<dyn NADecoder + Send> {
Box::new(VP34Decoder::new(4))
}
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
-pub fn get_decoder() -> Box<NADecoder + Send> {
+pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(VP5Decoder::new())
}
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
-pub fn get_decoder_vp6() -> Box<NADecoder + Send> {
+pub fn get_decoder_vp6() -> Box<dyn NADecoder + Send> {
Box::new(VP6Decoder::new(false))
}
-pub fn get_decoder_vp6_alpha() -> Box<NADecoder + Send> {
+pub fn get_decoder_vp6_alpha() -> Box<dyn NADecoder + Send> {
Box::new(VP6Decoder::new(true))
}
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
-pub fn get_decoder() -> Box<NADecoder + Send> {
+pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(VP7Decoder::new())
}
return;
}
let (w, h) = reffrm.get_dimensions(plane);
- let wa = if plane == 0 { ((w + 15) & !15) } else { ((w + 7) & !7) } as isize;
- let ha = if plane == 0 { ((h + 15) & !15) } else { ((h + 7) & !7) } as isize;
+ let wa = if plane == 0 { (w + 15) & !15 } else { (w + 7) & !7 } as isize;
+ let ha = if plane == 0 { (h + 15) & !15 } else { (h + 7) & !7 } as isize;
let bsize = (size as isize) + (EDGE_PRE as isize) + (EDGE_POST as isize);
let ref_x = (xpos as isize) + ((mvx >> 3) as isize) - (EDGE_PRE as isize);
let ref_y = (ypos as isize) + ((mvy >> 3) as isize) - (EDGE_PRE as isize);
};
let (w, h) = reffrm.get_dimensions(plane);
- let wa = if plane == 0 { ((w + 15) & !15) } else { ((w + 7) & !7) } as isize;
- let ha = if plane == 0 { ((h + 15) & !15) } else { ((h + 7) & !7) } as isize;
+ let wa = if plane == 0 { (w + 15) & !15 } else { (w + 7) & !7 } as isize;
+ let ha = if plane == 0 { (h + 15) & !15 } else { (h + 7) & !7 } as isize;
let mut start_x = (xpos as isize) + ((mvx >> 3) as isize) - (EDGE_PRE as isize);
let mut end_x = (xpos as isize) + ((mvx >> 3) as isize) + ((size + EDGE_POST) as isize);
if xstep < 0 {
#[cfg(feature="demuxer_vx")]
mod vx;
-const GAME_DEMUXERS: &[&DemuxerCreator] = &[
+const GAME_DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_bmv")]
&bmv::BMVDemuxerCreator {},
#[cfg(feature="demuxer_bmv3")]
}
Ok(())
}
- fn decode_band(&mut self, pic_hdr: &PictureHeader, dec: &mut IndeoXParser, br: &mut BitReader, plane_no: usize, band_no: usize) -> DecoderResult<()> {
+ fn decode_band(&mut self, pic_hdr: &PictureHeader, dec: &mut dyn IndeoXParser, br: &mut BitReader, plane_no: usize, band_no: usize) -> DecoderResult<()> {
let bidx = match plane_no {
0 => { band_no },
_ => { pic_hdr.luma_bands + plane_no - 1 },
unreachable!();
}
- fn decode_single_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
+ fn decode_single_frame<'a>(&mut self, dec: &mut dyn IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
let pic_hdr = dec.decode_picture_header(br)?;
self.ftype = pic_hdr.ftype;
if pic_hdr.ftype.is_null() {
Ok(buftype)
}
- pub fn decode_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
+ pub fn decode_frame<'a>(&mut self, dec: &mut dyn IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult<NABufferType> {
let res = self.decode_single_frame(dec, br);
if res.is_err() { return res; }
if (self.ftype == IVIFrameType::Intra) && (br.left() > 16) {
#[cfg(feature="demuxer_wavpack")]
mod wavpack;
-const LL_AUDIO_DEMUXERS: &[&DemuxerCreator] = &[
+const LL_AUDIO_DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_ape")]
&ape::APEDemuxerCreator {},
#[cfg(feature="demuxer_flac")]
#[cfg(feature="demuxer_bink")]
mod bink;
-const RAD_DEMUXERS: &[&DemuxerCreator] = &[
+const RAD_DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_smk")]
&smacker::SMKDemuxerCreator {},
#[cfg(feature="demuxer_bink")]
fn get_pts_inc(val: i32) -> u64 {
if val > 0 { (val as u64) * 100 }
- else if val < 0 { (-val as u64) }
+ else if val < 0 { -val as u64 }
else { 1 }
}
dst = &mut tmp2;
}
let a = (1 << 12) - ((src[i + 1] * src[i + 1]) >> 12);
- let scale = if a != 0 { (1 << 24) / a } else { (1 << 24) };
+ let scale = if a != 0 { (1 << 24) / a } else { 1 << 24 };
for j in 0..=i {
let result = (src[j] - ((tmp3[i + 1] * src[i - j]) >> 12)).checked_mul(scale);
if let Some(val) = result {
Ok(())
}
-fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult<RV34SliceHeader> {
+fn decode_slice_header(br: &mut BitReader, bd: &mut dyn RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult<RV34SliceHeader> {
validate!(slice_no < slice_offs.len());
br.seek((slice_offs[slice_no] * 8) as u32)?;
let mut shdr = bd.decode_slice_header(br, old_width, old_height)?;
base_ts: 0,
}
}
- fn decode_mb_header_intra(&mut self, bd: &mut RV34BitstreamDecoder, br: &mut BitReader, is_i16: bool, im: &mut IntraModeState, q: u8, has_top: bool, has_dq: bool) -> DecoderResult<MBInfo> {
+ fn decode_mb_header_intra(&mut self, bd: &mut dyn RV34BitstreamDecoder, br: &mut BitReader, is_i16: bool, im: &mut IntraModeState, q: u8, has_top: bool, has_dq: bool) -> DecoderResult<MBInfo> {
if is_i16 {
let imode = br.read(2)? as i8;
im.fill_block(imode);
Ok(MBInfo { mbtype: MBType::MBIntra, skip_run: 0, dquant: dq })
}
}
- fn decode_mb_header_inter(&mut self, bd: &mut RV34BitstreamDecoder, br: &mut BitReader, ftype: FrameType, mbtype: MBType, im: &mut IntraModeState, q: u8, has_top: bool) -> DecoderResult<MBInfo> {
+ fn decode_mb_header_inter(&mut self, bd: &mut dyn RV34BitstreamDecoder, br: &mut BitReader, ftype: FrameType, mbtype: MBType, im: &mut IntraModeState, q: u8, has_top: bool) -> DecoderResult<MBInfo> {
let hdr = bd.decode_inter_mb_hdr(br, ftype, mbtype)?;
validate!(hdr.mbtype != MBType::Invalid);
if hdr.dquant {
}
#[allow(clippy::cyclomatic_complexity)]
- pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> {
+ pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut dyn RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> {
let mut slice_offs: Vec<usize> = Vec::new();
parse_slice_offsets(src, &mut slice_offs)?;
let ini_off = slice_offs.len() * 8 + 1;
#[allow(clippy::needless_range_loop)]
mod realmedia;
-const RM_DEMUXERS: &[&DemuxerCreator] = &[
+const RM_DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_real")]
&realmedia::RealMediaDemuxerCreator {},
#[cfg(feature="demuxer_real")]
}
/// Tries to detect container format for provided file name.
-pub fn detect_format_by_name(name: &str) -> Option<(&'static str)> {
+pub fn detect_format_by_name(name: &str) -> Option<&'static str> {
if name.is_empty() {
return None;
}
#[cfg(feature="demuxer_vivo")]
mod vivo;
-const DEMUXERS: &[&DemuxerCreator] = &[
+const DEMUXERS: &[&dyn DemuxerCreator] = &[
#[cfg(feature="demuxer_vivo")]
&vivo::VivoDemuxerCreator {},
];