From ac818eac7671fa8ddfea5aa4fb86fc0b5ab82d2e Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 27 Sep 2020 13:24:03 +0200 Subject: [PATCH] fix some warnings (unneeded parentheses, missing dyn keyword) --- nihav-codec-support/src/codecs/h263/decoder.rs | 12 ++++++------ nihav-commonfmt/src/demuxers/mod.rs | 2 +- nihav-commonfmt/src/demuxers/wav.rs | 2 +- nihav-commonfmt/src/muxers/mod.rs | 2 +- nihav-core/src/demuxers/mod.rs | 12 ++++++------ nihav-core/src/io/byteio.rs | 8 ++++---- nihav-core/src/io/codebook.rs | 2 +- nihav-core/src/muxers/mod.rs | 10 +++++----- nihav-duck/src/codecs/vp3.rs | 4 ++-- nihav-duck/src/codecs/vp5.rs | 2 +- nihav-duck/src/codecs/vp6.rs | 4 ++-- nihav-duck/src/codecs/vp7.rs | 2 +- nihav-duck/src/codecs/vp7dsp.rs | 8 ++++---- nihav-game/src/demuxers/mod.rs | 2 +- nihav-indeo/src/codecs/ivibr.rs | 6 +++--- nihav-llaudio/src/demuxers/mod.rs | 2 +- nihav-rad/src/demuxers/mod.rs | 2 +- nihav-rad/src/demuxers/smacker.rs | 2 +- nihav-realmedia/src/codecs/ra144.rs | 2 +- nihav-realmedia/src/codecs/rv3040.rs | 8 ++++---- nihav-realmedia/src/demuxers/mod.rs | 2 +- nihav-registry/src/detect.rs | 2 +- nihav-vivo/src/demuxers/mod.rs | 2 +- 23 files changed, 50 insertions(+), 50 deletions(-) diff --git a/nihav-codec-support/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index f5c528a..a477711 100644 --- a/nihav-codec-support/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -209,7 +209,7 @@ impl H263BaseDecoder { } 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) { @@ -282,7 +282,7 @@ impl H263BaseDecoder { } 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]); @@ -406,7 +406,7 @@ impl H263BaseDecoder { mb_pos } #[allow(clippy::cyclomatic_complexity)] - pub fn parse_frame(&mut self, bd: &mut BlockDecoder, bdsp: &BlockDSP) -> DecoderResult { + pub fn parse_frame(&mut self, bd: &mut dyn BlockDecoder, bdsp: &dyn BlockDSP) -> DecoderResult { let pinfo = bd.decode_pichdr()?; let mut mvi = MVInfo::new(); let mut mvi2 = MVInfo::new(); @@ -663,7 +663,7 @@ impl H263BaseDecoder { self.ipbs.clear(); } - pub fn get_bframe(&mut self, bdsp: &BlockDSP) -> DecoderResult { + pub fn get_bframe(&mut self, bdsp: &dyn BlockDSP) -> DecoderResult { if !self.has_b || self.ipbs.get_lastref().is_none() || self.ipbs.get_nextref().is_none() { return Err(DecoderError::MissingReference); } @@ -683,7 +683,7 @@ impl H263BaseDecoder { } } -fn recon_b_mb(buf: &mut NAVideoBuffer, 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, 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; @@ -747,7 +747,7 @@ fn recon_b_mb(buf: &mut NAVideoBuffer, ipbs: &mut IPBShuffler, bdsp: &BlockD } fn recon_b_frame(mut b_buf: NAVideoBufferRef, bck_buf: NAVideoBufferRef, fwd_buf: NAVideoBufferRef, - 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); diff --git a/nihav-commonfmt/src/demuxers/mod.rs b/nihav-commonfmt/src/demuxers/mod.rs index ba8a8df..d602cfc 100644 --- a/nihav-commonfmt/src/demuxers/mod.rs +++ b/nihav-commonfmt/src/demuxers/mod.rs @@ -15,7 +15,7 @@ mod mov; #[cfg(feature="demuxer_wav")] mod wav; -const DEMUXERS: &[&DemuxerCreator] = &[ +const DEMUXERS: &[&dyn DemuxerCreator] = &[ #[cfg(feature="demuxer_avi")] &avi::AVIDemuxerCreator {}, #[cfg(feature="demuxer_mov")] diff --git a/nihav-commonfmt/src/demuxers/wav.rs b/nihav-commonfmt/src/demuxers/wav.rs index a579279..ce6318a 100644 --- a/nihav-commonfmt/src/demuxers/wav.rs +++ b/nihav-commonfmt/src/demuxers/wav.rs @@ -25,7 +25,7 @@ impl<'a> DemuxCore<'a> for WAVDemuxer<'a> { 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")); diff --git a/nihav-commonfmt/src/muxers/mod.rs b/nihav-commonfmt/src/muxers/mod.rs index 5865172..6df929c 100644 --- a/nihav-commonfmt/src/muxers/mod.rs +++ b/nihav-commonfmt/src/muxers/mod.rs @@ -5,7 +5,7 @@ mod avi; #[cfg(feature="muxer_wav")] mod wav; -const MUXERS: &[&MuxerCreator] = &[ +const MUXERS: &[&dyn MuxerCreator] = &[ #[cfg(feature="muxer_avi")] &avi::AVIMuxerCreator {}, #[cfg(feature="muxer_wav")] diff --git a/nihav-core/src/demuxers/mod.rs b/nihav-core/src/demuxers/mod.rs index 352c160..b54e563 100644 --- a/nihav-core/src/demuxers/mod.rs +++ b/nihav-core/src/demuxers/mod.rs @@ -88,7 +88,7 @@ impl StreamManager { /// Adds a new stream. pub fn add_stream(&mut self, stream: NAStream) -> Option { 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); @@ -442,7 +442,7 @@ pub trait DemuxerCreator { } /// Creates demuxer for a provided bytestream. -pub fn create_demuxer<'a>(dmxcr: &DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult> { +pub fn create_demuxer<'a>(dmxcr: &dyn DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult> { let mut dmx = dmxcr.new_demuxer(br); let mut str = StreamManager::new(); let mut seek_idx = SeekIndex::new(); @@ -453,7 +453,7 @@ pub fn create_demuxer<'a>(dmxcr: &DemuxerCreator, br: &'a mut ByteReader<'a>) -> /// List of registered demuxers. #[derive(Default)] pub struct RegisteredDemuxers { - dmxs: Vec<&'static DemuxerCreator>, + dmxs: Vec<&'static dyn DemuxerCreator>, } impl RegisteredDemuxers { @@ -462,11 +462,11 @@ 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); @@ -475,7 +475,7 @@ impl RegisteredDemuxers { 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() } } diff --git a/nihav-core/src/io/byteio.rs b/nihav-core/src/io/byteio.rs index 3677501..adbb636 100644 --- a/nihav-core/src/io/byteio.rs +++ b/nihav-core/src/io/byteio.rs @@ -75,7 +75,7 @@ pub trait ByteIO { /// [`MemoryReader`]: ./struct.MemoryReader.html #[allow(dead_code)] pub struct ByteReader<'a> { - io: &'a mut ByteIO, + io: &'a mut dyn ByteIO, } /// Bytestream reader from memory. @@ -241,7 +241,7 @@ impl<'a> ByteReader<'a> { /// # 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 { @@ -639,7 +639,7 @@ impl ByteIO for FileReader { /// [`MemoryWriter`]: ./struct.MemoryWriter.html #[allow(dead_code)] pub struct ByteWriter<'a> { - io: &'a mut ByteIO, + io: &'a mut dyn ByteIO, } /// Bytestream writer to memory. @@ -665,7 +665,7 @@ pub struct GrowableMemoryWriter<'a> { 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<()> { diff --git a/nihav-core/src/io/codebook.rs b/nihav-core/src/io/codebook.rs index 384a743..0ec8883 100644 --- a/nihav-core/src/io/codebook.rs +++ b/nihav-core/src/io/codebook.rs @@ -289,7 +289,7 @@ fn build_esc_lut(table: &mut Vec, impl Codebook { /// Constructs a new `Codebook` instance using provided codebook description and mode. - pub fn new(cb: &mut CodebookDescReader, mode: CodebookMode) -> CodebookResult { + pub fn new(cb: &mut dyn CodebookDescReader, mode: CodebookMode) -> CodebookResult { let mut maxbits = 0; let mut nnz = 0; let mut escape_list: EscapeCodes = HashMap::new(); diff --git a/nihav-core/src/muxers/mod.rs b/nihav-core/src/muxers/mod.rs index 69ab917..40a6eb3 100644 --- a/nihav-core/src/muxers/mod.rs +++ b/nihav-core/src/muxers/mod.rs @@ -134,7 +134,7 @@ pub trait MuxerCreator { } /// Creates muxer for a provided bytestream writer. -pub fn create_muxer<'a>(mxcr: &MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult> { +pub fn create_muxer<'a>(mxcr: &dyn MuxerCreator, str: StreamManager, bw: &'a mut ByteWriter<'a>) -> MuxerResult> { let mut mux = mxcr.new_muxer(bw); mux.create(&str)?; Ok(Muxer::new(mux, str)) @@ -143,7 +143,7 @@ pub fn create_muxer<'a>(mxcr: &MuxerCreator, str: StreamManager, bw: &'a mut Byt /// List of registered muxers. #[derive(Default)] pub struct RegisteredMuxers { - muxes: Vec<&'static MuxerCreator>, + muxes: Vec<&'static dyn MuxerCreator>, } impl RegisteredMuxers { @@ -152,11 +152,11 @@ 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); @@ -165,7 +165,7 @@ impl RegisteredMuxers { 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() } } diff --git a/nihav-duck/src/codecs/vp3.rs b/nihav-duck/src/codecs/vp3.rs index 9d6ef6a..9d56936 100644 --- a/nihav-duck/src/codecs/vp3.rs +++ b/nihav-duck/src/codecs/vp3.rs @@ -1872,11 +1872,11 @@ impl NAOptionHandler for VP34Decoder { fn query_option_value(&self, _name: &str) -> Option { None } } -pub fn get_decoder_vp3() -> Box { +pub fn get_decoder_vp3() -> Box { Box::new(VP34Decoder::new(3)) } -pub fn get_decoder_vp4() -> Box { +pub fn get_decoder_vp4() -> Box { Box::new(VP34Decoder::new(4)) } diff --git a/nihav-duck/src/codecs/vp5.rs b/nihav-duck/src/codecs/vp5.rs index 70c26c6..48fda2d 100644 --- a/nihav-duck/src/codecs/vp5.rs +++ b/nihav-duck/src/codecs/vp5.rs @@ -284,7 +284,7 @@ impl NAOptionHandler for VP5Decoder { fn query_option_value(&self, _name: &str) -> Option { None } } -pub fn get_decoder() -> Box { +pub fn get_decoder() -> Box { Box::new(VP5Decoder::new()) } diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index 93722d3..3dda67b 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -720,11 +720,11 @@ impl NAOptionHandler for VP6Decoder { fn query_option_value(&self, _name: &str) -> Option { None } } -pub fn get_decoder_vp6() -> Box { +pub fn get_decoder_vp6() -> Box { Box::new(VP6Decoder::new(false)) } -pub fn get_decoder_vp6_alpha() -> Box { +pub fn get_decoder_vp6_alpha() -> Box { Box::new(VP6Decoder::new(true)) } diff --git a/nihav-duck/src/codecs/vp7.rs b/nihav-duck/src/codecs/vp7.rs index 2632b40..9243f93 100644 --- a/nihav-duck/src/codecs/vp7.rs +++ b/nihav-duck/src/codecs/vp7.rs @@ -1430,7 +1430,7 @@ impl NAOptionHandler for VP7Decoder { fn query_option_value(&self, _name: &str) -> Option { None } } -pub fn get_decoder() -> Box { +pub fn get_decoder() -> Box { Box::new(VP7Decoder::new()) } diff --git a/nihav-duck/src/codecs/vp7dsp.rs b/nihav-duck/src/codecs/vp7dsp.rs index 27d6fb4..57acc33 100644 --- a/nihav-duck/src/codecs/vp7dsp.rs +++ b/nihav-duck/src/codecs/vp7dsp.rs @@ -575,8 +575,8 @@ fn mc_block(dst: &mut [u8], doff: usize, dstride: usize, xpos: usize, ypos: usiz 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); @@ -621,8 +621,8 @@ pub fn mc_block_special(dst: &mut [u8], doff: usize, dstride: usize, xpos: usize }; 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 { diff --git a/nihav-game/src/demuxers/mod.rs b/nihav-game/src/demuxers/mod.rs index d9eeaaa..efc83ac 100644 --- a/nihav-game/src/demuxers/mod.rs +++ b/nihav-game/src/demuxers/mod.rs @@ -14,7 +14,7 @@ mod vmd; #[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")] diff --git a/nihav-indeo/src/codecs/ivibr.rs b/nihav-indeo/src/codecs/ivibr.rs index 2169b69..c6609cc 100644 --- a/nihav-indeo/src/codecs/ivibr.rs +++ b/nihav-indeo/src/codecs/ivibr.rs @@ -552,7 +552,7 @@ impl IVIDecoder { } 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 }, @@ -827,7 +827,7 @@ br.skip(skip_part as u32)?; unreachable!(); } - fn decode_single_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult { + fn decode_single_frame<'a>(&mut self, dec: &mut dyn IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult { let pic_hdr = dec.decode_picture_header(br)?; self.ftype = pic_hdr.ftype; if pic_hdr.ftype.is_null() { @@ -914,7 +914,7 @@ br.skip(skip_part as u32)?; Ok(buftype) } - pub fn decode_frame<'a>(&mut self, dec: &mut IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult { + pub fn decode_frame<'a>(&mut self, dec: &mut dyn IndeoXParser, br: &mut BitReader<'a>) -> DecoderResult { let res = self.decode_single_frame(dec, br); if res.is_err() { return res; } if (self.ftype == IVIFrameType::Intra) && (br.left() > 16) { diff --git a/nihav-llaudio/src/demuxers/mod.rs b/nihav-llaudio/src/demuxers/mod.rs index ce0f012..d1d38a2 100644 --- a/nihav-llaudio/src/demuxers/mod.rs +++ b/nihav-llaudio/src/demuxers/mod.rs @@ -14,7 +14,7 @@ mod tta; #[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")] diff --git a/nihav-rad/src/demuxers/mod.rs b/nihav-rad/src/demuxers/mod.rs index 1bdf74d..b196964 100644 --- a/nihav-rad/src/demuxers/mod.rs +++ b/nihav-rad/src/demuxers/mod.rs @@ -10,7 +10,7 @@ mod smacker; #[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")] diff --git a/nihav-rad/src/demuxers/smacker.rs b/nihav-rad/src/demuxers/smacker.rs index 6d1173c..5580a87 100644 --- a/nihav-rad/src/demuxers/smacker.rs +++ b/nihav-rad/src/demuxers/smacker.rs @@ -90,7 +90,7 @@ struct SmackerVideoDemuxer<'a> { 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 } } diff --git a/nihav-realmedia/src/codecs/ra144.rs b/nihav-realmedia/src/codecs/ra144.rs index 5cae66c..63d4d12 100644 --- a/nihav-realmedia/src/codecs/ra144.rs +++ b/nihav-realmedia/src/codecs/ra144.rs @@ -219,7 +219,7 @@ fn eval_reflection(coeffs: &[i16; LPC_ORDER]) -> Option { 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 { diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index f9a1817..e4d8420 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -532,7 +532,7 @@ fn parse_slice_offsets(src: &[u8], offsets: &mut Vec) -> DecoderResult<() Ok(()) } -fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult { +fn decode_slice_header(br: &mut BitReader, bd: &mut dyn RV34BitstreamDecoder, slice_no: usize, slice_offs: &[usize], old_width: usize, old_height: usize) -> DecoderResult { 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)?; @@ -777,7 +777,7 @@ impl RV34Decoder { 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 { + 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 { if is_i16 { let imode = br.read(2)? as i8; im.fill_block(imode); @@ -793,7 +793,7 @@ impl RV34Decoder { 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 { + 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 { let hdr = bd.decode_inter_mb_hdr(br, ftype, mbtype)?; validate!(hdr.mbtype != MBType::Invalid); if hdr.dquant { @@ -1096,7 +1096,7 @@ impl RV34Decoder { } #[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 = Vec::new(); parse_slice_offsets(src, &mut slice_offs)?; let ini_off = slice_offs.len() * 8 + 1; diff --git a/nihav-realmedia/src/demuxers/mod.rs b/nihav-realmedia/src/demuxers/mod.rs index 0ba1316..1b044a6 100644 --- a/nihav-realmedia/src/demuxers/mod.rs +++ b/nihav-realmedia/src/demuxers/mod.rs @@ -9,7 +9,7 @@ macro_rules! validate { #[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")] diff --git a/nihav-registry/src/detect.rs b/nihav-registry/src/detect.rs index 210d000..e916dc6 100644 --- a/nihav-registry/src/detect.rs +++ b/nihav-registry/src/detect.rs @@ -360,7 +360,7 @@ pub fn detect_format(name: &str, src: &mut ByteReader) -> Option<(&'static str, } /// 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; } diff --git a/nihav-vivo/src/demuxers/mod.rs b/nihav-vivo/src/demuxers/mod.rs index c76f106..2f4a94d 100644 --- a/nihav-vivo/src/demuxers/mod.rs +++ b/nihav-vivo/src/demuxers/mod.rs @@ -9,7 +9,7 @@ macro_rules! validate { #[cfg(feature="demuxer_vivo")] mod vivo; -const DEMUXERS: &[&DemuxerCreator] = &[ +const DEMUXERS: &[&dyn DemuxerCreator] = &[ #[cfg(feature="demuxer_vivo")] &vivo::VivoDemuxerCreator {}, ]; -- 2.39.5