+++ /dev/null
-[package]
-name = "nihav"
-version = "0.1.0"
-authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
-edition = "2018"
-
-[features]
-default = ["all_decoders", "all_demuxers"]
-demuxers = []
-all_demuxers = ["demuxer_avi", "demuxer_gdv", "demuxer_real"]
-demuxer_avi = ["demuxers"]
-demuxer_gdv = ["demuxers"]
-demuxer_real = ["demuxers"]
-
-decoders = []
-h263 = []
-
-dsp = []
-fft = ["dsp"]
-mdct = ["fft", "dsp"]
-dsp_window = ["dsp"]
-
-all_decoders = ["all_video_decoders", "all_audio_decoders"]
-
-all_video_decoders = ["decoder_clearvideo", "decoder_gdvvid", "decoder_indeo2", "decoder_indeo3", "decoder_indeo4", "decoder_indeo5", "decoder_intel263", "decoder_realvideo1", "decoder_realvideo2", "decoder_realvideo3", "decoder_realvideo4", "decoder_realvideo6"]
-decoder_clearvideo = ["decoders"]
-decoder_gdvvid = ["decoders"]
-decoder_indeo2 = ["decoders"]
-decoder_indeo3 = ["decoders"]
-decoder_indeo4 = ["decoders"]
-decoder_indeo5 = ["decoders"]
-decoder_intel263 = ["h263", "decoders"]
-decoder_realvideo1 = ["h263", "decoders"]
-decoder_realvideo2 = ["h263", "decoders"]
-decoder_realvideo3 = ["decoders"]
-decoder_realvideo4 = ["decoders"]
-decoder_realvideo6 = ["decoders"]
-
-all_audio_decoders = ["decoder_pcm", "decoder_imc", "decoders_real"]
-decoder_pcm = ["decoders"]
-decoder_ts102366 = ["decoders", "fft"]
-decoder_imc = ["decoders", "fft", "dsp_window"]
-decoders_real = ["decoder_realaudio144", "decoder_realaudio288", "decoder_sipro", "decoder_ts102366", "decoder_cook", "decoder_atrac3", "decoder_aac", "decoder_ralf"]
-decoder_realaudio144 = ["decoders"]
-decoder_realaudio288 = ["decoders"]
-decoder_sipro = ["decoders"]
-decoder_cook = ["decoders", "fft", "mdct"]
-decoder_atrac3 = ["decoders", "mdct"]
-decoder_aac = ["decoders", "mdct", "dsp_window"]
-decoder_ralf = ["decoders"]
--- /dev/null
+[package]
+name = "nihav_allstuff"
+version = "0.1.0"
+authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
+edition = "2018"
+
+[dependencies]
+nihav_core = { path = "../nihav-core" }
+nihav_game = { path = "../nihav-game" }
+nihav_indeo = { path = "../nihav-indeo" }
+nihav_realmedia = { path = "../nihav-realmedia" }
\ No newline at end of file
--- /dev/null
+extern crate nihav_core;
+extern crate nihav_game;
+extern crate nihav_indeo;
+extern crate nihav_realmedia;
+
+use nihav_core::codecs::{RegisteredDecoders, core_register_all_codecs};
+use nihav_core::demuxers::{RegisteredDemuxers, core_register_all_demuxers};
+
+use nihav_game::codecs::game_register_all_codecs;
+use nihav_game::demuxers::game_register_all_demuxers;
+
+use nihav_indeo::codecs::indeo_register_all_codecs;
+
+use nihav_realmedia::codecs::realmedia_register_all_codecs;
+use nihav_realmedia::demuxers::realmedia_register_all_demuxers;
+
+pub fn nihav_register_all_codecs(rd: &mut RegisteredDecoders) {
+ core_register_all_codecs(rd);
+ game_register_all_codecs(rd);
+ indeo_register_all_codecs(rd);
+ realmedia_register_all_codecs(rd);
+}
+
+pub fn nihav_register_all_demuxers(rd: &mut RegisteredDemuxers) {
+ core_register_all_demuxers(rd);
+ game_register_all_demuxers(rd);
+ realmedia_register_all_demuxers(rd);
+}
--- /dev/null
+[package]
+name = "nihav_core"
+version = "0.1.0"
+authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
+edition = "2018"
+
+[features]
+default = ["all_decoders", "all_demuxers"]
+demuxers = []
+all_demuxers = ["demuxer_avi"]
+demuxer_avi = ["demuxers"]
+
+decoders = []
+h263 = []
+
+dsp = []
+fft = ["dsp"]
+mdct = ["fft", "dsp"]
+dsp_window = ["dsp"]
+
+all_decoders = ["all_video_decoders", "all_audio_decoders"]
+
+all_video_decoders = ["decoder_clearvideo"]
+decoder_clearvideo = ["decoders"]
+
+all_audio_decoders = ["decoder_pcm", "decoder_ts102366", "decoder_sipro", "decoder_atrac3", "decoder_aac"]
+decoder_pcm = ["decoders"]
+decoder_ts102366 = ["decoders", "fft"]
+decoder_sipro = ["decoders"]
+decoder_atrac3 = ["decoders", "mdct"]
+decoder_aac = ["decoders", "mdct", "dsp_window"]
pub mod data;
pub mod decoder;
-#[cfg(feature="decoder_intel263")]
-pub mod intel263;
-#[cfg(feature="decoder_realvideo1")]
-pub mod rv10;
-#[cfg(feature="decoder_realvideo2")]
-pub mod rv20;
-
pub trait BlockDecoder {
fn decode_pichdr(&mut self) -> DecoderResult<PicInfo>;
fn decode_slice_header(&mut self, pinfo: &PicInfo) -> DecoderResult<SliceInfo>;
}
#[allow(dead_code)]
-struct HAMShuffler {
+pub struct HAMShuffler {
lastframe: Option<NAVideoBuffer<u8>>,
}
impl HAMShuffler {
#[allow(dead_code)]
- fn new() -> Self { HAMShuffler { lastframe: None } }
+ pub fn new() -> Self { HAMShuffler { lastframe: None } }
#[allow(dead_code)]
- fn clear(&mut self) { self.lastframe = None; }
+ pub fn clear(&mut self) { self.lastframe = None; }
#[allow(dead_code)]
- fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- fn clone_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn clone_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref mut frm) = self.lastframe {
let newfrm = frm.copy_buffer();
*frm = newfrm.clone();
}
}
#[allow(dead_code)]
- fn get_output_frame(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_output_frame(&mut self) -> Option<NAVideoBuffer<u8>> {
match self.lastframe {
Some(ref frm) => Some(frm.clone()),
None => None,
}
#[allow(dead_code)]
-struct IPShuffler {
+pub struct IPShuffler {
lastframe: Option<NAVideoBuffer<u8>>,
}
impl IPShuffler {
#[allow(dead_code)]
- fn new() -> Self { IPShuffler { lastframe: None } }
+ pub fn new() -> Self { IPShuffler { lastframe: None } }
#[allow(dead_code)]
- fn clear(&mut self) { self.lastframe = None; }
+ pub fn clear(&mut self) { self.lastframe = None; }
#[allow(dead_code)]
- fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- fn get_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_ref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
}
#[allow(dead_code)]
-struct IPBShuffler {
+pub struct IPBShuffler {
lastframe: Option<NAVideoBuffer<u8>>,
nextframe: Option<NAVideoBuffer<u8>>,
}
impl IPBShuffler {
#[allow(dead_code)]
- fn new() -> Self { IPBShuffler { lastframe: None, nextframe: None } }
+ pub fn new() -> Self { IPBShuffler { lastframe: None, nextframe: None } }
#[allow(dead_code)]
- fn clear(&mut self) { self.lastframe = None; self.nextframe = None; }
+ pub fn clear(&mut self) { self.lastframe = None; self.nextframe = None; }
#[allow(dead_code)]
- fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
+ pub fn add_frame(&mut self, buf: NAVideoBuffer<u8>) {
mem::swap(&mut self.lastframe, &mut self.nextframe);
self.lastframe = Some(buf);
}
#[allow(dead_code)]
- fn get_lastref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_lastref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- fn get_nextref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_nextref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref frm) = self.nextframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- fn get_b_fwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_b_fwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref frm) = self.nextframe {
Some(frm.clone())
} else {
}
}
#[allow(dead_code)]
- fn get_b_bwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
+ pub fn get_b_bwdref(&mut self) -> Option<NAVideoBuffer<u8>> {
if let Some(ref frm) = self.lastframe {
Some(frm.clone())
} else {
#[derive(Clone,Copy)]
pub struct DecoderInfo {
- name: &'static str,
- get_decoder: fn () -> Box<NADecoder>,
+ pub name: &'static str,
+ pub get_decoder: fn () -> Box<NADecoder>,
}
-#[cfg(any(feature="h263", feature="decoder_realvideo3", feature="decoder_realvideo4"))]
-mod blockdsp;
+#[cfg(any(feature="h263"))]
+pub mod blockdsp;
#[cfg(feature="decoder_clearvideo")]
mod clearvideo;
#[cfg(feature="decoder_gdvvid")]
mod gremlinvideo;
-#[cfg(any(feature="decoder_indeo2", feature="decoder_indeo3", feature="decoder_indeo4", feature="decoder_indeo5", feature="decoder_imc"))]
-mod indeo;
#[cfg(feature="h263")]
-mod h263;
-#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4", feature="decoder_realvideo6", feature="decoder_realaudio144", feature="decoder_realaudio288", feature="decoder_cook", feature="decoder_ralf"))]
-mod real;
+pub mod h263;
#[cfg(feature="decoder_aac")]
mod aac;
DecoderInfo { name: "clearvideo", get_decoder: clearvideo::get_decoder },
#[cfg(feature="decoder_clearvideo")]
DecoderInfo { name: "clearvideo_rm", get_decoder: clearvideo::get_decoder_rm },
-#[cfg(feature="decoder_gdvvid")]
- DecoderInfo { name: "gdv-audio", get_decoder: gremlinvideo::get_decoder_audio },
-#[cfg(feature="decoder_gdvvid")]
- DecoderInfo { name: "gdv-video", get_decoder: gremlinvideo::get_decoder_video },
-#[cfg(feature="decoder_indeo2")]
- DecoderInfo { name: "indeo2", get_decoder: indeo::indeo2::get_decoder },
-#[cfg(feature="decoder_indeo3")]
- DecoderInfo { name: "indeo3", get_decoder: indeo::indeo3::get_decoder },
-#[cfg(feature="decoder_indeo4")]
- DecoderInfo { name: "indeo4", get_decoder: indeo::indeo4::get_decoder },
-#[cfg(feature="decoder_indeo5")]
- DecoderInfo { name: "indeo5", get_decoder: indeo::indeo5::get_decoder },
-#[cfg(feature="decoder_intel263")]
- DecoderInfo { name: "intel263", get_decoder: h263::intel263::get_decoder },
-#[cfg(feature="decoder_realvideo1")]
- DecoderInfo { name: "realvideo1", get_decoder: h263::rv10::get_decoder },
-#[cfg(feature="decoder_realvideo2")]
- DecoderInfo { name: "realvideo2", get_decoder: h263::rv20::get_decoder },
-#[cfg(feature="decoder_realvideo3")]
- DecoderInfo { name: "realvideo3", get_decoder: real::rv30::get_decoder },
-#[cfg(feature="decoder_realvideo4")]
- DecoderInfo { name: "realvideo4", get_decoder: real::rv40::get_decoder },
-#[cfg(feature="decoder_realvideo6")]
- DecoderInfo { name: "realvideo6", get_decoder: real::rv60::get_decoder },
#[cfg(feature="decoder_pcm")]
DecoderInfo { name: "pcm", get_decoder: pcm::get_decoder },
-#[cfg(feature="decoder_imc")]
- DecoderInfo { name: "imc", get_decoder: indeo::imc::get_decoder_imc },
-#[cfg(feature="decoder_imc")]
- DecoderInfo { name: "iac", get_decoder: indeo::imc::get_decoder_iac },
-#[cfg(feature="decoder_realaudio144")]
- DecoderInfo { name: "ra14.4", get_decoder: real::ra144::get_decoder },
-#[cfg(feature="decoder_realaudio288")]
- DecoderInfo { name: "ra28.8", get_decoder: real::ra288::get_decoder },
#[cfg(feature="decoder_sipro")]
DecoderInfo { name: "sipro", get_decoder: sipro::get_decoder },
#[cfg(feature="decoder_ts102366")]
DecoderInfo { name: "ac3", get_decoder: ts102366::get_decoder },
-#[cfg(feature="decoder_cook")]
- DecoderInfo { name: "cook", get_decoder: real::cook::get_decoder },
#[cfg(feature="decoder_atrac3")]
DecoderInfo { name: "atrac3", get_decoder: atrac3::get_decoder },
#[cfg(feature="decoder_aac")]
DecoderInfo { name: "aac", get_decoder: aac::get_decoder },
-#[cfg(feature="decoder_ralf")]
- DecoderInfo { name: "ralf", get_decoder: real::ralf::get_decoder },
];
-pub fn find_decoder(name: &str) -> Option<fn () -> Box<NADecoder>> {
- for &dec in DECODERS {
- if dec.name == name {
- return Some(dec.get_decoder);
+pub fn core_register_all_codecs(rd: &mut RegisteredDecoders) {
+ for decoder in DECODERS.into_iter() {
+ rd.add_decoder(decoder.clone());
+ }
+}
+
+pub struct RegisteredDecoders {
+ decs: Vec<DecoderInfo>,
+}
+
+impl RegisteredDecoders {
+ pub fn new() -> Self {
+ Self { decs: Vec::new() }
+ }
+ pub fn add_decoder(&mut self, dec: DecoderInfo) {
+ self.decs.push(dec);
+ }
+ pub fn find_decoder(&self, name: &str) -> Option<fn () -> Box<NADecoder>> {
+ for &dec in self.decs.iter() {
+ if dec.name == name {
+ return Some(dec.get_decoder);
+ }
}
+ None
}
- None
}
TryAgain,
}
-type DemuxerResult<T> = Result<T, DemuxerError>;
+pub type DemuxerResult<T> = Result<T, DemuxerError>;
pub trait DemuxCore<'a> {
fn open(&mut self, strmgr: &mut StreamManager) -> DemuxerResult<()>;
($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DemuxerError::InvalidData); } };
}
-#[cfg(feature="demuxer_gdv")]
-mod gdv;
#[cfg(feature="demuxer_avi")]
mod avi;
-#[cfg(feature="demuxer_real")]
-mod realmedia;
const DEMUXERS: &[&'static DemuxerCreator] = &[
#[cfg(feature="demuxer_avi")]
&avi::AVIDemuxerCreator {},
-#[cfg(feature="demuxer_gdv")]
- &gdv::GDVDemuxerCreator {},
-#[cfg(feature="demuxer_real")]
- &realmedia::RealMediaDemuxerCreator {},
-#[cfg(feature="demuxer_real")]
- &realmedia::RealAudioDemuxerCreator {},
-#[cfg(feature="demuxer_real")]
- &realmedia::RealIVRDemuxerCreator {},
];
-pub fn find_demuxer(name: &str) -> Option<&DemuxerCreator> {
- for &dmx in DEMUXERS {
- if dmx.get_name() == name {
- return Some(dmx);
- }
- }
- None
-}
-
pub fn create_demuxer<'a>(dmxcr: &DemuxerCreator, br: &'a mut ByteReader<'a>) -> DemuxerResult<Demuxer<'a>> {
let mut dmx = dmxcr.new_demuxer(br);
let mut str = StreamManager::new();
dmx.open(&mut str)?;
Ok(Demuxer::new(dmx, str))
}
+
+pub struct RegisteredDemuxers {
+ dmxs: Vec<&'static DemuxerCreator>,
+}
+
+impl RegisteredDemuxers {
+ pub fn new() -> Self {
+ Self { dmxs: Vec::new() }
+ }
+ pub fn add_demuxer(&mut self, dmx: &'static DemuxerCreator) {
+ self.dmxs.push(dmx);
+ }
+ pub fn find_demuxer(&self, name: &str) -> Option<&DemuxerCreator> {
+ for &dmx in self.dmxs.iter() {
+ if dmx.get_name() == name {
+ return Some(dmx);
+ }
+ }
+ None
+ }
+}
+
+pub fn core_register_all_demuxers(rd: &mut RegisteredDemuxers) {
+ for demuxer in DEMUXERS.into_iter() {
+ rd.add_demuxer(*demuxer);
+ }
+}
#[derive(Clone)]
pub struct CodecDescription {
- name: &'static str,
- fname: &'static str,
- ctype: CodecType,
- caps: u32,
+ pub name: &'static str,
+ pub fname: &'static str,
+ pub ctype: CodecType,
+ pub caps: u32,
}
impl CodecDescription {
--- /dev/null
+[package]
+name = "nihav_game"
+version = "0.1.0"
+authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
+edition = "2018"
+
+[dependencies.nihav_core]
+path = "../nihav-core"
+features = []
+
+[features]
+default = ["all_decoders", "all_demuxers"]
+demuxers = []
+all_demuxers = ["demuxer_gdv"]
+demuxer_gdv = ["demuxers"]
+
+all_decoders = ["all_video_decoders", "all_audio_decoders"]
+decoders = []
+
+all_video_decoders = ["decoder_gdvvid"]
+decoder_gdvvid = ["decoders"]
+
+all_audio_decoders = []
-use crate::formats;
-use crate::formats::{NAChannelType, NAChannelMap};
-use super::*;
-use crate::io::byteio::*;
+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::codecs::*;
+use nihav_core::io::byteio::*;
struct GremlinVideoDecoder {
info: Rc<NACodecInfo>,
--- /dev/null
+use nihav_core::codecs::*;
+
+macro_rules! validate {
+ ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
+}
+
+#[cfg(feature="decoder_gdvvid")]
+pub mod gremlinvideo;
+
+const GAME_CODECS: &[DecoderInfo] = &[
+#[cfg(feature="decoder_gdvvid")]
+ DecoderInfo { name: "gdv-audio", get_decoder: gremlinvideo::get_decoder_audio },
+#[cfg(feature="decoder_gdvvid")]
+ DecoderInfo { name: "gdv-video", get_decoder: gremlinvideo::get_decoder_video },
+];
+
+pub fn game_register_all_codecs(rd: &mut RegisteredDecoders) {
+ for decoder in GAME_CODECS.into_iter() {
+ rd.add_decoder(decoder.clone());
+ }
+}
-use super::*;
-//use io::byteio::*;
-//use frame::*;
-use crate::formats::*;
+use nihav_core::frame::*;
+use nihav_core::demuxers::*;
+use nihav_core::io::byteio::*;
+use nihav_core::formats::*;
//use std::collections::HashMap;
enum GDVState {
--- /dev/null
+use nihav_core::demuxers::*;
+
+macro_rules! validate {
+ ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DemuxerError::InvalidData); } };
+}
+
+#[cfg(feature="demuxer_gdv")]
+mod gdv;
+
+const GAME_DEMUXERS: &[&'static DemuxerCreator] = &[
+#[cfg(feature="demuxer_gdv")]
+ &gdv::GDVDemuxerCreator {},
+];
+
+pub fn game_register_all_demuxers(rd: &mut RegisteredDemuxers) {
+ for demuxer in GAME_DEMUXERS.into_iter() {
+ rd.add_demuxer(*demuxer);
+ }
+}
--- /dev/null
+extern crate nihav_core;
+
+pub mod codecs;
+pub mod demuxers;
\ No newline at end of file
--- /dev/null
+[package]
+name = "nihav_indeo"
+version = "0.1.0"
+authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
+edition = "2018"
+
+[dependencies.nihav_core]
+path = "../nihav-core"
+features = ["h263", "fft", "dsp_window"]
+
+[features]
+default = ["all_decoders"]
+
+all_decoders = ["decoder_imc", "decoder_indeo2", "decoder_indeo3", "decoder_indeo4", "decoder_indeo5", "decoder_intel263"]
+decoders = []
+
+decoder_imc = ["decoders"]
+decoder_indeo2 = ["decoders"]
+decoder_indeo3 = ["decoders"]
+decoder_indeo4 = ["decoders"]
+decoder_indeo5 = ["decoders"]
+decoder_intel263 = ["decoders"]
use std::mem;
use std::ptr;
use std::f32::consts;
-
-use crate::formats::*;
-use crate::frame::*;
-use super::super::*;
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::dsp::fft::*;
-use crate::dsp::window::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+
+use nihav_core::formats::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::dsp::fft::*;
+use nihav_core::dsp::window::*;
const BANDS: usize = 32;
const COEFFS: usize = 256;
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::formats;
-use super::super::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::formats;
+use nihav_core::codecs::*;
+use nihav_core::frame::*;
static INDEO2_DELTA_TABLE: [[u8; 256]; 4] = [
[
-use crate::formats;
-use super::super::*;
-use crate::io::byteio::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats;
+use nihav_core::codecs::*;
+use nihav_core::frame::*;
+use nihav_core::io::byteio::*;
use std::io::SeekFrom;
use std::mem;
-use std::cell::Ref;
-use crate::io::bitreader::*;
-use crate::formats;
-use super::super::*;
+use std::rc::Rc;
+use std::cell::{Ref, RefCell};
+use nihav_core::io::bitreader::*;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
use super::ivi::*;
use super::ivibr::*;
-use std::cell::Ref;
-use crate::io::bitreader::*;
-use crate::formats;
-use super::super::*;
+use std::rc::Rc;
+use std::cell::{Ref, RefCell};
+use nihav_core::io::bitreader::*;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
use super::ivi::*;
use super::ivibr::*;
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::formats;
-use super::super::*;
-use super::*;
-use super::decoder::*;
-use super::data::*;
-use super::code::H263BlockDSP;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::codecs::h263::*;
+use nihav_core::codecs::h263::decoder::*;
+use nihav_core::codecs::h263::data::*;
+use nihav_core::codecs::h263::code::H263BlockDSP;
#[allow(dead_code)]
struct Tables {
use std::mem;
use std::rc::Rc;
use std::cell::{Ref,RefCell};
-use crate::io::bitreader::*;
+use nihav_core::io::bitreader::*;
//use io::intcode::*;
-use super::super::*;
-use crate::formats::*;
+use nihav_core::codecs::*;
+use nihav_core::formats::*;
+use nihav_core::frame::*;
use super::ivi::*;
use super::ividsp::*;
--- /dev/null
+use nihav_core::codecs::*;
+
+macro_rules! validate {
+ ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
+}
+
+#[cfg(feature="decoder_intel263")]
+mod intel263;
+#[cfg(feature="decoder_indeo2")]
+mod indeo2;
+#[cfg(feature="decoder_indeo3")]
+mod indeo3;
+#[cfg(feature="decoder_indeo4")]
+mod indeo4;
+#[cfg(feature="decoder_indeo5")]
+mod indeo5;
+
+#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
+mod ivi;
+#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
+mod ivibr;
+#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
+mod ividsp;
+
+#[cfg(feature="decoder_imc")]
+mod imc;
+
+const INDEO_CODECS: &[DecoderInfo] = &[
+#[cfg(feature="decoder_indeo2")]
+ DecoderInfo { name: "indeo2", get_decoder: indeo2::get_decoder },
+#[cfg(feature="decoder_indeo3")]
+ DecoderInfo { name: "indeo3", get_decoder: indeo3::get_decoder },
+#[cfg(feature="decoder_indeo4")]
+ DecoderInfo { name: "indeo4", get_decoder: indeo4::get_decoder },
+#[cfg(feature="decoder_indeo5")]
+ DecoderInfo { name: "indeo5", get_decoder: indeo5::get_decoder },
+#[cfg(feature="decoder_intel263")]
+ DecoderInfo { name: "intel263", get_decoder: intel263::get_decoder },
+
+#[cfg(feature="decoder_imc")]
+ DecoderInfo { name: "imc", get_decoder: imc::get_decoder_imc },
+#[cfg(feature="decoder_imc")]
+ DecoderInfo { name: "iac", get_decoder: imc::get_decoder_iac },
+];
+
+pub fn indeo_register_all_codecs(rd: &mut RegisteredDecoders) {
+ for decoder in INDEO_CODECS.into_iter() {
+ rd.add_decoder(decoder.clone());
+ }
+}
--- /dev/null
+extern crate nihav_core;
+
+pub mod codecs;
--- /dev/null
+[package]
+name = "nihav_realmedia"
+version = "0.1.0"
+authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"]
+edition = "2018"
+
+[dependencies.nihav_core]
+path = "../nihav-core"
+features = ["h263", "mdct"]
+
+[features]
+default = ["all_decoders", "all_demuxers"]
+demuxers = []
+all_demuxers = ["demuxer_real"]
+demuxer_real = ["demuxers"]
+
+all_decoders = ["all_video_decoders", "all_audio_decoders"]
+decoders = []
+h263 = []
+
+all_video_decoders = ["decoder_realvideo1", "decoder_realvideo2", "decoder_realvideo3", "decoder_realvideo4", "decoder_realvideo6"]
+decoder_realvideo1 = ["h263", "decoders"]
+decoder_realvideo2 = ["h263", "decoders"]
+decoder_realvideo3 = ["decoders"]
+decoder_realvideo4 = ["decoders"]
+decoder_realvideo6 = ["decoders"]
+
+all_audio_decoders = ["decoder_realaudio144", "decoder_realaudio288", "decoder_cook", "decoder_ralf"]
+decoder_realaudio144 = ["decoders"]
+decoder_realaudio288 = ["decoders"]
+decoder_cook = ["decoders"]
+decoder_ralf = ["decoders"]
-use crate::formats::*;
-use crate::frame::*;
-use super::super::*;
-use crate::dsp::fft::FFTMode;
-use crate::dsp::mdct::IMDCT;
-use crate::io::bitreader::*;
-use crate::io::byteio::{ByteReader, MemoryReader};
-use crate::io::codebook::*;
-use crate::io::intcode::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::dsp::fft::FFTMode;
+use nihav_core::dsp::mdct::IMDCT;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::byteio::{ByteReader, MemoryReader};
+use nihav_core::io::codebook::*;
+use nihav_core::io::intcode::*;
use std::f32::consts;
use std::mem::swap;
--- /dev/null
+use nihav_core::codecs::*;
+
+macro_rules! validate {
+ ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
+}
+
+#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
+mod rv3040;
+#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
+mod rv34codes;
+#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
+mod rv34dsp;
+
+#[cfg(feature="decoder_realvideo1")]
+pub mod rv10;
+#[cfg(feature="decoder_realvideo2")]
+pub mod rv20;
+#[cfg(feature="decoder_realvideo3")]
+pub mod rv30;
+#[cfg(feature="decoder_realvideo3")]
+pub mod rv30dsp;
+#[cfg(feature="decoder_realvideo4")]
+pub mod rv40;
+#[cfg(feature="decoder_realvideo4")]
+pub mod rv40dsp;
+#[cfg(feature="decoder_realvideo6")]
+pub mod rv60;
+#[cfg(feature="decoder_realvideo6")]
+pub mod rv60codes;
+#[cfg(feature="decoder_realvideo6")]
+pub mod rv60dsp;
+
+#[cfg(feature="decoder_realaudio144")]
+pub mod ra144;
+#[cfg(feature="decoder_realaudio288")]
+pub mod ra288;
+#[cfg(feature="decoder_cook")]
+pub mod cook;
+#[cfg(feature="decoder_ralf")]
+pub mod ralf;
+
+const RM_CODECS: &[DecoderInfo] = &[
+#[cfg(feature="decoder_realvideo1")]
+ DecoderInfo { name: "realvideo1", get_decoder: rv10::get_decoder },
+#[cfg(feature="decoder_realvideo2")]
+ DecoderInfo { name: "realvideo2", get_decoder: rv20::get_decoder },
+#[cfg(feature="decoder_realvideo3")]
+ DecoderInfo { name: "realvideo3", get_decoder: rv30::get_decoder },
+#[cfg(feature="decoder_realvideo4")]
+ DecoderInfo { name: "realvideo4", get_decoder: rv40::get_decoder },
+#[cfg(feature="decoder_realvideo6")]
+ DecoderInfo { name: "realvideo6", get_decoder: rv60::get_decoder },
+
+#[cfg(feature="decoder_realaudio144")]
+ DecoderInfo { name: "ra14.4", get_decoder: ra144::get_decoder },
+#[cfg(feature="decoder_realaudio288")]
+ DecoderInfo { name: "ra28.8", get_decoder: ra288::get_decoder },
+#[cfg(feature="decoder_cook")]
+ DecoderInfo { name: "cook", get_decoder: cook::get_decoder },
+#[cfg(feature="decoder_ralf")]
+ DecoderInfo { name: "ralf", get_decoder: ralf::get_decoder },
+];
+
+pub fn realmedia_register_all_codecs(rd: &mut RegisteredDecoders) {
+ for decoder in RM_CODECS.into_iter() {
+ rd.add_decoder(decoder.clone());
+ }
+}
-use crate::formats::*;
-use crate::frame::*;
-use super::super::*;
-use crate::io::bitreader::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::io::bitreader::*;
const NBLOCKS: usize = 4;
const BLOCKSIZE: usize = 40;
-use crate::formats::*;
-use crate::frame::*;
-use super::super::*;
-use crate::io::bitreader::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::io::bitreader::*;
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
const NBLOCKS: usize = 32;
const BLOCKSIZE: usize = 5;
-use crate::formats::*;
-use crate::frame::*;
-use crate::codecs::*;
-use crate::io::byteio::*;
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::io::intcode::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::io::byteio::*;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::io::intcode::*;
struct CodebookSet {
filter_params_cb: Codebook<u16>,
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::formats;
-use super::super::*;
-use super::*;
-use super::code::H263BlockDSP;
-use super::decoder::*;
-use super::data::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::codecs::h263::*;
+use nihav_core::codecs::h263::code::H263BlockDSP;
+use nihav_core::codecs::h263::decoder::*;
+use nihav_core::codecs::h263::data::*;
#[allow(dead_code)]
struct Tables {
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::formats;
-use super::super::*;
-use super::*;
-use super::code::H263BlockDSP;
-use super::decoder::*;
-use super::data::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
+use nihav_core::codecs::h263::*;
+use nihav_core::codecs::h263::code::H263BlockDSP;
+use nihav_core::codecs::h263::decoder::*;
+use nihav_core::codecs::h263::data::*;
+
#[allow(dead_code)]
struct Tables {
-use crate::formats;
-use crate::io::bitreader::*;
-use crate::io::intcode::*;
-use crate::codecs::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::intcode::*;
+use nihav_core::frame::*;
+use nihav_core::codecs::*;
use super::rv3040::*;
use super::rv30dsp::*;
-use crate::formats::YUV420_FORMAT;
-use crate::frame::{NABufferType, NAVideoInfo, NAVideoBuffer, FrameType, alloc_video_buffer};
-use crate::codecs::{MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
-use crate::io::bitreader::{BitReader,BitReaderMode};
-use crate::io::intcode::*;
+use nihav_core::formats::YUV420_FORMAT;
+use nihav_core::frame::{NABufferType, NAVideoInfo, NAVideoBuffer, FrameType, alloc_video_buffer};
+use nihav_core::codecs::{MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
+use nihav_core::io::bitreader::{BitReader,BitReaderMode};
+use nihav_core::io::intcode::*;
use std::mem;
use super::rv34codes::*;
-use crate::frame::{FrameType, NAVideoBuffer};
-use crate::codecs::MV;
-use crate::codecs::blockdsp::edge_emu;
+use nihav_core::frame::{FrameType, NAVideoBuffer};
+use nihav_core::codecs::MV;
+use nihav_core::codecs::blockdsp::edge_emu;
use super::rv3040::{RV34DSP, RV34MBInfo};
fn clip8(a: i16) -> u8 {
-use crate::codecs::DecoderResult;
-use crate::io::bitreader::BitReader;
-use crate::io::codebook::*;
+use nihav_core::codecs::DecoderResult;
+use nihav_core::io::bitreader::BitReader;
+use nihav_core::io::codebook::*;
struct CBPSet {
cbp_pattern: Codebook<u16>,
-use crate::formats;
-use crate::io::bitreader::*;
-use crate::io::codebook::*;
-use crate::io::intcode::*;
-use crate::codecs::*;
+use std::rc::Rc;
+use std::cell::RefCell;
+use nihav_core::formats;
+use nihav_core::frame::*;
+use nihav_core::io::bitreader::*;
+use nihav_core::io::codebook::*;
+use nihav_core::io::intcode::*;
+use nihav_core::codecs::*;
use super::rv3040::*;
use super::rv40dsp::*;
--- /dev/null
+use frame::NAVideoBuffer;
+use codecs::MV;
+use codecs::blockdsp::edge_emu;
+use super::rv3040::{RV34DSP, RV34MBInfo};
+
+fn clip8(a: i16) -> u8 {
+ if a < 0 { 0 }
+ else if a > 255 { 255 }
+ else { a as u8 }
+}
+
+macro_rules! el {
+ ($s: ident, $o: expr) => ( $s[$o] as i16 )
+}
+
+macro_rules! filter {
+ (01; $s: ident, $o: expr, $step: expr) => (
+ clip8((( el!($s, $o - 2 * $step)
+ -5 * el!($s, $o - 1 * $step)
+ +52 * el!($s, $o - 0 * $step)
+ +20 * el!($s, $o + 1 * $step)
+ -5 * el!($s, $o + 2 * $step)
+ + el!($s, $o + 3 * $step) + 32) >> 6) as i16)
+ );
+ (02; $s: ident, $o: expr, $step: expr) => (
+ clip8((( el!($s, $o - 2 * $step)
+ -5 * el!($s, $o - 1 * $step)
+ +20 * el!($s, $o - 0 * $step)
+ +20 * el!($s, $o + 1 * $step)
+ -5 * el!($s, $o + 2 * $step)
+ + el!($s, $o + 3 * $step) + 16) >> 5) as i16)
+ );
+ (03; $s: ident, $o: expr, $step: expr) => (
+ clip8((( el!($s, $o - 2 * $step)
+ -5 * el!($s, $o - 1 * $step)
+ +20 * el!($s, $o - 0 * $step)
+ +52 * el!($s, $o + 1 * $step)
+ -5 * el!($s, $o + 2 * $step)
+ + el!($s, $o + 3 * $step) + 32) >> 6) as i16)
+ );
+}
+
+trait HFilt {
+ const HMODE: usize;
+ fn filter_h(src: &[u8], idx: usize) -> u8 {
+ match Self::HMODE {
+ 1 => filter!(01; src, idx, 1),
+ 2 => filter!(02; src, idx, 1),
+ 3 => filter!(03; src, idx, 1),
+ _ => src[idx],
+ }
+ }
+}
+trait VFilt {
+ const VMODE: usize;
+ fn filter_v(src: &[u8], idx: usize, stride: usize) -> u8 {
+ match Self::VMODE {
+ 1 => filter!(01; src, idx, stride),
+ 2 => filter!(02; src, idx, stride),
+ 3 => filter!(03; src, idx, stride),
+ _ => src[idx],
+ }
+ }
+}
+trait MC: HFilt+VFilt {
+ const SIZE: usize;
+ fn mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize) {
+ if (Self::HMODE != 0) && (Self::VMODE != 0) {
+ let mut buf: [u8; (16 + 5) * 16] = [0; (16 + 5) * 16];
+ let mut bidx = 0;
+ let bstride = Self::SIZE;
+ sidx -= sstride * 2;
+ for _ in 0..Self::SIZE+5 {
+ for x in 0..Self::SIZE { buf[bidx + x] = Self::filter_h(src, sidx + x); }
+ bidx += bstride;
+ sidx += sstride;
+ }
+ bidx = bstride * 2;
+ for _ in 0..Self::SIZE {
+ for x in 0..Self::SIZE { dst[didx + x] = Self::filter_v(&buf, bidx + x, bstride); }
+ didx += dstride;
+ bidx += bstride;
+ }
+ } else if Self::HMODE != 0 {
+ for _ in 0..Self::SIZE {
+ for x in 0..Self::SIZE {
+ dst[didx + x] = Self::filter_h(src, sidx + x);
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+ } else if Self::VMODE != 0 {
+ for _ in 0..Self::SIZE {
+ for x in 0..Self::SIZE {
+ dst[didx + x] = Self::filter_v(src, sidx + x, sstride);
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+ } else {
+ for _ in 0..Self::SIZE {
+ for x in 0..Self::SIZE {
+ dst[didx + x] = src[sidx + x];
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+ }
+ }
+}
+
+macro_rules! mc {
+ ($name: ident, $size: expr, $vf: expr, $hf: expr) => {
+ struct $name;
+ impl HFilt for $name { const HMODE: usize = $hf; }
+ impl VFilt for $name { const VMODE: usize = $vf; }
+ impl MC for $name { const SIZE: usize = $size; }
+ };
+}
+
+mc!(MC00_16, 16, 0, 0);
+mc!(MC01_16, 16, 0, 1);
+mc!(MC02_16, 16, 0, 2);
+mc!(MC03_16, 16, 0, 3);
+mc!(MC10_16, 16, 1, 0);
+mc!(MC11_16, 16, 1, 1);
+mc!(MC12_16, 16, 1, 2);
+mc!(MC13_16, 16, 1, 3);
+mc!(MC20_16, 16, 2, 0);
+mc!(MC21_16, 16, 2, 1);
+mc!(MC22_16, 16, 2, 2);
+mc!(MC23_16, 16, 2, 3);
+mc!(MC30_16, 16, 3, 1);
+mc!(MC31_16, 16, 3, 1);
+mc!(MC32_16, 16, 3, 2);
+mc!(MC33_16, 16, 3, 3);
+
+mc!(MC00_8, 8, 0, 0);
+mc!(MC01_8, 8, 0, 1);
+mc!(MC02_8, 8, 0, 2);
+mc!(MC03_8, 8, 0, 3);
+mc!(MC10_8, 8, 1, 0);
+mc!(MC11_8, 8, 1, 1);
+mc!(MC12_8, 8, 1, 2);
+mc!(MC13_8, 8, 1, 3);
+mc!(MC20_8, 8, 2, 0);
+mc!(MC21_8, 8, 2, 1);
+mc!(MC22_8, 8, 2, 2);
+mc!(MC23_8, 8, 2, 3);
+mc!(MC30_8, 8, 3, 1);
+mc!(MC31_8, 8, 3, 1);
+mc!(MC32_8, 8, 3, 2);
+mc!(MC33_8, 8, 3, 3);
+
+
+const RV40_CHROMA_BIAS: [[u16; 4]; 4] = [
+ [ 0, 4, 8, 4 ],
+ [ 8, 7, 8, 7 ],
+ [ 0, 8, 4, 8 ],
+ [ 8, 7, 8, 7 ]
+];
+
+fn rv40_chroma_mc(dst: &mut [u8], mut didx: usize, dstride: usize, src: &[u8], mut sidx: usize, sstride: usize, size: usize, x: usize, y: usize) {
+ if (x == 0) && (y == 0) {
+ for _ in 0..size {
+ for x in 0..size { dst[didx + x] = src[sidx + x]; }
+ didx += dstride;
+ sidx += sstride;
+ }
+ return;
+ }
+ let bias = RV40_CHROMA_BIAS[y >> 1][x >> 1];
+ if (x > 0) && (y > 0) {
+ let a = ((4 - x) * (4 - y)) as u16;
+ let b = (( x) * (4 - y)) as u16;
+ let c = ((4 - x) * ( y)) as u16;
+ let d = (( x) * ( y)) as u16;
+ for _ in 0..size {
+ for x in 0..size {
+ dst[didx + x] = ((a * (src[sidx + x] as u16)
+ + b * (src[sidx + x + 1] as u16)
+ + c * (src[sidx + x + sstride] as u16)
+ + d * (src[sidx + x + 1 + sstride] as u16) + bias) >> 4) as u8;
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+ } else {
+ let a = ((4 - x) * (4 - y)) as u16;
+ let e = (( x) * (4 - y) + (4 - x) * ( y)) as u16;
+ let step = if y > 0 { sstride } else { 1 };
+ for _ in 0..size {
+ for x in 0..size {
+ dst[didx + x] = ((a * (src[sidx + x] as u16)
+ + e * (src[sidx + x + step] as u16) + bias) >> 4) as u8;
+ }
+ didx += dstride;
+ sidx += sstride;
+ }
+ }
+}
+
+pub struct RV40DSP {
+ luma_mc: [[fn (&mut [u8], usize, usize, &[u8], usize, usize); 16]; 2],
+}
+
+impl RV40DSP {
+ pub fn new() -> Self {
+ RV40DSP {
+ luma_mc: [
+ [ MC00_16::mc, MC01_16::mc, MC02_16::mc, MC03_16::mc,
+ MC10_16::mc, MC11_16::mc, MC12_16::mc, MC13_16::mc,
+ MC20_16::mc, MC21_16::mc, MC22_16::mc, MC23_16::mc,
+ MC30_16::mc, MC31_16::mc, MC32_16::mc, MC33_16::mc ],
+ [ MC00_8::mc, MC01_8::mc, MC02_8::mc, MC03_8::mc,
+ MC10_8::mc, MC11_8::mc, MC12_8::mc, MC13_8::mc,
+ MC20_8::mc, MC21_8::mc, MC22_8::mc, MC23_8::mc,
+ MC30_8::mc, MC31_8::mc, MC32_8::mc, MC33_8::mc ] ],
+ }
+ }
+}
+
+fn check_pos(x: usize, y: usize, size: usize, w: usize, h: usize, dx: i16, dy: i16, e0: isize, e1: isize, e2: isize, e3: isize) -> bool {
+ let xn = (x as isize) + (dx as isize);
+ let yn = (y as isize) + (dy as isize);
+
+ (xn - e0 >= 0) && (xn + (size as isize) + e1 <= (w as isize)) && (yn - e2 >= 0) && (yn + (size as isize) + e3 <= (h as isize))
+}
+
+const RV40_EDGE1: [isize; 4] = [ 0, 2, 2, 2 ];
+const RV40_EDGE2: [isize; 4] = [ 0, 3, 3, 3 ];
+
+impl RV34DSP for RV40DSP {
+ fn loop_filter(&self, _frame: &mut NAVideoBuffer<u8>, _mbinfo: &[RV34MBInfo], _mb_w: usize, _mb_h: usize) {
+ }
+ fn do_luma_mc(&self, frame: &mut NAVideoBuffer<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, mv: MV, use16: bool, avg: bool) {
+ let size: usize = if use16 { 16 } else { 8 };
+ let dstride = frame.get_stride(0);
+ let doffset = frame.get_offset(0) + (if !avg { x + y * dstride } else { 0 });
+ let mut data = frame.get_data_mut();
+ let dst: &mut [u8] = data.as_mut_slice();
+
+ let (w_, h_) = prev_frame.get_dimensions(0);
+ let w = (w_ + 15) & !15;
+ let h = (h_ + 15) & !15;
+
+ let dx = mv.x >> 2;
+ let cx = (mv.x & 3) as usize;
+ let dy = mv.y >> 2;
+ let cy = (mv.y & 3) as usize;
+ let mode = cx + cy * 4;
+
+ if check_pos(x, y, size, w, h, dx, dy, RV40_EDGE1[cx], RV40_EDGE2[cx], RV40_EDGE1[cy], RV40_EDGE2[cy]) {
+ let sstride = prev_frame.get_stride(0);
+ let mut soffset = prev_frame.get_offset(0) + x + y * sstride;
+ let data = prev_frame.get_data();
+ let src: &[u8] = data.as_slice();
+ soffset = ((soffset as isize) + (dx as isize) + (dy as isize) * (sstride as isize)) as usize;
+ self.luma_mc[if use16 { 0 } else { 1 }][mode](dst, doffset, dstride, src, soffset, sstride);
+ } else {
+ let mut ebuf: [u8; 32*22] = [0; 32*22];
+ edge_emu(prev_frame, (x as isize) + (dx as isize) - 2, (y as isize) + (dy as isize) - 2, 16+5, 16+5, &mut ebuf, 32, 0);
+ self.luma_mc[if use16 { 0 } else { 1 }][mode](dst, doffset, dstride, &ebuf, 32*2 + 2, 32);
+ }
+ }
+ fn do_chroma_mc(&self, frame: &mut NAVideoBuffer<u8>, prev_frame: &NAVideoBuffer<u8>, x: usize, y: usize, comp: usize, mv: MV, use8: bool, avg: bool) {
+ let size: usize = if use8 { 8 } else { 4 };
+ let dstride = frame.get_stride(comp);
+ let doffset = frame.get_offset(comp) + (if !avg { x + y * dstride } else { 0 });
+ let mut data = frame.get_data_mut();
+ let dst: &mut [u8] = data.as_mut_slice();
+
+ let (w_, h_) = prev_frame.get_dimensions(comp);
+ let w = (w_ + 7) & !7;
+ let h = (h_ + 7) & !7;
+
+ let mvx = mv.x / 2;
+ let mvy = mv.y / 2;
+ let dx = mvx >> 2;
+ let mut cx = (mvx & 3) as usize;
+ let dy = mvy >> 2;
+ let mut cy = (mvy & 3) as usize;
+
+ if (cx == 3) && (cy == 3) {
+ cx = 2;
+ cy = 2;
+ }
+
+ if check_pos(x, y, size, w, h, dx, dy, 0, 0, 1, 1) {
+ let sstride = prev_frame.get_stride(comp);
+ let mut soffset = prev_frame.get_offset(comp) + x + y * sstride;
+ let data = prev_frame.get_data();
+ let src: &[u8] = data.as_slice();
+ soffset = ((soffset as isize) + (dx as isize) + (dy as isize) * (sstride as isize)) as usize;
+ rv40_chroma_mc(dst, doffset, dstride, src, soffset, sstride, size, cx, cy);
+ } else {
+ let mut ebuf: [u8; 16*10] = [0; 16*10];
+ edge_emu(prev_frame, (x as isize) + (dx as isize), (y as isize) + (dy as isize), 8+1, 8+1, &mut ebuf, 16, comp);
+ rv40_chroma_mc(dst, doffset, dstride, &ebuf, 0, 16, size, cx, cy);
+ }
+ }
+}
-use crate::frame::{FrameType, NAVideoBuffer};
-use crate::codecs::MV;
-use crate::codecs::blockdsp::edge_emu;
+use nihav_core::frame::{FrameType, NAVideoBuffer};
+use nihav_core::codecs::MV;
+use nihav_core::codecs::blockdsp::edge_emu;
use super::rv3040::{RV34DSP, RV34MBInfo};
fn clip8(a: i16) -> u8 {
use std::rc::Rc;
use std::cell::RefCell;
-use crate::formats::YUV420_FORMAT;
-use crate::frame::*;
-use crate::codecs::{NADecoder, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler};
-use crate::io::byteio::{MemoryReader,ByteReader};
-use crate::io::bitreader::{BitReader,BitReaderMode};
-use crate::io::intcode::*;
+use nihav_core::formats::YUV420_FORMAT;
+use nihav_core::frame::*;
+use nihav_core::codecs::{NADecoder, 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::*;
use super::rv60codes::*;
use super::rv60dsp::*;
-use crate::codecs::*;
-use crate::io::bitreader::BitReader;
-use crate::io::codebook::*;
+use nihav_core::codecs::*;
+use nihav_core::io::bitreader::BitReader;
+use nihav_core::io::codebook::*;
use std::mem;
use std::ptr;
-use crate::frame::NAVideoBuffer;
-use crate::codecs::MV;
-use crate::codecs::blockdsp::edge_emu;
+use nihav_core::frame::NAVideoBuffer;
+use nihav_core::codecs::MV;
+use nihav_core::codecs::blockdsp::edge_emu;
fn clip8(val: i16) -> u8 { val.min(255).max(0) as u8 }
--- /dev/null
+use std::rc::Rc;
+use nihav_core::demuxers::*;
+
+macro_rules! validate {
+ ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DemuxerError::InvalidData); } };
+}
+
+#[cfg(feature="demuxer_real")]
+mod realmedia;
+
+const RM_DEMUXERS: &[&'static DemuxerCreator] = &[
+#[cfg(feature="demuxer_real")]
+ &realmedia::RealMediaDemuxerCreator {},
+#[cfg(feature="demuxer_real")]
+ &realmedia::RealAudioDemuxerCreator {},
+#[cfg(feature="demuxer_real")]
+ &realmedia::RealIVRDemuxerCreator {},
+];
+
+pub fn realmedia_register_all_demuxers(rd: &mut RegisteredDemuxers) {
+ for demuxer in RM_DEMUXERS.into_iter() {
+ rd.add_demuxer(*demuxer);
+ }
+}
use super::*;
-use super::DemuxerError::*;
-//use io::byteio::*;
-//use frame::*;
-use crate::formats::*;
+use nihav_core::demuxers::DemuxerError::*;
+use nihav_core::io::byteio::*;
+use nihav_core::frame::*;
+use nihav_core::formats::*;
use std::io::SeekFrom;
use std::mem;
use std::fmt;
--- /dev/null
+extern crate nihav_core;
+
+pub mod codecs;
+pub mod demuxers;
\ No newline at end of file
+++ /dev/null
-#[cfg(feature="decoder_indeo2")]
-pub mod indeo2;
-#[cfg(feature="decoder_indeo3")]
-pub mod indeo3;
-#[cfg(feature="decoder_indeo4")]
-pub mod indeo4;
-#[cfg(feature="decoder_indeo5")]
-pub mod indeo5;
-
-#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
-mod ivi;
-#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
-mod ivibr;
-#[cfg(any(feature="decoder_indeo4", feature="decoder_indeo5"))]
-mod ividsp;
-
-#[cfg(feature="decoder_imc")]
-pub mod imc;
+++ /dev/null
-#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
-mod rv3040;
-#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
-mod rv34codes;
-#[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
-mod rv34dsp;
-
-#[cfg(feature="decoder_realvideo3")]
-pub mod rv30;
-#[cfg(feature="decoder_realvideo3")]
-pub mod rv30dsp;
-#[cfg(feature="decoder_realvideo4")]
-pub mod rv40;
-#[cfg(feature="decoder_realvideo4")]
-pub mod rv40dsp;
-#[cfg(feature="decoder_realvideo6")]
-pub mod rv60;
-#[cfg(feature="decoder_realvideo6")]
-pub mod rv60codes;
-#[cfg(feature="decoder_realvideo6")]
-pub mod rv60dsp;
-
-#[cfg(feature="decoder_realaudio144")]
-pub mod ra144;
-#[cfg(feature="decoder_realaudio288")]
-pub mod ra288;
-#[cfg(feature="decoder_cook")]
-pub mod cook;
-#[cfg(feature="decoder_ralf")]
-pub mod ralf;
-