add flush() to decoder interface
[nihav.git] / nihav-indeo / src / codecs / indeo5.rs
index 98bd34031aad20d432acae4d93297529629af43d..81111647d7d64d175cdc124f9bb9b62a29c54d8f 100644 (file)
@@ -1,5 +1,3 @@
-use std::rc::Rc;
-use std::cell::{Ref, RefCell};
 use nihav_core::io::bitreader::*;
 use nihav_core::formats;
 use nihav_core::frame::*;
@@ -493,7 +491,7 @@ impl IndeoXParser for Indeo5Parser {
 }
 
 struct Indeo5Decoder {
-    info:   Rc<NACodecInfo>,
+    info:   NACodecInfoRef,
     dec:    IVIDecoder,
     ip:     Indeo5Parser,
 }
@@ -509,20 +507,20 @@ impl Indeo5Decoder {
 }
 
 impl NADecoder for Indeo5Decoder {
-    fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+    fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
         if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
             let w = vinfo.get_width();
             let h = vinfo.get_height();
             let f = vinfo.is_flipped();
             let fmt = formats::YUV410_FORMAT;
             let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, f, fmt));
-            self.info = Rc::new(NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()));
+            self.info = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
             Ok(())
         } else {
             Err(DecoderError::InvalidData)
         }
     }
-    fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+    fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
         let src = pkt.get_buffer();
         let mut br = BitReader::new(src.as_slice(), src.len(), BitReaderMode::LE);
 
@@ -530,7 +528,10 @@ impl NADecoder for Indeo5Decoder {
         let mut frm = NAFrame::new_from_pkt(pkt, self.info.clone(), bufinfo);
         frm.set_keyframe(self.dec.is_intra());
         frm.set_frame_type(self.dec.get_frame_type());
-        Ok(Rc::new(RefCell::new(frm)))
+        Ok(frm.into_ref())
+    }
+    fn flush(&mut self) {
+        self.dec.flush();
     }
 }
 
@@ -664,7 +665,7 @@ const INDEO5_Q4_INTRA: &[u16; 16] = &INDEO5_QUANT4X4_INTRA;
 const INDEO5_Q4_INTER: &[u16; 16] = &INDEO5_QUANT4X4_INTER;
 
 const INDEO5_SCAN8X8: [&[usize; 64]; 4] = [
-    &IVI_ZIGZAG, &IVI_SCAN_8X8_VER, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_HOR
+    &ZIGZAG, &IVI_SCAN_8X8_VER, &IVI_SCAN_8X8_HOR, &IVI_SCAN_8X8_HOR
 ];
 const INDEO5_SCAN4X4: &[usize; 16] = &IVI_SCAN_4X4;
 
@@ -713,7 +714,7 @@ const INDEO5_QSCALE4_INTER: [u8; 24] = [
     0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23
 ];
 
-pub fn get_decoder() -> Box<NADecoder> {
+pub fn get_decoder() -> Box<dyn NADecoder> {
     Box::new(Indeo5Decoder::new())
 }