switch NACodecInfo to Arc
[nihav.git] / nihav-game / src / codecs / vmd.rs
index a70ef6044e2518a3e47af225e3ae8b05ec556502..dc831c4fb8200834e1eb8e2af4fded93f25c6ebe 100644 (file)
@@ -147,7 +147,7 @@ fn decode_frame_data(br: &mut ByteReader, dst: &mut [u8], mut dpos: usize, strid
 }
 
 struct VMDVideoDecoder {
-    info:       Rc<NACodecInfo>,
+    info:       NACodecInfoRef,
     pal:        [u8; 768],
     buf:        Vec<u8>,
     width:      usize,
@@ -158,7 +158,7 @@ struct VMDVideoDecoder {
 impl VMDVideoDecoder {
     fn new() -> Self {
         Self {
-            info:       Rc::new(NACodecInfo::default()),
+            info:       NACodecInfoRef::default(),
             pal:        [0; 768],
             buf:        Vec::new(),
             width:      0,
@@ -169,7 +169,7 @@ impl VMDVideoDecoder {
     fn decode_frame(&mut self, br: &mut ByteReader, buf: &mut NAVideoBuffer<u8>) -> DecoderResult<bool> {
         let paloff = buf.get_offset(1);
         let stride = buf.get_stride(0);
-        let mut data = buf.get_data_mut();
+        let data = buf.get_data_mut().unwrap();
         let dst = data.as_mut_slice();
 
         let frame_x                             = br.read_u16le()? as usize;
@@ -215,12 +215,12 @@ impl VMDVideoDecoder {
 }
 
 impl NADecoder for VMDVideoDecoder {
-    fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+    fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
         if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
             self.width  = vinfo.get_width();
             self.height = vinfo.get_height();
             let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(self.width, self.height, false, PAL8_FORMAT));
-            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();
             validate!(info.get_extradata().is_some());
 
             if let Some(ref edata) = info.get_extradata() {
@@ -351,7 +351,7 @@ impl VMDAudioDecoder {
 }
 
 impl NADecoder for VMDAudioDecoder {
-    fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+    fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
         if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
             let fmt;
             if ainfo.get_format().get_bits() == 8 {
@@ -398,11 +398,11 @@ impl NADecoder for VMDAudioDecoder {
             if self.is16bit {
                 let mut adata = abuf.get_abuf_i16().unwrap();
                 let off1 = adata.get_offset(1);
-                let mut dst = adata.get_data_mut();
+                let mut dst = adata.get_data_mut().unwrap();
                 self.decode_16bit(&mut dst, off1, &mut br, nblocks, mask)?;
             } else {
                 let mut adata = abuf.get_abuf_u8().unwrap();
-                let mut dst = adata.get_data_mut();
+                let dst = adata.get_data_mut().unwrap();
                 let mut doff = 0;
                 let mut mask = mask;
                 let channels = self.chmap.num_channels();