From: Kostya Shishkov Date: Thu, 7 Nov 2024 19:09:00 +0000 (+0100) Subject: nihav_game: fix or update clippy warnings and remove some dead code X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=cb56d1669d51b11e03977a0363c45779cd4c785c;p=nihav.git nihav_game: fix or update clippy warnings and remove some dead code --- diff --git a/nihav-game/src/codecs/bmv.rs b/nihav-game/src/codecs/bmv.rs index 31fd855..ac487b0 100644 --- a/nihav-game/src/codecs/bmv.rs +++ b/nihav-game/src/codecs/bmv.rs @@ -25,6 +25,7 @@ impl<'a> BMVReader<'a> { 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; } @@ -69,6 +70,7 @@ impl<'a> BMVWriter<'a> { 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; } diff --git a/nihav-game/src/codecs/bmv3.rs b/nihav-game/src/codecs/bmv3.rs index 525273d..6d4149f 100644 --- a/nihav-game/src/codecs/bmv3.rs +++ b/nihav-game/src/codecs/bmv3.rs @@ -90,9 +90,9 @@ impl BMV3VideoDecoder { *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; } } @@ -468,12 +468,11 @@ impl NADecoder for BMV3VideoDecoder { 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; diff --git a/nihav-game/src/codecs/ipma.rs b/nihav-game/src/codecs/ipma.rs index fcdeac3..99d4122 100644 --- a/nihav-game/src/codecs/ipma.rs +++ b/nihav-game/src/codecs/ipma.rs @@ -1,3 +1,4 @@ +use std::cmp::Ordering; use nihav_core::codecs::*; use nihav_core::io::bitreader::*; @@ -57,7 +58,6 @@ impl LZWState { Ok(tot_len) } - #[allow(clippy::comparison_chain)] fn decode(&mut self, br: &mut BitReader, dst: &mut [u8]) -> DecoderResult<()> { self.reset(); @@ -73,23 +73,25 @@ impl LZWState { 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 { diff --git a/nihav-game/src/codecs/lhst500f22.rs b/nihav-game/src/codecs/lhst500f22.rs index 8590492..b65341f 100644 --- a/nihav-game/src/codecs/lhst500f22.rs +++ b/nihav-game/src/codecs/lhst500f22.rs @@ -39,9 +39,9 @@ impl LHDecoder { } } 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(()) diff --git a/nihav-game/src/codecs/midivid.rs b/nihav-game/src/codecs/midivid.rs index fec4cd6..1e3b858 100644 --- a/nihav-game/src/codecs/midivid.rs +++ b/nihav-game/src/codecs/midivid.rs @@ -143,14 +143,13 @@ impl NADecoder for MidividDecoder { 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(); diff --git a/nihav-game/src/codecs/mod.rs b/nihav-game/src/codecs/mod.rs index ba1ce15..ddf10c3 100644 --- a/nihav-game/src/codecs/mod.rs +++ b/nihav-game/src/codecs/mod.rs @@ -25,6 +25,7 @@ pub mod ipma; #[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; @@ -43,6 +44,7 @@ pub mod smush; #[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; diff --git a/nihav-game/src/codecs/smush/v1.rs b/nihav-game/src/codecs/smush/v1.rs index 40e6008..dbee752 100644 --- a/nihav-game/src/codecs/smush/v1.rs +++ b/nihav-game/src/codecs/smush/v1.rs @@ -272,8 +272,8 @@ self.height = (self.height + 7) & !7; 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; @@ -478,7 +478,6 @@ impl Smush1Decoder { 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); diff --git a/nihav-game/src/codecs/vmd.rs b/nihav-game/src/codecs/vmd.rs index bbca21e..06cc63b 100644 --- a/nihav-game/src/codecs/vmd.rs +++ b/nihav-game/src/codecs/vmd.rs @@ -220,16 +220,15 @@ impl VMDVideoDecoder { 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) } } diff --git a/nihav-game/src/codecs/vx.rs b/nihav-game/src/codecs/vx.rs index 82aca2a..0a8de06 100644 --- a/nihav-game/src/codecs/vx.rs +++ b/nihav-game/src/codecs/vx.rs @@ -146,13 +146,12 @@ fn pred_dc(buf: &mut [u8], mut pos: usize, x: usize, y: usize, w: usize, h: usiz 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; } @@ -173,11 +172,10 @@ fn pred_dc4x4(buf: &mut [u8], mut pos: usize, x: usize, y: usize) { 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; } } @@ -1415,6 +1413,7 @@ impl AudioState { 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); diff --git a/nihav-game/src/demuxers/bmv.rs b/nihav-game/src/demuxers/bmv.rs index 66f1df9..d276897 100644 --- a/nihav-game/src/demuxers/bmv.rs +++ b/nihav-game/src/demuxers/bmv.rs @@ -11,10 +11,7 @@ struct BMVDemuxer<'a> { } 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); @@ -114,8 +111,6 @@ struct BMV3Demuxer<'a> { } 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; diff --git a/nihav-game/src/demuxers/fst.rs b/nihav-game/src/demuxers/fst.rs index f71601e..64b777d 100644 --- a/nihav-game/src/demuxers/fst.rs +++ b/nihav-game/src/demuxers/fst.rs @@ -1,7 +1,6 @@ use nihav_core::frame::*; use nihav_core::demuxers::*; -#[allow(dead_code)] struct FutureVisionVideoDemuxer<'a> { src: &'a mut ByteReader<'a>, cur_frame: usize, @@ -14,7 +13,6 @@ struct FutureVisionVideoDemuxer<'a> { } 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; @@ -53,7 +51,6 @@ impl<'a> DemuxCore<'a> for FutureVisionVideoDemuxer<'a> { Ok(()) } - #[allow(unused_variables)] fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { if self.cur_frame >= self.vsize.len() { return Err(DemuxerError::EOF); } let (id, size, pts) = if self.vframe { @@ -111,7 +108,6 @@ impl DemuxerCreator for FSTDemuxerCreator { fn get_name(&self) -> &'static str { "fst" } } -#[allow(dead_code)] struct FutureVisionAudioDemuxer<'a> { src: &'a mut ByteReader<'a>, a_id: usize, @@ -120,7 +116,6 @@ struct FutureVisionAudioDemuxer<'a> { } 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; @@ -140,7 +135,6 @@ impl<'a> DemuxCore<'a> for FutureVisionAudioDemuxer<'a> { Ok(()) } - #[allow(unused_variables)] fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { if self.src.tell() >= self.end { return Err(DemuxerError::EOF); } let size = (self.end - self.src.tell()).min(0x2000) as usize; diff --git a/nihav-game/src/demuxers/gdv.rs b/nihav-game/src/demuxers/gdv.rs index 8ae27c6..fc25600 100644 --- a/nihav-game/src/demuxers/gdv.rs +++ b/nihav-game/src/demuxers/gdv.rs @@ -7,7 +7,6 @@ enum GDVState { AudioRead, } -#[allow(dead_code)] struct GremlinVideoDemuxer<'a> { src: &'a mut ByteReader<'a>, frames: u16, @@ -15,7 +14,6 @@ struct GremlinVideoDemuxer<'a> { asize: usize, apacked: bool, state: GDVState, - pktdta: Vec, a_id: Option, v_id: Option, } @@ -47,7 +45,6 @@ const GDV_SIZE_TABLE: &[GDVFixedSizes] = &[ ]; 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()?; @@ -101,7 +98,6 @@ impl<'a> DemuxCore<'a> for GremlinVideoDemuxer<'a> { Ok(()) } - #[allow(unused_variables)] fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { if self.cur_frame >= self.frames { return Err(DemuxerError::EOF); } match self.state { @@ -120,11 +116,6 @@ impl<'a> NAOptionHandler for GremlinVideoDemuxer<'a> { fn set_options(&mut self, _options: &[NAOption]) { } fn query_option_value(&self, _name: &str) -> Option { 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 { @@ -133,7 +124,6 @@ impl<'a> GremlinVideoDemuxer<'a> { asize: 0, apacked: false, state: GDVState::NewFrame, -pktdta: Vec::new(), src: io, a_id: None, v_id: None, diff --git a/nihav-game/src/demuxers/mod.rs b/nihav-game/src/demuxers/mod.rs index b9cdcb1..c01a4ae 100644 --- a/nihav-game/src/demuxers/mod.rs +++ b/nihav-game/src/demuxers/mod.rs @@ -25,6 +25,7 @@ mod seq; #[cfg(feature="demuxer_sga")] mod sga; #[cfg(feature="demuxer_siff")] +#[allow(clippy::upper_case_acronyms)] mod siff; #[cfg(feature="demuxer_smush")] mod smush; diff --git a/nihav-game/src/demuxers/q.rs b/nihav-game/src/demuxers/q.rs index ebd93b2..a694e1d 100644 --- a/nihav-game/src/demuxers/q.rs +++ b/nihav-game/src/demuxers/q.rs @@ -1,7 +1,6 @@ use nihav_core::frame::*; use nihav_core::demuxers::*; -#[allow(dead_code)] struct QDemuxer<'a> { src: &'a mut ByteReader<'a>, vpts: u64, @@ -15,7 +14,6 @@ struct QDemuxer<'a> { } 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; @@ -24,7 +22,7 @@ impl<'a> DemuxCore<'a> for QDemuxer<'a> { 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 { diff --git a/nihav-game/src/demuxers/rbt.rs b/nihav-game/src/demuxers/rbt.rs index 9f6da60..c2ee3e2 100644 --- a/nihav-game/src/demuxers/rbt.rs +++ b/nihav-game/src/demuxers/rbt.rs @@ -3,7 +3,6 @@ use nihav_core::demuxers::*; const AFRAME_HDR_SIZE: usize = 16; -#[allow(dead_code)] struct RobotDemuxer<'a> { src: &'a mut ByteReader<'a>, version: u16, @@ -21,7 +20,6 @@ struct RobotDemuxer<'a> { } 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)?; diff --git a/nihav-game/src/demuxers/seq.rs b/nihav-game/src/demuxers/seq.rs index ae5b099..cbd1bdc 100644 --- a/nihav-game/src/demuxers/seq.rs +++ b/nihav-game/src/demuxers/seq.rs @@ -8,7 +8,6 @@ struct SequenceDemuxer<'a> { } 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; diff --git a/nihav-game/src/demuxers/vmd.rs b/nihav-game/src/demuxers/vmd.rs index cf73654..d5c9753 100644 --- a/nihav-game/src/demuxers/vmd.rs +++ b/nihav-game/src/demuxers/vmd.rs @@ -31,7 +31,6 @@ struct VMDDemuxer<'a> { } 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; @@ -68,7 +67,7 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { 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..])?); @@ -109,15 +108,15 @@ impl<'a> DemuxCore<'a> for VMDDemuxer<'a> { let idx_off = u64::from(read_u32le(&header[812..])?); src.seek(SeekFrom::Start(idx_off))?; let mut offs: Vec = 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)?; diff --git a/nihav-game/src/demuxers/vx.rs b/nihav-game/src/demuxers/vx.rs index 7bc60e8..f46597e 100644 --- a/nihav-game/src/demuxers/vx.rs +++ b/nihav-game/src/demuxers/vx.rs @@ -26,8 +26,6 @@ struct VXDemuxer<'a> { } 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; @@ -105,7 +103,6 @@ impl<'a> DemuxCore<'a> for VXDemuxer<'a> { Ok(()) } - #[allow(dead_code)] fn get_frame(&mut self, strmgr: &mut StreamManager) -> DemuxerResult { if self.apkt.is_some() { let mut ret = None; diff --git a/nihav-game/src/lib.rs b/nihav-game/src/lib.rs index 2a568d9..bec2b58 100644 --- a/nihav-game/src/lib.rs +++ b/nihav-game/src/lib.rs @@ -2,22 +2,9 @@ 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; diff --git a/nihav-game/src/muxers/ea.rs b/nihav-game/src/muxers/ea.rs index 4da1fc6..8a48165 100644 --- a/nihav-game/src/muxers/ea.rs +++ b/nihav-game/src/muxers/ea.rs @@ -19,8 +19,6 @@ impl<'a> EAMuxer<'a> { } 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);