aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-game/src
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2019-04-29 13:02:12 +0200
committerKostya Shishkov <kostya.shishkov@gmail.com>2019-04-29 13:02:12 +0200
commit2422d9699cd56cbb86ac32b3e8dd026e20a89db5 (patch)
treece89fa9df27f1fb2ee52574f9b7b7d90a7739f23 /nihav-game/src
parentcd830591a8770b4a56ce9b938574adcee3ed33f5 (diff)
downloadnihav-2422d9699cd56cbb86ac32b3e8dd026e20a89db5.tar.gz
switch NACodecInfo to Arc
Diffstat (limited to 'nihav-game/src')
-rw-r--r--nihav-game/src/codecs/bmv.rs11
-rw-r--r--nihav-game/src/codecs/bmv3.rs11
-rw-r--r--nihav-game/src/codecs/gremlinvideo.rs13
-rw-r--r--nihav-game/src/codecs/vmd.rs10
4 files changed, 20 insertions, 25 deletions
diff --git a/nihav-game/src/codecs/bmv.rs b/nihav-game/src/codecs/bmv.rs
index 46e5f65..79b8745 100644
--- a/nihav-game/src/codecs/bmv.rs
+++ b/nihav-game/src/codecs/bmv.rs
@@ -101,16 +101,15 @@ impl<'a> BMVWriter<'a> {
}
struct BMVVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
pal: [u8; 768],
frame: [u8; FRAME_W * FRAME_H],
}
impl BMVVideoDecoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
Self {
- info: dummy_info, pal: [0; 768], frame: [0; FRAME_W * FRAME_H],
+ info: NACodecInfoRef::default(), pal: [0; 768], frame: [0; FRAME_W * FRAME_H],
}
}
fn decode_frame(&mut self, src: &[u8], bufinfo: &mut NABufferType, line: i16) -> DecoderResult<()> {
@@ -170,7 +169,7 @@ impl BMVVideoDecoder {
}
impl NADecoder for BMVVideoDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(_vinfo) = info.get_properties() {
let fmt = NAPixelFormaton::new(ColorModel::RGB(RGBSubmodel::RGB),
Some(NAPixelChromaton::new(0, 0, true, 8, 0, 0, 3)),
@@ -179,7 +178,7 @@ impl NADecoder for BMVVideoDecoder {
None, None,
FORMATON_FLAG_PALETTE, 3);
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(FRAME_W, FRAME_H, false, 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 {
@@ -258,7 +257,7 @@ fn scale_sample(samp: u8, scale: i32) -> i16 {
}
impl NADecoder for BMVAudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), ainfo.get_channels(), formats::SND_S16P_FORMAT, 32);
self.chmap = NAChannelMap::from_str("L,R").unwrap();
diff --git a/nihav-game/src/codecs/bmv3.rs b/nihav-game/src/codecs/bmv3.rs
index 099f070..687ca23 100644
--- a/nihav-game/src/codecs/bmv3.rs
+++ b/nihav-game/src/codecs/bmv3.rs
@@ -69,7 +69,7 @@ impl NibbleReader {
}
struct BMV3VideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
stride: usize,
height: usize,
frame: Vec<u16>,
@@ -85,7 +85,6 @@ struct BMV3VideoDecoder {
impl BMV3VideoDecoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
let mut frame1 = Vec::with_capacity(BMV_MAX_SIZE);
frame1.resize(BMV_MAX_SIZE, 0);
let mut frame2 = Vec::with_capacity(BMV_MAX_SIZE);
@@ -103,7 +102,7 @@ impl BMV3VideoDecoder {
}
Self {
- info: dummy_info,
+ info: NACodecInfoRef::default(),
stride: 0,
height: 0,
frame: frame1,
@@ -442,10 +441,10 @@ impl BMV3VideoDecoder {
}
impl NADecoder for BMV3VideoDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(vinfo.get_width(), vinfo.get_height(), false, RGB565_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();
self.stride = vinfo.get_width();
self.height = vinfo.get_height();
@@ -553,7 +552,7 @@ fn decode_block(mode: u8, src: &[u8], dst: &mut [i16], mut pred: i16) -> i16 {
}
impl NADecoder for BMV3AudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), ainfo.get_channels(), formats::SND_S16P_FORMAT, 32);
self.chmap = NAChannelMap::from_str("L,R").unwrap();
diff --git a/nihav-game/src/codecs/gremlinvideo.rs b/nihav-game/src/codecs/gremlinvideo.rs
index 9dd67ca..cf7f7b1 100644
--- a/nihav-game/src/codecs/gremlinvideo.rs
+++ b/nihav-game/src/codecs/gremlinvideo.rs
@@ -1,5 +1,3 @@
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::frame::*;
use nihav_core::formats;
use nihav_core::formats::{NAChannelType, NAChannelMap};
@@ -7,7 +5,7 @@ use nihav_core::codecs::*;
use nihav_core::io::byteio::*;
struct GremlinVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
pal: [u8; 768],
frame: Vec<u8>,
scale_v: bool,
@@ -61,9 +59,8 @@ impl Bits32 {
impl GremlinVideoDecoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
GremlinVideoDecoder {
- info: dummy_info, pal: [0; 768], frame: Vec::new(),
+ info: NACodecInfoRef::default(), pal: [0; 768], frame: Vec::new(),
scale_v: false, scale_h: false
}
}
@@ -374,14 +371,14 @@ impl GremlinVideoDecoder {
}
impl NADecoder for GremlinVideoDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let w = vinfo.get_width();
let h = vinfo.get_height();
if !vinfo.get_format().is_paletted() { return Err(DecoderError::NotImplemented); }
let fmt = formats::PAL8_FORMAT;
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, h, false, 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();
self.frame.resize(PREAMBLE_SIZE + w * h, 0);
for i in 0..2 {
@@ -513,7 +510,7 @@ fn get_default_chmap(nch: u8) -> NAChannelMap {
}
impl NADecoder for GremlinAudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), ainfo.get_channels(), formats::SND_S16P_FORMAT, ainfo.get_block_len());
self.chmap = get_default_chmap(ainfo.get_channels());
diff --git a/nihav-game/src/codecs/vmd.rs b/nihav-game/src/codecs/vmd.rs
index bbe5218..dc831c4 100644
--- a/nihav-game/src/codecs/vmd.rs
+++ b/nihav-game/src/codecs/vmd.rs
@@ -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,
@@ -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 {