]> git.nihav.org Git - nihav.git/commitdiff
split NihAV into subcrates
authorKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 17 Jan 2019 11:25:49 +0000 (12:25 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Thu, 17 Jan 2019 11:25:49 +0000 (12:25 +0100)
78 files changed:
Cargo.toml [deleted file]
nihav-allstuff/Cargo.toml [new file with mode: 0644]
nihav-allstuff/src/lib.rs [new file with mode: 0644]
nihav-core/Cargo.toml [new file with mode: 0644]
nihav-core/src/TODO [moved from src/TODO with 100% similarity]
nihav-core/src/codecs/aac.rs [moved from src/codecs/aac.rs with 100% similarity]
nihav-core/src/codecs/atrac3.rs [moved from src/codecs/atrac3.rs with 100% similarity]
nihav-core/src/codecs/blockdsp.rs [moved from src/codecs/blockdsp.rs with 100% similarity]
nihav-core/src/codecs/clearvideo.rs [moved from src/codecs/clearvideo.rs with 100% similarity]
nihav-core/src/codecs/h263/code.rs [moved from src/codecs/h263/code.rs with 100% similarity]
nihav-core/src/codecs/h263/data.rs [moved from src/codecs/h263/data.rs with 100% similarity]
nihav-core/src/codecs/h263/decoder.rs [moved from src/codecs/h263/decoder.rs with 100% similarity]
nihav-core/src/codecs/h263/mod.rs [moved from src/codecs/h263/mod.rs with 98% similarity]
nihav-core/src/codecs/mod.rs [moved from src/codecs/mod.rs with 61% similarity]
nihav-core/src/codecs/pcm.rs [moved from src/codecs/pcm.rs with 100% similarity]
nihav-core/src/codecs/sipro.rs [moved from src/codecs/sipro.rs with 100% similarity]
nihav-core/src/codecs/ts102366.rs [moved from src/codecs/ts102366.rs with 100% similarity]
nihav-core/src/demuxers/avi.rs [moved from src/demuxers/avi.rs with 100% similarity]
nihav-core/src/demuxers/mod.rs [moved from src/demuxers/mod.rs with 90% similarity]
nihav-core/src/detect.rs [moved from src/detect.rs with 100% similarity]
nihav-core/src/dsp/fft.rs [moved from src/dsp/fft.rs with 100% similarity]
nihav-core/src/dsp/mdct.rs [moved from src/dsp/mdct.rs with 100% similarity]
nihav-core/src/dsp/mod.rs [moved from src/dsp/mod.rs with 100% similarity]
nihav-core/src/dsp/window.rs [moved from src/dsp/window.rs with 100% similarity]
nihav-core/src/formats.rs [moved from src/formats.rs with 100% similarity]
nihav-core/src/frame.rs [moved from src/frame.rs with 100% similarity]
nihav-core/src/io/bitreader.rs [moved from src/io/bitreader.rs with 100% similarity]
nihav-core/src/io/byteio.rs [moved from src/io/byteio.rs with 100% similarity]
nihav-core/src/io/codebook.rs [moved from src/io/codebook.rs with 100% similarity]
nihav-core/src/io/intcode.rs [moved from src/io/intcode.rs with 100% similarity]
nihav-core/src/io/mod.rs [moved from src/io/mod.rs with 100% similarity]
nihav-core/src/lib.rs [moved from src/lib.rs with 100% similarity]
nihav-core/src/register.rs [moved from src/register.rs with 98% similarity]
nihav-core/src/test/dec_video.rs [moved from src/test/dec_video.rs with 100% similarity]
nihav-core/src/test/mod.rs [moved from src/test/mod.rs with 100% similarity]
nihav-core/src/test/wavwriter.rs [moved from src/test/wavwriter.rs with 100% similarity]
nihav-game/Cargo.toml [new file with mode: 0644]
nihav-game/src/codecs/gremlinvideo.rs [moved from src/codecs/gremlinvideo.rs with 99% similarity]
nihav-game/src/codecs/mod.rs [new file with mode: 0644]
nihav-game/src/demuxers/gdv.rs [moved from src/demuxers/gdv.rs with 98% similarity]
nihav-game/src/demuxers/mod.rs [new file with mode: 0644]
nihav-game/src/lib.rs [new file with mode: 0644]
nihav-indeo/Cargo.toml [new file with mode: 0644]
nihav-indeo/src/codecs/imc.rs [moved from src/codecs/indeo/imc.rs with 99% similarity]
nihav-indeo/src/codecs/indeo2.rs [moved from src/codecs/indeo/indeo2.rs with 98% similarity]
nihav-indeo/src/codecs/indeo3.rs [moved from src/codecs/indeo/indeo3.rs with 99% similarity]
nihav-indeo/src/codecs/indeo4.rs [moved from src/codecs/indeo/indeo4.rs with 99% similarity]
nihav-indeo/src/codecs/indeo5.rs [moved from src/codecs/indeo/indeo5.rs with 99% similarity]
nihav-indeo/src/codecs/intel263.rs [moved from src/codecs/h263/intel263.rs with 97% similarity]
nihav-indeo/src/codecs/ivi.rs [moved from src/codecs/indeo/ivi.rs with 100% similarity]
nihav-indeo/src/codecs/ivibr.rs [moved from src/codecs/indeo/ivibr.rs with 99% similarity]
nihav-indeo/src/codecs/ividsp.rs [moved from src/codecs/indeo/ividsp.rs with 100% similarity]
nihav-indeo/src/codecs/mod.rs [new file with mode: 0644]
nihav-indeo/src/lib.rs [new file with mode: 0644]
nihav-realmedia/Cargo.toml [new file with mode: 0644]
nihav-realmedia/src/codecs/cook.rs [moved from src/codecs/real/cook.rs with 99% similarity]
nihav-realmedia/src/codecs/mod.rs [new file with mode: 0644]
nihav-realmedia/src/codecs/ra144.rs [moved from src/codecs/real/ra144.rs with 99% similarity]
nihav-realmedia/src/codecs/ra288.rs [moved from src/codecs/real/ra288.rs with 98% similarity]
nihav-realmedia/src/codecs/ralf.rs [moved from src/codecs/real/ralf.rs with 99% similarity]
nihav-realmedia/src/codecs/rv10.rs [moved from src/codecs/h263/rv10.rs with 98% similarity]
nihav-realmedia/src/codecs/rv20.rs [moved from src/codecs/h263/rv20.rs with 98% similarity]
nihav-realmedia/src/codecs/rv30.rs [moved from src/codecs/real/rv30.rs with 98% similarity]
nihav-realmedia/src/codecs/rv3040.rs [moved from src/codecs/real/rv3040.rs with 99% similarity]
nihav-realmedia/src/codecs/rv30dsp.rs [moved from src/codecs/real/rv30dsp.rs with 99% similarity]
nihav-realmedia/src/codecs/rv34codes.rs [moved from src/codecs/real/rv34codes.rs with 99% similarity]
nihav-realmedia/src/codecs/rv34dsp.rs [moved from src/codecs/real/rv34dsp.rs with 100% similarity]
nihav-realmedia/src/codecs/rv40.rs [moved from src/codecs/real/rv40.rs with 99% similarity]
nihav-realmedia/src/codecs/rv40dsp-trait.rs [new file with mode: 0644]
nihav-realmedia/src/codecs/rv40dsp.rs [moved from src/codecs/real/rv40dsp.rs with 99% similarity]
nihav-realmedia/src/codecs/rv60.rs [moved from src/codecs/real/rv60.rs with 99% similarity]
nihav-realmedia/src/codecs/rv60codes.rs [moved from src/codecs/real/rv60codes.rs with 99% similarity]
nihav-realmedia/src/codecs/rv60dsp.rs [moved from src/codecs/real/rv60dsp.rs with 99% similarity]
nihav-realmedia/src/demuxers/mod.rs [new file with mode: 0644]
nihav-realmedia/src/demuxers/realmedia.rs [moved from src/demuxers/realmedia.rs with 99% similarity]
nihav-realmedia/src/lib.rs [new file with mode: 0644]
src/codecs/indeo/mod.rs [deleted file]
src/codecs/real/mod.rs [deleted file]

diff --git a/Cargo.toml b/Cargo.toml
deleted file mode 100644 (file)
index 6bda4bb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-[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"]
diff --git a/nihav-allstuff/Cargo.toml b/nihav-allstuff/Cargo.toml
new file mode 100644 (file)
index 0000000..e366f4e
--- /dev/null
@@ -0,0 +1,11 @@
+[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
diff --git a/nihav-allstuff/src/lib.rs b/nihav-allstuff/src/lib.rs
new file mode 100644 (file)
index 0000000..cb1e713
--- /dev/null
@@ -0,0 +1,28 @@
+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);
+}
diff --git a/nihav-core/Cargo.toml b/nihav-core/Cargo.toml
new file mode 100644 (file)
index 0000000..35657bc
--- /dev/null
@@ -0,0 +1,31 @@
+[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"]
similarity index 100%
rename from src/TODO
rename to nihav-core/src/TODO
similarity index 98%
rename from src/codecs/h263/mod.rs
rename to nihav-core/src/codecs/h263/mod.rs
index 87188879f39131322d55d3ad62b44078f5dba4a7..1cd10a2e18283d99df3c96c7a3f5fcd7635ee1ef 100644 (file)
@@ -5,13 +5,6 @@ pub mod code;
 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>;
similarity index 61%
rename from src/codecs/mod.rs
rename to nihav-core/src/codecs/mod.rs
index 92aba8edf098e77923747d3cdd7ee09adb593b34..f3fabf3a642dad3c249c7c08a9f9fe16ed652aff 100644 (file)
@@ -50,21 +50,21 @@ macro_rules! validate {
 }
 
 #[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();
@@ -74,7 +74,7 @@ impl HAMShuffler {
         }
     }
     #[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,
@@ -83,21 +83,21 @@ impl HAMShuffler {
 }
 
 #[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 {
@@ -107,23 +107,23 @@ impl IPShuffler {
 }
 
 #[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 {
@@ -131,7 +131,7 @@ impl IPBShuffler {
         }
     }
     #[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 {
@@ -139,7 +139,7 @@ impl IPBShuffler {
         }
     }
     #[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 {
@@ -147,7 +147,7 @@ impl IPBShuffler {
         }
     }
     #[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 {
@@ -231,23 +231,19 @@ pub trait NADecoder {
 
 #[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;
@@ -265,60 +261,42 @@ const DECODERS: &[DecoderInfo] = &[
     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
 }
similarity index 90%
rename from src/demuxers/mod.rs
rename to nihav-core/src/demuxers/mod.rs
index adf954af270d215ed0bf5aa88f769308095b61af..56e670db986575f50bf2e0e52f85955e2833844b 100644 (file)
@@ -14,7 +14,7 @@ pub enum DemuxerError {
     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<()>;
@@ -204,39 +204,45 @@ macro_rules! validate {
     ($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);
+    }
+}
similarity index 100%
rename from src/detect.rs
rename to nihav-core/src/detect.rs
similarity index 100%
rename from src/dsp/fft.rs
rename to nihav-core/src/dsp/fft.rs
similarity index 100%
rename from src/dsp/mdct.rs
rename to nihav-core/src/dsp/mdct.rs
similarity index 100%
rename from src/dsp/mod.rs
rename to nihav-core/src/dsp/mod.rs
similarity index 100%
rename from src/formats.rs
rename to nihav-core/src/formats.rs
similarity index 100%
rename from src/frame.rs
rename to nihav-core/src/frame.rs
similarity index 100%
rename from src/io/byteio.rs
rename to nihav-core/src/io/byteio.rs
similarity index 100%
rename from src/io/mod.rs
rename to nihav-core/src/io/mod.rs
similarity index 100%
rename from src/lib.rs
rename to nihav-core/src/lib.rs
similarity index 98%
rename from src/register.rs
rename to nihav-core/src/register.rs
index b0bce3a2ad59e63906e22d048bcf88d6cbe7c010..5ab28bb94797cf0df7b9b73ffa3abb6bfb036e76 100644 (file)
@@ -30,10 +30,10 @@ const CODEC_CAP_SCALABLE:u32    = 0x000010;
 
 #[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 {
similarity index 100%
rename from src/test/mod.rs
rename to nihav-core/src/test/mod.rs
diff --git a/nihav-game/Cargo.toml b/nihav-game/Cargo.toml
new file mode 100644 (file)
index 0000000..789161d
--- /dev/null
@@ -0,0 +1,23 @@
+[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 = []
similarity index 99%
rename from src/codecs/gremlinvideo.rs
rename to nihav-game/src/codecs/gremlinvideo.rs
index 28663a4d49538c7bdd32f770aa0b725b61488350..b6929d11a9e7d65714941040dc9d9de75b226007 100644 (file)
@@ -1,7 +1,10 @@
-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>,
diff --git a/nihav-game/src/codecs/mod.rs b/nihav-game/src/codecs/mod.rs
new file mode 100644 (file)
index 0000000..1b6e473
--- /dev/null
@@ -0,0 +1,21 @@
+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());
+    }
+}
similarity index 98%
rename from src/demuxers/gdv.rs
rename to nihav-game/src/demuxers/gdv.rs
index 63b7364df6d5ba0d29f057bafbe8725ed50e3619..6acacc141aeac9c241dc878a3f48fd1eb627d545 100644 (file)
@@ -1,7 +1,7 @@
-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 {
diff --git a/nihav-game/src/demuxers/mod.rs b/nihav-game/src/demuxers/mod.rs
new file mode 100644 (file)
index 0000000..f2aeb3b
--- /dev/null
@@ -0,0 +1,19 @@
+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);
+    }
+}
diff --git a/nihav-game/src/lib.rs b/nihav-game/src/lib.rs
new file mode 100644 (file)
index 0000000..d7a15d0
--- /dev/null
@@ -0,0 +1,4 @@
+extern crate nihav_core;
+
+pub mod codecs;
+pub mod demuxers;
\ No newline at end of file
diff --git a/nihav-indeo/Cargo.toml b/nihav-indeo/Cargo.toml
new file mode 100644 (file)
index 0000000..f257862
--- /dev/null
@@ -0,0 +1,22 @@
+[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"]
similarity index 99%
rename from src/codecs/indeo/imc.rs
rename to nihav-indeo/src/codecs/imc.rs
index f11daa90c29a3a7b7723ca80840dd7fe81a85808..5840846e9ef81b1643e1fb0960b48f75d21bd227 100644 (file)
@@ -1,14 +1,16 @@
 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;
similarity index 98%
rename from src/codecs/indeo/indeo2.rs
rename to nihav-indeo/src/codecs/indeo2.rs
index 61f1c777c8945fc583bb0b8e3355963a8d9b5057..ffd36c608103e79a15ca3df69a8f2f28f9cc9a8f 100644 (file)
@@ -1,7 +1,10 @@
-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] = [
     [
similarity index 99%
rename from src/codecs/indeo/indeo3.rs
rename to nihav-indeo/src/codecs/indeo3.rs
index 5b4876de33a959184e338dca1be84008ea8f70ed..e17c1184867e6ed4eaa32f2963c23f95c3f58478 100644 (file)
@@ -1,6 +1,9 @@
-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;
 
similarity index 99%
rename from src/codecs/indeo/indeo4.rs
rename to nihav-indeo/src/codecs/indeo4.rs
index 773b17724cc26063712d601095a5fb21a213d344..58c246ecd5f768697eadcd4398b6c19fb2dfda5c 100644 (file)
@@ -1,7 +1,9 @@
-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::*;
 
similarity index 99%
rename from src/codecs/indeo/indeo5.rs
rename to nihav-indeo/src/codecs/indeo5.rs
index c761a8e06787c1d12045707aa845729101acbe86..5256fa424ee13c6d6e1393cb7bf6f3d12ca21a10 100644 (file)
@@ -1,7 +1,9 @@
-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::*;
 
similarity index 97%
rename from src/codecs/h263/intel263.rs
rename to nihav-indeo/src/codecs/intel263.rs
index 9e36a49651991db54e016ed4c215da5893bb4bf2..df9b85235300e6d4b0fec25e1070689120d76e26 100644 (file)
@@ -1,11 +1,14 @@
-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 {
similarity index 99%
rename from src/codecs/indeo/ivibr.rs
rename to nihav-indeo/src/codecs/ivibr.rs
index 3011e1a90421a6a83ed8ec1b702ed0f3e2ef27e0..10581c80a539e55c7a570b09f6b0d5a6eff05338 100644 (file)
@@ -1,10 +1,11 @@
 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::*;
 
diff --git a/nihav-indeo/src/codecs/mod.rs b/nihav-indeo/src/codecs/mod.rs
new file mode 100644 (file)
index 0000000..63bad83
--- /dev/null
@@ -0,0 +1,50 @@
+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());
+    }
+}
diff --git a/nihav-indeo/src/lib.rs b/nihav-indeo/src/lib.rs
new file mode 100644 (file)
index 0000000..adda3bf
--- /dev/null
@@ -0,0 +1,3 @@
+extern crate nihav_core;
+
+pub mod codecs;
diff --git a/nihav-realmedia/Cargo.toml b/nihav-realmedia/Cargo.toml
new file mode 100644 (file)
index 0000000..cfaf2ac
--- /dev/null
@@ -0,0 +1,32 @@
+[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"]
similarity index 99%
rename from src/codecs/real/cook.rs
rename to nihav-realmedia/src/codecs/cook.rs
index 2fcff98f6dc312a7c92a8b5782339d0a550e85d3..de7ac54069da3be4453318deddb5a0b1d60f9f5a 100644 (file)
@@ -1,12 +1,14 @@
-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;
 
diff --git a/nihav-realmedia/src/codecs/mod.rs b/nihav-realmedia/src/codecs/mod.rs
new file mode 100644 (file)
index 0000000..1fe37e0
--- /dev/null
@@ -0,0 +1,68 @@
+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());
+    }
+}
similarity index 99%
rename from src/codecs/real/ra144.rs
rename to nihav-realmedia/src/codecs/ra144.rs
index 1fdace09689208f5e54c218b0070ef0647a379a1..45e98ebc92464b51767338f91f20bd9c88f6a99b 100644 (file)
@@ -1,7 +1,9 @@
-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;
similarity index 98%
rename from src/codecs/real/ra288.rs
rename to nihav-realmedia/src/codecs/ra288.rs
index 6a5a352795615535117859b115be385ead54c331..3d9b51ba340689fa3e4e3e89ccac244f16ffc430 100644 (file)
@@ -1,7 +1,9 @@
-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;
similarity index 99%
rename from src/codecs/real/ralf.rs
rename to nihav-realmedia/src/codecs/ralf.rs
index 3b5d88f2f82af8a2fbde6bf6bb2896cb11c18896..f65eaeaff0254536ad1df2421902981582825e9f 100644 (file)
@@ -1,10 +1,12 @@
-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>,
similarity index 98%
rename from src/codecs/h263/rv10.rs
rename to nihav-realmedia/src/codecs/rv10.rs
index 7e41b7afdb957c75e88c416d66177795f3fa5cef..3e21315f349d5141d886a2e6ad7fa2d42917a1e2 100644 (file)
@@ -1,11 +1,14 @@
-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 {
similarity index 98%
rename from src/codecs/h263/rv20.rs
rename to nihav-realmedia/src/codecs/rv20.rs
index 11dbe2edb199f73390617e4dd82d67b35cb60a61..d839840c4adfeb56476074dcf2c72c4895516e66 100644 (file)
@@ -1,11 +1,15 @@
-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 {
similarity index 98%
rename from src/codecs/real/rv30.rs
rename to nihav-realmedia/src/codecs/rv30.rs
index cf7e31317d58baa6a044bd3fcf3d379ec21fed55..348209099444514646fbb611a1fe7c08e77e18e7 100644 (file)
@@ -1,7 +1,10 @@
-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::*;
 
similarity index 99%
rename from src/codecs/real/rv3040.rs
rename to nihav-realmedia/src/codecs/rv3040.rs
index d1107ba0786a1a2378693c137636e14528d91f15..2d76eaa3e6d2b8ff8f11ea9b129bcd4a66add547 100644 (file)
@@ -1,8 +1,8 @@
-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::*;
similarity index 99%
rename from src/codecs/real/rv30dsp.rs
rename to nihav-realmedia/src/codecs/rv30dsp.rs
index b1365db5bbf0c23671ca804a4cd59e1d5fabaf32..dc7ed094efb7f922856f2fabab63535b581fe74b 100644 (file)
@@ -1,6 +1,6 @@
-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 {
similarity index 99%
rename from src/codecs/real/rv34codes.rs
rename to nihav-realmedia/src/codecs/rv34codes.rs
index 370f288a7a815c3fb55f9ecce72d1d4bf80f40ab..290d50398b729bf29f1a0273b27240d047946233 100644 (file)
@@ -1,6 +1,6 @@
-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>,
similarity index 99%
rename from src/codecs/real/rv40.rs
rename to nihav-realmedia/src/codecs/rv40.rs
index c6645989f4f174f5638e92629b6539995705bc8f..542b644006be82ff1511e987e8714cca952e9a7d 100644 (file)
@@ -1,8 +1,11 @@
-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::*;
 
diff --git a/nihav-realmedia/src/codecs/rv40dsp-trait.rs b/nihav-realmedia/src/codecs/rv40dsp-trait.rs
new file mode 100644 (file)
index 0000000..f00fd9c
--- /dev/null
@@ -0,0 +1,302 @@
+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);
+        }
+    }
+}
similarity index 99%
rename from src/codecs/real/rv40dsp.rs
rename to nihav-realmedia/src/codecs/rv40dsp.rs
index a6ee60797d3cdf621640c799d98ce9b95bc4562a..030321c30acd10307a22d8514de807c445fbdbcb 100644 (file)
@@ -1,6 +1,6 @@
-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 {
similarity index 99%
rename from src/codecs/real/rv60.rs
rename to nihav-realmedia/src/codecs/rv60.rs
index 2d1262b2b88e9d9802de15bd325295cba848e8a2..20a0f7ac92b2e4cd3c930d1d73d6e7096908ba17 100644 (file)
@@ -1,11 +1,11 @@
 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::*;
similarity index 99%
rename from src/codecs/real/rv60codes.rs
rename to nihav-realmedia/src/codecs/rv60codes.rs
index 3b85a808ec1408e9f6fc4f9e477d9dd05c083902..43bdce7442757baef3db63d296f9155a72eb5df5 100644 (file)
@@ -1,6 +1,6 @@
-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;
 
similarity index 99%
rename from src/codecs/real/rv60dsp.rs
rename to nihav-realmedia/src/codecs/rv60dsp.rs
index 3850acccad6c463ab43c12b38de3c1cd77165cb0..14e3fdbf183b9b2bfd780fda39327c8fcc2f1377 100644 (file)
@@ -1,6 +1,6 @@
-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 }
 
diff --git a/nihav-realmedia/src/demuxers/mod.rs b/nihav-realmedia/src/demuxers/mod.rs
new file mode 100644 (file)
index 0000000..5acf1f4
--- /dev/null
@@ -0,0 +1,24 @@
+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);
+    }
+}
similarity index 99%
rename from src/demuxers/realmedia.rs
rename to nihav-realmedia/src/demuxers/realmedia.rs
index 9026384f4242741d2887ab41c5171b5f05c2ccd8..22d964e7588d53659916cb3aea90632a75d16143 100644 (file)
@@ -1,8 +1,8 @@
 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;
diff --git a/nihav-realmedia/src/lib.rs b/nihav-realmedia/src/lib.rs
new file mode 100644 (file)
index 0000000..d7a15d0
--- /dev/null
@@ -0,0 +1,4 @@
+extern crate nihav_core;
+
+pub mod codecs;
+pub mod demuxers;
\ No newline at end of file
diff --git a/src/codecs/indeo/mod.rs b/src/codecs/indeo/mod.rs
deleted file mode 100644 (file)
index e1fcdcd..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#[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;
diff --git a/src/codecs/real/mod.rs b/src/codecs/real/mod.rs
deleted file mode 100644 (file)
index 244b901..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#[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;
-