}
}
+pub type BlkInterpFunc = fn(&mut [u8], usize, &[u8], usize, usize, usize);
+
pub fn copy_blocks(dst: &mut NAVideoBuffer<u8>, src: &NAVideoBuffer<u8>,
dx: usize, dy: usize, sx: isize, sy: isize, bw: usize, bh: usize,
preborder: usize, postborder: usize,
- mode: usize, interp: &[fn(&mut [u8], usize, &[u8], usize, usize, usize)])
+ mode: usize, interp: &[BlkInterpFunc])
{
let pre = if mode != 0 { preborder as isize } else { 0 };
let post = if mode != 0 { postborder as isize } else { 0 };
}
}
-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)
}
}
-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 { }
#[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 }
}
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;
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);
}
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);
#[allow(clippy::many_single_char_names)]
pub mod code;
pub mod data;
+#[allow(clippy::needless_range_loop)]
pub mod decoder;
pub trait BlockDecoder {
}
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,
}
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)]
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;
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;
perm_tab.push(0); // size = 1
perm_tab.push(0); // size = 2
perm_tab.push(1);
- for blen in 2..bits+1 {
+ for blen in 2..=bits {
let ssize = 1 << blen;
for i in 0..ssize { perm_tab.push(swp_idx(i, blen)); }
}
tab.push((consts::PI / 8.0).sin()); // size = 1
tab.push((consts::PI / 8.0).cos());
if bits > 1 {
- for blen in 1..bits+1 {
+ for blen in 1..=bits {
let tsize = 1 << blen;
let base = consts::PI / ((tsize * 8) as f32);
for i in 0..tsize {
let mut val = inval;
for _ in 0..8 {
ret = (ret << 4) | (REV_TAB[(val & 0xF) as usize] as u32);
- val = val >> 4;
+ val >>= 4;
}
ret
}
let size = 1 << bits;
let mut table = Vec::with_capacity(size);
for _ in 0..4 { table.push(FFTC_ZERO); }
- for b in 3..(bits+1) {
+ for b in 3..=bits {
let qsize = (1 << (b - 2)) as usize;
let base = -consts::PI / ((qsize * 2) as f32);
for k in 0..qsize {
gen_sr_perms(&mut swaps[3*size/4..], size/4);
}
-fn gen_swaps_for_perm(swaps: &mut Vec<usize>, perms: &Vec<usize>) {
+fn gen_swaps_for_perm(swaps: &mut Vec<usize>, perms: &[usize]) {
let mut idx_arr: Vec<usize> = Vec::with_capacity(perms.len());
for i in 0..perms.len() { idx_arr.push(i); }
let mut run_size = 0;
for (mode, _) in ffts.iter().rev() {
mode.permute(&mut perms);
}
- gen_swaps_for_perm(&mut swaps, &perms);
+ gen_swaps_for_perm(&mut swaps, perms.as_slice());
FFT { perms, swaps, ffts }
}
fwd_fft: bool,
}
-fn crossadd(a: &FFTComplex, b: &FFTComplex) -> FFTComplex {
+fn crossadd(a: FFTComplex, b: FFTComplex) -> FFTComplex {
FFTComplex { re: a.re + b.re, im: a.im - b.im }
}
let in0 = buf[n + 1];
let in1 = buf[self.size - n - 1];
- let t0 = crossadd(&in0, &in1);
+ let t0 = crossadd(in0, in1);
let t1 = FFTComplex { re: in1.im + in0.im, im: in1.re - in0.re };
let tab = self.table[n];
let t2 = FFTComplex { re: t1.im * tab.im + t1.re * tab.re, im: t1.im * tab.re - t1.re * tab.im };
let in0 = buf[n + 1];
let in1 = buf[self.size - n - 1];
- let t0 = crossadd(&in0, &in1).scale(0.5);
+ let t0 = crossadd(in0, in1).scale(0.5);
let t1 = FFTComplex { re: in0.im + in1.im, im: in0.re - in1.re };
let t2 = t1 * self.table[n];
- buf[n + 1] = crossadd(&t0, &t2);
+ buf[n + 1] = crossadd(t0, t2);
buf[self.size - n - 1] = FFTComplex { re: t0.re - t2.re, im: -(t0.im + t2.im) };
}
let a = buf[0].re;
for n in 0..size { dst[n] = scale; }
},
WindowType::Sine => {
- let param;
- if half {
- param = consts::PI / ((2 * size) as f32);
- } else {
- param = consts::PI / (size as f32);
- }
+ let param = if half {
+ consts::PI / ((2 * size) as f32)
+ } else {
+ consts::PI / (size as f32)
+ };
for n in 0..size {
dst[n] = (((n as f32) + 0.5) * param).sin() * scale;
}
},
WindowType::KaiserBessel(alpha) => {
let dlen = if half { size as f32 } else { (size as f32) * 0.5 };
- let alpha2 = ((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen)) as f64;
+ let alpha2 = f64::from((alpha * consts::PI / dlen) * (alpha * consts::PI / dlen));
let mut kb: Vec<f64> = Vec::with_capacity(size);
let mut sum = 0.0;
fn bessel_i0(inval: f64) -> f64 {
let mut val: f64 = 1.0;
for n in (1..64).rev() {
- val *= inval / ((n * n) as f64);
+ val *= inval / f64::from(n * n);
val += 1.0;
}
val
#[cfg(feature="decoders")]
+#[allow(clippy::cast_lossless)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::too_many_arguments)]
#[allow(clippy::unreadable_literal)]
pub mod codecs;
#[cfg(feature="demuxers")]
pub mod demuxers;
+#[allow(clippy::too_many_arguments)]
pub mod formats;
pub mod frame;
+#[allow(clippy::too_many_arguments)]
pub mod io;
pub mod refs;
pub mod register;
pub mod scale;
#[cfg(feature="dsp")]
+#[allow(clippy::excessive_precision)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::needless_range_loop)]
#[allow(clippy::unreadable_literal)]
pub mod dsp;