diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2019-05-14 13:08:05 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2019-05-14 13:08:05 +0200 |
commit | e243ceb4d694cc08767ad70027bb6963f4cefea3 (patch) | |
tree | aff7ef58ee740515e89a7dbf66acf0456110b4a3 /nihav-core/src/codecs/h263 | |
parent | 250c49f64633580d3e294a7b871fad4618694209 (diff) | |
download | nihav-e243ceb4d694cc08767ad70027bb6963f4cefea3.tar.gz |
core: fix most clippy warnings
Diffstat (limited to 'nihav-core/src/codecs/h263')
-rw-r--r-- | nihav-core/src/codecs/h263/code.rs | 35 | ||||
-rw-r--r-- | nihav-core/src/codecs/h263/data.rs | 4 | ||||
-rw-r--r-- | nihav-core/src/codecs/h263/decoder.rs | 12 | ||||
-rw-r--r-- | nihav-core/src/codecs/h263/mod.rs | 33 |
4 files changed, 42 insertions, 42 deletions
diff --git a/nihav-core/src/codecs/h263/code.rs b/nihav-core/src/codecs/h263/code.rs index c18a9ea..fa02e4e 100644 --- a/nihav-core/src/codecs/h263/code.rs +++ b/nihav-core/src/codecs/h263/code.rs @@ -121,15 +121,16 @@ const W8: i32 = 181; const ROW_SHIFT: u8 = 8; const COL_SHIFT: u8 = 14; +#[allow(clippy::erasing_op)] fn idct_row(row: &mut [i16]) { - let in0 = ((row[0] as i32) << 11) + (1 << (ROW_SHIFT - 1)); - let in1 = (row[4] as i32) << 11; - let in2 = row[6] as i32; - let in3 = row[2] as i32; - let in4 = row[1] as i32; - let in5 = row[7] as i32; - let in6 = row[5] as i32; - let in7 = row[3] as i32; + let in0 = ((i32::from(row[0])) << 11) + (1 << (ROW_SHIFT - 1)); + let in1 = (i32::from(row[4])) << 11; + let in2 = i32::from(row[6]); + let in3 = i32::from(row[2]); + let in4 = i32::from(row[1]); + let in5 = i32::from(row[7]); + let in6 = i32::from(row[5]); + let in7 = i32::from(row[3]); let tmp = W7 * (in4 + in5); let a4 = tmp + (W1 - W7) * in4; @@ -167,15 +168,16 @@ fn idct_row(row: &mut [i16]) { row[4] = ((b5 - b6) >> ROW_SHIFT) as i16; } +#[allow(clippy::erasing_op)] fn idct_col(blk: &mut [i16; 64], off: usize) { - let in0 = ((blk[off + 0*8] as i32) << 8) + (1 << (COL_SHIFT - 1)); - let in1 = (blk[off + 4*8] as i32) << 8; - let in2 = blk[off + 6*8] as i32; - let in3 = blk[off + 2*8] as i32; - let in4 = blk[off + 1*8] as i32; - let in5 = blk[off + 7*8] as i32; - let in6 = blk[off + 5*8] as i32; - let in7 = blk[off + 3*8] as i32; + let in0 = ((i32::from(blk[off + 0*8])) << 8) + (1 << (COL_SHIFT - 1)); + let in1 = (i32::from(blk[off + 4*8])) << 8; + let in2 = i32::from(blk[off + 6*8]); + let in3 = i32::from(blk[off + 2*8]); + let in4 = i32::from(blk[off + 1*8]); + let in5 = i32::from(blk[off + 7*8]); + let in6 = i32::from(blk[off + 5*8]); + let in7 = i32::from(blk[off + 3*8]); let tmp = W7 * (in4 + in5); let a4 = (tmp + (W1 - W7) * in4) >> 3; @@ -345,6 +347,7 @@ impl H263BlockDSP { } } +#[allow(clippy::erasing_op)] fn deblock_hor(buf: &mut NAVideoBuffer<u8>, comp: usize, q: u8, off: usize) { let stride = buf.get_stride(comp); let dptr = buf.get_data_mut().unwrap(); diff --git a/nihav-core/src/codecs/h263/data.rs b/nihav-core/src/codecs/h263/data.rs index 029c5bb..36b22e1 100644 --- a/nihav-core/src/codecs/h263/data.rs +++ b/nihav-core/src/codecs/h263/data.rs @@ -114,7 +114,7 @@ pub const H263_CHROMA_QUANT: [u8; 32] = [ pub struct H263ShortCodeReader { tab: &'static [(u8, u8)] } impl H263ShortCodeReader { - pub fn new(tab: &'static [(u8, u8)]) -> Self { H263ShortCodeReader { tab: tab } } + pub fn new(tab: &'static [(u8, u8)]) -> Self { H263ShortCodeReader { tab } } } impl CodebookDescReader<u8> for H263ShortCodeReader { @@ -202,7 +202,7 @@ pub const H263_RL_CODES_AIC: &[H263RLCodeDesc] = rlcodes!( pub struct H263RLCodeReader { tab: &'static [H263RLCodeDesc] } impl H263RLCodeReader { - pub fn new(tab: &'static [H263RLCodeDesc]) -> Self { H263RLCodeReader { tab: tab } } + pub fn new(tab: &'static [H263RLCodeDesc]) -> Self { H263RLCodeReader { tab } } } impl CodebookDescReader<H263RLSym> for H263RLCodeReader { diff --git a/nihav-core/src/codecs/h263/decoder.rs b/nihav-core/src/codecs/h263/decoder.rs index a0e7ce4..502187d 100644 --- a/nihav-core/src/codecs/h263/decoder.rs +++ b/nihav-core/src/codecs/h263/decoder.rs @@ -162,8 +162,8 @@ impl H263BaseDecoder { last_ts: 0, next_ts: 0, tsdiff: 0, has_b: false, b_data: Vec::new(), pred_coeffs: Vec::new(), - is_gob: is_gob, slice_reset: slice_reset, - may_have_b_frames: may_have_b_frames, + is_gob, slice_reset, + may_have_b_frames, mv_data: Vec::new(), } } @@ -219,9 +219,7 @@ impl H263BaseDecoder { let fmt = formats::YUV420_FORMAT; let vinfo = NAVideoInfo::new(self.w, self.h, false, fmt); - let bufret = alloc_video_buffer(vinfo, 4); - if let Err(_) = bufret { return Err(DecoderError::InvalidData); } - let bufinfo = bufret.unwrap(); + let bufinfo = alloc_video_buffer(vinfo, 4)?; let mut buf = bufinfo.get_vbuf().unwrap(); let mut slice = if self.is_gob { @@ -531,9 +529,7 @@ impl H263BaseDecoder { let fmt = formats::YUV420_FORMAT; let vinfo = NAVideoInfo::new(self.w, self.h, false, fmt); - let bufret = alloc_video_buffer(vinfo, 4); - if let Err(_) = bufret { return Err(DecoderError::InvalidData); } - let bufinfo = bufret.unwrap(); + let bufinfo = alloc_video_buffer(vinfo, 4)?; let mut b_buf = bufinfo.get_vbuf().unwrap(); if let (Some(ref bck_buf), Some(ref fwd_buf)) = (self.ipbs.get_nextref(), self.ipbs.get_lastref()) { diff --git a/nihav-core/src/codecs/h263/mod.rs b/nihav-core/src/codecs/h263/mod.rs index 1cd10a2..76cd7a1 100644 --- a/nihav-core/src/codecs/h263/mod.rs +++ b/nihav-core/src/codecs/h263/mod.rs @@ -1,6 +1,7 @@ use super::{DecoderResult, MV, ZERO_MV}; use crate::frame::NAVideoBuffer; +#[allow(clippy::many_single_char_names)] pub mod code; pub mod data; pub mod decoder; @@ -46,7 +47,7 @@ pub struct PBInfo { impl PBInfo { pub fn new(trb: u8, dbquant: u8, improved: bool) -> Self { - PBInfo{ trb: trb, dbquant: dbquant, improved: improved } + PBInfo{ trb, dbquant, improved } } pub fn get_trb(&self) -> u8 { self.trb } pub fn get_dbquant(&self) -> u8 { self.dbquant } @@ -72,9 +73,9 @@ pub struct PicInfo { impl PicInfo { pub fn new(w: usize, h: usize, mode: Type, mvmode: MVMode, umv: bool, apm: bool, quant: u8, ts: u16, pb: Option<PBInfo>, plusinfo: Option<PlusInfo>) -> Self { PicInfo { - w: w, h: h, mode: mode, mvmode: mvmode, - umv: umv, apm: apm, quant: quant, - pb: pb, ts: ts, plusinfo: plusinfo + w, h, mode, mvmode, + umv, apm, quant, + pb, ts, plusinfo } } pub fn get_width(&self) -> usize { self.w } @@ -107,7 +108,7 @@ pub struct PlusInfo { impl PlusInfo { pub fn new(aic: bool, deblock: bool, aiv_mode: bool, mq_mode: bool) -> Self { - PlusInfo { aic: aic, deblock: deblock, aiv_mode: aiv_mode, mq_mode: mq_mode } + PlusInfo { aic, deblock, aiv_mode, mq_mode } } } @@ -137,10 +138,10 @@ const SLICE_NO_END: usize = 99999999; impl SliceInfo { pub fn new(mb_x: usize, mb_y: usize, mb_end: usize, quant: u8) -> Self { - SliceInfo{ mb_x: mb_x, mb_y: mb_y, mb_end: mb_end, quant: quant } + SliceInfo{ mb_x, mb_y, mb_end, quant } } pub fn new_gob(mb_x: usize, mb_y: usize, quant: u8) -> Self { - SliceInfo{ mb_x: mb_x, mb_y: mb_y, mb_end: SLICE_NO_END, quant: quant } + SliceInfo{ mb_x, mb_y, mb_end: SLICE_NO_END, quant } } pub fn get_default_slice(pinfo: &PicInfo) -> Self { SliceInfo{ mb_x: 0, mb_y: 0, mb_end: SLICE_NO_END, quant: pinfo.get_quant() } @@ -153,7 +154,7 @@ impl SliceInfo { impl SliceState { pub fn new(is_iframe: bool) -> Self { SliceState { - is_iframe: is_iframe, mb_x: 0, mb_y: 0, first_line: true, first_mb: true, + is_iframe, mb_x: 0, mb_y: 0, first_line: true, first_mb: true, slice_mb_x: 0, slice_mb_y: 0, quant: 0 } } @@ -227,9 +228,9 @@ impl BlockInfo { BlockInfo { intra: mode == Type::I, skip: (cbp == 0) && (mode != Type::I), - mode: mode, - cbp: cbp, - q: q, + mode, + cbp, + q, mv: [MV::new(0, 0), MV::new(0, 0), MV::new(0, 0), MV::new(0, 0)], num_mv: 0, bpart: false, @@ -279,10 +280,10 @@ impl BlockInfo { impl BBlockInfo { pub fn new(present: bool, cbp: u8, num_mv: usize, fwd: bool) -> Self { BBlockInfo { - present: present, - cbp: cbp, - num_mv: num_mv, - fwd: fwd, + present, + cbp, + num_mv, + fwd, } } pub fn get_num_mv(&self) -> usize { self.num_mv } @@ -337,7 +338,7 @@ impl H263MVTrait for MV { let bscale = (trb as i32) - (trd as i32); let x = if bvec.x != 0 { fwdvec.x - pvec.x } else if trd != 0 { (bscale * (pvec.x as i32) / (trd as i32)) as i16 } else { 0 }; let y = if bvec.y != 0 { fwdvec.y - pvec.y } else if trd != 0 { (bscale * (pvec.y as i32) / (trd as i32)) as i16 } else { 0 }; - MV { x: x, y: y } + MV { x, y } } } |