X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=videoplayer%2Fsrc%2Fvideodec.rs;fp=videoplayer%2Fsrc%2Fvideodec.rs;h=d385e68a591a6bd5983a3f4e1a88cb4ff20ac56e;hb=bbd6955561e875bf89815e09e2191ca9a98fde8f;hp=6965ae5ef63e1d822e1e97fb1c17dae271b03896;hpb=b452b665dbed05eff9b1560b220fadf1138d9f1d;p=nihav-player.git diff --git a/videoplayer/src/videodec.rs b/videoplayer/src/videodec.rs index 6965ae5..d385e68 100644 --- a/videoplayer/src/videodec.rs +++ b/videoplayer/src/videodec.rs @@ -59,7 +59,7 @@ impl VideoDecoder { self.ifmt.get_format() != vinfo.get_format() { self.ifmt = vinfo; let sc_ifmt = ScaleInfo { width: self.ifmt.get_width(), height: self.ifmt.get_height(), fmt: self.ifmt.get_format() }; - let do_yuv = if let ColorModel::YUV(_) = self.ifmt.get_format().get_model() { true } else { false }; + let do_yuv = self.ifmt.get_format().get_model().is_yuv(); let ofmt = if do_yuv { self.ofmt_yuv } else { self.ofmt_rgb }; self.scaler = NAScale::new(sc_ifmt, ofmt).expect("scaling should not fail"); } @@ -103,7 +103,7 @@ impl VideoDecoder { }, DecoderType::VideoMT(ref mut vdec, ref mut reord) => { let queue_id = reord.register_frame(); - match vdec.queue_pkt(&mut self.dec.dsupp, &pkt, queue_id) { + match vdec.queue_pkt(&mut self.dec.dsupp, pkt, queue_id) { Ok(true) => {}, Ok(false) => { while !vdec.can_take_input() || vdec.has_output() { @@ -119,7 +119,7 @@ impl VideoDecoder { }, }; } - match vdec.queue_pkt(&mut self.dec.dsupp, &pkt, queue_id) { + match vdec.queue_pkt(&mut self.dec.dsupp, pkt, queue_id) { Ok(true) => {}, Ok(false) => { println!("still can't queue frame!"); @@ -383,7 +383,7 @@ impl VideoControl { self.vqueue.len() >= size } pub fn try_send_video(&mut self, evt: PktSendEvent) -> bool { - if self.vqueue.len() > 0 { + if !self.vqueue.is_empty() { self.vqueue.push(evt); false } else { @@ -444,7 +444,7 @@ impl VideoControl { frm.rgb_tex.with_lock(None, |buffer: &mut [u8], pitch: usize| { let csize = sstride.min(pitch); for (dst, src) in buffer.chunks_mut(pitch).zip(src.chunks(sstride)) { - (&mut dst[..csize]).copy_from_slice(&src[..csize]); + dst[..csize].copy_from_slice(&src[..csize]); } true }).expect("surface should be locked");