}
impl NADecoder for AACDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let edata = info.get_extradata().unwrap();
validate!(edata.len() >= 2);
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for Atrac3Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.info = info.clone();
let edata = info.get_extradata().unwrap();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for ClearVideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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();
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();
if src.len() <= 1 { return Err(DecoderError::ShortData); }
let off = if self.is_rm {
}
impl NADecoder for PCMDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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); }
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let duration = get_duration(&ainfo, pkt.get_duration(), pkt.get_buffer().len());
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
impl NADecoder for SiproDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let mut found = false;
for i in 0..SIPRO_MODES.len() {
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for AudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
self.info = info.clone();
Ok(())
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
}
+pub struct NADecoderSupport {
+ pub pool_u8: NAVideoBufferPool<u8>,
+ pub pool_u16: NAVideoBufferPool<u16>,
+ pub pool_u32: NAVideoBufferPool<u32>,
+}
+
+impl NADecoderSupport {
+ pub fn new() -> Self {
+ Self {
+ pool_u8: NAVideoBufferPool::new(0),
+ pool_u16: NAVideoBufferPool::new(0),
+ pool_u32: NAVideoBufferPool::new(0),
+ }
+ }
+}
+
pub trait NADecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()>;
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef>;
+ fn init(&mut self, supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()>;
+ fn decode(&mut self, supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef>;
}
#[derive(Clone,Copy)]
buf.clone()
}
-pub struct NABufferPool {
- pool: Vec<NABufferRef<NABufferType>>,
+pub struct NAVideoBufferPool<T:Copy> {
+ pool: Vec<NAVideoBufferRef<T>>,
max_len: usize,
+ add_len: usize,
}
-impl NABufferPool {
+impl<T:Copy> NAVideoBufferPool<T> {
pub fn new(max_len: usize) -> Self {
Self {
pool: Vec::with_capacity(max_len),
max_len,
+ add_len: 0,
}
}
+ pub fn set_dec_bufs(&mut self, add_len: usize) {
+ self.add_len = add_len;
+ }
+ pub fn get_free(&mut self) -> Option<NAVideoBufferRef<T>> {
+ for e in self.pool.iter() {
+ if e.get_num_refs() == 1 {
+ return Some(e.clone());
+ }
+ }
+ None
+ }
+ pub fn get_copy(&mut self, rbuf: &NAVideoBufferRef<T>) -> Option<NAVideoBufferRef<T>> {
+ let res = self.get_free();
+ if res.is_none() {
+ return None;
+ }
+ let mut dbuf = res.unwrap();
+ dbuf.data.copy_from_slice(&rbuf.data);
+ Some(dbuf)
+ }
+ pub fn reset(&mut self) {
+ self.pool.truncate(0);
+ }
+}
+
+impl NAVideoBufferPool<u8> {
pub fn prealloc_video(&mut self, vinfo: NAVideoInfo, align: u8) -> Result<(), AllocatorError> {
- let nbufs = self.max_len - self.pool.len();
+ let nbufs = self.max_len + self.add_len - self.pool.len();
for _ in 0..nbufs {
- let buf = alloc_video_buffer(vinfo.clone(), align)?;
- self.pool.push(NABufferRef::new(buf));
+ let vbuf = alloc_video_buffer(vinfo.clone(), align)?;
+ if let NABufferType::Video(buf) = vbuf {
+ self.pool.push(buf);
+ } else if let NABufferType::VideoPacked(buf) = vbuf {
+ self.pool.push(buf);
+ } else {
+ return Err(AllocatorError::FormatError);
+ }
}
Ok(())
}
- pub fn prealloc_audio(&mut self, ainfo: NAAudioInfo, nsamples: usize, chmap: NAChannelMap) -> Result<(), AllocatorError> {
- let nbufs = self.max_len - self.pool.len();
+}
+
+impl NAVideoBufferPool<u16> {
+ pub fn prealloc_video(&mut self, vinfo: NAVideoInfo, align: u8) -> Result<(), AllocatorError> {
+ let nbufs = self.max_len + self.add_len - self.pool.len();
for _ in 0..nbufs {
- let buf = alloc_audio_buffer(ainfo.clone(), nsamples, chmap.clone())?;
- self.pool.push(NABufferRef::new(buf));
+ let vbuf = alloc_video_buffer(vinfo.clone(), align)?;
+ if let NABufferType::Video16(buf) = vbuf {
+ self.pool.push(buf);
+ } else {
+ return Err(AllocatorError::FormatError);
+ }
}
Ok(())
}
- pub fn add(&mut self, buf: NABufferType) -> bool {
- if self.pool.len() < self.max_len {
- self.pool.push(NABufferRef::new(buf));
- true
- } else {
- false
- }
- }
- pub fn get_free(&mut self) -> Option<NABufferRef<NABufferType>> {
- for e in self.pool.iter() {
- if e.get_num_refs() == 1 {
- return Some(e.clone());
+}
+
+impl NAVideoBufferPool<u32> {
+ pub fn prealloc_video(&mut self, vinfo: NAVideoInfo, align: u8) -> Result<(), AllocatorError> {
+ let nbufs = self.max_len + self.add_len - self.pool.len();
+ for _ in 0..nbufs {
+ let vbuf = alloc_video_buffer(vinfo.clone(), align)?;
+ if let NABufferType::Video32(buf) = vbuf {
+ self.pool.push(buf);
+ } else {
+ return Err(AllocatorError::FormatError);
}
}
- None
+ Ok(())
}
}
let mut br = ByteReader::new(&mut fr);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
- let mut decs: Vec<Option<Box<NADecoder>>> = Vec::new();
+ let mut decs: Vec<Option<(Box<NADecoderSupport>, Box<NADecoder>)>> = Vec::new();
for i in 0..dmx.get_num_streams() {
let s = dmx.get_stream(i).unwrap();
let info = s.get_info();
if let Some(df) = decfunc {
if (decode_video && info.is_video()) || (decode_audio && info.is_audio()) {
let mut dec = (df)();
- dec.init(info).unwrap();
- decs.push(Some(dec));
+ let mut dsupp = Box::new(NADecoderSupport::new());
+ dec.init(&mut dsupp, info).unwrap();
+ decs.push(Some((dsupp, dec)));
} else {
decs.push(None);
}
if pkt.get_pts().unwrap() > limit.unwrap() { break; }
}
let streamno = pkt.get_stream().get_id() as usize;
- if let Some(ref mut dec) = decs[streamno] {
- let frm = dec.decode(&pkt).unwrap();
+ if let Some((ref mut dsupp, ref mut dec)) = decs[streamno] {
+ let frm = dec.decode(dsupp, &pkt).unwrap();
if pkt.get_stream().get_info().is_video() && video_pfx.is_some() && frm.get_frame_type() != FrameType::Skip {
let pfx = video_pfx.unwrap();
let pts = if let Some(fpts) = frm.get_pts() { fpts } else { pkt.get_pts().unwrap() };
let mut br = ByteReader::new(&mut fr);
let mut dmx = create_demuxer(dmx_f, &mut br).unwrap();
- let mut decs: Vec<Option<Box<NADecoder>>> = Vec::new();
+ let mut decs: Vec<Option<(Box<NADecoderSupport>, Box<NADecoder>)>> = Vec::new();
for i in 0..dmx.get_num_streams() {
let s = dmx.get_stream(i).unwrap();
let info = s.get_info();
if let Some(df) = decfunc {
if info.is_audio() {
let mut dec = (df)();
- dec.init(info).unwrap();
- decs.push(Some(dec));
+ let mut dsupp = Box::new(NADecoderSupport::new());
+ dec.init(&mut dsupp, info).unwrap();
+ decs.push(Some((dsupp, dec)));
} else {
decs.push(None);
}
if pkt.get_pts().unwrap() > limit.unwrap() { break; }
}
let streamno = pkt.get_stream().get_id() as usize;
- if let Some(ref mut dec) = decs[streamno] {
- let frm = dec.decode(&pkt).unwrap();
+ if let Some((ref mut dsupp, ref mut dec)) = decs[streamno] {
+ let frm = dec.decode(dsupp, &pkt).unwrap();
if frm.get_info().is_audio() {
if !wrote_header {
wwr.write_header(frm.get_info().as_ref().get_properties().get_audio_info().unwrap()).unwrap();
}
impl NADecoder for DuckADPCMDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
validate!(ainfo.get_block_len() > 16);
self.block_len = ainfo.get_block_len();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
}
impl NADecoder for TM1Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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 = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
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();
validate!(src.len() > 10);
let hdr_size = (src[0].rotate_left(3) & 0x7F) as usize;
}
impl NADecoder for TM2Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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();
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();
validate!(src.len() >= 40 + (TM2StreamType::Num as usize) * 4 + 4);
let mut mr = MemoryReader::new_read(&src);
}
impl NADecoder for TM2XDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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)),
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();
validate!(src.len() > 8);
let mut mr = MemoryReader::new_read(&src);
}
impl NADecoder for TMRTDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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 = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
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();
validate!(src.len() > 10);
let hdr_size = (src[0].rotate_left(3) & 0x7F) as usize;
}
impl NADecoder for BMVVideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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)),
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();
validate!(src.len() > 1);
}
impl NADecoder for BMVAudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
}
impl NADecoder for BMV3VideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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 = NACodecInfo::new_ref(info.get_name(), myinfo, info.get_extradata()).into_ref();
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();
validate!(src.len() > 1);
}
impl NADecoder for BMV3AudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
}
impl NADecoder for GremlinVideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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 mr = MemoryReader::new_read(&src);
let mut br = ByteReader::new(&mut mr);
}
impl NADecoder for GremlinAudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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());
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
}
impl NADecoder for VMDVideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
self.width = vinfo.get_width();
self.height = vinfo.get_height();
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();
validate!(src.len() >= 10);
}
impl NADecoder for VMDAudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let fmt;
if ainfo.get_format().get_bits() == 8 {
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
const CHMAP_STEREO: [NAChannelType; 2] = [NAChannelType::L, NAChannelType::R];
impl NADecoder for IMCDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
self.chmap = NAChannelMap::new();
match ainfo.get_channels() {
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
const IR2_START: usize = 48;
impl NADecoder for Indeo2Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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();
if src.len() <= IR2_START { return Err(DecoderError::ShortData); }
let interframe = src[18];
const FLAG_NONREF: u16 = 1 << 8;
impl NADecoder for Indeo3Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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 mr = MemoryReader::new_read(&src);
let mut br = ByteReader::new(&mut mr);
}
impl NADecoder for Indeo4Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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);
}
impl NADecoder for Indeo5Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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);
}
impl NADecoder for Intel263Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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();
if src.len() == 8 {
const KB2H_NUM_SLICES: [usize; 4] = [ 2, 3, 4, 8 ];
impl NADecoder for Bink2Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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, src.len(), BitReaderMode::LE);
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: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let srate = ainfo.get_sample_rate();
let channels = ainfo.get_channels();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let pktbuf = pkt.get_buffer();
const BINK_FLAG_GRAY: u32 = 0x00020000;
impl NADecoder for BinkDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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, src.len(), BitReaderMode::LE);
}
impl NADecoder for SmackerVideoDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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();
validate!(src.len() >= PAL_SIZE);
}
impl NADecoder for SmackerAudioDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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 };
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
if let NACodecTypeInfo::Audio(_) = info.get_properties() {
let src = pkt.get_buffer();
}
impl NADecoder for CookDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let edata = info.get_extradata().unwrap();
validate!(edata.len() >= 4);
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for RA144Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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(),
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for RA288Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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(),
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for RALFDecoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
let edata = info.get_extradata().unwrap();
Err(DecoderError::InvalidData)
}
}
- fn decode(&mut self, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
+ fn decode(&mut self, _supp: &mut NADecoderSupport, pkt: &NAPacket) -> DecoderResult<NAFrameRef> {
let info = pkt.get_stream().get_info();
validate!(info.get_properties().is_audio());
let pktbuf = pkt.get_buffer();
}
impl NADecoder for RealVideo10Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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();
//println!(" decode frame size {}, {} slices", src.len(), src[0]+1);
impl NADecoder for RealVideo20Decoder {
#[allow(unused_variables)]
- fn init(&mut self, info: NACodecInfoRef) -> 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();
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 ibr = RealVideo20BR::new(&src, &self.tables, self.w, self.h, self.minor_ver, self.rpr);
}
impl NADecoder for RealVideo30Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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));
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 (bufinfo, ftype, pts) = self.dec.parse_frame(src.as_slice(), &mut self.bd)?;
}
impl NADecoder for RealVideo40Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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));
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 (bufinfo, ftype, ts) = self.dec.parse_frame(src.as_slice(), &mut self.bd)?;
use nihav_core::formats::YUV420_FORMAT;
use nihav_core::frame::*;
-use nihav_core::codecs::{NADecoder, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
+use nihav_core::codecs::{NADecoder, NADecoderSupport, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
use nihav_core::io::byteio::{MemoryReader,ByteReader};
use nihav_core::io::bitreader::{BitReader,BitReaderMode};
use nihav_core::io::intcode::*;
}
impl NADecoder for RealVideo60Decoder {
- fn init(&mut self, info: NACodecInfoRef) -> DecoderResult<()> {
+ fn init(&mut self, _supp: &mut NADecoderSupport, 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));
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();
validate!(src.len() > 9);