}
impl NADecoder for MSADPCMDecoder {
+ #[allow(clippy::int_plus_one)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.block_len = ainfo.get_block_len();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
let channels = self.chmap.num_channels();
- validate!(pktbuf.len() > 0 && (pktbuf.len() % self.block_len) == 0);
+ validate!(!pktbuf.is_empty() && (pktbuf.len() % self.block_len) == 0);
let nblocks = pktbuf.len() / self.block_len;
let nsamples = nblocks * self.block_samps;
let abuf = alloc_audio_buffer(self.ainfo, nsamples, self.chmap.clone())?;
impl MSADPCMEncoder {
fn new() -> Self { Self::default() }
fn encode_packet(&mut self) -> EncoderResult<NAPacket> {
- if self.samples.len() == 0 {
+ if self.samples.is_empty() {
return Err(EncoderError::TryAgain);
}
let len = (self.samples.len() / self.channels).min(self.block_len);
NACodecTypeInfo::None => {
let mut ofmt = EncodeParameters::default();
ofmt.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 1, SND_S16_FORMAT, DEFAULT_BLOCK_LEN));
- return Ok(ofmt);
+ Ok(ofmt)
},
- NACodecTypeInfo::Video(_) => return Err(EncoderError::FormatError),
+ NACodecTypeInfo::Video(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Audio(ainfo) => {
let mut outinfo = ainfo;
outinfo.channels = outinfo.channels.min(2);
}
let mut ofmt = *encinfo;
ofmt.format = NACodecTypeInfo::Audio(outinfo);
- return Ok(ofmt);
+ Ok(ofmt)
}
- };
+ }
}
fn init(&mut self, stream_id: u32, encinfo: EncodeParameters) -> EncoderResult<NAStreamRef> {
match encinfo.format {
Err(DecoderError::InvalidData)
}
}
+ #[allow(clippy::identity_op)]
fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let src = pkt.get_buffer();
validate!(src.len() >= 2);
struct Pixel16(u16);
impl Pixel16 {
- fn unpack(&self) -> (u8, u8, u8) {
+ fn unpack(self) -> (u8, u8, u8) {
(((self.0 >> 10) & 0x1F) as u8, ((self.0 >> 5) & 0x1F) as u8, (self.0 & 0x1F) as u8)
}
fn pack(r: u8, g: u8, b: u8) -> Self {
ofmt.format = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, true, RGB555_FORMAT));
Ok(ofmt)
},
- NACodecTypeInfo::Audio(_) => return Err(EncoderError::FormatError),
+ NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
NACodecTypeInfo::Video(vinfo) => {
let outinfo = NAVideoInfo::new((vinfo.width + 3) & !3, (vinfo.height + 3) & !3, true, RGB555_FORMAT);
let mut ofmt = *encinfo;
}
let out_info = NAVideoInfo::new(vinfo.width, vinfo.height, true, RGB555_FORMAT);
- let info = NACodecInfo::new("msvideo1", NACodecTypeInfo::Video(out_info.clone()), None);
+ let info = NACodecInfo::new("msvideo1", NACodecTypeInfo::Video(out_info), None);
let mut stream = NAStream::new(StreamType::Video, stream_id, info, encinfo.tb_num, encinfo.tb_den);
stream.set_num(stream_id as usize);
let stream = stream.into_ref();
- if let Err(_) = self.pool.prealloc_video(out_info, 2) {
+ if self.pool.prealloc_video(out_info, 2).is_err() {
return Err(EncoderError::AllocError);
}
extern crate nihav_core;
extern crate nihav_codec_support;
+#[allow(clippy::needless_range_loop)]
+#[allow(clippy::single_match)]
+#[allow(clippy::verbose_bit_mask)]
mod codecs;
pub use crate::codecs::ms_register_all_codecs;
pub use crate::codecs::ms_register_all_encoders;