aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-core/src/codecs/h263
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2019-05-15 14:36:43 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2019-05-15 14:36:43 +0200
commitfdb4b2fbe87ca6e15f6d5e8ad040b7c9ee883053 (patch)
tree1e21d8a62c6f24b78c3b0dd13495a9ee25724136 /nihav-core/src/codecs/h263
parente07387c7f125550a41faf36a509b252cf71d7f9a (diff)
downloadnihav-fdb4b2fbe87ca6e15f6d5e8ad040b7c9ee883053.tar.gz
core: fix some clippy warnings
Diffstat (limited to 'nihav-core/src/codecs/h263')
-rw-r--r--nihav-core/src/codecs/h263/code.rs4
-rw-r--r--nihav-core/src/codecs/h263/data.rs8
-rw-r--r--nihav-core/src/codecs/h263/decoder.rs6
-rw-r--r--nihav-core/src/codecs/h263/mod.rs15
4 files changed, 17 insertions, 16 deletions
diff --git a/nihav-core/src/codecs/h263/code.rs b/nihav-core/src/codecs/h263/code.rs
index fa02e4e..1f101a2 100644
--- a/nihav-core/src/codecs/h263/code.rs
+++ b/nihav-core/src/codecs/h263/code.rs
@@ -270,7 +270,7 @@ fn h263_interp11(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw:
}
}
-pub const H263_INTERP_FUNCS: &[fn(&mut [u8], usize, &[u8], usize, usize, usize)] = &[
+pub const H263_INTERP_FUNCS: &[blockdsp::BlkInterpFunc] = &[
h263_interp00, h263_interp01, h263_interp10, h263_interp11 ];
fn h263_interp00_avg(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize, bw: usize, bh: usize)
@@ -336,7 +336,7 @@ fn h263_interp11_avg(dst: &mut [u8], dstride: usize, src: &[u8], sstride: usize,
}
}
-pub const H263_INTERP_AVG_FUNCS: &[fn(&mut [u8], usize, &[u8], usize, usize, usize)] = &[
+pub const H263_INTERP_AVG_FUNCS: &[blockdsp::BlkInterpFunc] = &[
h263_interp00_avg, h263_interp01_avg, h263_interp10_avg, h263_interp11_avg ];
pub struct H263BlockDSP { }
diff --git a/nihav-core/src/codecs/h263/data.rs b/nihav-core/src/codecs/h263/data.rs
index 36b22e1..4f6a705 100644
--- a/nihav-core/src/codecs/h263/data.rs
+++ b/nihav-core/src/codecs/h263/data.rs
@@ -127,10 +127,10 @@ impl CodebookDescReader<u8> for H263ShortCodeReader {
#[derive(Clone,Copy)]
pub struct H263RLSym { run: u8, level: i8 }
impl H263RLSym {
- pub fn get_run(&self) -> u8 { self.run }
- pub fn is_last(&self) -> bool { self.level < 0 }
- pub fn is_escape(&self) -> bool { (self.run == 0) && (self.level == 0) }
- pub fn get_level(&self) -> i16 { if self.level < 0 { -self.level as i16 } else { self.level as i16 } }
+ pub fn get_run(self) -> u8 { self.run }
+ pub fn is_last(self) -> bool { self.level < 0 }
+ pub fn is_escape(self) -> bool { (self.run == 0) && (self.level == 0) }
+ pub fn get_level(self) -> i16 { if self.level < 0 { -self.level as i16 } else { self.level as i16 } }
}
pub struct H263RLCodeDesc { code: u8, bits: u8, sym: H263RLSym }
diff --git a/nihav-core/src/codecs/h263/decoder.rs b/nihav-core/src/codecs/h263/decoder.rs
index 502187d..2a841ba 100644
--- a/nihav-core/src/codecs/h263/decoder.rs
+++ b/nihav-core/src/codecs/h263/decoder.rs
@@ -522,7 +522,7 @@ impl H263BaseDecoder {
}
pub fn get_bframe(&mut self, bdsp: &BlockDSP) -> DecoderResult<NABufferType> {
- if !self.has_b || !self.ipbs.get_lastref().is_some() || !self.ipbs.get_nextref().is_some() {
+ if !self.has_b || self.ipbs.get_lastref().is_none() || self.ipbs.get_nextref().is_none() {
return Err(DecoderError::MissingReference);
}
self.has_b = false;
@@ -533,7 +533,7 @@ impl H263BaseDecoder {
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()) {
- recon_b_frame(&mut b_buf, fwd_buf, bck_buf, self.mb_w, self.mb_h, &self.b_data, bdsp);
+ recon_b_frame(&mut b_buf, fwd_buf, bck_buf, self.mb_w, self.mb_h, self.b_data.as_slice(), bdsp);
}
self.b_data.truncate(0);
@@ -542,7 +542,7 @@ impl H263BaseDecoder {
}
fn recon_b_frame(b_buf: &mut NAVideoBuffer<u8>, bck_buf: &NAVideoBuffer<u8>, fwd_buf: &NAVideoBuffer<u8>,
- mb_w: usize, mb_h: usize, b_data: &Vec<BMB>, bdsp: &BlockDSP) {
+ mb_w: usize, mb_h: usize, b_data: &[BMB], bdsp: &BlockDSP) {
let mut cbpi = CBPInfo::new();
let mut cur_mb = 0;
cbpi.reset(mb_w);
diff --git a/nihav-core/src/codecs/h263/mod.rs b/nihav-core/src/codecs/h263/mod.rs
index 76cd7a1..6f3d548 100644
--- a/nihav-core/src/codecs/h263/mod.rs
+++ b/nihav-core/src/codecs/h263/mod.rs
@@ -4,6 +4,7 @@ use crate::frame::NAVideoBuffer;
#[allow(clippy::many_single_char_names)]
pub mod code;
pub mod data;
+#[allow(clippy::needless_range_loop)]
pub mod decoder;
pub trait BlockDecoder {
@@ -29,8 +30,8 @@ pub enum Type {
}
impl Type {
- pub fn is_ref(&self) -> bool {
- match *self {
+ pub fn is_ref(self) -> bool {
+ match self {
Type::I | Type::P | Type::PB => true,
_ => false,
}
@@ -49,9 +50,9 @@ impl PBInfo {
pub fn new(trb: u8, dbquant: u8, improved: bool) -> Self {
PBInfo{ trb, dbquant, improved }
}
- pub fn get_trb(&self) -> u8 { self.trb }
- pub fn get_dbquant(&self) -> u8 { self.dbquant }
- pub fn is_improved(&self) -> bool { self.improved }
+ pub fn get_trb(self) -> u8 { self.trb }
+ pub fn get_dbquant(self) -> u8 { self.dbquant }
+ pub fn is_improved(self) -> bool { self.improved }
}
#[allow(dead_code)]
@@ -253,7 +254,7 @@ impl BlockInfo {
pub fn get_num_mvs2(&self) -> usize { self.num_mv2 }
pub fn get_mv2(&self, idx: usize) -> MV { self.mv2[idx] }
pub fn set_mv(&mut self, mvs: &[MV]) {
- if mvs.len() > 0 { self.skip = false; }
+ if !mvs.is_empty() { self.skip = false; }
let mut mv_arr: [MV; 4] = [MV::new(0, 0), MV::new(0, 0), MV::new(0, 0), MV::new(0, 0)];
for i in 0..mvs.len() { mv_arr[i] = mvs[i]; }
self.mv = mv_arr;
@@ -266,7 +267,7 @@ impl BlockInfo {
self.num_mv2 = bbinfo.get_num_mv();
}
pub fn set_b_mv(&mut self, mvs: &[MV]) {
- if mvs.len() > 0 { self.skip = false; }
+ if !mvs.is_empty() { self.skip = false; }
let mut mv_arr: [MV; 2] = [ZERO_MV, ZERO_MV];
for i in 0..mvs.len() { mv_arr[i] = mvs[i]; }
self.mv2 = mv_arr;