let mut window: [f32; 1024] = [0.0; 1024];
let factor = consts::PI / (2.0 * fsamples);
let scale = (2.0 / fsamples).sqrt() / 32768.0;
- for k in 0..samples {
- window[k] = (factor * ((k as f32) + 0.5)).sin() * scale;
+ for (k, el) in window[..samples].iter_mut().enumerate() {
+ *el = (factor * ((k as f32) + 0.5)).sin() * scale;
}
let mut pow_tab: [f32; 128] = [0.0; 128];
let mut hpow_tab: [f32; 128] = [0.0; 128];
self.js_bits = 0;
self.mode = Mode::Mono;
} else {
- validate!((js_bits >= 2) && (js_bits <= 6));
+ validate!((2..=6).contains(&js_bits));
self.js_bits = js_bits as u8;
self.mode = Mode::JointStereo;
}
if tbias1 + tbias2 > avail_bits * 2 {
let mut max = -999999;
let mut idx = total_subbands + 1;
- for j in 0..total_subbands {
- if exp_index1[j] >= (NUM_CATEGORIES - 1) { continue; }
- let t = -2 * (exp_index1[j] as i32) - (self.qindex[j] as i32) + bias;
+ for (j, (&exp_idx, &q_idx)) in exp_index1.iter()
+ .zip(self.qindex.iter()).enumerate().take(total_subbands) {
+ if exp_idx >= (NUM_CATEGORIES - 1) { continue; }
+ let t = -2 * (exp_idx as i32) - (q_idx as i32) + bias;
if t >= max {
max = t;
idx = j;
} else {
let mut min = 999999;
let mut idx = total_subbands + 1;
- for j in 0..total_subbands {
- if exp_index2[j] == 0 { continue; }
- let t = -2 * (exp_index2[j] as i32) - (self.qindex[j] as i32) + bias;
+ for (j, (&exp_idx, &q_idx)) in exp_index2.iter()
+ .zip(self.qindex.iter()).enumerate().take(total_subbands) {
+ if exp_idx == 0 { continue; }
+ let t = -2 * (exp_idx as i32) - (q_idx as i32) + bias;
if t < min {
min = t;
idx = j;
exp_index2[idx] -= 1;
}
}
- for i in 0..total_subbands {
- self.category[i] = exp_index2[i] as u8;
+ for (cat, &exp_idx) in self.category.iter_mut().zip(exp_index2.iter()).take(total_subbands) {
+ *cat = exp_idx as u8;
}
for _ in 0..num_vectors {
let mut ipos = 0;
for _ in 0..num_gains {
let idx = br.read(3)? as usize;
- let val;
- if br.read_bool()? {
- val = (br.read(4)? as i32) - 7;
- } else {
- val = -1;
- }
+ let val = if br.read_bool()? {
+ (br.read(4)? as i32) - 7
+ } else {
+ -1
+ };
validate!(idx >= ipos);
while ipos <= idx {
self.prev_gains[channel][ipos] = val;
unpack_band(&mut br, codebooks, &mut coef_index, &mut coef_sign, cat)?;
}
for i in 0..BAND_SIZE {
- let val;
- if coef_index[i] == 0 {
- let v = COOK_DITHER_TAB[cat];
- val = if !rnd.get_sign() { v } else { -v };
- } else {
- let v = COOK_QUANT_CENTROID[cat][coef_index[i] as usize];
- val = if !coef_sign[i] { v } else { -v };
- }
+ let val = if coef_index[i] == 0 {
+ let v = COOK_DITHER_TAB[cat];
+ if !rnd.get_sign() { v } else { -v }
+ } else {
+ let v = COOK_QUANT_CENTROID[cat][coef_index[i] as usize];
+ if !coef_sign[i] { v } else { -v }
+ };
self.block[channel][off + i] = val * dsp.hpow_tab[(self.qindex[sb] + 64) as usize];
}
off += BAND_SIZE;
Ok(())
}
+ #[allow(clippy::needless_range_loop)]
fn decode(&mut self, dsp: &mut CookDSP, rnd: &mut RND, codebooks: &Codebooks, src: &[u8], buf: &mut [u8], abuf: &mut NABufferType) -> DecoderResult<()> {
if self.mode == Mode::Stereo {
let mut schunk = src.chunks(src.len() / 2);
let mut bias: i32 = -32;
for i in 0..6 {
let mut sum = 0;
- for j in 0..total_subbands {
- let idx = ((32 >> i) + bias - (qindex[j] as i32)) / 2;
+ for &qidx in qindex[..total_subbands].iter() {
+ let idx = ((32 >> i) + bias - (qidx as i32)) / 2;
sum += COOK_EXP_BITS[idx.clip_cat()];
}
if sum >= (avail_bits - 32) {
}
#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
+#[allow(clippy::too_many_arguments)]
mod rv3040;
#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4", feature="encoder_realvideo4"))]
#[allow(clippy::erasing_op)]
mod rv34codes;
#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
+#[allow(clippy::collapsible_else_if)]
#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
#[allow(clippy::many_single_char_names)]
+#[allow(clippy::too_many_arguments)]
mod rv34dsp;
#[cfg(feature="decoder_realvideo1")]
#[cfg(feature="decoder_realvideo3")]
pub mod rv30;
#[cfg(feature="decoder_realvideo3")]
-#[allow(clippy::erasing_op)]
#[allow(clippy::many_single_char_names)]
#[allow(clippy::neg_multiply)]
+#[allow(clippy::too_many_arguments)]
pub mod rv30dsp;
#[cfg(feature="decoder_realvideo4")]
pub mod rv40;
#[cfg(any(feature="decoder_realvideo4", feature="encoder_realvideo4"))]
pub mod rv40data;
#[cfg(feature="decoder_realvideo4")]
+#[allow(clippy::eq_op)]
#[allow(clippy::erasing_op)]
#[allow(clippy::many_single_char_names)]
+#[allow(clippy::too_many_arguments)]
pub mod rv40dsp;
#[cfg(feature="decoder_realvideo6")]
pub mod rv60;
#[cfg(feature="decoder_realvideo6")]
+#[allow(clippy::identity_op)]
+#[allow(clippy::too_many_arguments)]
pub mod rv60codes;
#[cfg(feature="decoder_realvideo6")]
#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
#[allow(clippy::many_single_char_names)]
+#[allow(clippy::too_many_arguments)]
pub mod rv60dsp;
#[cfg(feature="decoder_realaudio144")]
-#[allow(clippy::manual_memcpy)]
pub mod ra144;
#[cfg(feature="decoder_realaudio288")]
pub mod ra288;
rescale_rms(self.lpc_refl_rms[if copyold { 1 } else { 0 }], energy)
}
}
+ #[allow(clippy::needless_range_loop)]
fn process_subblock(&mut self, br: &mut BitReader, lpc_coeffs: &[i16; LPC_ORDER], rms: u32) -> DecoderResult<()> {
let cba_idx = br.read(7)? as usize;
let gain = br.read(8)? as usize;
if cba_idx != 0 {
let len = cba_idx + BLOCKSIZE/2 - 1;
let soff = BUFFERSIZE - len;
- for i in 0..len.min(BLOCKSIZE) {
- tmp_a[i] = self.adapt_cb[i + soff];
- }
+ tmp_a[..len.min(BLOCKSIZE)].copy_from_slice(&self.adapt_cb[soff..][..len.min(BLOCKSIZE)]);
for i in len..BLOCKSIZE {
tmp_a[i] = self.adapt_cb[i + soff - len];
}
fn celp_synth_filter(dst: &mut [i16], src: &[i16], filt: &[i16; LPC_ORDER]) -> bool { //1,0,0xfff
for i in 0..BLOCKSIZE {
- let mut sum = -0xFFF;
- for j in 0..LPC_ORDER {
- sum += (filt[j] as i32) * (dst[LPC_ORDER + i - j - 1] as i32);
- }
+ let sum = filt.iter().zip(dst[i..].iter().rev())
+ .fold(-0xFFFi32, |acc, (&filt, &samp)| acc + (filt as i32) * (samp as i32));
let sum1 = (-sum >> 12) + (src[BUFFERSIZE - BLOCKSIZE + i] as i32);
if ((sum1 >> 16) != 0) && ((sum1 >> 16) != -1) { // overflow
return true;
let mut res = 1 << 16;
let mut shift = 10;
- for i in 0..LPC_ORDER {
- res = ((((1 << 24) - ((coeffs[i] * coeffs[i]) as u32)) >> 12) * res) >> 12;
+ for &coef in coeffs.iter() {
+ res = ((((1 << 24) - ((coef * coef) as u32)) >> 12) * res) >> 12;
if res == 0 { return 0; }
while res < (1 << 14) {
res <<= 2;
}
fn calc_irms(coeffs: &[i16; BLOCKSIZE]) -> u32 {
- let mut sum = 0;
- for i in 0..BLOCKSIZE {
- sum += ((coeffs[i] as i32) * (coeffs[i] as i32)) as u32;
- }
+ let sum = coeffs.iter().fold(0u32, |acc, &a| acc + (((a as i32) * (a as i32)) as u32));
if sum != 0 {
(1 << 29) / (fixp_sqrt(sum) >> 8)
} else {
for (i, block) in output.chunks_mut(BLOCKSIZE).enumerate() {
self.process_subblock(&mut br, &block_coeffs[i], refl_rms[i])?;
- for j in 0..BLOCKSIZE {
- block[j] = clip_out(self.audio[j + LPC_ORDER]) << 2;
+ for (dst, &src) in block.iter_mut().zip(self.audio[LPC_ORDER..].iter()) {
+ *dst = clip_out(src) << 2;
}
}
const BF_ORDER: usize = SP_LPC_ORDER + 1;
const BF_WORK_SIZE: usize = SP_LPC_ORDER + 40 + 35;
+#[allow(clippy::too_many_arguments)]
fn backfilter(hist: &mut [f32], rec: &mut [f32], filt: &mut [f32], win: &[f32], bw_tab: &[f32], start: usize, non_rec: usize, move_size: usize) {
let mut temp: [f32; BF_ORDER] = [0.0; BF_ORDER];
let order = filt.len();
for i in 0..SP_LPC_ORDER {
self.speech_hist[SP_START + i] = self.speech_hist[75 + i];
}
- let mut sum: f32 = 32.0;
- for i in 0..GAIN_LPC_ORDER {
- sum -= self.gain_hist[GAIN_START + GAIN_LPC_ORDER - 1 - i] * self.gain_lpc[i];
- }
- sum = sum.max(0.0).min(60.0);
+ let sum = self.gain_hist[GAIN_START..].iter().rev()
+ .zip(self.gain_lpc.iter())
+ .fold(32.0f32, |acc, (&a, &b)| acc - a * b)
+ .max(0.0).min(60.0);
let scale = (sum * 0.1151292546497).exp() * gain * (1.0 / ((1 << 23) as f32));
let mut buf: [f32; BLOCKSIZE] = [0.0; BLOCKSIZE];
- for i in 0..BLOCKSIZE {
- buf[i] = (RA288_CODEBOOK[cb_idx][i] as f32) * scale;
+ for (dst, &cb) in buf.iter_mut().zip(RA288_CODEBOOK[cb_idx].iter()) {
+ *dst = (cb as f32) * scale;
}
let mut sum: f32 = 0.0;
self.process_subblock(gain, cb);
- for j in 0..BLOCKSIZE {
- block[j] = self.speech_hist[SP_START + SP_LPC_ORDER + j];
- }
+ block.copy_from_slice(&self.speech_hist[SP_START + SP_LPC_ORDER..][..BLOCKSIZE]);
if (i & 7) == 3 {
backfilter(&mut self.speech_hist, &mut self.speech_rec, &mut self.speech_lpc, RA288_SPEECH_WINDOW, RA288_SPEECH_BW_TAB, 40, 35, SP_START);
backfilter(&mut self.gain_hist, &mut self.gain_rec, &mut self.gain_lpc, RA288_GAIN_WINDOW, RA288_GAIN_BW_TAB, 8, 20, GAIN_START);
}
fn is_none(&self) -> bool { self.params == FILTER_NONE }
fn is_raw(&self) -> bool { self.params == FILTER_RAW }
+ #[allow(clippy::comparison_chain)]
fn read_coeffs(&mut self, br: &mut BitReader, cset: &CodebookSet) -> DecoderResult<()> {
let coeff_cb = &cset.filter_coeffs_cb[self.bits as usize];
let mut cmode: i32 = 0;
fn new() -> Self {
Self { bias: 0, mode: 0, bits: 0, data: [0; 4096], filter: Filter::new() }
}
+ #[allow(clippy::identity_op)]
fn decode(&mut self, br: &mut BitReader, codebooks: &[CodebookSet; 3], length: usize) -> DecoderResult<()> {
let cset = &codebooks[self.mode as usize];
self.filter.params = br.read_cb(&cset.filter_params_cb).unwrap();
let length = read_block_length(&mut br).unwrap();
validate!(length + self.sample_offset <= self.max_frame_size);
- let dmode;
- if self.channels > 1 {
- dmode = (br.read(2).unwrap() + 1) as u8;
- } else {
- dmode = 0;
- }
+ let dmode = if self.channels > 1 {
+ (br.read(2).unwrap() + 1) as u8
+ } else {
+ 0
+ };
self.ch_data[0].mode = dmode >> 2;
self.ch_data[0].bits = 16;
self.ch_data[1].mode = if dmode >= 2 { 2 } else { 0 };
let mut br = BitReader::new(&self.pkt_buf[2..][..table_bytes], BitReaderMode::BE);
while br.tell() < table_bits {
let size = br.read(13 + self.channels).unwrap() as usize;
- let pts;
- if br.read_bool().unwrap() {
- pts = br.read(9).unwrap() as u16;
- } else {
- pts = 0;
- }
+ let pts = if br.read_bool().unwrap() {
+ br.read(9).unwrap() as u16
+ } else {
+ 0
+ };
self.blocks.push(Block{ size, _pts: pts });
}
}
use nihav_codec_support::codecs::h263::decoder::*;
use nihav_codec_support::codecs::h263::data::*;
-#[allow(dead_code)]
struct Tables {
intra_mcbpc_cb: Codebook<u8>,
inter_mcbpc_cb: Codebook<u8>,
cbpy_cb: Codebook<u8>,
rl_cb: Codebook<H263RLSym>,
- aic_rl_cb: Codebook<H263RLSym>,
mv_cb: Codebook<u8>,
luma_dc_cb: Codebook<u8>,
chroma_dc_cb: Codebook<u8>,
}
}
-#[allow(unused_variables)]
+ #[allow(clippy::collapsible_else_if)]
fn decode_block(&mut self, sstate: &SliceState, quant: u8, intra: bool, coded: bool, blk: &mut [i16; 64], plane_no: usize) -> DecoderResult<()> {
let br = &mut self.br;
let mut idx = 0;
impl<'a> BlockDecoder for RealVideo10BR<'a> {
-#[allow(unused_variables)]
fn decode_pichdr(&mut self) -> DecoderResult<PicInfo> {
self.slice_no = 0;
let shdr = self.read_slice_header()?;
validate!((shdr.mb_x == 0) && (shdr.mb_y == 0));
- let mb_end = shdr.mb_x + shdr.mb_y * self.mb_w + shdr.mb_c;
+ let _mb_end = shdr.mb_x + shdr.mb_y * self.mb_w + shdr.mb_c;
let ftype = if !shdr.is_p { Type::I } else { Type::P };
let picinfo = PicInfo::new(self.w, self.h, ftype, self.mvmode, false, false, shdr.qscale, 0, None, None);
Ok(picinfo)
}
- #[allow(unused_variables)]
- fn decode_slice_header(&mut self, info: &PicInfo) -> DecoderResult<SliceInfo> {
+ fn decode_slice_header(&mut self, _info: &PicInfo) -> DecoderResult<SliceInfo> {
let shdr = self.read_slice_header()?;
self.slice_no += 1;
let mb_end = shdr.mb_x + shdr.mb_y * self.mb_w + shdr.mb_c;
}
}
- #[allow(unused_variables)]
- fn decode_block_intra(&mut self, info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
+ fn decode_block_intra(&mut self, _info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
self.decode_block(sstate, quant, true, coded, blk, if no < 4 { 0 } else { no - 3 })
}
- #[allow(unused_variables)]
- fn decode_block_inter(&mut self, info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
+ fn decode_block_inter(&mut self, _info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
self.decode_block(sstate, quant, false, coded, blk, if no < 4 { 0 } else { no - 3 })
}
let cbpy_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = H263RLCodeReader::new(H263_RL_CODES);
let rl_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
- let mut coderead = H263RLCodeReader::new(H263_RL_CODES_AIC);
- let aic_rl_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = H263ShortCodeReader::new(H263_MV);
let mv_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = CodeReader::new(RV10_LUMA_DC_CODES, RV10_LUMA_DC_BITS);
inter_mcbpc_cb,
cbpy_cb,
rl_cb,
- aic_rl_cb,
mv_cb,
luma_dc_cb,
chroma_dc_cb,
use nihav_codec_support::codecs::h263::data::*;
-#[allow(dead_code)]
struct Tables {
intra_mcbpc_cb: Codebook<u8>,
inter_mcbpc_cb: Codebook<u8>,
struct RV20BlockDSP {}
impl RV20SliceInfo {
+ #[allow(clippy::too_many_arguments)]
fn new(ftype: Type, seq: u32, qscale: u8, mb_x: usize, mb_y: usize, mb_pos: usize, w: usize, h: usize, loop_filter: bool) -> Self {
RV20SliceInfo { ftype, seq, qscale, mb_x, mb_y, mb_pos, w, h, loop_filter }
}
fn copy_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
- for i in 0..4 {
+ for (i, mv) in mvs.iter().enumerate() {
let xadd = (i & 1) * 8;
let yadd = (i & 2) * 4;
- let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize;
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
- blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS);
+ blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_FUNCS);
}
let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3];
fn avg_blocks8x8(&self, dst: &mut NAVideoBuffer<u8>, src: NAVideoBufferRef<u8>, xpos: usize, ypos: usize, mvs: &[MV; 4]) {
let mut dst = NASimpleVideoFrame::from_video_buf(dst).unwrap();
- for i in 0..4 {
+ for (i, mv) in mvs.iter().enumerate() {
let xadd = (i & 1) * 8;
let yadd = (i & 2) * 4;
- let mode = ((mvs[i].x & 1) + (mvs[i].y & 1) * 2) as usize;
+ let mode = ((mv.x & 1) + (mv.y & 1) * 2) as usize;
- blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mvs[i].x >> 1, mvs[i].y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS);
+ blockdsp::copy_block(&mut dst, src.clone(), 0, xpos + xadd, ypos + yadd, mv.x >> 1, mv.y >> 1, 8, 8, 0, 1, mode, H263_INTERP_AVG_FUNCS);
}
let sum_mv = mvs[0] + mvs[1] + mvs[2] + mvs[3];
fn get_mb_pos_bits(mb_w: usize, mb_h: usize) -> u8 {
let max_pos = mb_w * mb_h - 1;
- for i in 0..H263_MBB.len() {
- if max_pos <= H263_MBB[i].blocks {
- return H263_MBB[i].bits;
+ for mbb in H263_MBB.iter() {
+ if max_pos <= mbb.blocks {
+ return mbb.bits;
}
}
0
}
}
-#[allow(unused_variables)]
+ #[allow(clippy::too_many_arguments)]
fn decode_block(&mut self, sstate: &SliceState, quant: u8, intra: bool, coded: bool, blk: &mut [i16; 64], plane_no: usize, acpred: ACPredMode) -> DecoderResult<()> {
let br = &mut self.br;
let mut idx = 0;
impl<'a> BlockDecoder for RealVideo20BR<'a> {
-#[allow(unused_variables)]
fn decode_pichdr(&mut self) -> DecoderResult<PicInfo> {
self.slice_no = 0;
let shdr = self.read_slice_header()?;
Ok(picinfo)
}
- #[allow(unused_variables)]
- fn decode_slice_header(&mut self, info: &PicInfo) -> DecoderResult<SliceInfo> {
+ fn decode_slice_header(&mut self, _info: &PicInfo) -> DecoderResult<SliceInfo> {
let shdr = self.read_slice_header()?;
self.slice_no += 1;
let mb_count;
self.decode_block(sstate, quant, true, coded, blk, if no < 4 { 0 } else { no - 3 }, info.get_acpred())
}
- #[allow(unused_variables)]
- fn decode_block_inter(&mut self, info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
+ fn decode_block_inter(&mut self, _info: &BlockInfo, sstate: &SliceState, quant: u8, no: usize, coded: bool, blk: &mut [i16; 64]) -> DecoderResult<()> {
self.decode_block(sstate, quant, false, coded, blk, if no < 4 { 0 } else { no - 3 }, ACPredMode::None)
}
}
impl<'a> RealVideo20BR<'a> {
-#[allow(unused_variables)]
fn read_slice_header(&mut self) -> DecoderResult<RV20SliceInfo> {
validate!(self.slice_no < self.num_slices);
validate!(marker == 0);
let qscale = br.read(5)? as u8;
validate!(qscale > 0);
- let loop_filter;
- if self.minor_ver >= 2 {
- loop_filter = br.read_bool()?;
- } else {
- loop_filter = false;
- }
+ let loop_filter = if self.minor_ver >= 2 { br.read_bool()? } else { false };
let seq = if self.minor_ver <= 1 {
br.read(8)? << 8
} else {
}
impl NADecoder for RealVideo20Decoder {
-#[allow(unused_variables)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let w = vinfo.get_width();
let ver = ((src[4] as u32) << 12) | ((src[5] as u32) << 4) | ((src[6] as u32) >> 4);
let maj_ver = ver >> 16;
let min_ver = (ver >> 8) & 0xFF;
- let mic_ver = ver & 0xFF;
+ let _mic_ver = ver & 0xFF;
validate!(maj_ver == 2);
self.minor_ver = min_ver as u8;
let rprb = src[1] & 7;
}
}
-#[allow(dead_code)]
#[derive(Debug,Clone,Copy,PartialEq)]
pub enum MBType {
MBIntra,
self.has_b.clear();
self.has_b.resize(size >> 2, false);
}
+ #[allow(clippy::identity_op)]
fn fill(&mut self, mb_x: usize, mb_y: usize, fwd: bool, mv: MV) {
let idx = mb_x * 2 + mb_y * 2 * self.w;
if fwd {
pub fn pred_mb_mv(&self, mb_x: usize, mb_y: usize, fwd: bool, has_top: bool, has_left: bool, has_tr: bool, has_tl: bool) -> MV {
self.pred_mv(mb_x * 2 + mb_y * 2 * self.w, fwd, has_top, has_left, has_tr, has_tl, true)
}
+ #[allow(clippy::collapsible_else_if)]
+ #[allow(clippy::identity_op)]
fn set_mb(&mut self, mb_x: usize, mb_y: usize, mbtype: MBType, ref_mvi: &Self, mvs: &[MV], sstate: &SState) {
let mb_idx = mb_x + mb_y * (self.w >> 1);
self.has_f[mb_idx] = mbtype.is_fwd();
for x in 0..2 {
let has_left = (x > 0) || sstate.has_left;
let has_tr = if y > 0 { x == 0 } else if x == 0 { sstate.has_top } else { sstate.has_tr };
- let has_tl;
- if y == 0 {
- has_tl = if x == 0 { sstate.has_tl } else { sstate.has_top };
- } else {
- has_tl = if x == 0 { sstate.has_left } else { true };
- }
+ let has_tl = if y == 0 {
+ if x == 0 { sstate.has_tl } else { sstate.has_top }
+ } else {
+ if x == 0 { sstate.has_left } else { true }
+ };
let pred_mv = self.pred_mv(idx8 + x, true, has_top, has_left, has_tr, has_tl, false);
let new_mv = mvs[x + y * 2] + pred_mv;
self.mv_f[idx8 + x] = new_mv;
let off = if vert { self.w } else { 1 };
let diffx = self.mv_f[idx].x - self.mv_f[idx - off].x;
let diffy = self.mv_f[idx].y - self.mv_f[idx - off].y;
- (diffx < -3) || (diffx > 3) || (diffy < -3) || (diffy > 3)
+ (diffx.abs() > 3) || (diffy.abs() > 3)
}
}
if let Ok(nhdr) = bd.decode_slice_header(br, shdr.width, shdr.height) {
validate!(nhdr.start > shdr.start);
shdr.end = nhdr.start;
- } else {
- if slice_no + 2 < slice_offs.len() {
- br.seek((slice_offs[slice_no + 2] * 8) as u32)?;
- if let Ok(nhdr) = bd.decode_slice_header(br, shdr.width, shdr.height) {
- validate!(nhdr.start > shdr.start);
- shdr.end = nhdr.start;
- } else {
- shdr.end = ((shdr.width + 15) >> 4) * ((shdr.height + 15) >> 4);
- }
+ } else if slice_no + 2 < slice_offs.len() {
+ br.seek((slice_offs[slice_no + 2] * 8) as u32)?;
+ if let Ok(nhdr) = bd.decode_slice_header(br, shdr.width, shdr.height) {
+ validate!(nhdr.start > shdr.start);
+ shdr.end = nhdr.start;
} else {
shdr.end = ((shdr.width + 15) >> 4) * ((shdr.height + 15) >> 4);
}
+ } else {
+ shdr.end = ((shdr.width + 15) >> 4) * ((shdr.height + 15) >> 4);
}
br.seek(cur_pos)?;
} else {
for y in 0..4 {
for x in 0..4 {
let mut coeffs: [i16; 16] = [0; 16];
- let has_ac;
- if (cur_cbp & 1) != 0 {
- has_ac = self.coderead.decode_block(br, &mut coeffs, luma_set, 0, q_ac, q_ac, q_ac)?;
- } else {
- has_ac = false;
- }
+ let has_ac = if (cur_cbp & 1) != 0 {
+ self.coderead.decode_block(br, &mut coeffs, luma_set, 0, q_ac, q_ac, q_ac)?
+ } else {
+ false
+ };
if is_16 {
coeffs[0] = coeffs16[x + y * 4];
} else {
for y in 0..2 {
for x in 0..2 {
let mut coeffs: [i16; 16] = [0; 16];
- let has_ac;
- if (cur_cbp & 1) != 0 {
- has_ac = self.coderead.decode_block(br, &mut coeffs, chroma_set, 1, q_dc, q_ac, q_ac)?;
- } else {
- has_ac = false;
- }
+ let has_ac = if (cur_cbp & 1) != 0 {
+ self.coderead.decode_block(br, &mut coeffs, chroma_set, 1, q_dc, q_ac, q_ac)?
+ } else {
+ false
+ };
if !is_16 {
let noright = (sstate.mb_x == sstate.mb_w - 1) && (x == 1);
let has_top = sstate.has_top || (y > 0);
for y in 0..4 {
for x in 0..4 {
let mut coeffs: [i16; 16] = [0; 16];
- let has_ac;
- if (cur_cbp & 1) != 0 {
- has_ac = self.coderead.decode_block(br, &mut coeffs, luma_set, 0, q_ac, q_ac, q_ac)?;
- } else {
- has_ac = false;
- }
+ let has_ac = if (cur_cbp & 1) != 0 {
+ self.coderead.decode_block(br, &mut coeffs, luma_set, 0, q_ac, q_ac, q_ac)?
+ } else {
+ false
+ };
if is_16 {
coeffs[0] = coeffs16[x + y * 4];
}
for _ in 0..2 {
for x in 0..2 {
let mut coeffs: [i16; 16] = [0; 16];
- let has_ac;
- if (cur_cbp & 1) != 0 {
- has_ac = self.coderead.decode_block(br, &mut coeffs, chroma_set, 1, q_dc, q_ac, q_ac)?;
- } else {
- has_ac = false;
- }
+ let has_ac = if (cur_cbp & 1) != 0 {
+ self.coderead.decode_block(br, &mut coeffs, chroma_set, 1, q_dc, q_ac, q_ac)?
+ } else {
+ false
+ };
if has_ac {
self.cdsp.transform(&mut coeffs);
} else {
}
#[allow(clippy::cognitive_complexity)]
+ #[allow(clippy::collapsible_else_if)]
pub fn parse_frame(&mut self, supp: &mut NADecoderSupport, src: &[u8], bd: &mut dyn RV34BitstreamDecoder) -> DecoderResult<(NABufferType, FrameType, u64)> {
let mut slice_offs: Vec<usize> = Vec::new();
parse_slice_offsets(src, &mut slice_offs)?;
self.decode_mb_header_intra(bd, &mut br, is_i16, &mut imode, q, sstate.has_top, false)?
} else {
if skip_run == 0 {
- let mbtype;
- if self.is_rv30 {
- mbtype = MBType::Invalid;
- } else {
- let mut hist = MBHist::new(hdr0.ftype);
- if sstate.has_top {
- hist.add(mbinfo[mb_pos - mb_w].mbtype);
- if sstate.has_tr { hist.add(mbinfo[mb_pos - mb_w + 1].mbtype); }
- }
- if sstate.has_left { hist.add(mbinfo[mb_pos - 1].mbtype); }
- if sstate.has_tl { hist.add(mbinfo[mb_pos - mb_w - 1].mbtype); }
- mbtype = hist.get_mbtype();
- }
+ let mbtype = if self.is_rv30 {
+ MBType::Invalid
+ } else {
+ let mut hist = MBHist::new(hdr0.ftype);
+ if sstate.has_top {
+ hist.add(mbinfo[mb_pos - mb_w].mbtype);
+ if sstate.has_tr { hist.add(mbinfo[mb_pos - mb_w + 1].mbtype); }
+ }
+ if sstate.has_left { hist.add(mbinfo[mb_pos - 1].mbtype); }
+ if sstate.has_tl { hist.add(mbinfo[mb_pos - mb_w - 1].mbtype); }
+ hist.get_mbtype()
+ };
self.decode_mb_header_inter(bd, &mut br, hdr0.ftype, mbtype, &mut imode, q, sstate.has_top)?
} else {
skip_run -= 1;
};
if !mbh.mbtype.is_intra() {
let mut mvs: [MV; 4] = [ZERO_MV; 4];
- for i in 0..mbh.mbtype.get_num_mvs() {
- mvs[i] = decode_mv(&mut br)?;
+ for mv in mvs[..mbh.mbtype.get_num_mvs()].iter_mut() {
+ *mv = decode_mv(&mut br)?;
}
if !self.is_b {
self.mvi.set_mb(mb_x, mb_y, mbh.mbtype, &self.ref_mvi, &mvs, &sstate);
else { a as u8 }
}
+#[allow(clippy::identity_op)]
fn rv3_filter_h(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, bsize: usize, c1: i16, c2: i16) {
for _ in 0..bsize {
for x in 0..bsize {
}
}
+#[allow(clippy::erasing_op)]
+#[allow(clippy::identity_op)]
fn rv3_filter_v(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, bsize: usize, c1: i16, c2: i16) {
for _ in 0..bsize {
for x in 0..bsize {
impl RV34CodeReader {
pub fn new(data: &'static [u8]) -> Self {
- let len = data.len();
- let mut lengths: Vec<u8> = Vec::with_capacity(len);
- let mut codes: Vec<u32> = Vec::with_capacity(len);
- let mut syms: Vec<u16> = Vec::with_capacity(len);
+ let data_len = data.len();
+ let mut lengths: Vec<u8> = Vec::with_capacity(data_len);
+ let mut codes: Vec<u32> = Vec::with_capacity(data_len);
+ let mut syms: Vec<u16> = Vec::with_capacity(data_len);
let mut counts: [u32; 17] = [0; 17];
let mut prefix: [u32; 17] = [0; 17];
- for i in 0..len {
- if data[i] > 0 {
- counts[data[i] as usize] += 1;
+ for &len in data.iter() {
+ if len > 0 {
+ counts[len as usize] += 1;
}
}
for i in 0..16 {
prefix[i + 1] = (prefix[i] + counts[i]) << 1;
}
- for i in 0..len {
- if data[i] == 0 { continue; }
- lengths.push(data[i]);
- let bits = data[i] as usize;
+ for (i, &len) in data.iter().enumerate() {
+ if len == 0 { continue; }
+ lengths.push(len);
+ let bits = len as usize;
codes.push(prefix[bits]);
prefix[bits] += 1;
syms.push(i as u16);
}
impl CBPSet {
+ #[allow(clippy::identity_op)]
fn new(intra: bool, set: usize, subset: usize) -> Self {
if intra {
let mut coderead = RV34CodeReader::new(&RV34_INTRA_CBPPAT[set][subset]);
Ok(nval)
}
+#[allow(clippy::identity_op)]
fn decode_subblock3(br: &mut BitReader, ccodes: &Codebook<u16>, idx: usize, q2: u16, q3: u16, q4: u16, coeffs: &mut [i16]) -> DecoderResult<()> {
let flags = RV34_MODULO_THREE_TABLE[idx];
coeffs[0*4 + 0] = decode_coeff(br, ccodes, (flags >> 6) & 3, 3, q2)?;
coeffs[0] = decode_coeff(br, ccodes, val, 3, q2)?;
Ok(())
}
+#[allow(clippy::identity_op)]
fn decode_subblock(br: &mut BitReader, ccodes: &Codebook<u16>, idx: usize, invert: bool, q4: u16, coeffs: &mut [i16]) -> DecoderResult<()> {
let flags = RV34_MODULO_THREE_TABLE[idx];
coeffs[0*4 + 0] = decode_coeff(br, ccodes, (flags >> 6) & 3, 3, q4)?;
Ok(())
}
-#[allow(dead_code)]
pub struct RV34Codes {
intra_set: Vec<FullSet>,
inter_set: Vec<FullSet>,
let ones = RV34_ONES_COUNT[pattern as usize];
- for i in 0..4 {
+ for (i, &shift) in RV34_CBP_SHIFTS.iter().enumerate() {
if ((pattern >> (3 - i)) & 1) != 0 {
let code = br.read_cb(&codeset.cbp[ones])? as u32;
- cbp |= code << RV34_CBP_SHIFTS[i];
+ cbp |= code << shift;
}
}
Ok(cbp)
}
+ #[allow(clippy::too_many_arguments)]
pub fn decode_block(&mut self, br: &mut BitReader, coeffs: &mut [i16], idx0: usize, idx1: usize, q2: u16, q3: u16, q4: u16) -> DecoderResult<bool> {
let codeset = if self.is_intra {
&self.intra_set[self.set_idx].cset
VerLeftNoDown
}
-#[allow(dead_code)]
#[derive(Debug,Clone,Copy)]
pub enum PredType8x8 {
DC,
}
pub fn transform_dc(&self, coeffs: &mut [i16]) {
let val = (((coeffs[0] as i32) * 13 * 13 + 0x200) >> 10) as i16;
- for i in 0..16 { coeffs[i] = val; }
+ for el in coeffs[..16].iter_mut() { *el = val; }
}
pub fn transform16(&self, coeffs: &mut [i16]) {
let mut tmp: [i32; 16] = [0; 16];
}
pub fn transform16_dc(&self, coeffs: &mut [i16]) {
let val = (((coeffs[0] as i32) * 13 * 13 * 3) >> 11) as i16;
- for i in 0..16 { coeffs[i] = val; }
+ for el in coeffs[..16].iter_mut() { *el = val; }
}
pub fn weight(&self, dst: &mut [u8], mut didx: usize, dstride: usize,
src: &[u8], mut sidx: usize, sstride: usize, ratio1: u32, ratio2: u32,
had_skip_run: false,
}
}
+ #[allow(clippy::collapsible_else_if)]
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;
Ok(RV34SliceHeader{ ftype, quant: q, deblock, pts, width: w, height: h, start, end: 0, set_idx })
}
+ #[allow(clippy::identity_op)]
fn decode_intra_pred(&mut self, br: &mut BitReader, types: &mut [i8], mut pos: usize, tstride: usize, has_top: bool) -> DecoderResult<()> {
let start;
if has_top {
let q1 = el!(pix, off + step);
let q2 = el!(pix, off + 2*step);
- let strength;
- if filter_p1 && filter_q1 {
- strength = (t << 2) + (p1 - q1);
- } else {
- strength = t << 2;
- }
+ let strength = if filter_p1 && filter_q1 {
+ (t << 2) + (p1 - q1)
+ } else { t << 2 };
let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
pix[off - step] = clip8(p0 + diff);
lim_p0q0: i16, lim_p1: i16, lim_q1: i16) {
rv40_weak_loop_filter4(pix, off, stride, 1, filter_p1, filter_q1, alpha, beta, lim_p0q0, lim_p1, lim_q1);
}
-#[allow(clippy::eq_op)]
fn rv40_weak_loop_filter4_v(pix: &mut [u8], off: usize, stride: usize,
filter_p1: bool, filter_q1: bool, alpha: i16, beta: i16,
lim_p0q0: i16, lim_p1: i16, lim_q1: i16) {
let q1 = el!(ch, 3 + 1);
let q2 = el!(ch, 3 + 2);
- let strength;
- if filter_p1 && filter_q1 {
- strength = (t << 2) + (p1 - q1);
- } else {
- strength = t << 2;
- }
+ let strength = if filter_p1 && filter_q1 {
+ (t << 2) + (p1 - q1)
+ } else { t << 2 };
let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
ch[3 - 1] = clip8(p0 + diff);
rv40_loop_strength(pix, off, stride, 1, beta, beta2, edge)
}
-#[allow(clippy::eq_op)]
fn rv40_loop_strength_v(pix: &[u8], off: usize, stride: usize,
beta: i16, beta2: i16, edge: bool) -> (bool, bool, bool) {
let src = &pix[off - 3..][..stride * 3 + 3 + 3];
}
impl CBPSet {
+ #[allow(clippy::identity_op)]
fn new(intra: bool, set: usize, subset: usize) -> Self {
if intra {
let cbp_pat = RV34CodeReader::new(&RV34_INTRA_CBPPAT[set][subset]);
use super::super::types::Block;
use super::clip8;
+#[allow(clippy::wrong_self_convention)]
pub trait BlockOps {
fn from_diff(&mut self, new: &[u8], old: &[u8], stride: usize);
fn add_to(&self, dst: &mut [u8], stride: usize);
}
(left, top)
}
+ #[allow(clippy::collapsible_else_if)]
#[allow(clippy::many_single_char_names)]
pub fn apply(&self, ptype: PredType4x4, buf: &mut [u8], stride: usize) {
match ptype {
let q1 = el!(pix, off + step);
let q2 = el!(pix, off + 2*step);
- let strength;
- if filter_p1 && filter_q1 {
- strength = (t << 2) + (p1 - q1);
- } else {
- strength = t << 2;
- }
+ let strength = if filter_p1 && filter_q1 {
+ (t << 2) + (p1 - q1)
+ } else {
+ t << 2
+ };
let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
pix[off - step] = clip8(p0 + diff);
lim_p0q0: i16, lim_p1: i16, lim_q1: i16) {
rv40_weak_loop_filter4(pix, off, stride, 1, filter_p1, filter_q1, alpha, beta, lim_p0q0, lim_p1, lim_q1);
}
-#[allow(clippy::eq_op)]
fn rv40_weak_loop_filter4_v(pix: &mut [u8], off: usize, stride: usize,
filter_p1: bool, filter_q1: bool, alpha: i16, beta: i16,
lim_p0q0: i16, lim_p1: i16, lim_q1: i16) {
let q1 = el!(ch, 3 + 1);
let q2 = el!(ch, 3 + 2);
- let strength;
- if filter_p1 && filter_q1 {
- strength = (t << 2) + (p1 - q1);
- } else {
- strength = t << 2;
- }
+ let strength = if filter_p1 && filter_q1 {
+ (t << 2) + (p1 - q1)
+ } else {
+ t << 2
+ };
let diff = clip_symm((strength + 4) >> 3, lim_p0q0);
ch[3 - 1] = clip8(p0 + diff);
rv40_loop_strength(pix, off, stride, 1, beta, beta2, edge)
}
-#[allow(clippy::eq_op)]
fn rv40_loop_strength_v(pix: &[u8], off: usize, stride: usize,
beta: i16, beta2: i16, edge: bool) -> (bool, bool, bool) {
let src = &pix[off - 3..][..stride * 3 + 3 + 3];
mod bitstream;
use bitstream::*;
+#[allow(clippy::eq_op)]
+#[allow(clippy::identity_op)]
+#[allow(clippy::too_many_arguments)]
mod dsp;
use dsp::loop_filter_frame;
mod estimator;
use estimator::*;
+#[allow(clippy::too_many_arguments)]
mod mb_coding;
use mb_coding::*;
const MAX_DIST: u32 = std::u32::MAX;
const DIST_THRESH: u32 = 256;
+#[allow(clippy::wrong_self_convention)]
trait FromPixels {
fn from_pixels(self) -> Self;
}
}
}
+#[allow(clippy::wrong_self_convention)]
trait MVOps {
fn scale(self, scale: i16) -> Self;
fn is_in_range(self, range: i16) -> bool;
const RV60_CUSTOM_MSG_LENS: [u32; 4] = [ 2, 4, 16, 32 ];
impl FrameHeader {
+ #[allow(clippy::identity_op)]
+ #[allow(clippy::needless_late_init)]
fn read(br: &mut BitReader) -> DecoderResult<Self> {
let marker = br.read(2)?;
validate!(marker == 3);
if br.read_bool()? {
let custom_msg_hdr_len = br.read(2)? as usize;
if custom_msg_hdr_len != 0 {
- for i in 0..custom_msg_hdr_len {
- br.skip(RV60_CUSTOM_MSG_LENS[i] * 8)?;
+ for &msg_len in RV60_CUSTOM_MSG_LENS[..custom_msg_hdr_len].iter() {
+ br.skip(msg_len * 8)?;
}
}
}
sum += first_size;
let mut lastsize = first_size;
sizes.push(first_size);
- for i in 1..nslices {
+ for &sign in signs[1..nslices].iter() {
let diff = br.read(nbits)? as isize;
- let size;
- if signs[i] {
- let sum = (lastsize as isize).checked_add(diff);
- validate!(sum.is_some());
- size = sum.unwrap() as usize;
- } else {
- let sum = (lastsize as isize).checked_sub(diff);
- validate!(sum.is_some());
- size = sum.unwrap() as usize;
- }
+ let newsize = if sign {
+ (lastsize as isize).checked_add(diff)
+ } else {
+ (lastsize as isize).checked_sub(diff)
+ };
+ validate!(newsize.is_some());
+ let size = newsize.unwrap() as usize;
sizes.push(size);
sum += size;
lastsize = size;
}
impl CBHeader {
+ #[allow(clippy::collapsible_else_if)]
fn read(br: &mut BitReader, ftype: FrameType, two_f_refs: bool, size: usize) -> DecoderResult<Self> {
- let cu_type;
let pu_type;
let mut imode: [IntraMode; 4] = [IntraMode::Index(0); 4];
let mut mv: [MVInfo; 4] = [MVInfo::default(); 4];
- if ftype == FrameType::I {
- cu_type = CUType::Intra;
- } else {
- cu_type = RV60_CU_TYPES[br.read(2)? as usize];
- }
+ let cu_type = if ftype == FrameType::I {
+ CUType::Intra
+ } else {
+ RV60_CU_TYPES[br.read(2)? as usize]
+ };
match cu_type {
CUType::Intra => {
if (size == 8) && br.read_bool()? {
pu_type = PUType::Full;
}
if pu_type == PUType::Quarters {
- for i in 0..4 {
- imode[i] = CBHeader::read_intra_mode(br)?;
+ for imode in imode.iter_mut() {
+ *imode = CBHeader::read_intra_mode(br)?;
}
} else if size <= 32 {
imode[0] = CBHeader::read_intra_mode(br)?;
}
fn read_mv_data(br: &mut BitReader, ftype: FrameType, two_f_refs: bool, size: usize, pu_type: PUType, mv: &mut [MVInfo; 4]) -> DecoderResult<()> {
let mv_count = pu_type.get_num_mvs();
- for i in 0..mv_count {
- mv[i] = CBHeader::read_mv_info(br, ftype, two_f_refs, size, pu_type)?;
+ for mv in mv[..mv_count].iter_mut() {
+ *mv = CBHeader::read_mv_info(br, ftype, two_f_refs, size, pu_type)?;
}
Ok(())
}
Ok(())
}
#[allow(clippy::cognitive_complexity)]
+ #[allow(clippy::collapsible_else_if)]
+ #[allow(clippy::identity_op)]
fn decode_cb_tree(&mut self, buf: &mut NASimpleVideoFrame<u8>, hdr: &FrameHeader, br: &mut BitReader, xpos: usize, ypos: usize, log_size: u8) -> DecoderResult<()> {
if (xpos >= hdr.awidth) || (ypos >= hdr.aheight) { return Ok(()); }
TransformType::T4X4 => {
let subset = if is_intra { 0 } else { 2 };
if size == 16 {
- let cbp16;
- if br.read_bool()? {
- cbp16 = rv6_decode_cbp16(br, &self.cbs, subset, self.sel_qp)?;
- } else {
- cbp16 = 0;
- }
+ let cbp16 = if br.read_bool()? {
+ rv6_decode_cbp16(br, &self.cbs, subset, self.sel_qp)?
+ } else { 0 };
if cbp16 != 0 {
rv6_decode_cu_4x4in16x16(br, &self.cbs, is_intra, self.qp, self.sel_qp, &mut self.y_coeffs, &mut self.u_coeffs, &mut self.v_coeffs, cbp16)?;
for y in 0..4 {
_ => unreachable!(),
}
}
+ #[allow(clippy::too_many_arguments)]
fn populate_ipred(&mut self, hdr: &FrameHeader, src: &[u8], soff: usize, stride: usize, xoff: usize, yoff: usize, size: usize, is_luma: bool) {
let src_off = if is_luma {
soff + self.xpos + xoff + (self.ypos + yoff) * stride
}
}
}
+ #[allow(clippy::collapsible_if)]
fn derive_deblock_strength(&mut self, xpos: usize, ypos: usize, size4: usize) {
let blk_pos = (xpos >> 2) + (ypos >> 2) * self.blk_stride;
let mut dblk_pos = self.dblk.get_pos(xpos, ypos);
pub fn rv6_decode_cbp16(br: &mut BitReader, cbs: &RV60Codebooks, subset: usize, qp: u8) -> DecoderResult<u32> {
let cb_set = RV60_QP_TO_IDX[qp as usize];
- let cbp16;
if subset == 0 {
- cbp16 = decode_super_cbp(br, &cbs.cbp8_cb[cb_set])?;
+ decode_super_cbp(br, &cbs.cbp8_cb[cb_set])
} else {
- cbp16 = decode_super_cbp(br, &cbs.cbp16_cb[cb_set][(subset - 1) * 4..][..4])?;
+ decode_super_cbp(br, &cbs.cbp16_cb[cb_set][(subset - 1) * 4..][..4])
}
- Ok(cbp16)
}
pub fn rv6_decode_cu_8x8(br: &mut BitReader, cbs: &RV60Codebooks, is_intra: bool, qp: u8, sel_qp: u8, y_coeffs: &mut [i16; 16 * 16], u_coeffs: &mut [i16; 8 * 8], v_coeffs: &mut [i16; 8 * 8], ccbp: u32, mode4x4: bool) -> DecoderResult<()> {
pub has_ld: bool,
}
+#[allow(clippy::needless_range_loop)]
impl IntraPredContext {
pub fn new() -> Self {
Self {
fn filter_bilin32(dst: &mut [u8], v0: u8, v1: u8, size: usize) {
let diff = (v1 as i16) - (v0 as i16);
let mut sum = ((v0 as i16) << 5) + (1 << (5 - 1));
- for i in 0..size {
- dst[i] = (sum >> 5) as u8;
+ for el in dst[..size].iter_mut() {
+ *el = (sum >> 5) as u8;
sum += diff;
}
}
#[cfg(feature="demuxer_real")]
#[allow(clippy::identity_op)]
-#[allow(clippy::needless_range_loop)]
mod realmedia;
const RM_DEMUXERS: &[&dyn DemuxerCreator] = &[
fn sipro_restore(buf: &mut [u8], factor: usize, fsize: usize) {
let stride = factor * fsize * 2 / 96;
- for i in 0..38 {
- let mut sidx = (RM_SIPRO_SWAPS[i][0] as usize) * stride;
- let mut didx = (RM_SIPRO_SWAPS[i][1] as usize) * stride;
+ for swap in RM_SIPRO_SWAPS.iter() {
+ let mut sidx = (swap[0] as usize) * stride;
+ let mut didx = (swap[1] as usize) * stride;
for _ in 0..stride {
let in0 = buf[sidx >> 1];
let in1 = buf[didx >> 1];
streams.push(RMStreamType::Audio(astr));
Ok(())
}
-#[allow(unused_variables)]
fn parse_video_stream(strmgr: &mut StreamManager, streams: &mut Vec<RMStreamType>, stream_no: u32, src: &mut ByteReader, edata_: &[u8], tag2: u32, duration: u32) -> DemuxerResult<()> {
src.read_skip(4)?;
let fcc = src.read_u32be()?;
let width = src.read_u16be()? as usize;
let height = src.read_u16be()? as usize;
- let bpp = src.read_u16be()?;
- let pad_w = src.read_u16be()?;
- let pad_h = src.read_u16be()?;
- let _fps;
- if tag2 == mktag!('V', 'I', 'D', 'O') {
- _fps = src.read_u32be()?;
- } else {
- _fps = 0x10000;
- }
- let extradata: Option<Vec<u8>>;
- if src.left() > 0 {
- let eslice = &edata_[(src.tell() as usize)..];
- extradata = Some(eslice.to_vec());
- } else {
- extradata = None;
- }
+ let _bpp = src.read_u16be()?;
+ let _pad_w = src.read_u16be()?;
+ let _pad_h = src.read_u16be()?;
+ let _fps = if tag2 == mktag!('V', 'I', 'D', 'O') {
+ src.read_u32be()?
+ } else {
+ 0x10000
+ };
+ let extradata = if src.left() > 0 {
+ let eslice = &edata_[(src.tell() as usize)..];
+ Some(eslice.to_vec())
+ } else {
+ None
+ };
let cname = find_codec_name(RM_VIDEO_CODEC_REGISTER, fcc);
let vhdr = NAVideoInfo::new(width, height, false, RGB24_FORMAT);
streams.push(RMStreamType::Video(vstr));
Ok(())
}
-#[allow(unused_variables)]
- #[allow(clippy::question_mark)]
+ #[allow(clippy::too_many_arguments)]
fn parse_packet_payload(src: &mut ByteReader, rmstream: &mut RMStreamType, stream: NAStreamRef, slice_buf: &mut Vec<u8>, queued_pkts: &mut Vec<NAPacket>, keyframe: bool, ts: u32, payload_size: usize) -> DemuxerResult<NAPacket> {
match rmstream {
RMStreamType::Video(ref mut vstr) => {
let packet_num = hdr1 & 0x7F;
let (_, frame_size) = read_14or30(src)?;
let (_, off) = read_14or30(src)?;
- let seq_no = src.read_byte()?;
+ let _seq_no = src.read_byte()?;
let hdr_skip = (src.tell() - pos) as usize;
let slice_size = payload_size - hdr_skip;
Ok(pkt)
},
1 => { // whole frame
- let seq_no = src.read_byte()?;
+ let _seq_no = src.read_byte()?;
read_video_buf(src, stream, ts, keyframe, payload_size - 2)
},
2 => { // last partial frame
let packet_num = hdr1 & 0x7F;
let (_, frame_size) = read_14or30(src)?;
let (_, tail_size) = read_14or30(src)?;
- let seq_no = src.read_byte()?;
+ let _seq_no = src.read_byte()?;
slice_buf.resize(tail_size as usize, 0);
src.read_buf(slice_buf.as_mut_slice())?;
if packet_num == 1 && frame_size == tail_size {
}
while src.tell() < pos + (payload_size as u64) {
- let res = read_multiple_frame(src, stream.clone(), false, false);
- if res.is_err() { break; }
- queued_pkts.push(res.unwrap());
+ let pkt = read_multiple_frame(src, stream.clone(), false, false)?;
+ queued_pkts.push(pkt);
}
queued_pkts.reverse();
let ts = stream.make_ts(Some(ts as u64), None, None);
Ok(pkt)
},
_ => { // multiple frames
- let res = read_multiple_frame(src, stream.clone(), keyframe, true);
- if res.is_err() { return res; }
+ let pkt0 = read_multiple_frame(src, stream.clone(), keyframe, true)?;
while src.tell() < pos + (payload_size as u64) {
- let res = read_multiple_frame(src, stream.clone(), false, false);
- if res.is_err() { break; }
- queued_pkts.push(res.unwrap());
+ let pkt = read_multiple_frame(src, stream.clone(), false, false)?;
+ queued_pkts.push(pkt);
}
queued_pkts.reverse();
- res
+ Ok(pkt0)
},
}
},
Ok(())
}
-#[allow(unused_variables)]
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
if !self.queued_pkts.is_empty() {
let pkt = self.queued_pkts.pop().unwrap();
if self.cur_data_chunk < self.data_chunks.len() {
let (pos, _, _) = self.data_chunks[self.cur_data_chunk];
self.src.seek(SeekFrom::Start(pos))?;
- let res = read_chunk(self.src);
- if let Ok((id, size, ver)) = res {
+ if let Ok((_id, size, ver)) = read_chunk(self.src) {
self.data_pos = self.src.tell();
self.data_ver = ver;
self.data_end = self.data_pos + (size as u64);
}
}
- #[allow(unused_variables)]
fn seek(&mut self, time: NATimePoint, seek_idx: &SeekIndex) -> DemuxerResult<()> {
self.queued_pkts.clear();
let ret = seek_idx.find_pos(time);
Ok(())
}
-#[allow(unused_variables)]
fn parse_aformat3(src: &mut ByteReader) -> DemuxerResult<RealAudioInfo> {
let start = src.tell();
let header_len = src.read_u16be()?;
})
}
-#[allow(unused_variables)]
fn parse_aformat4(src: &mut ByteReader) -> DemuxerResult<RealAudioInfo> {
let start = src.tell();
src.read_skip(2)?; // zeroes
let id = src.read_u32be()?;
validate!(id == mktag!(b".ra4"));
- let data_size = src.read_u32be()?;
+ let _data_size = src.read_u32be()?;
let _ver4 = src.read_u16be()?; // should be 4
let header_size = src.read_u32be()?;
let flavor = src.read_u16be()?;
})
}
-#[allow(unused_variables)]
fn parse_aformat5(src: &mut ByteReader) -> DemuxerResult<RealAudioInfo> {
let start = src.tell();
src.read_skip(2)?; // zeroes
let id = src.read_u32be()?;
validate!((id == mktag!(b".ra5")) || (id == mktag!(b".ra4")));
- let data_size = src.read_u32be()?;
+ let _data_size = src.read_u32be()?;
let _ver5 = src.read_u16be()?; // should be 5
let header_size = src.read_u32be()?;
let flavor = src.read_u16be()?;
let ileave_factor = src.read_u16be()?;
let frame_size = src.read_u16be()?;
let ileave_block_size = src.read_u16be()?;
- let user_data = src.read_u32be()?;
+ let _user_data = src.read_u32be()?;
let _sample_rate1 = src.read_u16be()?;
let sample_rate = src.read_u32be()?;
let sample_size = src.read_u32be()?;
slice_buf: Vec::new(),
}
}
-#[allow(unused_variables)]
fn read_header(&mut self, strmgr: &mut StreamManager, seek_idx: &mut SeekIndex) -> DemuxerResult<()> {
- let (id, size, ver) = read_chunk(self.src)?;
+ let (id, size, _ver) = read_chunk(self.src)?;
validate!((id == mktag!(b".RMF")) || (id == mktag!(b".RMP")));
validate!(size >= RMVB_HDR_SIZE);
let fver = self.src.read_u32be()?;
let prop_size = if ver == 0 { RMVB_PROP_SIZE } else { RMVB_PROP_SIZE + 4 };
validate!(size >= prop_size);
validate!((ver == 0) || (ver == 2));
- let maxbr = self.src.read_u32be()?;
- let avgbr = self.src.read_u32be()?;
- let maxps = self.src.read_u32be()?;
- let avgps = self.src.read_u32be()?;
- let num_pkt = self.src.read_u32be()? as usize;
- let duration = self.src.read_u32be()?;
- let preroll = self.src.read_u32be()?;
- let idx_off = self.src.read_size(ver)?;
- let data_off = self.src.read_u32be()?;
- let num_streams = self.src.read_u16be()? as usize;
- let flags = self.src.read_u16be()?;
+ let _maxbr = self.src.read_u32be()?;
+ let _avgbr = self.src.read_u32be()?;
+ let _maxps = self.src.read_u32be()?;
+ let _avgps = self.src.read_u32be()?;
+ let _num_pkt = self.src.read_u32be()? as usize;
+ let _duration = self.src.read_u32be()?;
+ let _preroll = self.src.read_u32be()?;
+ let _idx_off = self.src.read_size(ver)?;
+ let _data_off = self.src.read_u32be()?;
+ let _um_streams = self.src.read_u16be()? as usize;
+ let _flags = self.src.read_u16be()?;
if size > prop_size {
self.src.read_skip((size - prop_size) as usize)?;
}
}
Ok(false)
}
-#[allow(unused_variables)]
fn parse_content_desc(&mut self) -> DemuxerResult<()> {
let title_len = self.src.read_u16be()? as usize;
self.src.read_skip(title_len)?;
self.src.read_skip(comment_len)?;
Ok(())
}
-#[allow(unused_variables)]
fn parse_mdpr(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<()> {
let stream_no = self.src.read_u16be()? as u32;
//todo check stream_no for duplicates
- let maxbr = self.src.read_u32be()?;
- let avgbr = self.src.read_u32be()?;
- let maxps = self.src.read_u32be()?;
- let avgps = self.src.read_u32be()?;
- let start = self.src.read_u32be()?;
- let preroll = self.src.read_u32be()?;
+ let _maxbr = self.src.read_u32be()?;
+ let _avgbr = self.src.read_u32be()?;
+ let _maxps = self.src.read_u32be()?;
+ let _avgps = self.src.read_u32be()?;
+ let _start = self.src.read_u32be()?;
+ let _preroll = self.src.read_u32be()?;
let duration = self.src.read_u32be()?;
let sname_size = self.src.read_byte()? as usize;
- let sname = read_string_size(self.src, sname_size)?;
+ let _sname = read_string_size(self.src, sname_size)?;
let mime_size = self.src.read_byte()? as usize;
- let mime = read_string_size(self.src, mime_size)?;
+ let _mime = read_string_size(self.src, mime_size)?;
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![0; edata_size];
}
impl<'a> DemuxCore<'a> for RealAudioDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_idx: &mut SeekIndex) -> DemuxerResult<()> {
let magic = self.src.read_u32be()?;
validate!(magic == mktag!(b".ra\xFD"));
Err(DemuxerError::NoSuchInput)
}
- #[allow(unused_variables)]
- fn seek(&mut self, time: NATimePoint, seek_idx: &SeekIndex) -> DemuxerResult<()> {
+ fn seek(&mut self, _time: NATimePoint, _seek_idx: &SeekIndex) -> DemuxerResult<()> {
Err(NotImplemented)
}
}
impl<'a> DemuxCore<'a> for RealIVRDemuxer<'a> {
- #[allow(unused_variables)]
- fn open(&mut self, strmgr: &mut StreamManager, seek_idx: &mut SeekIndex) -> DemuxerResult<()> {
+ fn open(&mut self, strmgr: &mut StreamManager, _seek_idx: &mut SeekIndex) -> DemuxerResult<()> {
let magic = self.src.peek_u32be()?;
if magic == mktag!(b".REC") {
let mut rec = RecordDemuxer::new(0, 0);
}
}
- #[allow(unused_variables)]
- fn seek(&mut self, time: NATimePoint, seek_idx: &SeekIndex) -> DemuxerResult<()> {
+ fn seek(&mut self, _time: NATimePoint, _seek_idx: &SeekIndex) -> DemuxerResult<()> {
Err(NotImplemented)
}
extern crate nihav_codec_support;
#[cfg(any(feature="decoders", feature="encoders"))]
-#[allow(clippy::cast_lossless)]
-#[allow(clippy::collapsible_if)]
-#[allow(clippy::collapsible_else_if)]
-#[allow(clippy::comparison_chain)]
#[allow(clippy::excessive_precision)]
-#[allow(clippy::identity_op)]
-#[allow(clippy::needless_range_loop)]
#[allow(clippy::single_match)]
-#[allow(clippy::too_many_arguments)]
-#[allow(clippy::unreadable_literal)]
-#[allow(clippy::useless_let_if_seq)]
-#[allow(clippy::needless_late_init)]
#[allow(clippy::upper_case_acronyms)]
-#[allow(clippy::manual_range_contains)]
-#[allow(clippy::wrong_self_convention)]
mod codecs;
#[cfg(feature="decoders")]
pub use crate::codecs::realmedia_register_all_decoders;
pub use crate::codecs::realmedia_register_all_encoders;
#[cfg(feature="demuxers")]
-#[allow(clippy::cast_lossless)]
-#[allow(clippy::too_many_arguments)]
-#[allow(clippy::unreadable_literal)]
-#[allow(clippy::useless_let_if_seq)]
-#[allow(clippy::needless_late_init)]
#[allow(clippy::upper_case_acronyms)]
mod demuxers;
#[cfg(feature="demuxers")]