let pos = if fwd { 0 } else { src.len() - 1 };
Self { src, pos, fwd, nibble: 0, saved: false }
}
+ #[allow(clippy::collapsible_else_if)]
fn advance(&mut self) {
if self.fwd {
if self.pos < self.src.len() - 1 { self.pos += 1; }
self.pos == 0
}
}
+ #[allow(clippy::collapsible_else_if)]
fn advance(&mut self) {
if self.fwd {
if self.pos < self.data.len() - 1 { self.pos += 1; }
*el = i as u16;
}
let mut pixbuf = [[0u16; 256]; 7];
- for i in 0..7 {
- for j in 0..256 {
- pixbuf[i][j] = ((i << 8) + j + 0xF8) as u16;
+ for (i, row) in pixbuf.iter_mut().enumerate() {
+ for (j, el) in row.iter_mut().enumerate() {
+ *el = ((i << 8) + j + 0xF8) as u16;
}
}
if (flags & BMV_PAL) != 0 {
return Err(DecoderError::InvalidData);
}
- let off;
- if ((flags & 1) == 0) && ((flags & BMV_SCROLL) != 0) {
- off = br.read_u16le()? as usize;
- } else {
- off = 0;
- }
+ let off = if ((flags & 1) == 0) && ((flags & BMV_SCROLL) != 0) {
+ br.read_u16le()? as usize
+ } else {
+ 0
+ };
self.pos = off + self.stride;
self.is_intra = (flags & BMV_INTRA) == BMV_INTRA;
+use std::cmp::Ordering;
use nihav_core::codecs::*;
use nihav_core::io::bitreader::*;
Ok(tot_len)
}
- #[allow(clippy::comparison_chain)]
fn decode(&mut self, br: &mut BitReader, dst: &mut [u8]) -> DecoderResult<()> {
self.reset();
if idx == 257 {
break;
}
- if idx < self.dict_pos {
- let len = self.decode_idx(dst, pos, idx)?;
- if lastidx != INVALID_POS {
- self.add(lastidx, dst[pos]);
- }
- pos += len;
- } else if idx == self.dict_pos {
- validate!(lastidx != INVALID_POS);
- let len = self.decode_idx(dst, pos, lastidx)?;
- let lastsym = dst[pos];
- pos += len;
- validate!(pos < dst.len());
- dst[pos] = lastsym;
- pos += 1;
- self.add(lastidx, lastsym);
- } else {
- return Err(DecoderError::InvalidData);
+ match idx.cmp(&self.dict_pos) {
+ Ordering::Less => {
+ let len = self.decode_idx(dst, pos, idx)?;
+ if lastidx != INVALID_POS {
+ self.add(lastidx, dst[pos]);
+ }
+ pos += len;
+ },
+ Ordering::Equal => {
+ validate!(lastidx != INVALID_POS);
+ let len = self.decode_idx(dst, pos, lastidx)?;
+ let lastsym = dst[pos];
+ pos += len;
+ validate!(pos < dst.len());
+ dst[pos] = lastsym;
+ pos += 1;
+ self.add(lastidx, lastsym);
+ },
+ Ordering::Greater => return Err(DecoderError::InvalidData),
}
lastidx = idx;
if self.dict_pos == self.dict_lim && self.idx_bits < MAX_BITS {
}
}
fn unpack_bitalloc(&mut self, br: &mut BitReader) -> DecoderResult<()> {
- for i in 0..3 {
- for sb in 0..32 {
- self.bitalloc[i][sb] = br.read(BITALLOC_INFO[sb])? as u8;
+ for bitalloc_row in self.bitalloc.iter_mut() {
+ for (ba, &bits) in bitalloc_row.iter_mut().zip(BITALLOC_INFO.iter()) {
+ *ba = br.read(bits)? as u8;
}
}
Ok(())
let size = read_u32le(&src[0..])? as usize;
validate!(size + 8 == src.len());
- let data_ptr;
validate!(src.len() > 12);
- if read_u32le(&src[8..])? == 0 {
- lz_decompress(&src[12..], self.lzbuf.as_mut_slice())?;
- data_ptr = self.lzbuf.as_slice();
- } else {
- data_ptr = &src[12..];
- }
+ let data_ptr = if read_u32le(&src[8..])? == 0 {
+ lz_decompress(&src[12..], self.lzbuf.as_mut_slice())?;
+ self.lzbuf.as_slice()
+ } else {
+ &src[12..]
+ };
let mut buf;
let bufret = self.hams.clone_ref();
#[cfg(feature="decoder_kmvc")]
pub mod kmvc;
#[cfg(feature="decoder_lhst500f22")]
+#[allow(clippy::excessive_precision)]
pub mod lhst500f22;
#[cfg(feature="decoder_midivid")]
pub mod midivid;
#[cfg(feature="decoder_vmd")]
pub mod vmd;
#[cfg(feature="decoder_vx")]
+#[allow(clippy::collapsible_else_if)]
#[allow(clippy::erasing_op)]
#[allow(clippy::identity_op)]
pub mod vx;
fn do_mc(dst: &mut [u8], src: &[u8], stride: usize, xoff: isize, yoff: isize, w: usize, h: usize) {
let mut pos = xoff + yoff * (stride as isize);
for row in dst.chunks_mut(stride).take(4) {
- for i in 0..4 {
- row[i] = if pos >= 0 && (pos as usize) < w + (h - 1) * stride {
+ for el in row[..4].iter_mut() {
+ *el = if pos >= 0 && (pos as usize) < w + (h - 1) * stride {
src[pos as usize]
} else { 0 };
pos += 1;
Ok(())
}
- #[allow(clippy::verbose_bit_mask)]
fn decode_2(&mut self, br: &mut ByteReader, x: i16, y: i16, _w: usize, _h: usize, len: usize) -> DecoderResult<()> {
validate!((len & 3) == 0);
let dpos = (frame_x - self.xoff) * bpp + (frame_y - self.yoff) * stride;
let method = br.read_byte()?;
- let is_intra;
- if (method & 0x80) != 0 {
- validate!(!self.buf.is_empty());
- lz_unpack(br, &mut self.buf)?;
- let mut mr = MemoryReader::new_read(&self.buf);
- let mut buf_br = ByteReader::new(&mut mr);
- is_intra = decode_frame_data(&mut buf_br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?;
- } else {
- is_intra = decode_frame_data(br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?;
- }
+ let is_intra = if (method & 0x80) != 0 {
+ validate!(!self.buf.is_empty());
+ lz_unpack(br, &mut self.buf)?;
+ let mut mr = MemoryReader::new_read(&self.buf);
+ let mut buf_br = ByteReader::new(&mut mr);
+ decode_frame_data(&mut buf_br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?
+ } else {
+ decode_frame_data(br, &mut self.framebuf, dpos, stride, w, h, method & 0x7F)?
+ };
Ok(is_intra && frame_x == 0 && frame_y == 0 && w == self.width && h == self.height)
}
}
pos += 256;
}
}
-fn pred_dc4x4(buf: &mut [u8], mut pos: usize, x: usize, y: usize) {
+fn pred_dc4x4(buf: &mut [u8], pos: usize, x: usize, y: usize) {
if x == 0 && y == 0 {
- for _ in 0..4 {
- for x in 0..4 {
- buf[x] = 0x80;
+ for line in buf[pos..].chunks_mut(256).take(4) {
+ for el in line[..4].iter_mut() {
+ *el = 0x80;
}
- pos += 256;
}
return;
}
shift += 1;
}
let dc = (sum >> shift) as u8;
- for _ in 0..4 {
- for x in 0..4 {
- buf[pos + x] = dc;
+ for line in buf[pos..].chunks_mut(256).take(4) {
+ for el in line[..4].iter_mut() {
+ *el = dc;
}
- pos += 256;
}
}
apply_lpc(out, &self.pulse_buf, &mut self.lpc_hist, &self.cur_filt);
Ok(())
}
+ #[allow(clippy::needless_range_loop)]
fn decode_inter(&mut self, br: &mut ByteReader, val: u16, mode: u16, out: &mut [i32; 128]) -> DecoderResult<()> {
let (part0, part1) = self.pulse_hist.split_at_mut(128);
part0.copy_from_slice(part1);
}
impl<'a> DemuxCore<'a> for BMVDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
- let src = &mut self.src;
-
let vhdr = NAVideoInfo::new(640, 429, false, PAL8_FORMAT);
let vci = NACodecTypeInfo::Video(vhdr);
let vinfo = NACodecInfo::new("bmv-video", vci, None);
}
impl<'a> DemuxCore<'a> for BMV3Demuxer<'a> {
- #[allow(unused_variables)]
- #[allow(clippy::cast_lossless)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
use nihav_core::frame::*;
use nihav_core::demuxers::*;
-#[allow(dead_code)]
struct FutureVisionVideoDemuxer<'a> {
src: &'a mut ByteReader<'a>,
cur_frame: usize,
}
impl<'a> DemuxCore<'a> for FutureVisionVideoDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
Ok(())
}
- #[allow(unused_variables)]
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
if self.cur_frame >= self.vsize.len() { return Err(DemuxerError::EOF); }
let (id, size, pts) = if self.vframe {
fn get_name(&self) -> &'static str { "fst" }
}
-#[allow(dead_code)]
struct FutureVisionAudioDemuxer<'a> {
src: &'a mut ByteReader<'a>,
a_id: usize,
}
impl<'a> DemuxCore<'a> for FutureVisionAudioDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
Ok(())
}
- #[allow(unused_variables)]
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
if self.src.tell() >= self.end { return Err(DemuxerError::EOF); }
let size = (self.end - self.src.tell()).min(0x2000) as usize;
AudioRead,
}
-#[allow(dead_code)]
struct GremlinVideoDemuxer<'a> {
src: &'a mut ByteReader<'a>,
frames: u16,
asize: usize,
apacked: bool,
state: GDVState,
- pktdta: Vec<u8>,
a_id: Option<usize>,
v_id: Option<usize>,
}
];
impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
let magic = src.read_u32le()?;
Ok(())
}
- #[allow(unused_variables)]
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
if self.cur_frame >= self.frames { return Err(DemuxerError::EOF); }
match self.state {
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
-/*impl<'a> Drop for GremlinVideoDemuxer<'a> {
- #[allow(unused_variables)]
- fn drop(&mut self) {
- }
-}*/
impl<'a> GremlinVideoDemuxer<'a> {
fn new(io: &'a mut ByteReader<'a>) -> Self {
GremlinVideoDemuxer {
asize: 0,
apacked: false,
state: GDVState::NewFrame,
-pktdta: Vec::new(),
src: io,
a_id: None,
v_id: None,
#[cfg(feature="demuxer_sga")]
mod sga;
#[cfg(feature="demuxer_siff")]
+#[allow(clippy::upper_case_acronyms)]
mod siff;
#[cfg(feature="demuxer_smush")]
mod smush;
use nihav_core::frame::*;
use nihav_core::demuxers::*;
-#[allow(dead_code)]
struct QDemuxer<'a> {
src: &'a mut ByteReader<'a>,
vpts: u64,
}
impl<'a> DemuxCore<'a> for QDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
validate!(hdr[0] == 0x39);
validate!(hdr[1] == 0x68);
let version = hdr[2];
- validate!(version >= 3 && version <= 7);
+ validate!((3..=7).contains(&version));
let mut width = read_u16le(&hdr[4..])? as usize;
let mut height = read_u16le(&hdr[6..])? as usize;
if version > 3 {
const AFRAME_HDR_SIZE: usize = 16;
-#[allow(dead_code)]
struct RobotDemuxer<'a> {
src: &'a mut ByteReader<'a>,
version: u16,
}
impl<'a> DemuxCore<'a> for RobotDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let mut hdr = [0; 60];
self.src.read_buf(&mut hdr)?;
}
impl<'a> DemuxCore<'a> for SequenceDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
}
impl<'a> DemuxCore<'a> for VMDDemuxer<'a> {
- #[allow(unused_variables)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
src.read_u16le()?
} else { 0 };
if is_ext_audio {
- validate!(ext_audio_id >= 3 && ext_audio_id <= 6);
+ validate!((3..=6).contains(&ext_audio_id));
self.is_lhaud = true;
}
let srate = u32::from(read_u16le(&header[804..])?);
let idx_off = u64::from(read_u32le(&header[812..])?);
src.seek(SeekFrom::Start(idx_off))?;
let mut offs: Vec<u32> = Vec::with_capacity(nframes);
- for i in 0..nframes {
+ for _ in 0..nframes {
let _flags = src.read_u16le()?;
let off = src.read_u32le()?;
offs.push(off);
}
self.frames.reserve(nframes * fpb);
let mut ats = adelay;
- for i in 0..nframes {
- let mut off = offs[i];
+ for (i, &offset) in offs.iter().enumerate() {
+ let mut off = offset;
for _ in 0..fpb {
let chtype = src.read_byte()?;
src.read_skip(1)?;
}
impl<'a> DemuxCore<'a> for VXDemuxer<'a> {
- #[allow(unused_variables)]
- #[allow(clippy::cast_lossless)]
fn open(&mut self, strmgr: &mut StreamManager, _seek_index: &mut SeekIndex) -> DemuxerResult<()> {
let src = &mut self.src;
Ok(())
}
- #[allow(dead_code)]
fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<NAPacket> {
if self.apkt.is_some() {
let mut ret = None;
extern crate nihav_core;
extern crate nihav_codec_support;
-#[allow(clippy::collapsible_if)]
-#[allow(clippy::collapsible_else_if)]
-#[allow(clippy::excessive_precision)]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::manual_range_contains)]
-#[allow(clippy::unreadable_literal)]
-#[allow(clippy::useless_let_if_seq)]
#[allow(clippy::upper_case_acronyms)]
-#[allow(clippy::needless_late_init)]
mod codecs;
pub use crate::codecs::game_register_all_decoders;
-#[allow(clippy::collapsible_if)]
-#[allow(clippy::needless_range_loop)]
-#[allow(clippy::unreadable_literal)]
-#[allow(clippy::manual_range_contains)]
-#[allow(clippy::upper_case_acronyms)]
mod demuxers;
pub use crate::demuxers::game_register_all_demuxers;
}
impl<'a> MuxCore<'a> for EAMuxer<'a> {
- #[allow(clippy::unreadable_literal)]
- #[allow(clippy::cast_lossless)]
fn create(&mut self, strmgr: &StreamManager) -> MuxerResult<()> {
if strmgr.get_num_streams() == 0 {
return Err(MuxerError::InvalidArgument);