let mut tmp: [f32; BANDS] = [BITALLOC_LIMIT; BANDS];
for band in 0..BANDS {
if self.band_bits[band] != 6 {
- tmp[band] = (self.band_bits[band] as f32) * -2.0 + ch_data.bit_est[band] - 0.415;
+ tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415;
}
}
let mut peak = 0.0;
let mut tmp: [f32; BANDS] = [BITALLOC_TOP_LIMIT; BANDS];
for band in start..BANDS {
if self.band_bits[band] != 0 {
- tmp[band] = (self.band_bits[band] as f32) * -2.0 + ch_data.bit_est[band] - 0.415 + 2.0;
+ tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415 + 2.0;
}
}
while free_bits < cur_bits {
let mut tmp: [f32; BANDS] = [BITALLOC_LIMIT; BANDS];
for band in 0..BANDS {
if self.band_bits[band] != 6 {
- tmp[band] = (self.band_bits[band] as f32) * -2.0 + ch_data.bit_est[band] - 0.415;
+ tmp[band] = f32::from(self.band_bits[band]) * -2.0 + ch_data.bit_est[band] - 0.415;
}
}
let mut used_bits: i32 = 0;
sqrt_tab[i] = (i as f32).sqrt();
}
- LUTs { exp_lev: exp_lev, exp_10: exp_10, sqrt_tab: sqrt_tab }
+ LUTs { exp_lev, exp_10, sqrt_tab }
}
}
}
}
IMCDecoder {
- is_imc: is_imc,
+ is_imc,
chmap: NAChannelMap::new(),
ainfo: NAAudioInfo::new(0, 0, SND_F32P_FORMAT, 0),
info: NACodecInfo::new_dummy(),
- codes: codes,
+ codes,
ch_data: [IMCChannel::new(), IMCChannel::new()],
ba: BitAlloc::new(),
imdct: IMDCTContext::new(),
luts: LUTs::new(),
- cycle1: cycle1,
- cycle2: cycle2,
- weights1: weights1,
- weights2: weights2,
+ cycle1,
+ cycle2,
+ weights1,
+ weights2,
}
}
let maxc_pos = br.read(5)? as usize;
let max_coef = br.read(7)? as u8;
- let (c1, c2) = calc_maxcoef(max_coef as f32);
+ let (c1, c2) = calc_maxcoef(f32::from(max_coef));
for i in 0..BANDS {
if i != maxc_pos {
let level = br.read(4)?;
ch_data.mask_wght[band] = 0.0;
let val;
if self.ba.band_width[band] > 0 {
- val = (ch_data.new_floor[band] as f64).powi(2);
+ val = f64::from(ch_data.new_floor[band]).powi(2);
ch_data.log_floor2[band] = 2.0 * ch_data.log_floor[band];
} else {
val = 0.0;
}
if reset {
let ch_data = &mut self.ch_data[ch];
- let (mut c1, mut c2) = calc_maxcoef(level[0] as f32);
+ let (mut c1, mut c2) = calc_maxcoef(f32::from(level[0]));
ch_data.new_floor[0] = c1;
ch_data.log_floor[0] = c2;
for i in 1..BANDS {
lval = level[i] - 16;
}
c1 *= self.luts.exp_10[(lval + 16) as usize];
- c2 += 0.83048 * (lval as f32);
+ c2 += 0.83048 * f32::from(lval);
ch_data.new_floor[i] = c1;
ch_data.log_floor[i] = c2;
}
if level[i] < 16 {
let lval = level[i] - 7;
ch_data.new_floor[i] = self.luts.exp_10[(lval + 16) as usize] * ch_data.old_floor[i];
- ch_data.log_floor[i] += (lval as f32) * 0.83048;
+ ch_data.log_floor[i] += f32::from(lval) * 0.83048;
} else {
ch_data.new_floor[i] = ch_data.old_floor[i];
}
if !self.ba.band_present[band] { continue; }
for i in IMC_BANDS[band]..IMC_BANDS[band + 1] {
if self.ba.skip_flag[i] {
- bits_freed += self.ba.cw_len[i] as i32;
+ bits_freed += i32::from(self.ba.cw_len[i]);
self.ba.cw_len[i] = 0;
}
}
- bits_freed -= self.ba.skip_flag_bits[band] as i32;
+ bits_freed -= i32::from(self.ba.skip_flag_bits[band]);
}
if bits_freed < 0 { return Err(DecoderError::Bug); }
posttwiddle[i] = FFTComplex::exp(consts::PI / 256.0 * n).scale(1.0/32768.0);
}
IMDCTContext {
- pretwiddle1: pretwiddle1,
- pretwiddle2: pretwiddle2,
- posttwiddle: posttwiddle,
+ pretwiddle1,
+ pretwiddle2,
+ posttwiddle,
tmp: [FFTC_ZERO; COEFFS/2],
fft: FFTBuilder::new_fft(COEFFS/2, false),
- window: window,
+ window,
}
}
fn imdct(&mut self, coeffs: &[f32; COEFFS], dst: &mut [f32], last_im: &mut [f32; COEFFS/2]) {
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
ainfo.get_channels(),
SND_F32P_FORMAT, 0);
- self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo.clone()));
+ self.info = info.replace_info(NACodecTypeInfo::Audio(self.ainfo));
if !self.is_imc {
self.generate_iac_tables(ainfo.get_sample_rate() as f32);
struct IMCCodeReader { sel1: usize, sel2: usize }
impl IMCCodeReader {
- fn new(sel1: usize, sel2: usize) -> Self { IMCCodeReader { sel1: sel1, sel2: sel2 } }
+ fn new(sel1: usize, sel2: usize) -> Self { IMCCodeReader { sel1, sel2 } }
}
impl CodebookDescReader<u8> for IMCCodeReader {
fn bits(&mut self, idx: usize) -> u8 { IMC_CODE_LENGTHS[self.sel1][self.sel2][idx] }
- fn code(&mut self, idx: usize) -> u32 { IMC_CODE_CODES[self.sel1][self.sel2][idx] as u32 }
+ fn code(&mut self, idx: usize) -> u32 { u32::from(IMC_CODE_CODES[self.sel1][self.sel2][idx]) }
fn sym (&mut self, idx: usize) -> u8 { idx as u8 }
fn len(&mut self) -> usize { IMC_CODE_LENGTHS[0][0].len() }
}
impl CodebookDescReader<u8> for IR2CodeReader {
fn bits(&mut self, idx: usize) -> u8 { INDEO2_CODE_LENGTHS[idx] }
- fn code(&mut self, idx: usize) -> u32 { INDEO2_CODE_CODES[idx] as u32 }
+ fn code(&mut self, idx: usize) -> u32 { u32::from(INDEO2_CODE_CODES[idx]) }
fn sym (&mut self, idx: usize) -> u8 {
if idx < 0x7F { (idx + 1) as u8 } else { (idx + 2) as u8 }
}
let dummy_info = NACodecInfo::new_dummy();
let mut coderead = IR2CodeReader{};
let cb = Codebook::new(&mut coderead, CodebookMode::LSB).unwrap();
- Indeo2Decoder { info: dummy_info, cb: cb, frmmgr: HAMShuffler::new() }
+ Indeo2Decoder { info: dummy_info, cb, frmmgr: HAMShuffler::new() }
}
fn decode_plane_intra(&self, br: &mut BitReader,
let stride = buf.get_stride(planeno);
let cb = &self.cb;
- let data = buf.get_data_mut().unwrap();
+ let data = buf.get_data_mut().unwrap();
let framebuf: &mut [u8] = data.as_mut_slice();
let table = &INDEO2_DELTA_TABLE[tableno];
}
x += run;
} else {
- let delta0 = (table[idx * 2 + 0] as i16) - 0x80;
- let delta1 = (table[idx * 2 + 1] as i16) - 0x80;
- let mut pix0 = framebuf[base + x + 0 - stride] as i16;
- let mut pix1 = framebuf[base + x + 1 - stride] as i16;
+ let delta0 = i16::from(table[idx * 2 + 0]) - 0x80;
+ let delta1 = i16::from(table[idx * 2 + 1]) - 0x80;
+ let mut pix0 = i16::from(framebuf[base + x + 0 - stride]);
+ let mut pix1 = i16::from(framebuf[base + x + 1 - stride]);
pix0 += delta0;
pix1 += delta1;
if pix0 < 0 { pix0 = 0; }
if x + run > w { return Err(DecoderError::InvalidData); }
x += run;
} else {
- let delta0 = (table[idx * 2 + 0] as i16) - 0x80;
- let delta1 = (table[idx * 2 + 1] as i16) - 0x80;
- let mut pix0 = framebuf[base + x + 0] as i16;
- let mut pix1 = framebuf[base + x + 1] as i16;
- pix0 += delta0 * 3 >> 2;
- pix1 += delta1 * 3 >> 2;
+ let delta0 = i16::from(table[idx * 2 + 0]) - 0x80;
+ let delta1 = i16::from(table[idx * 2 + 1]) - 0x80;
+ let mut pix0 = i16::from(framebuf[base + x + 0]);
+ let mut pix1 = i16::from(framebuf[base + x + 1]);
+ pix0 += (delta0 * 3) >> 2;
+ pix1 += (delta1 * 3) >> 2;
if pix0 < 0 { pix0 = 0; }
if pix1 < 0 { pix1 = 0; }
if pix0 > 255 { pix0 = 255; }
let chroma_tab = (tabs >> 2) & 3;
if interframe != 0 {
let vinfo = self.info.get_properties().get_video_info().unwrap();
- let bufret = alloc_video_buffer(vinfo, 2);
- if let Err(_) = bufret { return Err(DecoderError::InvalidData); }
- let bufinfo = bufret.unwrap();
+ let bufinfo = alloc_video_buffer(vinfo, 2)?;
let mut buf = bufinfo.get_vbuf().unwrap();
for plane in 0..3 {
let tabidx = (if plane == 0 { luma_tab } else { chroma_tab }) as usize;
Ok(frm.into_ref())
} else {
let bufret = self.frmmgr.clone_ref();
- if let None = bufret { return Err(DecoderError::MissingReference); }
+ if bufret.is_none() { return Err(DecoderError::MissingReference); }
let mut buf = bufret.unwrap();
for plane in 0..3 {
impl IV3Cell {
fn new(w: u16, h: u16) -> Self {
- IV3Cell { x: 0, y: 0, w: w, h: h, d: 20, vqt: false, mv: None }
+ IV3Cell { x: 0, y: 0, w, h, d: 20, vqt: false, mv: None }
}
fn split_h(&self) -> (Self, Self) {
let h1 = if self.h > 2 { ((self.h + 2) >> 2) << 1 } else { 1 };
cell2.d -= 1;
(cell1, cell2)
}
- fn no_mv(&self) -> bool { match self.mv { None => true, Some(_) => false } }
+ fn no_mv(&self) -> bool { self.mv.is_none() }
}
struct CellDecParams {
sidx = 0;
} else {
let mv = cell.mv.unwrap();
- let mx = mv.x as i16;
- let my = mv.y as i16;
+ let mx = i16::from(mv.x);
+ let my = i16::from(mv.y);
let l = (cell.x as i16) * 4 + mx;
let t = (cell.y as i16) * 4 + my;
let r = ((cell.x + cell.w) as i16) * 4 + mx;
tocopy = 4 - line;
}
if c >= 0xFD {
- let nl = 257 - (c as i16) - (line as i16);
+ let nl = 257 - i16::from(c) - (line as i16);
validate!(nl > 0);
tocopy = nl as usize;
}
fn copy_cell(&mut self, cell: IV3Cell, off: usize, stride: usize) -> DecoderResult<()> {
if cell.no_mv() { return Err(DecoderError::InvalidData); }
let mv = cell.mv.unwrap();
- let mx = mv.x as i16;
- let my = mv.y as i16;
+ let mx = i16::from(mv.x);
+ let my = i16::from(mv.y);
let l = (cell.x as i16) * 4 + mx;
let t = (cell.y as i16) * 4 + my;
let r = ((cell.x + cell.w) as i16) * 4 + mx;
for _ in 0..nvec {
let x = br.read_byte()? as i8;
let y = br.read_byte()? as i8;
- self.mvs.push(MV{ x: x, y: y });
+ self.mvs.push(MV{ x, y });
}
let shift = if planeno == 0 { 2 } else { 4 };
for _ in 0..nvec {
let y = br.read_byte()? as i8;
let x = br.read_byte()? as i8;
- self.mvs.push(MV{ x: x, y: y });
+ self.mvs.push(MV{ x, y });
}
let shift = if planeno == 0 { 2 } else { 4 };
if (frameno ^ hdr_2 ^ size ^ FRMH_TAG) != check {
return Err(DecoderError::InvalidData);
}
- if (size as i64) > br.left() { return Err(DecoderError::InvalidData); }
+ if i64::from(size) > br.left() { return Err(DecoderError::InvalidData); }
let ver = br.read_u16le()?;
if ver != 32 { return Err(DecoderError::NotImplemented); }
let flags = br.read_u16le()?;
let vinfo = self.info.get_properties().get_video_info().unwrap();
validate!((vinfo.get_width() & !3) == (self.width & !3).into());
validate!((vinfo.get_height() & !3) == (self.height & !3).into());
- 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 ystart = data_start + (yoff as u64);
- let ustart = data_start + (uoff as u64);
- let vstart = data_start + (voff as u64);
- let yendpos = data_start + (yend as u64);
- let uendpos = data_start + (uend as u64);
- let vendpos = data_start + (vend as u64);
+ let ystart = data_start + u64::from(yoff);
+ let ustart = data_start + u64::from(uoff);
+ let vstart = data_start + u64::from(voff);
+ let yendpos = data_start + u64::from(yend);
+ let uendpos = data_start + u64::from(uend);
+ let vendpos = data_start + u64::from(vend);
if intraframe {
self.decode_plane_intra(&mut br, 0, ystart, yendpos)?;
self.decode_plane_intra(&mut br, 1, ustart, uendpos)?;
let hh = (h / 2) as isize;
let mut band0 = src.as_ptr();
let mut band1 = band0.offset(hw);
- let mut band2 = band0.offset(((h / 2) * sstride) as isize);
+ let mut band2 = band0.add((h / 2) * sstride);
let mut band3 = band2.offset(hw);
let mut dst0 = dst.as_mut_ptr();
- let mut dst1 = dst0.offset(dstride as isize);
+ let mut dst1 = dst0.add(dstride);
for _ in 0..hh {
let mut b0_ptr = band0;
let mut b1_ptr = band1;
let mut d0_ptr = dst0;
let mut d1_ptr = dst1;
for _ in 0..hw {
- let p0 = *b0_ptr as i32;
- let p1 = *b1_ptr as i32;
- let p2 = *b2_ptr as i32;
- let p3 = *b3_ptr as i32;
+ let p0 = i32::from(*b0_ptr);
+ let p1 = i32::from(*b1_ptr);
+ let p2 = i32::from(*b2_ptr);
+ let p3 = i32::from(*b3_ptr);
let s0 = p0.wrapping_add(p2);
let s1 = p1.wrapping_add(p3);
let d0 = p0.wrapping_sub(p2);
d0_ptr = d0_ptr.offset(2);
d1_ptr = d1_ptr.offset(2);
}
- band0 = band0.offset(sstride as isize);
- band1 = band1.offset(sstride as isize);
- band2 = band2.offset(sstride as isize);
- band3 = band3.offset(sstride as isize);
- dst0 = dst0.offset((dstride * 2) as isize);
- dst1 = dst1.offset((dstride * 2) as isize);
+ band0 = band0.add(sstride);
+ band1 = band1.add(sstride);
+ band2 = band2.add(sstride);
+ band3 = band3.add(sstride);
+ dst0 = dst0.add(dstride * 2);
+ dst1 = dst1.add(dstride * 2);
}
}
}
fn new(src: &'a [u8], tables: &'a Tables) -> Self {
Intel263BR {
br: BitReader::new(src, src.len(), BitReaderMode::BE),
- tables: tables,
+ tables,
gob_no: 0,
mb_w: 0,
is_pb: false,
if !coded { return Ok(()); }
let rl_cb = &self.tables.rl_cb; // could be aic too
- let q_add = if quant == 0 { 0i16 } else { ((quant - 1) | 1) as i16 };
- let q = (quant * 2) as i16;
+ let q_add = if quant == 0 { 0i16 } else { i16::from((quant - 1) | 1) };
+ let q = i16::from(quant * 2);
while idx < 64 {
let code = br.read_cb(rl_cb)?;
let run;
}
fn decode_mv_component(br: &mut BitReader, mv_cb: &Codebook<u8>) -> DecoderResult<i16> {
- let code = br.read_cb(mv_cb)? as i16;
+ let code = i16::from(br.read_cb(mv_cb)?);
if code == 0 { return Ok(0) }
if !br.read_bool()? {
Ok(code)
let dquant = (cbpc & 4) != 0;
if dquant {
let idx = br.read(2)? as usize;
- q = ((q as i16) + (H263_DQUANT_TAB[idx] as i16)) as u8;
+ q = (i16::from(q) + i16::from(H263_DQUANT_TAB[idx])) as u8;
}
Ok(BlockInfo::new(Type::I, cbp, q))
},
let cbp = (cbpy << 2) | (cbpc & 3);
if dquant {
let idx = br.read(2)? as usize;
- q = ((q as i16) + (H263_DQUANT_TAB[idx] as i16)) as u8;
+ q = (i16::from(q) + i16::from(H263_DQUANT_TAB[idx])) as u8;
}
let mut binfo = BlockInfo::new(Type::I, cbp, q);
binfo.set_bpart(bbinfo);
let cbp = (cbpy << 2) | (cbpc & 3);
if dquant {
let idx = br.read(2)? as usize;
- q = ((q as i16) + (H263_DQUANT_TAB[idx] as i16)) as u8;
+ q = (i16::from(q) + i16::from(H263_DQUANT_TAB[idx])) as u8;
}
let mut binfo = BlockInfo::new(Type::P, cbp, q);
binfo.set_bpart(bbinfo);
let mut coderead = H263ShortCodeReader::new(H263_MV);
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,
- cbpy_cb: cbpy_cb,
- rl_cb: rl_cb,
- aic_rl_cb: aic_rl_cb,
- mv_cb: mv_cb,
+ intra_mcbpc_cb,
+ inter_mcbpc_cb,
+ cbpy_cb,
+ rl_cb,
+ aic_rl_cb,
+ mv_cb,
};
Intel263Decoder{
info: NACodecInfo::new_dummy(),
dec: H263BaseDecoder::new(true),
- tables: tables,
+ tables,
bdsp: H263BlockDSP::new(),
}
}
impl PictureHeader {
pub fn new(ftype: IVIFrameType, width: usize, height: usize, slice_w: usize, slice_h: usize, transparent: bool, luma_bands: usize, chroma_bands: usize, in_q: bool) -> Self {
PictureHeader {
- ftype: ftype,
- width: width, height: height, slice_w: slice_w, slice_h: slice_h,
- transparent: transparent,
- luma_bands: luma_bands, chroma_bands: chroma_bands,
- in_q: in_q,
+ ftype,
+ width, height, slice_w, slice_h,
+ transparent,
+ luma_bands, chroma_bands,
+ in_q,
}
}
pub fn new_null(ftype: IVIFrameType) -> Self {
PictureHeader {
- ftype: ftype,
+ ftype,
width: 0, height: 0, slice_w: 0, slice_h: 0,
transparent: false,
luma_bands: 0, chroma_bands: 0,
pub type TrFuncDC = fn (&mut [i32; 64], i32);
impl IVITransformType {
- pub fn is_8x8(&self) -> bool {
- match *self {
+ pub fn is_8x8(self) -> bool {
+ match self {
IVITransformType::Haar (ref sz, _) => { *sz == TSize::T8x8 },
IVITransformType::Slant(ref sz, _) => { *sz == TSize::T8x8 },
IVITransformType::DCT (ref sz, _) => { *sz == TSize::T8x8 },
IVITransformType::None (ref sz) => { *sz == TSize::T8x8 },
}
}
- pub fn is_2d(&self) -> bool {
- match *self {
+ pub fn is_2d(self) -> bool {
+ match self {
IVITransformType::Haar (_, ref dir) => { *dir == TDir::TwoD },
IVITransformType::Slant(_, ref dir) => { *dir == TDir::TwoD },
IVITransformType::DCT (_, ref dir) => { *dir == TDir::TwoD },
impl TxParams4x4 {
pub fn new(quant_intra: &'static [u16; 16], quant_inter: &'static [u16; 16], scan: &'static [usize; 16]) -> Self {
TxParams4x4 {
- quant_intra: quant_intra, quant_inter: quant_inter, scan: scan,
+ quant_intra, quant_inter, scan,
}
}
}
impl TxParams8x8 {
pub fn new(quant_intra: &'static [u16; 64], quant_inter: &'static [u16; 64], scan: &'static [usize; 64]) -> Self {
TxParams8x8 {
- quant_intra: quant_intra, quant_inter: quant_inter, scan: scan,
+ quant_intra, quant_inter, scan,
}
}
}
for i in 0..num_corr {
let pos1 = corr_map[i * 2 + 0] as usize;
let pos2 = corr_map[i * 2 + 1] as usize;
- let t = rvmap.runtab[pos1];
- rvmap.runtab[pos1] = rvmap.runtab[pos2];
- rvmap.runtab[pos2] = t;
- let t = rvmap.valtab[pos1];
- rvmap.valtab[pos1] = rvmap.valtab[pos2];
- rvmap.valtab[pos2] = t;
+ rvmap.runtab.swap(pos1, pos2);
+ rvmap.valtab.swap(pos1, pos2);
}
BandHeader {
- plane_no: plane_no, band_no: band_no,
- empty: false, halfpel: halfpel,
- inherit_mv: inherit_mv,
- has_qdelta: has_qdelta, inherit_qd: inherit_qd, quant: quant,
- mb_size: mb_size, blk_size: blk_size,
- rvmap: rvmap, blk_cb: blk_cb,
- tr: tr, ttype: ttype,
+ plane_no, band_no,
+ empty: false, halfpel,
+ inherit_mv,
+ has_qdelta, inherit_qd, quant,
+ mb_size, blk_size,
+ rvmap, blk_cb,
+ tr, ttype,
}
}
pub fn new_empty(plane_no: usize, band_no: usize) -> Self {
BandHeader {
- plane_no: plane_no, band_no: band_no,
+ plane_no, band_no,
empty: true, halfpel: true,
inherit_mv: false, has_qdelta: false, inherit_qd: false, quant: 0,
mb_size: 0, blk_size: 0,
impl IVITile {
pub fn new(pos_x: usize, pos_y: usize, w: usize, h: usize) -> Self {
IVITile {
- pos_x: pos_x, pos_y: pos_y, w: w, h: h,
+ pos_x, pos_y, w, h,
mb_w: 0, mb_h: 0, mb: Vec::new(),
}
}
use super::ividsp::*;
pub fn scale_mv(val: i32, scale: u8) -> i32 {
- (val + (if val > 0 { 1 } else { 0 }) + (scale as i32) - 1) >> scale
+ (val + (if val > 0 { 1 } else { 0 }) + i32::from(scale) - 1) >> scale
}
#[derive(Clone,Copy)]
Ok(base + add)
} else {
let nbits = cb.bits[0];
- return Ok(IVI_REVS[nbits as usize][self.read(nbits)? as usize]);
+ Ok(IVI_REVS[nbits as usize][self.read(nbits)? as usize])
}
}
#[inline(always)]
];
#[allow(unused_variables)]
+#[allow(clippy::many_single_char_names)]
fn read_trans_band_header(br: &mut BitReader, w: usize, h: usize, dst: &mut [i16], dstride: usize) -> DecoderResult<()> {
let color_plane = br.read(2)?;
let bit_depth = br.read(3)?;
validate!((idx >= 0) && (idx < 64));
let spos = tables.scan[idx as usize];
- let q = ((quant_mat[spos] as u32) * (quant as u32)) >> 9;
+ let q = (u32::from(quant_mat[spos]) * u32::from(quant)) >> 9;
if q > 1 {
let qq = q as i32;
let bias = (((q ^ 1) - 1) >> 1) as i32;
validate!((idx >= 0) && (idx < 16));
let spos = tables.scan[idx as usize];
- let q = ((quant_mat[spos] as u32) * (quant as u32)) >> 9;
+ let q = (u32::from(quant_mat[spos]) * u32::from(quant)) >> 9;
if q > 1 {
let qq = q as i32;
let bias = (((q ^ 1) - 1) >> 1) as i32;
fn put_block(frame: &mut [i16], offs: usize, stride: usize, blk: &[i32], blk_size: usize) {
unsafe {
- let mut dptr = frame.as_mut_ptr().offset(offs as isize);
+ let mut dptr = frame.as_mut_ptr().add(offs);
for y in 0..blk_size {
for x in 0..blk_size {
- *dptr.offset(x as isize) = blk[x + y * blk_size] as i16;
+ *dptr.add(x) = blk[x + y * blk_size] as i16;
}
- dptr = dptr.offset(stride as isize);
+ dptr = dptr.add(stride);
}
}
}
fn add_block(frame: &mut [i16], offs: usize, stride: usize, blk: &[i32], blk_size: usize) {
unsafe {
- let mut dptr = frame.as_mut_ptr().offset(offs as isize);
+ let mut dptr = frame.as_mut_ptr().add(offs);
for y in 0..blk_size {
for x in 0..blk_size {
- *dptr.offset(x as isize) = (*dptr.offset(x as isize)).wrapping_add(blk[x + y * blk_size] as i16);
+ *dptr.add(x) = (*dptr.add(x)).wrapping_add(blk[x + y * blk_size] as i16);
}
- dptr = dptr.offset(stride as isize);
+ dptr = dptr.add(stride);
}
}
}
}
}
+#[allow(clippy::many_single_char_names)]
fn do_mc(dst: &mut [i16], dstride: usize, src: &[i16], sstride: usize, x: usize, y: usize, l: usize, r: usize, t: usize, b: usize, mv_x: i32, mv_y: i32, is_hpel: bool, blk_size: usize) {
let (xoff, yoff, mv_mode) = if is_hpel {
(mv_x >> 1, mv_y >> 1, ((mv_x & 1) + (mv_y & 1) * 2) as u8)
}
}
+#[allow(clippy::many_single_char_names)]
fn do_mc_b(dst: &mut [i16], dstride: usize, src1: &[i16], sstride1: usize, src2: &[i16], sstride2: usize, x: usize, y: usize, l: usize, r: usize, t: usize, b: usize, mv_x: i32, mv_y: i32, mv2_x: i32, mv2_y: i32, is_hpel: bool, blk_size: usize) {
let (xoff1, yoff1, mv_mode1) = if is_hpel {
(mv_x >> 1, mv_y >> 1, ((mv_x & 1) + (mv_y & 1) * 2) as u8)
vinfoa: NAVideoInfo::new(0, 0, false, YUVA410_FORMAT),
bref: None,
- bands: bands,
+ bands,
tiles: Vec::new(), tile_start: [[0; 4]; 4], num_tiles: [[0; 4]; 4],
}
}
_ => {},
};
- let mut vinfo;
- if pic_hdr.transparent {
- vinfo = self.vinfoa.clone();
- } else {
- vinfo = self.vinfo.clone();
- }
+ let mut vinfo = if pic_hdr.transparent { self.vinfoa } else { self.vinfo };
vinfo.set_width(pic_hdr.width);
vinfo.set_height(pic_hdr.height);
let mut buftype = alloc_video_buffer(vinfo, 0)?;
res
}
- pub fn is_intra(&mut self) -> bool {
+ pub fn is_intra(&self) -> bool {
self.ftype.is_intra()
}
- pub fn get_frame_type(&mut self) -> FrameType {
+ pub fn get_frame_type(&self) -> FrameType {
match self.ftype {
IVIFrameType::Intra => { FrameType::I },
IVIFrameType::Intra1 => { FrameType::I },
let mut valtab: [i8; 256] = [0; 256];
runtab.copy_from_slice(&self.runtab);
valtab.copy_from_slice(&self.valtab);
- RVMap { eob_sym: self.eob_sym, esc_sym: self.esc_sym, runtab: runtab, valtab: valtab }
+ RVMap { eob_sym: self.eob_sym, esc_sym: self.esc_sym, runtab, valtab }
}
}
for _ in 0..h {
let mut last = *sptr;
for x in 0..w {
- let nv = *sptr.offset((x + 1) as isize);
- *dptr.offset(x as isize) = nv.wrapping_add(last) >> 1;
+ let nv = *sptr.add(x + 1);
+ *dptr.add(x) = nv.wrapping_add(last) >> 1;
last = nv;
}
- sptr = sptr.offset(sstride as isize);
- dptr = dptr.offset(dstride as isize);
+ sptr = sptr.add(sstride);
+ dptr = dptr.add(dstride);
}
}
},
}*/
unsafe {
let mut sptr0 = src.as_ptr();
- let mut sptr1 = sptr0.offset(sstride as isize);
+ let mut sptr1 = sptr0.add(sstride);
let mut dptr = dst.as_mut_ptr();
for _ in 0..h {
for x in 0..w {
- let a = *sptr0.offset(x as isize);
- let b = *sptr1.offset(x as isize);
- *dptr.offset(x as isize) = a.wrapping_add(b) >> 1;
+ let a = *sptr0.add(x);
+ let b = *sptr1.add(x);
+ *dptr.add(x) = a.wrapping_add(b) >> 1;
}
- sptr0 = sptr0.offset(sstride as isize);
- sptr1 = sptr1.offset(sstride as isize);
- dptr = dptr.offset(sstride as isize);
+ sptr0 = sptr0.add(sstride);
+ sptr1 = sptr1.add(sstride);
+ dptr = dptr.add(sstride);
}
}
},
}*/
unsafe {
let mut sptr0 = src.as_ptr();
- let mut sptr1 = sptr0.offset(sstride as isize);
+ let mut sptr1 = sptr0.add(sstride);
let mut dptr = dst.as_mut_ptr();
let mut la = *sptr0;
let mut lb = *sptr1;
for _ in 0..h {
for x in 0..w {
- let a = *sptr0.offset((x + 1) as isize);
- let b = *sptr1.offset((x + 1) as isize);
+ let a = *sptr0.add(x + 1);
+ let b = *sptr1.add(x + 1);
let aas = a.wrapping_add(la);
let bbs = b.wrapping_add(lb);
- *dptr.offset(x as isize) = aas.wrapping_add(bbs) >> 2;
+ *dptr.add(x) = aas.wrapping_add(bbs) >> 2;
la = a;
lb = b;
}
- sptr0 = sptr0.offset(sstride as isize);
- sptr1 = sptr1.offset(sstride as isize);
- dptr = dptr.offset(dstride as isize);
+ sptr0 = sptr0.add(sstride);
+ sptr1 = sptr1.add(sstride);
+ dptr = dptr.add(dstride);
}
}
},
mod ividsp;
#[cfg(feature="decoder_imc")]
+#[allow(clippy::excessive_precision)]
+#[allow(clippy::unreadable_literal)]
mod imc;
const INDEO_CODECS: &[DecoderInfo] = &[
];
pub fn indeo_register_all_codecs(rd: &mut RegisteredDecoders) {
- for decoder in INDEO_CODECS.into_iter() {
+ for decoder in INDEO_CODECS.iter() {
rd.add_decoder(decoder.clone());
}
}
extern crate nihav_core;
+#[allow(clippy::collapsible_if)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::too_many_arguments)]
+#[allow(clippy::useless_let_if_seq)]
+#[allow(clippy::verbose_bit_mask)]
pub mod codecs;
#[cfg(test)]