]> git.nihav.org Git - nihav-player.git/blobdiff - videoplayer/src/videodec.rs
videoplayer: print hurry up mode
[nihav-player.git] / videoplayer / src / videodec.rs
index d30f45fbd8cfafe67067625c4d90e0f4e53b58b7..7ebf17710fb7e2c38efacfbd18487920b74a3304 100644 (file)
@@ -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() {
@@ -113,17 +113,22 @@ impl VideoDecoder {
                                 },
                                 (Err(err), id) => {
                                     reord.drop_frame(id);
-                                    panic!("frame {} decoding error {:?}", id, err);
+                                    if err != DecoderError::MissingReference {
+                                        println!("frame {} decoding error {:?}", id, err);
+                                    }
                                 },
                             };
                         }
-                        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) => panic!("still can't queue frame!"),
-                            Err(err) => panic!("queueing error {:?}", err),
+                            Ok(false) => {
+                                println!("still can't queue frame!");
+                                VDEC_STATE.set_state(DecodingState::Error);
+                            },
+                            Err(err) => println!("queueing error {:?}", err),
                         };
                     },
-                    Err(err) => panic!("queueing error {:?}", err),
+                    Err(err) => println!("queueing error {:?}", err),
                 };
                 while let Some(frm) = reord.get_frame() {
                     let bt = frm.get_buffer();
@@ -156,7 +161,9 @@ impl VideoDecoder {
                         },
                         (Err(err), id) => {
                             reord.drop_frame(id);
-                            panic!("frame {} decoding error {:?}", id, err);
+                            if err != DecoderError::MissingReference {
+                                println!("frame {} decoding error {:?}", id, err);
+                            }
                         },
                     };
                 }
@@ -168,7 +175,9 @@ impl VideoDecoder {
                         (Err(DecoderError::NoFrame), _) => {},
                         (Err(err), id) => {
                             reord.drop_frame(id);
-                            panic!("frame {} decoding error {:?}", id, err);
+                            if err != DecoderError::MissingReference {
+                                println!("frame {} decoding error {:?}", id, err);
+                            }
                         },
                     };
                 }
@@ -265,6 +274,7 @@ fn start_video_decoding(width: usize, height: usize, tb_num: u32, tb_den: u32, v
                     Ok(PktSendEvent::HurryUp) => {
                         skip_mode = skip_mode.advance();
                         if let DecoderType::Video(ref mut dec, ref mut _reord) = vdec.dec.dec {
+                            println!("setting hurry up mode to {}", skip_mode.to_string());
                             dec.set_options(&[NAOption{
                                 name: FRAME_SKIP_OPTION,
                                 value: NAValue::String(skip_mode.to_string()),
@@ -374,7 +384,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 {
@@ -435,7 +445,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");