-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
}
struct AACDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
chmap: NAChannelMap,
m4ainfo: M4AInfo,
pairs: Vec<ChannelPair>,
}
impl NADecoder for AACDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let edata = info.get_extradata().unwrap();
validate!(edata.len() >= 2);
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
}
struct Atrac3Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
channels: usize,
chmap: NAChannelMap,
samples: usize,
}
impl NADecoder for Atrac3Decoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.info = info.clone();
let edata = info.get_extradata().unwrap();
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::io::byteio::{ByteReader,MemoryReader};
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
#[allow(dead_code)]
struct ClearVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dc_cb: Codebook<i8>,
ac_cb: Codebook<u16>,
frmmgr: HAMShuffler,
impl ClearVideoDecoder {
fn new(is_rm: bool) -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
+ let dummy_info = NACodecInfo::new_dummy();
let mut coderead = CLVDCCodeReader{};
let dc_cb = Codebook::new(&mut coderead, CodebookMode::MSB).unwrap();
let mut coderead = CLVACCodeReader{};
}
impl NADecoder for ClearVideoDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if info.get_extradata().is_none() { return Err(DecoderError::InvalidData); }
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
let w = vinfo.get_width();
let f = vinfo.is_flipped();
let fmt = formats::YUV420_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();
self.frmmgr.clear();
let edata = info.get_extradata().unwrap();
//todo detect simply by extradata contents?
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::codecs::*;
}
impl NADecoder for PCMDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.chmap = get_default_chmap(ainfo.get_channels());
if self.chmap.num_channels() == 0 { return Err(DecoderError::InvalidData); }
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
struct SiproDecoder {
chmap: NAChannelMap,
ainfo: NAAudioInfo,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
mode: &'static SiproModeInfo,
mode_type: SiproMode,
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
impl NADecoder for SiproDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let mut found = false;
for i in 0..SIPRO_MODES.len() {
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
}
struct AudioDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
ablk: AudioBlock,
imdct512: IMDCTContext,
imdct256: IMDCTContext,
}
impl NADecoder for AudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
self.info = info.clone();
Ok(())
use std::ops::{Add, AddAssign, Sub, SubAssign};
pub use crate::frame::*;
-pub use std::rc::Rc;
use std::mem;
use crate::io::byteio::ByteIOError;
use crate::io::bitreader::BitReaderError;
pub trait NADecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()>;
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()>;
fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef>;
}
use std::fmt;
pub use std::rc::Rc;
pub use std::cell::*;
+use std::sync::Arc;
pub use crate::formats::*;
pub use crate::refs::*;
pub struct NACodecInfo {
name: &'static str,
properties: NACodecTypeInfo,
- extradata: Option<Rc<Vec<u8>>>,
+ extradata: Option<Arc<Vec<u8>>>,
}
+pub type NACodecInfoRef = Arc<NACodecInfo>;
+
impl NACodecInfo {
pub fn new(name: &'static str, p: NACodecTypeInfo, edata: Option<Vec<u8>>) -> Self {
let extradata = match edata {
None => None,
- Some(vec) => Some(Rc::new(vec)),
+ Some(vec) => Some(Arc::new(vec)),
};
NACodecInfo { name: name, properties: p, extradata: extradata }
}
- pub fn new_ref(name: &'static str, p: NACodecTypeInfo, edata: Option<Rc<Vec<u8>>>) -> Self {
+ pub fn new_ref(name: &'static str, p: NACodecTypeInfo, edata: Option<Arc<Vec<u8>>>) -> Self {
NACodecInfo { name: name, properties: p, extradata: edata }
}
+ pub fn into_ref(self) -> NACodecInfoRef { Arc::new(self) }
pub fn get_properties(&self) -> NACodecTypeInfo { self.properties }
- pub fn get_extradata(&self) -> Option<Rc<Vec<u8>>> {
+ pub fn get_extradata(&self) -> Option<Arc<Vec<u8>>> {
if let Some(ref vec) = self.extradata { return Some(vec.clone()); }
None
}
if let NACodecTypeInfo::Audio(_) = self.properties { return true; }
false
}
- pub fn new_dummy() -> Rc<Self> {
- Rc::new(DUMMY_CODEC_INFO)
+ pub fn new_dummy() -> Arc<Self> {
+ Arc::new(DUMMY_CODEC_INFO)
}
- pub fn replace_info(&self, p: NACodecTypeInfo) -> Rc<Self> {
- Rc::new(NACodecInfo { name: self.name, properties: p, extradata: self.extradata.clone() })
+ pub fn replace_info(&self, p: NACodecTypeInfo) -> Arc<Self> {
+ Arc::new(NACodecInfo { name: self.name, properties: p, extradata: self.extradata.clone() })
}
}
Int(i32),
Long(i64),
String(String),
- Data(Rc<Vec<u8>>),
+ Data(Arc<Vec<u8>>),
}
#[derive(Debug,Clone,Copy,PartialEq)]
pub struct NAFrame {
ts: NATimeInfo,
buffer: NABufferType,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
ftype: FrameType,
key: bool,
options: HashMap<String, NAValue>,
pub fn new(ts: NATimeInfo,
ftype: FrameType,
keyframe: bool,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
options: HashMap<String, NAValue>,
buffer: NABufferType) -> Self {
NAFrame { ts: ts, buffer: buffer, info: info, ftype: ftype, key: keyframe, options: options }
}
- pub fn get_info(&self) -> Rc<NACodecInfo> { self.info.clone() }
+ pub fn get_info(&self) -> NACodecInfoRef { self.info.clone() }
pub fn get_frame_type(&self) -> FrameType { self.ftype }
pub fn is_keyframe(&self) -> bool { self.key }
pub fn set_frame_type(&mut self, ftype: FrameType) { self.ftype = ftype; }
media_type: StreamType,
id: u32,
num: usize,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
tb_num: u32,
tb_den: u32,
}
impl NAStream {
pub fn new(mt: StreamType, id: u32, info: NACodecInfo, tb_num: u32, tb_den: u32) -> Self {
let (n, d) = reduce_timebase(tb_num, tb_den);
- NAStream { media_type: mt, id: id, num: 0, info: Rc::new(info), tb_num: n, tb_den: d }
+ NAStream { media_type: mt, id: id, num: 0, info: info.into_ref(), tb_num: n, tb_den: d }
}
pub fn get_id(&self) -> u32 { self.id }
pub fn get_num(&self) -> usize { self.num }
pub fn set_num(&mut self, num: usize) { self.num = num; }
- pub fn get_info(&self) -> Rc<NACodecInfo> { self.info.clone() }
+ pub fn get_info(&self) -> NACodecInfoRef { self.info.clone() }
pub fn get_timebase(&self) -> (u32, u32) { (self.tb_num, self.tb_den) }
pub fn set_timebase(&mut self, tb_num: u32, tb_den: u32) {
let (n, d) = reduce_timebase(tb_num, tb_den);
}
pub trait FrameFromPacket {
- fn new_from_pkt(pkt: &NAPacket, info: Rc<NACodecInfo>, buf: NABufferType) -> NAFrame;
+ fn new_from_pkt(pkt: &NAPacket, info: NACodecInfoRef, buf: NABufferType) -> NAFrame;
fn fill_timestamps(&mut self, pkt: &NAPacket);
}
impl FrameFromPacket for NAFrame {
- fn new_from_pkt(pkt: &NAPacket, info: Rc<NACodecInfo>, buf: NABufferType) -> NAFrame {
+ fn new_from_pkt(pkt: &NAPacket, info: NACodecInfoRef, buf: NABufferType) -> NAFrame {
NAFrame::new(pkt.ts, FrameType::Other, pkt.keyframe, info, HashMap::new(), buf)
}
fn fill_timestamps(&mut self, pkt: &NAPacket) {
}
impl NADecoder for DuckADPCMDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
validate!(ainfo.get_block_len() > 16);
self.block_len = ainfo.get_block_len();
#[derive(Default)]
struct TM1Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
last_delta_set: usize,
last_table_idx: usize,
delta_tables: DeltaTables,
}
impl NADecoder for TM1Decoder {
- 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, YUV410_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();
Ok(())
} else {
Err(DecoderError::InvalidData)
#[derive(Default)]
struct TM2Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
streams: [TM2Stream; TM2StreamType::Num as usize],
width: usize,
height: usize,
}
impl NADecoder for TM2Decoder {
- 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, YUV410_FORMAT));
self.width = vinfo.get_width();
self.height = vinfo.get_height();
self.cur_frame = TM2Frame::alloc(self.width, self.height);
self.prev_frame = TM2Frame::alloc(self.width, self.height);
- 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)
#[derive(Default)]
struct TM2XDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
width: usize,
height: usize,
dec_buf: Vec<u8>,
}
impl NADecoder for TM2XDecoder {
- 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::YUV(YUVSubmodel::YUVJ),
Some(NAPixelChromaton::new(0, 0, false, 8, 0, 0, 1)),
self.height = vinfo.get_height();
self.cur_frame.resize(self.width, self.height);
self.ref_frame.resize(self.width, self.height);
- 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)
#[derive(Default)]
struct TMRTDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
}
const TMRT_DELTA_TAB: [&[i16]; 3] = [
}
impl NADecoder for TMRTDecoder {
- 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, YUV410_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();
Ok(())
} else {
Err(DecoderError::InvalidData)
}
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<()> {
}
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)),
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 {
}
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();
}
struct BMV3VideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
stride: usize,
height: usize,
frame: Vec<u16>,
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);
}
Self {
- info: dummy_info,
+ info: NACodecInfoRef::default(),
stride: 0,
height: 0,
frame: frame1,
}
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();
}
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();
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::frame::*;
use nihav_core::formats;
use nihav_core::formats::{NAChannelType, NAChannelMap};
use nihav_core::io::byteio::*;
struct GremlinVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
pal: [u8; 768],
frame: Vec<u8>,
scale_v: bool,
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
}
}
}
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 {
}
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());
}
struct VMDVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
pal: [u8; 768],
buf: Vec<u8>,
width: usize,
impl VMDVideoDecoder {
fn new() -> Self {
Self {
- info: Rc::new(NACodecInfo::default()),
+ info: NACodecInfoRef::default(),
pal: [0; 768],
buf: Vec::new(),
width: 0,
}
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() {
}
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 {
use std::mem;
use std::ptr;
use std::f32::consts;
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
chmap: NAChannelMap,
ainfo: NAAudioInfo,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
codes: [[Codebook<u8>; 4]; 4],
ch_data: [IMCChannel; 2],
const CHMAP_STEREO: [NAChannelType; 2] = [NAChannelType::L, NAChannelType::R];
impl NADecoder for IMCDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.chmap = NAChannelMap::new();
match ainfo.get_channels() {
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::formats;
}
struct Indeo2Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
cb: Codebook<u8>,
frmmgr: HAMShuffler,
}
impl Indeo2Decoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
+ let dummy_info = NACodecInfo::new_dummy();
let mut coderead = IR2CodeReader{};
let cb = Codebook::new(&mut coderead, CodebookMode::LSB).unwrap();
Indeo2Decoder { info: dummy_info, cb: cb, frmmgr: HAMShuffler::new() }
const IR2_START: usize = 48;
impl NADecoder for Indeo2Decoder {
- 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();
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();
self.frmmgr.clear();
Ok(())
} else {
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats;
use nihav_core::codecs::*;
use nihav_core::io::byteio::*;
}
struct Indeo3Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
bpos: u8,
bbuf: u8,
width: u16,
impl Indeo3Decoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
+ let dummy_info = NACodecInfo::new_dummy();
Indeo3Decoder { info: dummy_info, bpos: 0, bbuf: 0, width: 0, height: 0,
mvs: Vec::new(), altquant: [0; 16],
vq_offset: 0, bufs: Buffers::new() }
const FLAG_NONREF: u16 = 1 << 8;
impl NADecoder for Indeo3Decoder {
- 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();
let fmt = formats::YUV410_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.bufs.reset();
Ok(())
} else {
-use std::rc::Rc;
-use std::cell::{Ref, RefCell};
use nihav_core::io::bitreader::*;
use nihav_core::formats;
use nihav_core::frame::*;
}
struct Indeo4Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: IVIDecoder,
}
}
impl NADecoder for Indeo4Decoder {
- 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();
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)
-use std::rc::Rc;
-use std::cell::{Ref, RefCell};
use nihav_core::io::bitreader::*;
use nihav_core::formats;
use nihav_core::frame::*;
}
struct Indeo5Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: IVIDecoder,
ip: Indeo5Parser,
}
}
impl NADecoder for Indeo5Decoder {
- 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();
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)
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::formats;
}
struct Intel263Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: H263BaseDecoder,
tables: Tables,
bdsp: H263BlockDSP,
};
Intel263Decoder{
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfo::new_dummy(),
dec: H263BaseDecoder::new(true),
tables: tables,
bdsp: H263BlockDSP::new(),
}
impl NADecoder for Intel263Decoder {
- 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();
let fmt = formats::YUV420_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();
Ok(())
} else {
Err(DecoderError::InvalidData)
#[derive(Default)]
struct Bink2Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
ips: IPShuffler,
version: u32,
const KB2H_NUM_SLICES: [usize; 4] = [ 2, 3, 4, 8 ];
impl NADecoder for Bink2Decoder {
- 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 self.has_alpha { FORMATON_FLAG_ALPHA } else { 0 },
if self.has_alpha { 4 } else { 3 });
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();
Ok(())
} else {
const RUN_TAB: [usize; 16] = [ 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64 ];
impl NADecoder for BinkAudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let srate = ainfo.get_sample_rate();
let channels = ainfo.get_channels();
#[derive(Default)]
struct BinkDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
ips: IPShuffler,
hams: HAMShuffler,
const BINK_FLAG_GRAY: u32 = 0x00020000;
impl NADecoder for BinkDecoder {
- 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();
None, None, None, None, 0, 1);
}
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.init_bundle_lengths(w.max(8), (w + 7) >> 3);
self.init_bundle_bufs((w + 7) >> 3, (h + 7) >> 3);
];
struct SmackerVideoDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
mmap_tree: SmackerTree16,
mclr_tree: SmackerTree16,
full_tree: SmackerTree16,
impl SmackerVideoDecoder {
fn new() -> Self {
- let dummy_info = Rc::new(DUMMY_CODEC_INFO);
Self {
- info: dummy_info,
+ info: NACodecInfoRef::default(),
mmap_tree: SmackerTree16::new(),
mclr_tree: SmackerTree16::new(),
full_tree: SmackerTree16::new(),
}
impl NADecoder for SmackerVideoDecoder {
- 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();
out_h <<= 1;
}
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(w, out_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 {
}
impl NADecoder for SmackerAudioDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.bits = ainfo.get_format().get_bits();
let fmt = if self.bits == 8 { SND_U8_FORMAT } else { SND_S16P_FORMAT };
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
}
struct CookDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
chmap: NAChannelMap,
src: [u8; 65536],
num_pairs: usize,
}
impl NADecoder for CookDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let edata = info.get_extradata().unwrap();
validate!(edata.len() >= 4);
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
struct RA144Decoder {
chmap: NAChannelMap,
ainfo: NAAudioInfo,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
old_energy: u16,
lpc_data: [[i32; LPC_ORDER]; 2],
}
impl NADecoder for RA144Decoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.chmap.add_channels(&CHMAP_MONO);
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
struct RA288Decoder {
chmap: NAChannelMap,
ainfo: NAAudioInfo,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
speech_lpc: [f32; SP_LPC_ORDER],
speech_hist: [f32; 111],
}
impl NADecoder for RA288Decoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.chmap.add_channels(&CHMAP_MONO);
self.ainfo = NAAudioInfo::new(ainfo.get_sample_rate(),
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::*;
use nihav_core::frame::*;
use nihav_core::codecs::*;
const RALF_MAX_PACKET_SIZE: usize = 8192;
struct RALFDecoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
chmap: NAChannelMap,
channels: u8,
}
impl NADecoder for RALFDecoder {
- fn init(&mut self, info: Rc<NACodecInfo>) -> DecoderResult<()> {
+ fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let edata = info.get_extradata().unwrap();
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::formats;
}
struct RealVideo10Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: H263BaseDecoder,
tables: Tables,
w: usize,
};
RealVideo10Decoder{
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfoRef::default(),
dec: H263BaseDecoder::new_with_opts(false, false, false),
tables: tables,
w: 0,
}
impl NADecoder for RealVideo10Decoder {
- 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();
let fmt = formats::YUV420_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.w = w;
self.h = h;
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::io::bitreader::*;
use nihav_core::io::codebook::*;
use nihav_core::formats;
}
struct RealVideo20Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: H263BaseDecoder,
tables: Tables,
w: usize,
};
RealVideo20Decoder{
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfoRef::default(),
dec: H263BaseDecoder::new_b_frames(false),
tables: tables,
w: 0,
impl NADecoder for RealVideo20Decoder {
#[allow(unused_variables)]
- 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();
let fmt = formats::YUV420_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.w = w;
self.h = h;
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats;
use nihav_core::io::bitreader::*;
use nihav_core::io::intcode::*;
struct RealVideo30Decoder {
bd: RealVideo30BR,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: RV34Decoder,
}
fn new() -> Self {
RealVideo30Decoder{
bd: RealVideo30BR::new(),
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfoRef::default(),
dec: RV34Decoder::new(true, Box::new(RV30DSP::new())),
}
}
}
impl NADecoder for RealVideo30Decoder {
- 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 = formats::YUV420_FORMAT;
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, 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();
let edata = info.get_extradata().unwrap();
let src: &[u8] = &edata;
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats;
use nihav_core::frame::*;
use nihav_core::io::bitreader::*;
struct RealVideo40Decoder {
bd: RealVideo40BR,
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
dec: RV34Decoder,
}
fn new() -> Self {
RealVideo40Decoder{
bd: RealVideo40BR::new(),
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfoRef::default(),
dec: RV34Decoder::new(false, Box::new(RV40DSP::new())),
}
}
}
impl NADecoder for RealVideo40Decoder {
- 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 = formats::YUV420_FORMAT;
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, 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();
let edata = info.get_extradata().unwrap();
let src: &[u8] = &edata;
-use std::rc::Rc;
-use std::cell::RefCell;
use nihav_core::formats::YUV420_FORMAT;
use nihav_core::frame::*;
use nihav_core::codecs::{NADecoder, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
}
struct RealVideo60Decoder {
- info: Rc<NACodecInfo>,
+ info: NACodecInfoRef,
cbs: RV60Codebooks,
ipbs: IPBShuffler,
dsp: RV60DSP,
let vb = vt.get_vbuf();
let avg_buf = vb.unwrap();
RealVideo60Decoder{
- info: Rc::new(DUMMY_CODEC_INFO),
+ info: NACodecInfoRef::default(),
cbs: RV60Codebooks::init(),
ipbs: IPBShuffler::new(),
ipred: IntraPredContext::new(),
}
impl NADecoder for RealVideo60Decoder {
- 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 = YUV420_FORMAT;
let myinfo = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, 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();
let edata = info.get_extradata().unwrap();
let src: &[u8] = &edata;