realmedia: fix some clippy warnings
authorKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 15 May 2019 12:13:30 +0000 (14:13 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 15 May 2019 12:13:30 +0000 (14:13 +0200)
18 files changed:
nihav-realmedia/src/codecs/cook.rs
nihav-realmedia/src/codecs/mod.rs
nihav-realmedia/src/codecs/ra144.rs
nihav-realmedia/src/codecs/ra288.rs
nihav-realmedia/src/codecs/ralf.rs
nihav-realmedia/src/codecs/rv10.rs
nihav-realmedia/src/codecs/rv20.rs
nihav-realmedia/src/codecs/rv30.rs
nihav-realmedia/src/codecs/rv3040.rs
nihav-realmedia/src/codecs/rv30dsp.rs
nihav-realmedia/src/codecs/rv34codes.rs
nihav-realmedia/src/codecs/rv34dsp.rs
nihav-realmedia/src/codecs/rv40.rs
nihav-realmedia/src/codecs/rv60.rs
nihav-realmedia/src/codecs/rv60dsp.rs
nihav-realmedia/src/demuxers/mod.rs
nihav-realmedia/src/demuxers/realmedia.rs
nihav-realmedia/src/lib.rs

index c7018c33be09e278dec37dab58b81106f01ba82c..62a28112bfe496f1647cc5920f6bbb23909564cc 100644 (file)
@@ -17,8 +17,8 @@ enum Mode {
 }
 
 impl Mode {
-    fn get_channels(&self) -> usize {
-        match *self {
+    fn get_channels(self) -> usize {
+        match self {
             Mode::Mono  => 1,
             _           => 2,
         }
@@ -74,9 +74,9 @@ impl Codebooks {
                      Codebook::new(&mut vq5, CodebookMode::MSB).unwrap(),
                      Codebook::new(&mut vq6, CodebookMode::MSB).unwrap()];
         Codebooks {
-            cpl_cb:     cpl_cb,
-            quant_cb:   quant_cb,
-            vq_cb:      vq_cb,
+            cpl_cb,
+            quant_cb,
+            vq_cb,
         }
     }
 }
@@ -111,7 +111,7 @@ impl CookDSP {
             gain_tab[i] = pow_tab[i + 53].powf(8.0 / fsamples);
         }
         let size = samples;
-        CookDSP { imdct: IMDCT::new(samples*2, false), window: window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
+        CookDSP { imdct: IMDCT::new(samples*2, false), window, out: [0.0; 2048], size, pow_tab, hpow_tab, gain_tab }
     }
 }
 
@@ -337,11 +337,11 @@ impl CookChannelPair {
             let cend   = COOK_CPL_BAND[self.subbands - 1] as usize;
             if br.read_bool()? {
                 let cb = &codebooks.cpl_cb[(self.js_bits - 2) as usize];
-                for i in cstart..cend+1 {
+                for i in cstart..=cend {
                     self.decouple[i]                    = br.read_cb(cb)? as u8;
                 }
             } else {
-                for i in cstart..cend+1 {
+                for i in cstart..=cend {
                     self.decouple[i]                    = br.read(self.js_bits)? as u8;
                 }
             }
index a5cc74cc2f12c42588f29939cf7e14d9139eee04..c5ff9bcc232dc5ff9bef8c7eeed38d696222d638 100644 (file)
@@ -11,6 +11,7 @@ mod rv3040;
 mod rv34codes;
 #[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
 #[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
 mod rv34dsp;
 
 #[cfg(feature="decoder_realvideo1")]
@@ -21,11 +22,14 @@ pub mod rv20;
 pub mod rv30;
 #[cfg(feature="decoder_realvideo3")]
 #[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
+#[allow(clippy::neg_multiply)]
 pub mod rv30dsp;
 #[cfg(feature="decoder_realvideo4")]
 pub mod rv40;
 #[cfg(feature="decoder_realvideo4")]
 #[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
 pub mod rv40dsp;
 #[cfg(feature="decoder_realvideo6")]
 pub mod rv60;
@@ -33,6 +37,7 @@ pub mod rv60;
 pub mod rv60codes;
 #[cfg(feature="decoder_realvideo6")]
 #[allow(clippy::erasing_op)]
+#[allow(clippy::many_single_char_names)]
 pub mod rv60dsp;
 
 #[cfg(feature="decoder_realaudio144")]
index b1e730fd85a29da768d460af0950d134f37f98e6..87edae96844994999a9ad8ef818e5f2c07d44674 100644 (file)
@@ -220,7 +220,7 @@ fn eval_reflection(coeffs: &[i16; LPC_ORDER]) -> Option<u32> {
         }
         let a = (1 << 12) - ((src[i + 1] * src[i + 1]) >> 12);
         let scale = if a != 0 { (1 << 24) / a } else { (1 << 24) };
-        for j in 0..(i+1) {
+        for j in 0..=i {
             let result = (src[j] - ((tmp3[i + 1] * src[i - j]) >> 12)).checked_mul(scale);
             if let Some(val) = result {
                 dst[j] = val >> 12;
@@ -248,7 +248,7 @@ impl NADecoder for RA144Decoder {
             self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
                                           1,
                                           SND_S16_FORMAT, NBLOCKS * BLOCKSIZE);
-            self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+            self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
             Ok(())
         } else {
             Err(DecoderError::InvalidData)
index 4daf5172650184ac9fca7b356bedab751be9bf75..9a30ab467967958ef4ff7510a5209f1f06a77f0b 100644 (file)
@@ -38,14 +38,14 @@ fn backfilter(hist: &mut [f32], rec: &mut [f32], filt: &mut [f32], win: &[f32],
     for i in 0..(order + start + non_rec) {
         work[i] = win[i] * hist[i];
     }
-    for i in (0..order + 1).rev() {
+    for i in (0..=order).rev() {
         let src1 = &work[(order - i)..];
         let src2 = &work[order + start - i..];
         tmp1[i] = scalarprod(&work[order..],         src1, start);
         tmp2[i] = scalarprod(&work[order + start..], src2, non_rec);
     }
 
-    for i in 0..(order + 1) {
+    for i in 0..=order {
         rec[i]  = rec[i] * 0.5625 + tmp1[i];
         temp[i] = rec[i]          + tmp2[i];
     }
@@ -157,7 +157,7 @@ impl NADecoder for RA288Decoder {
             self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
                                           1,
                                           SND_F32P_FORMAT, NBLOCKS * BLOCKSIZE);
-            self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+            self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
             Ok(())
         } else {
             Err(DecoderError::InvalidData)
index 6edfd85bcd0f15c92a1b88499bc951d2e77109ff..c4728620098bdd328ff1ea2b69b4a94f3b655d33 100644 (file)
@@ -402,7 +402,7 @@ impl NADecoder for RALFDecoder {
             let table_bytes = table_bits >> 3;
             validate!((table_bytes + 3 <= pktbuf.len()) && (pktbuf.len() <= RALF_MAX_PACKET_SIZE));
             let cmp_len = table_bytes + 2;
-            validate!(&pktbuf[..cmp_len] == &self.pkt_buf[..cmp_len]);
+            validate!(pktbuf[..cmp_len] == self.pkt_buf[..cmp_len]);
             {
                 let copy_size = pktbuf.len() - cmp_len;
                 let dst = &mut self.pkt_buf[RALF_MAX_PACKET_SIZE..][..copy_size];
@@ -429,7 +429,7 @@ impl NADecoder for RALFDecoder {
         self.blocks.truncate(0);
         {
             let mut br = BitReader::new(&self.pkt_buf[2..], table_bytes, BitReaderMode::BE);
-            while br.tell() < table_bits.into() {
+            while br.tell() < table_bits {
                 let size                                = br.read(13 + self.channels).unwrap() as usize;
                 let pts;
                 if br.read_bool().unwrap() {
index 79b6a2248aab1dd0841eb002eb10ff890fa0211c..4b75a4035e95798ce706630e7b6e97e090875edb 100644 (file)
@@ -57,7 +57,7 @@ struct RV10SliceInfo {
 
 impl RV10SliceInfo {
     fn new(is_p: bool, qscale: u8, mb_x: usize, mb_y: usize, mb_c: usize) -> Self {
-        RV10SliceInfo { is_p: is_p, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_c: mb_c }
+        RV10SliceInfo { is_p, qscale, mb_x, mb_y, mb_c }
     }
 }
 
@@ -77,7 +77,7 @@ impl<'a> RealVideo10BR<'a> {
         let soff = nslices * 8 + 1;
         RealVideo10BR {
             br:         BitReader::new(&src[soff..], src.len() - soff, BitReaderMode::BE),
-            tables:     tables,
+            tables,
             num_slices: nslices,
             slice_no:   0,
             slice_off:  slice_offs,
@@ -85,10 +85,10 @@ impl<'a> RealVideo10BR<'a> {
             h:          height,
             mb_w:       (width  + 15) >> 4,
             mb_h:       (height + 15) >> 4,
-            new_ver:    new_ver,
+            new_ver,
             dc_coded:   [false; 3],
             last_dc:    [0; 3],
-            mvmode:     mvmode,
+            mvmode,
         }
     }
 
@@ -379,20 +379,20 @@ impl RealVideo10Decoder {
         let chroma_dc_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
 
         let tables = Tables {
-            intra_mcbpc_cb: intra_mcbpc_cb,
-            inter_mcbpc_cb: inter_mcbpc_cb,
-            cbpy_cb:        cbpy_cb,
-            rl_cb:          rl_cb,
-            aic_rl_cb:      aic_rl_cb,
-            mv_cb:          mv_cb,
-            luma_dc_cb:     luma_dc_cb,
-            chroma_dc_cb:   chroma_dc_cb,
+            intra_mcbpc_cb,
+            inter_mcbpc_cb,
+            cbpy_cb,
+            rl_cb,
+            aic_rl_cb,
+            mv_cb,
+            luma_dc_cb,
+            chroma_dc_cb,
         };
 
         RealVideo10Decoder{
             info:           NACodecInfoRef::default(),
             dec:            H263BaseDecoder::new_with_opts(false, false, false),
-            tables:         tables,
+            tables,
             w:              0,
             h:              0,
             new_ver:        false,
@@ -478,7 +478,7 @@ pub struct CodeReader { codes: &'static [u16], bits: &'static [u8] }
 
 impl CodeReader {
     pub fn new(codes: &'static [u16], bits: &'static [u8]) -> Self {
-        CodeReader { codes: codes, bits: bits }
+        CodeReader { codes, bits }
     }
 }
 
index a7b5f7fdb8ee923fe41fab0dc1a8a4b7ce75a43a..66413b2438178170cb2403659d55c4e04d2f2f78 100644 (file)
@@ -68,7 +68,7 @@ struct RV20SliceInfo {
 
 impl RV20SliceInfo {
     fn new(ftype: Type, seq: u32, qscale: u8, mb_x: usize, mb_y: usize, mb_pos: usize, w: usize, h: usize) -> Self {
-        RV20SliceInfo { ftype: ftype, seq: seq, qscale: qscale, mb_x: mb_x, mb_y: mb_y, mb_pos: mb_pos, w: w, h: h }
+        RV20SliceInfo { ftype, seq, qscale, mb_x, mb_y, mb_pos, w, h }
     }
 }
 
@@ -98,17 +98,17 @@ impl<'a> RealVideo20BR<'a> {
         }
         RealVideo20BR {
             br:         BitReader::new(&src[soff..], src.len() - soff, BitReaderMode::BE),
-            tables:     tables,
+            tables,
             num_slices: nslices,
             slice_no:   0,
             slice_off:  slice_offs,
             w:          width,
             h:          height,
-            mb_w:       mb_w,
-            mb_h:       mb_h,
+            mb_w,
+            mb_h,
             mb_pos_bits: mbpb,
-            minor_ver:  minor_ver,
-            rpr:        rpr,
+            minor_ver,
+            rpr,
         }
     }
 
@@ -432,20 +432,20 @@ impl RealVideo20Decoder {
         let mv_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
 
         let tables = Tables {
-            intra_mcbpc_cb: intra_mcbpc_cb,
-            inter_mcbpc_cb: inter_mcbpc_cb,
-            mbtype_b_cb:    mbtype_b_cb,
-            cbpy_cb:        cbpy_cb,
-            cbpc_b_cb:      cbpc_b_cb,
-            rl_cb:          rl_cb,
-            aic_rl_cb:      aic_rl_cb,
-            mv_cb:          mv_cb,
+            intra_mcbpc_cb,
+            inter_mcbpc_cb,
+            mbtype_b_cb,
+            cbpy_cb,
+            cbpc_b_cb,
+            rl_cb,
+            aic_rl_cb,
+            mv_cb,
         };
 
         RealVideo20Decoder{
             info:           NACodecInfoRef::default(),
             dec:            H263BaseDecoder::new_b_frames(false),
-            tables:         tables,
+            tables,
             w:              0,
             h:              0,
             minor_ver:      0,
index 4f7028030befeda29a02f968441b8bf1fc08e00e..d42317642d45d9da38fe731968a86f57849d11cf 100644 (file)
@@ -49,7 +49,7 @@ impl RV34BitstreamDecoder for RealVideo30BR {
         let start               = br.read(get_slice_start_offset_bits(w, h))? as usize;
                                   br.skip(1)?;
 
-        Ok(RV34SliceHeader{ ftype: ftype, quant: q, deblock: deblock, pts: pts, width: w, height: h, start: start, end: 0, set_idx: 0 })
+        Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx: 0 })
     }
     fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, _has_top: bool) -> DecoderResult<()> {
         for _ in 0..4 {
@@ -79,7 +79,7 @@ impl RV34BitstreamDecoder for RealVideo30BR {
         let idx = if ftype == FrameType::P { 0 } else { 1 };
         Ok(MBInfo { mbtype: RV30_MB_TYPES[idx][code], skip_run: 0, dquant: dq })
     }
-    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], _mbinfo: &Vec<RV34MBInfo>) -> (MV, MV) {
+    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], _mbinfo: &[RV34MBInfo]) -> (MV, MV) {
         let mb_x = sstate.mb_x;
         let mb_y = sstate.mb_y;
         let mv_f;
@@ -131,7 +131,7 @@ impl NADecoder for RealVideo30Decoder {
             if src.len() < num_rpr * 2 + 8 { return Err(DecoderError::ShortData); }
             self.bd.rpr_bits  = ((num_rpr >> 1) + 1) as u8;
             if self.bd.rpr_bits > 3 { self.bd.rpr_bits = 3; }
-            for i in 0..num_rpr+1 {
+            for i in 0..=num_rpr {
                 self.bd.widths.push ((src[6 + i * 2] as usize) << 2);
                 self.bd.heights.push((src[7 + i * 2] as usize) << 2);
             }
index 1e83d31e5227fa177af2297352b929772b8f96f3..f7f5334aa2dfe48c99e00ba08c2fe30a26e7c783 100644 (file)
@@ -19,11 +19,11 @@ pub struct GenericCache<T: Copy> {
 impl<T:Copy> GenericCache<T> {
     pub fn new(height: usize, stride: usize, default: T) -> Self {
         let mut ret = Self {
-                stride: stride,
-                height: height,
+                stride,
+                height,
                 xpos:   0,
                 data:   Vec::with_capacity((height + 1) * stride),
-                default: default,
+                default,
             };
         ret.reset();
         ret
@@ -106,17 +106,17 @@ pub enum MBType {
 }
 
 impl MBType {
-    pub fn is_intra(&self) -> bool {
-        (*self == MBType::MBIntra) || (*self == MBType::MBIntra16)
+    pub fn is_intra(self) -> bool {
+        (self == MBType::MBIntra) || (self == MBType::MBIntra16)
     }
-    pub fn is_16(&self) -> bool {
-        (*self == MBType::MBIntra16) || (*self == MBType::MBP16x16Mix)
+    pub fn is_16(self) -> bool {
+        (self == MBType::MBIntra16) || (self == MBType::MBP16x16Mix)
     }
-    pub fn is_intra_or_16(&self) -> bool {
+    pub fn is_intra_or_16(self) -> bool {
         self.is_intra() || self.is_16()
     }
-    pub fn get_num_mvs(&self) -> usize {
-        match *self {
+    pub fn get_num_mvs(self) -> usize {
+        match self {
             MBType::MBIntra | MBType::MBIntra16 |
             MBType::MBSkip | MBType::MBDirect                       => 0,
             MBType::MBP16x16 | MBType::MBP16x16Mix |
@@ -126,42 +126,42 @@ impl MBType {
             MBType::Invalid => unreachable!(),
         }
     }
-    pub fn is_fwd(&self) -> bool {
-        match *self {
+    pub fn is_fwd(self) -> bool {
+        match self {
             MBType::MBP16x16 | MBType::MBP16x16Mix |
             MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 |
             MBType::MBForward => true,
             _ => false,
         }
     }
-    pub fn is_bwd(&self) -> bool {
-        match *self {
+    pub fn is_bwd(self) -> bool {
+        match self {
             MBType::MBBidir | MBType::MBBackward => true,
             _                  => false,
         }
     }
-    pub fn has_mv_dir(&self, fwd: bool) -> bool {
-        match *self {
+    pub fn has_mv_dir(self, fwd: bool) -> bool {
+        match self {
             MBType::MBBidir             => true,
             MBType::MBForward  if  fwd  => true,
             MBType::MBBackward if !fwd  => true,
             _ => false,
         }
     }
-    pub fn is_nomv(&self) -> bool {
-        match *self {
+    pub fn is_nomv(self) -> bool {
+        match self {
             MBType::MBIntra | MBType::MBIntra16 | MBType::MBSkip | MBType::MBDirect => true,
             _                  => false,
         }
     }
-    /*pub fn is_16x16(&self) -> bool {
-        match *self {
+    /*pub fn is_16x16(self) -> bool {
+        match self {
             MBType::MBP16x8 | MBType::MBP8x16 | MBType::MBP8x8 => false,
             _ => true,
         }
     }*/
-    fn get_weight(&self) -> usize {
-        match *self {
+    fn get_weight(self) -> usize {
+        match self {
             MBType::MBIntra     => 0,
             MBType::MBIntra16   => 1,
             MBType::MBSkip      => unreachable!(),
@@ -535,7 +535,7 @@ pub trait RV34BitstreamDecoder {
     fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()>;
     fn quant_dc(&self, is_intra: bool, q: u8) -> u8;
     fn decode_inter_mb_hdr(&mut self, br: &mut BitReader, ftype: FrameType, mbtype: MBType) -> DecoderResult<MBInfo>;
-    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &Vec<RV34MBInfo>) -> (MV, MV);
+    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV);
 }
 
 pub trait RV34DSP {
@@ -568,7 +568,7 @@ fn parse_slice_offsets(src: &[u8], offsets: &mut Vec<usize>) -> DecoderResult<()
     Ok(())
 }
 
-fn decode_slice_header(br: &mut BitReader, bd: &mut RV34BitstreamDecoder, slice_no: usize, slice_offs: &Vec<usize>, old_width: usize, old_height: usize) -> DecoderResult<RV34SliceHeader> {
+fn decode_slice_header(br: &mut BitReader, bd: &mut 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)?;
@@ -713,7 +713,7 @@ impl MBHist {
 fn decode_mv(br: &mut BitReader) -> DecoderResult<MV> {
     let x = br.read_code_signed(IntCodeType::Gamma)? as i16;
     let y = br.read_code_signed(IntCodeType::Gamma)? as i16;
-    Ok(MV{ x: x, y: y })
+    Ok(MV{ x, y })
 }
 
 fn do_mc_16x16(dsp: &Box<dyn RV34DSP>, buf: &mut NAVideoBuffer<u8>, prevbuf: &NAVideoBuffer<u8>, mb_x: usize, mb_y: usize, mv: MV, avg: bool) {
@@ -778,9 +778,9 @@ impl RV34Decoder {
         let vb = vt.get_vbuf();
         let avg_buf = vb.unwrap();
         RV34Decoder {
-            is_rv30:    is_rv30,
+            is_rv30,
             coderead:   RV34Codes::new(),
-            dsp:        dsp,
+            dsp,
             cdsp:       RV34CommonDSP::new(),
             ipbs:       IPBShuffler::new(),
             mvi:        MVInfo::new(),
@@ -790,7 +790,7 @@ impl RV34Decoder {
             last_ts: 0, next_ts: 0,
             ratio1: 0, ratio2: 0,
             is_b:       false,
-            avg_buf:    avg_buf,
+            avg_buf,
             base_ts:    0,
         }
     }
@@ -798,7 +798,7 @@ impl RV34Decoder {
         if is_i16 {
             let imode = br.read(2)? as i8;
             im.fill_block(imode);
-            return Ok(MBInfo { mbtype: MBType::MBIntra16, skip_run: 0, dquant: false });
+            Ok(MBInfo { mbtype: MBType::MBIntra16, skip_run: 0, dquant: false })
         } else {
             let dq = if !has_dq {
                     if !self.is_rv30 { !br.read_bool()? } else { false }
@@ -807,7 +807,7 @@ impl RV34Decoder {
                 decode_dquant(br, q)?;
             }
             bd.decode_intra_pred(br, im.cache.data.as_mut_slice(), im.cache.xpos, im.cache.stride, has_top)?;
-            return Ok(MBInfo { mbtype: MBType::MBIntra, skip_run: 0, dquant: dq });
+            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> {
@@ -819,7 +819,7 @@ impl RV34Decoder {
         if hdr.mbtype.is_intra() {
             return self.decode_mb_header_intra(bd, br, hdr.mbtype.is_16(), im, q, has_top, true);
         }
-        return Ok(hdr);
+        Ok(hdr)
     }
 
     fn decode_mb_intra(&mut self, sstate: &SState, imode: &IntraModeState, buf: &mut NAVideoBuffer<u8>, br: &mut BitReader, is_16: bool) -> DecoderResult<()> {
@@ -1118,7 +1118,7 @@ impl RV34Decoder {
         let ini_off = slice_offs.len() * 8 + 1;
 
         let mut br = BitReader::new(&src[ini_off..], src.len() - ini_off, BitReaderMode::BE);
-        let hdr0 = decode_slice_header(&mut br, bd, 0, &slice_offs, self.width, self.height)?;
+        let hdr0 = decode_slice_header(&mut br, bd, 0, slice_offs.as_slice(), self.width, self.height)?;
         validate!((hdr0.width != 0) && (hdr0.height != 0));
         self.width  = hdr0.width;
         self.height = hdr0.height;
@@ -1232,7 +1232,7 @@ impl RV34Decoder {
                     if !self.is_b {
                         self.mvi.set_mb(mb_x, mb_y, mbh.mbtype, &self.ref_mvi, &mvs, &sstate);
                     } else {
-                        let (mv_f, mv_b) = bd.predict_b_mv(&sstate, &self.mvi, mbh.mbtype, &mvs, &mbinfo);
+                        let (mv_f, mv_b) = bd.predict_b_mv(&sstate, &self.mvi, mbh.mbtype, &mvs, mbinfo.as_slice());
                         self.mvi.fill(mb_x, mb_y, true,  mv_f);
                         self.mvi.fill(mb_x, mb_y, false, mv_b);
                     }
@@ -1260,7 +1260,7 @@ impl RV34Decoder {
                     self.decode_mb_inter(&sstate, &mbh, &mut buf, &mut br, is_16)?;
                 }
 
-                let mi = RV34MBInfo { cbp: cbp, q: q, mbtype: mbh.mbtype, deblock: 0, cbp_c: 0 };
+                let mi = RV34MBInfo { cbp, q, mbtype: mbh.mbtype, deblock: 0, cbp_c: 0 };
                 mbinfo.push(mi);
                 if is_intra {
                     mbinfo[mb_pos].deblock = 0xFFFF;
index 92719165f8059dc1d4e691dc298d7db4797311c0..86e8488de3b9286b03e26748f587525d2ffb330a 100644 (file)
@@ -34,7 +34,7 @@ macro_rules! mc_matrix {
             ($c1 * 6) * ($s[$o] as i32) + ($c1 * 9) * ($s[$o + 1] as i32) + ($c1) * ($s[$o + 2] as i32)
         );
     ($s: ident, $o: expr, $c1: expr, $d1: expr, $d2: expr) => (
-            (-$c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + (-$c1) * ($s[$o + 2] as i32)
+            -($c1) * ($s[$o - 1] as i32) + ($c1 * $d1) * ($s[$o] as i32) + ($c1 * $d2) * ($s[$o + 1] as i32) + -($c1) * ($s[$o + 2] as i32)
         );
     ($s: ident, $o: expr, $ss: expr, $c1: expr, $c2: expr, $d1: expr, $d2: expr) => (
         ((mc_matrix!($s, $o -     $ss,  -1, $d1, $d2) +
index 290d50398b729bf29f1a0273b27240d047946233..1436a41de03d2fae36adca132aab451172829e74 100644 (file)
@@ -50,7 +50,7 @@ impl RV34CodeReader {
             syms.push(i as u16);
         }
 
-        RV34CodeReader { codes: codes, lengths: lengths, syms: syms }
+        RV34CodeReader { codes, lengths, syms }
     }
 }
 
@@ -97,7 +97,7 @@ impl RV34CBPCodeReader {
             syms.push(RV34_CBP_SYMS[i]);
         }
 
-        RV34CBPCodeReader { codes: codes, lengths: lengths, syms: syms }
+        RV34CBPCodeReader { codes, lengths, syms }
     }
 }
 
@@ -197,14 +197,14 @@ impl FullSet {
             let cset = CoefSet::new(intra, set);
             let mut coderead = RV34CodeReader::new(&RV34_INTRA_COEFFS[set]);
             let coeffs = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
-            FullSet { cbp: cbp, cset: cset, coeffs: coeffs }
+            FullSet { cbp, cset, coeffs }
         } else {
             let cbp0 = CBPSet::new(intra, set, 0);
             let cbp: Vec<CBPSet> = vec![cbp0];
             let cset = CoefSet::new(intra, set);
             let mut coderead = RV34CodeReader::new(&RV34_INTER_COEFFS[set]);
             let coeffs = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
-            FullSet { cbp: cbp, cset: cset, coeffs: coeffs }
+            FullSet { cbp, cset, coeffs }
         }
     }
 }
@@ -392,7 +392,7 @@ const RV34_MODULO_THREE_TABLE: [u8; 108] = [
     0xE0, 0xE1, 0xE2, 0xE4, 0xE5, 0xE6, 0xE8, 0xE9, 0xEA,
 ];
 
-const RV34_INTRA_CBPPAT: &'static [[[u8; 1296]; 2]; 5] = &[
+const RV34_INTRA_CBPPAT: &[[[u8; 1296]; 2]; 5] = &[
   [
     [
        8, 10, 10, 10, 10, 10, 11, 10, 10, 11, 10, 10, 10, 10, 10,  6,
@@ -1226,7 +1226,7 @@ const RV34_INTRA_CBPPAT: &'static [[[u8; 1296]; 2]; 5] = &[
   ],
 ];
 
-const RV34_INTRA_CBP: &'static [[[u8; 16]; 8]; 5] = &[
+const RV34_INTRA_CBP: &[[[u8; 16]; 8]; 5] = &[
   [
     [ 0,  3,  3,  4,  3,  5,  5,  5,  2,  5,  4,  6,  4,  6,  6,  6, ],
     [ 0,  2,  3,  4,  2,  5,  6,  7,  3,  6,  5,  7,  4,  7,  8,  8, ],
@@ -1275,7 +1275,7 @@ const RV34_INTRA_CBP: &'static [[[u8; 16]; 8]; 5] = &[
   ],
 ];
 
-const RV34_INTRA_FIRSTPAT: &'static [[[u8; 864]; 4]; 5] = &[
+const RV34_INTRA_FIRSTPAT: &[[[u8; 864]; 4]; 5] = &[
   [
     [
        0, 10,  5, 10,  7, 12,  9, 11,  8, 13,  9, 12, 10, 13, 11, 12,
@@ -2389,7 +2389,7 @@ const RV34_INTRA_FIRSTPAT: &'static [[[u8; 864]; 4]; 5] = &[
   ],
 ];
 
-const RV34_INTRA_SECONDPAT: &'static [[[u8; 108]; 2]; 5] = &[
+const RV34_INTRA_SECONDPAT: &[[[u8; 108]; 2]; 5] = &[
   [
     [
        0,  5, 10,  3,  6, 10,  7,  8,  9,  4,  6, 10,  6,  7,  9,  8,
@@ -2483,7 +2483,7 @@ const RV34_INTRA_SECONDPAT: &'static [[[u8; 108]; 2]; 5] = &[
   ],
 ];
 
-const RV34_INTRA_THIRDPAT: &'static [[[u8; 108]; 2]; 5] = &[
+const RV34_INTRA_THIRDPAT: &[[[u8; 108]; 2]; 5] = &[
   [
     [
        0,  5, 10,  3,  6, 10,  7,  8, 10,  4,  7, 10,  6,  7, 10,  8,
@@ -2577,7 +2577,7 @@ const RV34_INTRA_THIRDPAT: &'static [[[u8; 108]; 2]; 5] = &[
   ],
 ];
 
-const RV34_INTRA_COEFFS: &'static [[u8; 32]; 5] = &[
+const RV34_INTRA_COEFFS: &[[u8; 32]; 5] = &[
   [
     1,  3,  3,  4,  4,  5,  6,  6,  6,  7,  7,  7,  8,  8,  9,  9,
     9,  9, 10, 10, 10, 11, 11, 11, 10, 10, 10, 12, 13, 14, 15, 15,
@@ -2596,7 +2596,7 @@ const RV34_INTRA_COEFFS: &'static [[u8; 32]; 5] = &[
   ]
 ];
 
-const RV34_INTER_CBPPAT: &'static [[u8; 1296]; 7] = &[
+const RV34_INTER_CBPPAT: &[[u8; 1296]; 7] = &[
 [
   7,  9,  9,  8,  9,  8,  9,  8,  9,  9,  8,  8,  8,  8,  8,  4,
   7, 10, 11, 10, 11, 10, 12, 10, 12, 11, 11, 10, 11, 10, 10,  7,
@@ -3211,7 +3211,7 @@ const RV34_INTER_CBP: &[[[u8; 16]; 4]; 7] = &[
  [ 0,  4,  4,  3,  5,  4,  5,  4,  5,  5,  4,  4,  3,  4,  4,  3 ]
 ]];
 
-const RV34_INTER_FIRSTPAT: &'static [[[u8; 864]; 2]; 7] = &[
+const RV34_INTER_FIRSTPAT: &[[[u8; 864]; 2]; 7] = &[
   [
     [
        0,  7,  5,  7,  5,  7,  6,  6,  7, 10,  7,  9,  8,  9,  8,  7,
@@ -3999,7 +3999,7 @@ const RV34_INTER_FIRSTPAT: &'static [[[u8; 864]; 2]; 7] = &[
   ],
 ];
 
-const RV34_INTER_SECONDPAT: &'static [[[u8; 108]; 2]; 7] = &[
+const RV34_INTER_SECONDPAT: &[[[u8; 108]; 2]; 7] = &[
   [
     [
        0,  4,  8,  3,  6,  8,  6,  7,  8,  4,  6,  8,  6,  7,  8,  7,
@@ -4129,7 +4129,7 @@ const RV34_INTER_SECONDPAT: &'static [[[u8; 108]; 2]; 7] = &[
   ],
 ];
 
-const RV34_INTER_THIRDPAT: &'static [[[u8; 108]; 2]; 7] = &[
+const RV34_INTER_THIRDPAT: &[[[u8; 108]; 2]; 7] = &[
   [
     [
        0,  5,  8,  3,  6,  9,  6,  7,  9,  4,  6,  9,  6,  7,  9,  8,
index 21171c1bec4c4fa2aebb7f7c59f7e063281c29ed..a8f9e0353a2606a86c7777ed6db6a9936cefe74e 100644 (file)
@@ -30,8 +30,10 @@ pub enum PredType8x8 {
     DC128
 }
 
+type IPred4x4Func = fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]);
+
 pub struct RV34CommonDSP {
-    pub ipred4x4:   [fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]); 15],
+    pub ipred4x4:   [IPred4x4Func; 15],
     pub ipred8x8:   [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
     pub ipred16x16: [fn(buf: &mut [u8], idx: usize, stride: usize); 7],
 }
@@ -547,7 +549,7 @@ fn ipred_16x16_plane(buf: &mut [u8], mut idx: usize, stride: usize) {
     }
 }
 
-const IPRED_FUNCS4X4: [fn(buf: &mut [u8], idx: usize, stride: usize, tr: &[u8]); 15] = [
+const IPRED_FUNCS4X4: [IPred4x4Func; 15] = [
     ipred_4x4_ver, ipred_4x4_hor, ipred_4x4_dc,
     ipred_4x4_diag_down_left, ipred_4x4_diag_down_right,
     ipred_4x4_ver_right, ipred_4x4_hor_down, ipred_4x4_ver_left, ipred_4x4_hor_up,
index 61045c251fff161c6ed7d5e72069ab5952d865a7..7586aae78c3b8a000ace07942faaa9f71cedcb2b 100644 (file)
@@ -97,15 +97,15 @@ impl RealVideo40BR {
         RealVideo40BR {
             width:          0,
             height:         0,
-            aic_top_cb:     aic_top_cb,
-            aic_mode1_cb:   aic_mode1_cb,
-            aic_mode2_cb:   aic_mode2_cb,
-            ptype_cb:       ptype_cb,
-            btype_cb:       btype_cb,
+            aic_top_cb,
+            aic_mode1_cb,
+            aic_mode2_cb,
+            ptype_cb,
+            btype_cb,
             had_skip_run:   false,
         }
     }
-    fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &Vec<RV34MBInfo>, mbtype: MBType, fwd: bool) -> MV {
+    fn predict_b_mv_component(&self, sstate: &SState, mvi: &MVInfo, mbinfo: &[RV34MBInfo], mbtype: MBType, fwd: bool) -> MV {
         let mut pred_mvs: [MV; 3] = [ZERO_MV; 3];
         let mut mv_count: usize = 0;
         let mb_x = sstate.mb_x;
@@ -192,7 +192,7 @@ impl RV34BitstreamDecoder for RealVideo40BR {
 
         self.had_skip_run = false;
 
-        Ok(RV34SliceHeader{ ftype: ftype, quant: q, deblock: deblock, pts: pts, width: w, height: h, start: start, end: 0, set_idx: set_idx })
+        Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx })
     }
     fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()> {
         let start;
@@ -276,9 +276,9 @@ impl RV34BitstreamDecoder for RealVideo40BR {
             mbtype = if ftype == FrameType::P { br.read_cb(&self.ptype_cb[idx])? }
                      else { br.read_cb(&self.btype_cb[idx])? };
         }
-        Ok(MBInfo { mbtype: mbtype, skip_run: 0, dquant: dquant })
+        Ok(MBInfo { mbtype, skip_run: 0, dquant })
     }
-    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &Vec<RV34MBInfo>) -> (MV, MV) {
+    fn predict_b_mv(&self, sstate: &SState, mvi: &MVInfo, mbtype: MBType, mvs: &[MV], mbinfo: &[RV34MBInfo]) -> (MV, MV) {
         let mut mv_f = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, true);
         let mut mv_b = self.predict_b_mv_component(sstate, mvi, mbinfo, mbtype, false);
 
@@ -325,7 +325,7 @@ impl NADecoder for RealVideo40Decoder {
 
 {
 println!("edata:");
-for i in 0..src.len() { print!(" {:02X}", src[i]); } println!("");
+for i in 0..src.len() { print!(" {:02X}", src[i]); } println!();
 }
             if src.len() < 2 { return Err(DecoderError::InvalidData); }
 
index 1d13efdd9e073cce2976b335363da40b7bc87014..a4cf919cb8337841acb5f58ace5a06ccb131e060 100644 (file)
@@ -257,58 +257,58 @@ const RV60_PU_TYPES: [PUType; 8] = [
 ];
 
 impl PUType {
-    fn get_num_mvs(&self) -> usize {
-        match *self {
+    fn get_num_mvs(self) -> usize {
+        match self {
             PUType::Full        => 1,
             PUType::Quarters    => 4,
             _                   => 2,
         }
     }
-    fn get_mv_size(&self, part_no: usize, size: usize) -> (usize, usize) {
+    fn get_mv_size(self, part_no: usize, size: usize) -> (usize, usize) {
         let mv_size = size >> 2;
-        match *self {
+        match self {
             PUType::Full        => (mv_size, mv_size),
             PUType::N2Hor       => (mv_size, mv_size >> 1),
             PUType::N2Ver       => (mv_size >> 1, mv_size),
             PUType::Quarters    => (mv_size >> 1, mv_size >> 1),
             PUType::N4Hor       => {
                     if part_no == 0 {
-                        (mv_size,     mv_size >> 2)
+                        (mv_size,      mv_size  >> 2)
                     } else {
-                        (mv_size, 3 * mv_size >> 2)
+                        (mv_size, (3 * mv_size) >> 2)
                     }
                 },
             PUType::N34Hor      => {
                     if part_no == 0 {
-                        (mv_size, 3 * mv_size >> 2)
+                        (mv_size, (3 * mv_size) >> 2)
                     } else {
-                        (mv_size,     mv_size >> 2)
+                        (mv_size,      mv_size  >> 2)
                     }
                 },
             PUType::N4Ver       => {
                     if part_no == 0 {
-                        (    mv_size >> 2, mv_size)
+                        (     mv_size  >> 2, mv_size)
                     } else {
-                        (3 * mv_size >> 2, mv_size)
+                        ((3 * mv_size) >> 2, mv_size)
                     }
                 },
             PUType::N34Ver      => {
                     if part_no == 0 {
-                        (3 * mv_size >> 2, mv_size)
+                        ((3 * mv_size) >> 2, mv_size)
                     } else {
-                        (    mv_size >> 2, mv_size)
+                        (     mv_size  >> 2, mv_size)
                     }
                 },
         }
     }
-    fn has_hor_split(&self) -> bool {
-        match *self {
+    fn has_hor_split(self) -> bool {
+        match self {
             PUType::N2Hor | PUType::N4Hor | PUType::N34Hor | PUType::Quarters => true,
             _ => false,
         }
     }
-    fn has_ver_split(&self) -> bool {
-        match *self {
+    fn has_ver_split(self) -> bool {
+        match self {
             PUType::N2Ver | PUType::N4Ver | PUType::N34Ver | PUType::Quarters => true,
             _ => false,
         }
@@ -355,28 +355,28 @@ enum MVRef {
 const SKIP_MV_REF: [MVRef; 4] = [ MVRef::Skip0,  MVRef::Skip1, MVRef::Skip2,  MVRef::Skip3 ];
 
 impl MVRef {
-    fn get_skip_mv_num(&self) -> usize {
-        match *self {
+    fn get_skip_mv_num(self) -> usize {
+        match self {
             MVRef::Skip1    => 1,
             MVRef::Skip2    => 2,
             MVRef::Skip3    => 3,
             _               => 0,
         }
     }
-    fn is_ref0(&self) -> bool {
-        match *self {
+    fn is_ref0(self) -> bool {
+        match self {
             MVRef::Ref0 | MVRef::Ref0AndBRef => true,
             _ => false,
         }
     }
-    fn is_fwd(&self) -> bool {
-        match *self {
+    fn is_fwd(self) -> bool {
+        match self {
             MVRef::Ref0 | MVRef::Ref1 | MVRef::Ref0AndBRef => true,
             _ => false,
         }
     }
-    fn is_bwd(&self) -> bool {
-        match *self {
+    fn is_bwd(self) -> bool {
+        match self {
             MVRef::BRef | MVRef::Ref0AndBRef => true,
             _ => false,
         }
@@ -550,7 +550,7 @@ struct PUInfo {
 }
 
 impl PUInfo {
-    fn is_intra(&self) -> bool { self.cu_type == CUType::Intra }
+    fn is_intra(self) -> bool { self.cu_type == CUType::Intra }
 }
 
 const RV60_CANDIDATE_INTRA_ANGLES: [u8; 6] = [ 0, 1, 10, 26, 18, 2 ];
@@ -650,7 +650,7 @@ impl RealVideo60Decoder {
             ipbs:       IPBShuffler::new(),
             ipred:      IntraPredContext::new(),
             dsp:        RV60DSP::new(),
-            avg_buf:    avg_buf,
+            avg_buf,
             y_coeffs:   [0; 16 * 16],
             u_coeffs:   [0; 8 * 8],
             v_coeffs:   [0; 8 * 8],
index ab9010520032dcf0c26849cb1b0569a12b0bb10b..3c88f39cd88ee78982a61747f1864fb86e3a2aa9 100644 (file)
@@ -826,10 +826,10 @@ impl IntraPredContext {
             let inv_angle  = RV60_IPRED_INV_ANGLE[angle - 10];
             let add_size = (size * (ang_weight as usize) + 31) >> 5;
             if size <= 16 {
-                for i in 0..size+1 {
+                for i in 0..=size {
                     filtered1[32-1 + i] = self.l[i];
                 }
-                for i in 0..size+1 {
+                for i in 0..=size {
                     filtered2[32-1 + i] = self.t[i];
                 }
             } else {
@@ -852,10 +852,10 @@ impl IntraPredContext {
             let inv_angle  = RV60_IPRED_INV_ANGLE[26 - angle];
             let add_size = (size * (ang_weight as usize) + 31) >> 5;
             if size <= 16 {
-                for i in 0..size+1 {
+                for i in 0..=size {
                     filtered1[32-1 + i] = self.t[i];
                 }
-                for i in 0..size+1 {
+                for i in 0..=size {
                     filtered2[32-1 + i] = self.l[i];
                 }
             } else {
index ebe9ee39f032c1332002f433bf987393e43499d1..c5825b3ffc553d2aac21e1ea90187453e4871384 100644 (file)
@@ -7,7 +7,7 @@ macro_rules! validate {
 #[cfg(feature="demuxer_real")]
 mod realmedia;
 
-const RM_DEMUXERS: &[&'static DemuxerCreator] = &[
+const RM_DEMUXERS: &[&DemuxerCreator] = &[
 #[cfg(feature="demuxer_real")]
     &realmedia::RealMediaDemuxerCreator {},
 #[cfg(feature="demuxer_real")]
@@ -17,7 +17,7 @@ const RM_DEMUXERS: &[&'static DemuxerCreator] = &[
 ];
 
 pub fn realmedia_register_all_demuxers(rd: &mut RegisteredDemuxers) {
-    for demuxer in RM_DEMUXERS.into_iter() {
+    for demuxer in RM_DEMUXERS.iter() {
         rd.add_demuxer(*demuxer);
     }
 }
index 30b0ccd8a295c10223960ce8b7264b0ac68e36da..549d14d58ec54168d53e9839e734b65fe75672c6 100644 (file)
@@ -123,8 +123,7 @@ impl RMAudioStream {
                 Deinterleaver::Generic |
                 Deinterleaver::Sipro    => {
                         let bsize = (info.frame_size as usize) * (info.factor as usize);
-                        buf = Vec::with_capacity(bsize);
-                        buf.resize(bsize, 0u8);
+                        buf = vec![0; bsize];
                     },
                 Deinterleaver::VBR      => {
                         buf = Vec::new();
@@ -134,7 +133,7 @@ impl RMAudioStream {
             deint = Deinterleaver::None;
             buf = Vec::new();
         }
-        RMAudioStream { deint: deint, iinfo: iinfo, buf: buf, sub_packet: 0 }
+        RMAudioStream { deint, iinfo, buf, sub_packet: 0 }
     }
     fn read_apackets(&mut self, queued_packets: &mut Vec<NAPacket>, src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe: bool, payload_size: usize) -> DemuxerResult<NAPacket> {
         let (tb_num, tb_den) = stream.get_timebase();
@@ -381,8 +380,7 @@ fn read_14or30(src: &mut ByteReader) -> DemuxerResult<(bool, u32)> {
 
 fn read_video_buf(src: &mut ByteReader, stream: NAStreamRef, ts: u32, keyframe: bool, frame_size: usize) -> DemuxerResult<NAPacket> {
     let size = (frame_size as usize) + 9;
-    let mut vec: Vec<u8> = Vec::with_capacity(size);
-    vec.resize(size, 0);
+    let mut vec: Vec<u8> = vec![0; size];
     //v[0] = 0; // 1 slice
     vec[4] = 1;
     src.read_buf(&mut vec[9..])?;
@@ -420,7 +418,7 @@ impl RMDemuxCommon {
         } else if ((tag2 == mktag!('V', 'I', 'D', 'O')) || (tag2 == mktag!('I', 'M', 'A', 'G'))) && ((tag as usize) <= edata.len()) {
             Self::parse_video_stream(strmgr, &mut str_data.streams, stream_no, &mut src, edata.as_slice(), tag2)?;
         } else if tag == mktag!(b"LSD:") {
-            let extradata = Some(edata.clone());
+            let extradata = Some(edata.to_owned());
 
             src.read_skip(4)?; //version
             let channels    = src.read_u16be()?;
@@ -809,10 +807,10 @@ fn parse_aformat3(src: &mut ByteReader) -> DemuxerResult<RealAudioInfo> {
     validate!(end - start <= (header_len as u64) + 2);
 
     Ok(RealAudioInfo {
-        fcc: fcc, flavor: flavor,
+        fcc, flavor,
         sample_rate: 8000, sample_size: 16, channels: 1, channel_mask: 0,
-        granularity: granularity, bytes_per_minute: bytes_per_minute,
-        total_bytes: total_bytes, edata_size: 0,
+        granularity, bytes_per_minute,
+        total_bytes, edata_size: 0,
         ileave_info: None,
     })
 }
@@ -862,11 +860,11 @@ fn parse_aformat4(src: &mut ByteReader) -> DemuxerResult<RealAudioInfo> {
         };
 
     Ok(RealAudioInfo {
-        fcc: fcc, flavor: flavor,
-        sample_rate: sample_rate, sample_size: sample_size as u16, channels: channels, channel_mask: 0,
-        granularity: granularity, bytes_per_minute: bytes_per_minute,
+        fcc, flavor,
+        sample_rate, sample_size: sample_size as u16, channels, channel_mask: 0,
+        granularity, bytes_per_minute,
         total_bytes: total_bytes & 0xFFFFFF, edata_size: 0,
-        ileave_info: ileave_info,
+        ileave_info,
     })
 }
 
@@ -912,7 +910,7 @@ unimplemented!("ra5 interleave pattern");
 
     let ileave_info = if is_interleaved != 0 {
             Some(InterleaveInfo {
-                    id: interleaver_id, factor: ileave_factor, block_size: ileave_block_size, frame_size: frame_size,
+                    id: interleaver_id, factor: ileave_factor, block_size: ileave_block_size, frame_size,
                 })
         } else {
             None
@@ -924,11 +922,11 @@ unimplemented!("ra5 interleave pattern");
     }
 
     Ok(RealAudioInfo {
-        fcc: fcc, flavor: flavor,
-        sample_rate: sample_rate, sample_size: sample_size as u16, channels: channels, channel_mask: 0,
-        granularity: granularity, bytes_per_minute: bytes_per_minute,
-        total_bytes: total_bytes & 0xFFFFFF, edata_size: edata_size,
-        ileave_info: ileave_info,
+        fcc, flavor,
+        sample_rate, sample_size: sample_size as u16, channels, channel_mask: 0,
+        granularity, bytes_per_minute,
+        total_bytes: total_bytes & 0xFFFFFF, edata_size,
+        ileave_info,
     })
 }
 
@@ -1067,8 +1065,7 @@ impl<'a> RealMediaDemuxer<'a> {
 //println!("mime = {}", mime);
         let edata_size      = self.src.read_u32be()? as usize;
         let edata: Option<Vec<u8>> = if edata_size == 0 { None } else {
-            let mut edvec: Vec<u8> = Vec::with_capacity(edata_size);
-            edvec.resize(edata_size, 0);
+            let mut edvec: Vec<u8> = vec![0; edata_size];
             self.src.read_buf(&mut edvec)?;
             Some(edvec)
         };
@@ -1146,8 +1143,7 @@ println!(" got ainfo {:?}", ainfo);
         let extradata = if ainfo.edata_size == 0 {
                 None
             } else {
-                let mut dta: Vec<u8> = Vec::with_capacity(ainfo.edata_size as usize);
-                dta.resize(ainfo.edata_size as usize, 0);
+                let mut dta: Vec<u8> = vec![0; ainfo.edata_size as usize];
                 self.src.read_buf(dta.as_mut_slice())?;
                 Some(dta)
             };
@@ -1220,8 +1216,7 @@ enum IVRRecord {
 impl IVRRecord {
     fn read_string(src: &mut ByteReader) -> DemuxerResult<Vec<u8>> {
         let len                     = src.read_u32be()? as usize;
-        let mut val = Vec::with_capacity(len);
-        val.resize(len, 0);
+        let mut val = vec![0; len];
         src.read_buf(val.as_mut_slice())?;
         Ok(val)
     }
@@ -1252,8 +1247,7 @@ impl IVRRecord {
             4 => {
                     let name = Self::read_string(src)?;
                     let len  = src.read_u32be()? as usize;
-                    let mut val = Vec::with_capacity(len);
-                    val.resize(len, 0);
+                    let mut val = vec![0; len];
                     src.read_buf(val.as_mut_slice())?;
                     Ok(IVRRecord::BinaryData(name, val))
                 },
@@ -1315,7 +1309,7 @@ impl RecordDemuxer {
         RecordDemuxer {
             start_pos:      pos,
             cur_pos:        pos,
-            start_str:      start_str,
+            start_str,
             remap_ids:      Vec::new(),
         }
     }
@@ -1405,7 +1399,7 @@ impl RecordDemuxer {
         loop {
             let rec = IVRRecord::read(src)?;
             match rec {
-                IVRRecord::Packet { ts, str, flags, len, checksum: _ } => {
+                IVRRecord::Packet { ts, str, flags, len, .. } => {
                         let payload_size = len;
                         let sr = self.remap_ids.iter().position(|x| *x == str);
                         validate!(sr.is_some());
index d7a15d0e109a5c1bda8a448fb620b62a6de72cee..412982e9925a94fea292390aff08643a3a2aab01 100644 (file)
@@ -1,4 +1,18 @@
 extern crate nihav_core;
 
+#[cfg(feature="decoders")]
+#[allow(clippy::cast_lossless)]
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::excessive_precision)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::unreadable_literal)]
+#[allow(clippy::useless_let_if_seq)]
 pub mod codecs;
+#[cfg(feature="demuxers")]
+#[allow(clippy::cast_lossless)]
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::unreadable_literal)]
+#[allow(clippy::useless_let_if_seq)]
 pub mod demuxers;
\ No newline at end of file