diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-02-20 11:00:24 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2020-02-20 11:00:24 +0100 |
commit | b4d5b8515e75383b4fc59ea2813c90c615d59a96 (patch) | |
tree | cf9ea1f458965eea90dff60a607dc90bf42887b3 | |
parent | 2b8bf9a03242bbd6e80091082a50ec13b1a95143 (diff) | |
download | nihav-b4d5b8515e75383b4fc59ea2813c90c615d59a96.tar.gz |
split nihav-codec-support crate from nihav-core
The former is intended just for NihAV decoders, the latter is for both
NihAV crates and for the code using NihAV.
65 files changed, 454 insertions, 385 deletions
diff --git a/nihav-codec-support/Cargo.toml b/nihav-codec-support/Cargo.toml new file mode 100644 index 0000000..c302a16 --- /dev/null +++ b/nihav-codec-support/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "nihav_codec_support" +version = "0.1.0" +authors = ["Kostya Shishkov <kostya.shishkov@gmail.com>"] +edition = "2018" + +[dependencies.nihav_core] +path = "../nihav-core" + +[features] +default = [] + +blockdsp = [] +h263 = ["blockdsp"] + +dsp = [] +dct = ["dsp"] +fft = ["dsp"] +mdct = ["fft", "dsp"] +dsp_window = ["dsp"] diff --git a/nihav-core/src/codecs/blockdsp.rs b/nihav-codec-support/src/codecs/blockdsp.rs index 0b66527..da92742 100644 --- a/nihav-core/src/codecs/blockdsp.rs +++ b/nihav-codec-support/src/codecs/blockdsp.rs @@ -1,5 +1,5 @@ //! Various pixel block manipulation functions. -use crate::frame::*; +use nihav_core::frame::*; /// Puts YUV420 16x16 macroblock data onto picture in the requested place. pub fn put_blocks(buf: &mut NAVideoBuffer<u8>, xpos: usize, ypos: usize, blk: &[[i16;64]; 6]) { diff --git a/nihav-core/src/codecs/h263/code.rs b/nihav-codec-support/src/codecs/h263/code.rs index 1f101a2..d794c69 100644 --- a/nihav-core/src/codecs/h263/code.rs +++ b/nihav-codec-support/src/codecs/h263/code.rs @@ -1,4 +1,4 @@ -use crate::frame::NAVideoBuffer; +use nihav_core::frame::NAVideoBuffer; use super::{BlockDSP, CBPInfo, MV}; use super::super::blockdsp; //use super::h263data::*; diff --git a/nihav-core/src/codecs/h263/data.rs b/nihav-codec-support/src/codecs/h263/data.rs index de827d4..9a2d4a2 100644 --- a/nihav-core/src/codecs/h263/data.rs +++ b/nihav-codec-support/src/codecs/h263/data.rs @@ -1,4 +1,4 @@ -use crate::io::codebook::CodebookDescReader; +use nihav_core::io::codebook::CodebookDescReader; #[allow(dead_code)] pub const H263_SCALES: &[u8] = &[ diff --git a/nihav-core/src/codecs/h263/decoder.rs b/nihav-codec-support/src/codecs/h263/decoder.rs index 494c0e3..929854a 100644 --- a/nihav-core/src/codecs/h263/decoder.rs +++ b/nihav-codec-support/src/codecs/h263/decoder.rs @@ -1,10 +1,11 @@ //use std::mem; -use crate::frame::*; +use nihav_core::codecs::DecoderError; +use nihav_core::frame::*; use super::super::*; use super::super::blockdsp; use super::*; //use super::code::*; -use crate::formats; +use nihav_core::formats; #[allow(dead_code)] struct MVInfo { diff --git a/nihav-core/src/codecs/h263/mod.rs b/nihav-codec-support/src/codecs/h263/mod.rs index 6f3d548..33d71ba 100644 --- a/nihav-core/src/codecs/h263/mod.rs +++ b/nihav-codec-support/src/codecs/h263/mod.rs @@ -1,5 +1,6 @@ -use super::{DecoderResult, MV, ZERO_MV}; -use crate::frame::NAVideoBuffer; +use nihav_core::codecs::DecoderResult; +use super::{MV, ZERO_MV}; +use nihav_core::frame::NAVideoBuffer; #[allow(clippy::many_single_char_names)] pub mod code; diff --git a/nihav-codec-support/src/codecs/mod.rs b/nihav-codec-support/src/codecs/mod.rs new file mode 100644 index 0000000..4353ad9 --- /dev/null +++ b/nihav-codec-support/src/codecs/mod.rs @@ -0,0 +1,313 @@ +//! Decoder support functions and definitions. +use std::fmt; +use std::ops::{Add, AddAssign, Sub, SubAssign}; + +pub use nihav_core::frame::*; +use std::mem; + +/// Frame manager for hold-and-modify codecs. +/// +/// This frame manager simplifies frame management for the case when codec decodes new frame by updating parts of the previous frame. +/// +/// # Examples +/// +/// ````norun +/// let mut frame = if is_intra_frame { +/// allocate_video_frame() +/// } else { +/// let ret = shuffler.clone_ref(); +/// if ret.is_none() { +/// return Err(DecodingError::MissingReference); +/// } +/// ret.unwrap() +/// }; +/// // output data into the frame +/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference +/// ```` +#[allow(dead_code)] +pub struct HAMShuffler { + lastframe: Option<NAVideoBufferRef<u8>>, +} + +impl HAMShuffler { + /// Constructs a new instance of frame manager. + #[allow(dead_code)] + pub fn new() -> Self { HAMShuffler { lastframe: None } } + /// Clears the reference. + #[allow(dead_code)] + pub fn clear(&mut self) { self.lastframe = None; } + /// Sets a new frame reference. + #[allow(dead_code)] + pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { + self.lastframe = Some(buf); + } + /// Provides a copy of the reference frame if present or `None` if it is not. + #[allow(dead_code)] + pub fn clone_ref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref mut frm) = self.lastframe { + let newfrm = frm.copy_buffer(); + *frm = newfrm.clone().into_ref(); + Some(newfrm.into_ref()) + } else { + None + } + } + /// Returns the original saved reference frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<u8>> { + match self.lastframe { + Some(ref frm) => Some(frm.clone()), + None => None, + } + } +} + +impl Default for HAMShuffler { + fn default() -> Self { Self { lastframe: None } } +} + +/// Frame manager for codecs with intra and inter frames. +/// +/// This frame manager simplifies frame management for the case when codec decodes new frame using previous frame as source of some data. +/// +/// # Examples +/// +/// ````norun +/// let mut frame = allocate_video_frame(); +/// if is_inter_frame { +/// let ret = shuffler.get_ref(); +/// if ret.is_none() { +/// return Err(DecodingError::MissingReference); +/// } +/// let ref_frame = ret.unwrap(); +/// // keep decoding using data from ref_frame +/// } +/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference +/// ```` +#[allow(dead_code)] +pub struct IPShuffler { + lastframe: Option<NAVideoBufferRef<u8>>, +} + +impl IPShuffler { + /// Constructs a new instance of frame manager. + #[allow(dead_code)] + pub fn new() -> Self { IPShuffler { lastframe: None } } + /// Clears the reference. + #[allow(dead_code)] + pub fn clear(&mut self) { self.lastframe = None; } + /// Sets a new frame reference. + #[allow(dead_code)] + pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { + self.lastframe = Some(buf); + } + /// Returns the original saved reference frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_ref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref frm) = self.lastframe { + Some(frm.clone()) + } else { + None + } + } +} + +impl Default for IPShuffler { + fn default() -> Self { Self { lastframe: None } } +} + +/// Frame manager for codecs with I-, P- and B-frames. +/// +/// This frame manager simplifies frame management for the case when codec uses I/P/B frame scheme. +/// +/// # Examples +/// +/// ````norun +/// let mut frame = allocate_video_frame(); +/// for mb in all_macroblocks { +/// // decode macroblock type +/// match mb_type { +/// MBType::Inter => { +/// do_mc(&mut frame, shuffler.get_lastref().unwrap()); +/// }, +/// MBType::BForward => { +/// do_mc(&mut frame, shuffler.get_b_fwdref().unwrap()); +/// }, +/// MBType::BBackward => { +/// do_mc(&mut frame, shuffler.get_b_bwdref().unwrap()); +/// }, +/// // handle the rest of cases +/// }; +/// if is_random_access_frame { +/// shuffler.clear(); // remove all saved references +/// } +/// if is_intra_frame || is_p_frame { +/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference +/// } +/// ```` +#[allow(dead_code)] +pub struct IPBShuffler { + lastframe: Option<NAVideoBufferRef<u8>>, + nextframe: Option<NAVideoBufferRef<u8>>, +} + +impl IPBShuffler { + /// Constructs a new instance of frame manager. + #[allow(dead_code)] + pub fn new() -> Self { IPBShuffler { lastframe: None, nextframe: None } } + /// Clears the reference. + #[allow(dead_code)] + pub fn clear(&mut self) { self.lastframe = None; self.nextframe = None; } + /// Sets a new frame reference. + #[allow(dead_code)] + pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { + mem::swap(&mut self.lastframe, &mut self.nextframe); + self.lastframe = Some(buf); + } + /// Returns the previous reference frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_lastref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref frm) = self.lastframe { + Some(frm.clone()) + } else { + None + } + } + /// Returns second last reference frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_nextref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref frm) = self.nextframe { + Some(frm.clone()) + } else { + None + } + } + /// Returns the temporally following reference for B-frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_b_fwdref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref frm) = self.nextframe { + Some(frm.clone()) + } else { + None + } + } + /// Returns the temporally preceeding reference for B-frame or `None` if it is not present. + #[allow(dead_code)] + pub fn get_b_bwdref(&mut self) -> Option<NAVideoBufferRef<u8>> { + if let Some(ref frm) = self.lastframe { + Some(frm.clone()) + } else { + None + } + } +} + +impl Default for IPBShuffler { + fn default() -> Self { Self { lastframe: None, nextframe: None } } +} + +/// Motion vector data type. +/// +/// # Examples +/// +/// ``` +/// use nihav_codec_support::codecs::MV; +/// +/// let mv0 = MV::new(1, 3); +/// let mv1 = MV { x: 2, y: 3 }; // choose whatever style you prefer +/// let mv2 = mv1 - mv0; +/// let mv_pred = MV::pred(mv0, mv1, mv2); // get median prediction for the vectors (1, 0) +/// ``` +#[derive(Debug,Clone,Copy,Default,PartialEq)] +pub struct MV { + /// X coordinate of the vector. + pub x: i16, + /// Y coordinate of the vector. + pub y: i16, +} + +#[allow(clippy::many_single_char_names)] +#[allow(clippy::collapsible_if)] +impl MV { + /// Creates a new motion vector instance. + pub fn new(x: i16, y: i16) -> Self { MV{ x, y } } + /// Predicts median from provided motion vectors. + /// + /// Each component of the vector is predicted as the median of corresponding input vector components. + pub fn pred(a: MV, b: MV, c: MV) -> Self { + let x; + if a.x < b.x { + if b.x < c.x { + x = b.x; + } else { + if a.x < c.x { x = c.x; } else { x = a.x; } + } + } else { + if b.x < c.x { + if a.x < c.x { x = a.x; } else { x = c.x; } + } else { + x = b.x; + } + } + let y; + if a.y < b.y { + if b.y < c.y { + y = b.y; + } else { + if a.y < c.y { y = c.y; } else { y = a.y; } + } + } else { + if b.y < c.y { + if a.y < c.y { y = a.y; } else { y = c.y; } + } else { + y = b.y; + } + } + MV { x, y } + } +} + +/// Zero motion vector. +pub const ZERO_MV: MV = MV { x: 0, y: 0 }; + +impl Add for MV { + type Output = MV; + fn add(self, other: MV) -> MV { MV { x: self.x + other.x, y: self.y + other.y } } +} + +impl AddAssign for MV { + fn add_assign(&mut self, other: MV) { self.x += other.x; self.y += other.y; } +} + +impl Sub for MV { + type Output = MV; + fn sub(self, other: MV) -> MV { MV { x: self.x - other.x, y: self.y - other.y } } +} + +impl SubAssign for MV { + fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; } +} + +impl fmt::Display for MV { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{},{}", self.x, self.y) + } +} + +#[cfg(any(feature="blockdsp"))] +pub mod blockdsp; + +#[cfg(feature="h263")] +pub mod h263; + +/// The common 8x8 zigzag scan. +pub const ZIGZAG: [usize; 64] = [ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63 +]; diff --git a/nihav-core/src/data/mod.rs b/nihav-codec-support/src/data/mod.rs index 65abbf6..35a8973 100644 --- a/nihav-core/src/data/mod.rs +++ b/nihav-codec-support/src/data/mod.rs @@ -10,7 +10,7 @@ /// /// Create a cache for one line and use top pixel for prediction: /// ``` -/// use nihav_core::data::GenericCache; +/// use nihav_codec_support::data::GenericCache; /// /// # let width = 640; /// # let height = 480; diff --git a/nihav-core/src/dsp/dct.rs b/nihav-codec-support/src/dsp/dct.rs index 2a74449..2a74449 100644 --- a/nihav-core/src/dsp/dct.rs +++ b/nihav-codec-support/src/dsp/dct.rs diff --git a/nihav-core/src/dsp/fft.rs b/nihav-codec-support/src/dsp/fft.rs index 4629f75..4629f75 100644 --- a/nihav-core/src/dsp/fft.rs +++ b/nihav-codec-support/src/dsp/fft.rs diff --git a/nihav-core/src/dsp/mdct.rs b/nihav-codec-support/src/dsp/mdct.rs index e6ed3dc..e6ed3dc 100644 --- a/nihav-core/src/dsp/mdct.rs +++ b/nihav-codec-support/src/dsp/mdct.rs diff --git a/nihav-core/src/dsp/mod.rs b/nihav-codec-support/src/dsp/mod.rs index 2ff322d..2ff322d 100644 --- a/nihav-core/src/dsp/mod.rs +++ b/nihav-codec-support/src/dsp/mod.rs diff --git a/nihav-core/src/dsp/window.rs b/nihav-codec-support/src/dsp/window.rs index eb350e3..eb350e3 100644 --- a/nihav-core/src/dsp/window.rs +++ b/nihav-codec-support/src/dsp/window.rs diff --git a/nihav-codec-support/src/lib.rs b/nihav-codec-support/src/lib.rs new file mode 100644 index 0000000..e2c2ef6 --- /dev/null +++ b/nihav-codec-support/src/lib.rs @@ -0,0 +1,19 @@ +//! Code and data for easier development of NihAV decoders. +#[allow(clippy::cast_lossless)] +#[allow(clippy::identity_op)] +#[allow(clippy::too_many_arguments)] +#[allow(clippy::unreadable_literal)] +pub mod codecs; + +#[cfg(feature="dsp")] +#[allow(clippy::excessive_precision)] +#[allow(clippy::identity_op)] +#[allow(clippy::needless_range_loop)] +#[allow(clippy::unreadable_literal)] +pub mod dsp; + +pub mod data; + +pub mod test; + +extern crate nihav_core; diff --git a/nihav-core/src/test/dec_video.rs b/nihav-codec-support/src/test/dec_video.rs index 1dc2bed..cca4cb4 100644 --- a/nihav-core/src/test/dec_video.rs +++ b/nihav-codec-support/src/test/dec_video.rs @@ -1,11 +1,11 @@ //! Routines for testing decoders. use std::fs::File; use std::io::prelude::*; -use crate::frame::*; -use crate::codecs::*; -use crate::demuxers::*; -//use crate::io::byteio::*; -use crate::scale::*; +use nihav_core::frame::*; +use nihav_core::codecs::*; +use nihav_core::demuxers::*; +//use nihav_core::io::byteio::*; +use nihav_core::scale::*; use super::wavwriter::WavWriter; use super::md5::MD5; pub use super::ExpectedTestResult; @@ -435,8 +435,8 @@ fn frame_checksum(md5: &mut MD5, frm: NAFrameRef) { /// /// Test RealVideo 4 decoder in test stream: /// ```no_run -/// use nihav_core::test::ExpectedTestResult; -/// use nihav_core::test::dec_video::test_decoding; +/// use nihav_codec_support::test::ExpectedTestResult; +/// use nihav_codec_support::test::dec_video::test_decoding; /// use nihav_core::codecs::RegisteredDecoders; /// use nihav_core::demuxers::RegisteredDemuxers; /// diff --git a/nihav-core/src/test/md5.rs b/nihav-codec-support/src/test/md5.rs index af9a155..af9a155 100644 --- a/nihav-core/src/test/md5.rs +++ b/nihav-codec-support/src/test/md5.rs diff --git a/nihav-core/src/test/mod.rs b/nihav-codec-support/src/test/mod.rs index 367be24..367be24 100644 --- a/nihav-core/src/test/mod.rs +++ b/nihav-codec-support/src/test/mod.rs diff --git a/nihav-core/src/test/wavwriter.rs b/nihav-codec-support/src/test/wavwriter.rs index 50b1949..982fbc3 100644 --- a/nihav-core/src/test/wavwriter.rs +++ b/nihav-codec-support/src/test/wavwriter.rs @@ -1,6 +1,6 @@ //! Audio output in WAV format. -use crate::io::byteio::*; -use crate::frame::*; +use nihav_core::io::byteio::*; +use nihav_core::frame::*; use std::io::SeekFrom; /// WAVE output writer. diff --git a/nihav-commonfmt/Cargo.toml b/nihav-commonfmt/Cargo.toml index 1ab9d0c..396f189 100644 --- a/nihav-commonfmt/Cargo.toml +++ b/nihav-commonfmt/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" [dependencies.nihav_core] path = "../nihav-core" + +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" features = ["h263", "mdct", "fft", "dsp_window"] [dev-dependencies] diff --git a/nihav-commonfmt/src/codecs/aac.rs b/nihav-commonfmt/src/codecs/aac.rs index 290868a..b689862 100644 --- a/nihav-commonfmt/src/codecs/aac.rs +++ b/nihav-commonfmt/src/codecs/aac.rs @@ -1,8 +1,8 @@ use nihav_core::formats::*; use nihav_core::frame::*; use nihav_core::codecs::*; -use nihav_core::dsp::mdct::IMDCT; -use nihav_core::dsp::window::*; +use nihav_codec_support::dsp::mdct::IMDCT; +use nihav_codec_support::dsp::window::*; use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use std::fmt; diff --git a/nihav-commonfmt/src/codecs/atrac3.rs b/nihav-commonfmt/src/codecs/atrac3.rs index 044fea6..0227742 100644 --- a/nihav-commonfmt/src/codecs/atrac3.rs +++ b/nihav-commonfmt/src/codecs/atrac3.rs @@ -4,7 +4,7 @@ use nihav_core::codecs::*; use nihav_core::io::bitreader::*; use nihav_core::io::byteio::*; use nihav_core::io::codebook::*; -use nihav_core::dsp::mdct::IMDCT; +use nihav_codec_support::dsp::mdct::IMDCT; use std::f32::consts; #[derive(Clone,Copy,PartialEq)] diff --git a/nihav-commonfmt/src/codecs/clearvideo.rs b/nihav-commonfmt/src/codecs/clearvideo.rs index 4735731..ea3a9f2 100644 --- a/nihav-commonfmt/src/codecs/clearvideo.rs +++ b/nihav-commonfmt/src/codecs/clearvideo.rs @@ -3,6 +3,7 @@ use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::formats; use nihav_core::codecs::*; +use nihav_codec_support::codecs::{HAMShuffler, MV, ZERO_MV, ZIGZAG}; struct CLVDCCodeReader { } struct CLVACCodeReader { } diff --git a/nihav-commonfmt/src/codecs/ts102366.rs b/nihav-commonfmt/src/codecs/ts102366.rs index cdad890..3f5de52 100644 --- a/nihav-commonfmt/src/codecs/ts102366.rs +++ b/nihav-commonfmt/src/codecs/ts102366.rs @@ -2,7 +2,7 @@ use nihav_core::formats::*; use nihav_core::frame::*; use nihav_core::codecs::*; use nihav_core::io::bitreader::*; -use nihav_core::dsp::fft::*; +use nihav_codec_support::dsp::fft::*; use std::str::FromStr; use std::f32::consts; diff --git a/nihav-commonfmt/src/lib.rs b/nihav-commonfmt/src/lib.rs index ce931fe..cdb70ec 100644 --- a/nihav-commonfmt/src/lib.rs +++ b/nihav-commonfmt/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; #[cfg(feature="decoders")] #[allow(clippy::unreadable_literal)] diff --git a/nihav-core/Cargo.toml b/nihav-core/Cargo.toml index e898b04..9b04164 100644 --- a/nihav-core/Cargo.toml +++ b/nihav-core/Cargo.toml @@ -9,12 +9,3 @@ default = ["decoders", "demuxers"] decoders = [] demuxers = [] - -blockdsp = [] -h263 = ["blockdsp"] - -dsp = [] -dct = ["dsp"] -fft = ["dsp"] -mdct = ["fft", "dsp"] -dsp_window = ["dsp"] diff --git a/nihav-core/src/codecs/mod.rs b/nihav-core/src/codecs/mod.rs index b409f67..9aced07 100644 --- a/nihav-core/src/codecs/mod.rs +++ b/nihav-core/src/codecs/mod.rs @@ -1,9 +1,5 @@ //! Decoder interface definitions. -use std::fmt; -use std::ops::{Add, AddAssign, Sub, SubAssign}; - pub use crate::frame::*; -use std::mem; use crate::io::byteio::ByteIOError; use crate::io::bitreader::BitReaderError; use crate::io::codebook::CodebookError; @@ -54,295 +50,6 @@ impl From<AllocatorError> for DecoderError { fn from(_: AllocatorError) -> Self { DecoderError::AllocError } } -/// Frame manager for hold-and-modify codecs. -/// -/// This frame manager simplifies frame management for the case when codec decodes new frame by updating parts of the previous frame. -/// -/// # Examples -/// -/// ````norun -/// let mut frame = if is_intra_frame { -/// allocate_video_frame() -/// } else { -/// let ret = shuffler.clone_ref(); -/// if ret.is_none() { -/// return Err(DecodingError::MissingReference); -/// } -/// ret.unwrap() -/// }; -/// // output data into the frame -/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference -/// ```` -#[allow(dead_code)] -pub struct HAMShuffler { - lastframe: Option<NAVideoBufferRef<u8>>, -} - -impl HAMShuffler { - /// Constructs a new instance of frame manager. - #[allow(dead_code)] - pub fn new() -> Self { HAMShuffler { lastframe: None } } - /// Clears the reference. - #[allow(dead_code)] - pub fn clear(&mut self) { self.lastframe = None; } - /// Sets a new frame reference. - #[allow(dead_code)] - pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { - self.lastframe = Some(buf); - } - /// Provides a copy of the reference frame if present or `None` if it is not. - #[allow(dead_code)] - pub fn clone_ref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref mut frm) = self.lastframe { - let newfrm = frm.copy_buffer(); - *frm = newfrm.clone().into_ref(); - Some(newfrm.into_ref()) - } else { - None - } - } - /// Returns the original saved reference frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_output_frame(&mut self) -> Option<NAVideoBufferRef<u8>> { - match self.lastframe { - Some(ref frm) => Some(frm.clone()), - None => None, - } - } -} - -impl Default for HAMShuffler { - fn default() -> Self { Self { lastframe: None } } -} - -/// Frame manager for codecs with intra and inter frames. -/// -/// This frame manager simplifies frame management for the case when codec decodes new frame using previous frame as source of some data. -/// -/// # Examples -/// -/// ````norun -/// let mut frame = allocate_video_frame(); -/// if is_inter_frame { -/// let ret = shuffler.get_ref(); -/// if ret.is_none() { -/// return Err(DecodingError::MissingReference); -/// } -/// let ref_frame = ret.unwrap(); -/// // keep decoding using data from ref_frame -/// } -/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference -/// ```` -#[allow(dead_code)] -pub struct IPShuffler { - lastframe: Option<NAVideoBufferRef<u8>>, -} - -impl IPShuffler { - /// Constructs a new instance of frame manager. - #[allow(dead_code)] - pub fn new() -> Self { IPShuffler { lastframe: None } } - /// Clears the reference. - #[allow(dead_code)] - pub fn clear(&mut self) { self.lastframe = None; } - /// Sets a new frame reference. - #[allow(dead_code)] - pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { - self.lastframe = Some(buf); - } - /// Returns the original saved reference frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_ref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } - } -} - -impl Default for IPShuffler { - fn default() -> Self { Self { lastframe: None } } -} - -/// Frame manager for codecs with I-, P- and B-frames. -/// -/// This frame manager simplifies frame management for the case when codec uses I/P/B frame scheme. -/// -/// # Examples -/// -/// ````norun -/// let mut frame = allocate_video_frame(); -/// for mb in all_macroblocks { -/// // decode macroblock type -/// match mb_type { -/// MBType::Inter => { -/// do_mc(&mut frame, shuffler.get_lastref().unwrap()); -/// }, -/// MBType::BForward => { -/// do_mc(&mut frame, shuffler.get_b_fwdref().unwrap()); -/// }, -/// MBType::BBackward => { -/// do_mc(&mut frame, shuffler.get_b_bwdref().unwrap()); -/// }, -/// // handle the rest of cases -/// }; -/// if is_random_access_frame { -/// shuffler.clear(); // remove all saved references -/// } -/// if is_intra_frame || is_p_frame { -/// shuffler.add_frame(frame.clone()); // tells frame manager to use the frame as the next reference -/// } -/// ```` -#[allow(dead_code)] -pub struct IPBShuffler { - lastframe: Option<NAVideoBufferRef<u8>>, - nextframe: Option<NAVideoBufferRef<u8>>, -} - -impl IPBShuffler { - /// Constructs a new instance of frame manager. - #[allow(dead_code)] - pub fn new() -> Self { IPBShuffler { lastframe: None, nextframe: None } } - /// Clears the reference. - #[allow(dead_code)] - pub fn clear(&mut self) { self.lastframe = None; self.nextframe = None; } - /// Sets a new frame reference. - #[allow(dead_code)] - pub fn add_frame(&mut self, buf: NAVideoBufferRef<u8>) { - mem::swap(&mut self.lastframe, &mut self.nextframe); - self.lastframe = Some(buf); - } - /// Returns the previous reference frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_lastref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } - } - /// Returns second last reference frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_nextref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref frm) = self.nextframe { - Some(frm.clone()) - } else { - None - } - } - /// Returns the temporally following reference for B-frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_b_fwdref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref frm) = self.nextframe { - Some(frm.clone()) - } else { - None - } - } - /// Returns the temporally preceeding reference for B-frame or `None` if it is not present. - #[allow(dead_code)] - pub fn get_b_bwdref(&mut self) -> Option<NAVideoBufferRef<u8>> { - if let Some(ref frm) = self.lastframe { - Some(frm.clone()) - } else { - None - } - } -} - -impl Default for IPBShuffler { - fn default() -> Self { Self { lastframe: None, nextframe: None } } -} - -/// Motion vector data type. -/// -/// # Examples -/// -/// ``` -/// use nihav_core::codecs::MV; -/// -/// let mv0 = MV::new(1, 3); -/// let mv1 = MV { x: 2, y: 3 }; // choose whatever style you prefer -/// let mv2 = mv1 - mv0; -/// let mv_pred = MV::pred(mv0, mv1, mv2); // get median prediction for the vectors (1, 0) -/// ``` -#[derive(Debug,Clone,Copy,Default,PartialEq)] -pub struct MV { - /// X coordinate of the vector. - pub x: i16, - /// Y coordinate of the vector. - pub y: i16, -} - -#[allow(clippy::many_single_char_names)] -#[allow(clippy::collapsible_if)] -impl MV { - /// Creates a new motion vector instance. - pub fn new(x: i16, y: i16) -> Self { MV{ x, y } } - /// Predicts median from provided motion vectors. - /// - /// Each component of the vector is predicted as the median of corresponding input vector components. - pub fn pred(a: MV, b: MV, c: MV) -> Self { - let x; - if a.x < b.x { - if b.x < c.x { - x = b.x; - } else { - if a.x < c.x { x = c.x; } else { x = a.x; } - } - } else { - if b.x < c.x { - if a.x < c.x { x = a.x; } else { x = c.x; } - } else { - x = b.x; - } - } - let y; - if a.y < b.y { - if b.y < c.y { - y = b.y; - } else { - if a.y < c.y { y = c.y; } else { y = a.y; } - } - } else { - if b.y < c.y { - if a.y < c.y { y = a.y; } else { y = c.y; } - } else { - y = b.y; - } - } - MV { x, y } - } -} - -/// Zero motion vector. -pub const ZERO_MV: MV = MV { x: 0, y: 0 }; - -impl Add for MV { - type Output = MV; - fn add(self, other: MV) -> MV { MV { x: self.x + other.x, y: self.y + other.y } } -} - -impl AddAssign for MV { - fn add_assign(&mut self, other: MV) { self.x += other.x; self.y += other.y; } -} - -impl Sub for MV { - type Output = MV; - fn sub(self, other: MV) -> MV { MV { x: self.x - other.x, y: self.y - other.y } } -} - -impl SubAssign for MV { - fn sub_assign(&mut self, other: MV) { self.x -= other.x; self.y -= other.y; } -} - -impl fmt::Display for MV { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{},{}", self.x, self.y) - } -} - /// Auxiliary structure for storing data used by decoder but also controlled by the caller. pub struct NADecoderSupport { /// Frame buffer pool for 8-bit or packed video frames. @@ -391,12 +98,6 @@ pub struct DecoderInfo { pub get_decoder: fn () -> Box<dyn NADecoder + Send>, } -#[cfg(any(feature="blockdsp"))] -pub mod blockdsp; - -#[cfg(feature="h263")] -pub mod h263; - /// Structure for registering known decoders. /// /// It is supposed to be filled using `register_all_codecs()` from some decoders crate and then it can be used to create decoders for the requested codecs. @@ -428,15 +129,3 @@ impl RegisteredDecoders { self.decs.iter() } } - -/// The common 8x8 zigzag scan. -pub const ZIGZAG: [usize; 64] = [ - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -]; diff --git a/nihav-core/src/lib.rs b/nihav-core/src/lib.rs index 2652c14..a53f304 100644 --- a/nihav-core/src/lib.rs +++ b/nihav-core/src/lib.rs @@ -21,14 +21,3 @@ pub mod detect; pub mod reorder; pub mod scale; pub mod soundcvt; - -#[cfg(feature="dsp")] -#[allow(clippy::excessive_precision)] -#[allow(clippy::identity_op)] -#[allow(clippy::needless_range_loop)] -#[allow(clippy::unreadable_literal)] -pub mod dsp; - -pub mod data; - -pub mod test; diff --git a/nihav-duck/Cargo.toml b/nihav-duck/Cargo.toml index 4f56963..c5c65d2 100644 --- a/nihav-duck/Cargo.toml +++ b/nihav-duck/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" [dependencies.nihav_core] path = "../nihav-core" + +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" features = ["fft", "dsp_window", "blockdsp"] [dev-dependencies] diff --git a/nihav-duck/src/codecs/on2avc.rs b/nihav-duck/src/codecs/on2avc.rs index b060501..f2f5a3d 100644 --- a/nihav-duck/src/codecs/on2avc.rs +++ b/nihav-duck/src/codecs/on2avc.rs @@ -4,8 +4,8 @@ use nihav_core::io::byteio::read_u16le; use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::io::intcode::*; -use nihav_core::dsp::fft::*; -use nihav_core::dsp::mdct::IMDCT; +use nihav_codec_support::dsp::fft::*; +use nihav_codec_support::dsp::mdct::IMDCT; use std::str::FromStr; diff --git a/nihav-duck/src/codecs/vp3.rs b/nihav-duck/src/codecs/vp3.rs index 3b8560e..b7fefcf 100644 --- a/nihav-duck/src/codecs/vp3.rs +++ b/nihav-duck/src/codecs/vp3.rs @@ -1,7 +1,8 @@ use std::mem; use std::ptr; use nihav_core::codecs::*; -use nihav_core::codecs::blockdsp::*; +use nihav_codec_support::codecs::{MV, ZERO_MV, ZIGZAG}; +use nihav_codec_support::codecs::blockdsp::*; use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::io::intcode::*; diff --git a/nihav-duck/src/codecs/vp5.rs b/nihav-duck/src/codecs/vp5.rs index 35244df..4076989 100644 --- a/nihav-duck/src/codecs/vp5.rs +++ b/nihav-duck/src/codecs/vp5.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; use nihav_core::io::bitreader::*; +use nihav_codec_support::codecs::{MV, ZIGZAG}; use super::vpcommon::*; use super::vp56::*; diff --git a/nihav-duck/src/codecs/vp56.rs b/nihav-duck/src/codecs/vp56.rs index de3a849..6f9f18c 100644 --- a/nihav-duck/src/codecs/vp56.rs +++ b/nihav-duck/src/codecs/vp56.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; use nihav_core::io::bitreader::*; +use nihav_codec_support::codecs::{MV, ZERO_MV}; use super::vpcommon::*; pub const TOKEN_LARGE: u8 = 5; diff --git a/nihav-duck/src/codecs/vp6.rs b/nihav-duck/src/codecs/vp6.rs index da0fe40..9a6add7 100644 --- a/nihav-duck/src/codecs/vp6.rs +++ b/nihav-duck/src/codecs/vp6.rs @@ -1,6 +1,7 @@ use nihav_core::codecs::*; use nihav_core::io::bitreader::*; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::{MV, ZIGZAG}; +use nihav_codec_support::codecs::blockdsp::edge_emu; use super::vpcommon::*; use super::vp56::*; diff --git a/nihav-duck/src/codecs/vp7.rs b/nihav-duck/src/codecs/vp7.rs index 9b3eef3..9464def 100644 --- a/nihav-duck/src/codecs/vp7.rs +++ b/nihav-duck/src/codecs/vp7.rs @@ -1,6 +1,7 @@ use nihav_core::codecs::*; use nihav_core::io::byteio::*; -use nihav_core::data::GenericCache; +use nihav_codec_support::codecs::{MV, ZERO_MV}; +use nihav_codec_support::data::GenericCache; use super::vpcommon::*; use super::vp7data::*; use super::vp7dsp::*; diff --git a/nihav-duck/src/codecs/vp7dsp.rs b/nihav-duck/src/codecs/vp7dsp.rs index afd035f..6dfc98f 100644 --- a/nihav-duck/src/codecs/vp7dsp.rs +++ b/nihav-duck/src/codecs/vp7dsp.rs @@ -1,5 +1,5 @@ use nihav_core::frame::*; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::blockdsp::edge_emu; fn clip_u8(val: i16) -> u8 { val.max(0).min(255) as u8 diff --git a/nihav-duck/src/codecs/vpcommon.rs b/nihav-duck/src/codecs/vpcommon.rs index 8dbe161..f41b89b 100644 --- a/nihav-duck/src/codecs/vpcommon.rs +++ b/nihav-duck/src/codecs/vpcommon.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; -use nihav_core::codecs::blockdsp::*; +use nihav_codec_support::codecs::blockdsp; +use nihav_codec_support::codecs::blockdsp::*; pub const VP_YUVA420_FORMAT: NAPixelFormaton = NAPixelFormaton{ model: ColorModel::YUV(YUVSubmodel::YUVJ), diff --git a/nihav-duck/src/lib.rs b/nihav-duck/src/lib.rs index 1760338..4e85ac5 100644 --- a/nihav-duck/src/lib.rs +++ b/nihav-duck/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; mod codecs; diff --git a/nihav-game/Cargo.toml b/nihav-game/Cargo.toml index a429135..b52dabb 100644 --- a/nihav-game/Cargo.toml +++ b/nihav-game/Cargo.toml @@ -8,6 +8,10 @@ edition = "2018" path = "../nihav-core" features = [] +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" +features = [] + [dev-dependencies] nihav_commonfmt = { path = "../nihav-commonfmt" } diff --git a/nihav-game/src/codecs/midivid.rs b/nihav-game/src/codecs/midivid.rs index df788f6..48456d6 100644 --- a/nihav-game/src/codecs/midivid.rs +++ b/nihav-game/src/codecs/midivid.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; use nihav_core::io::byteio::*; +use nihav_codec_support::codecs::HAMShuffler; #[derive(Default)] struct MidividDecoder { diff --git a/nihav-game/src/codecs/vmd.rs b/nihav-game/src/codecs/vmd.rs index 1f4964e..987408a 100644 --- a/nihav-game/src/codecs/vmd.rs +++ b/nihav-game/src/codecs/vmd.rs @@ -1,5 +1,6 @@ use nihav_core::codecs::*; use nihav_core::io::byteio::*; +use nihav_codec_support::codecs::HAMShuffler; use std::str::FromStr; macro_rules! lz_op { diff --git a/nihav-game/src/lib.rs b/nihav-game/src/lib.rs index 20207be..a91da7b 100644 --- a/nihav-game/src/lib.rs +++ b/nihav-game/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; mod codecs; pub use codecs::game_register_all_codecs; diff --git a/nihav-indeo/Cargo.toml b/nihav-indeo/Cargo.toml index 901d0e4..ffa8390 100644 --- a/nihav-indeo/Cargo.toml +++ b/nihav-indeo/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" [dependencies.nihav_core] path = "../nihav-core" + +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" features = ["h263", "fft", "dsp_window"] [dev-dependencies] diff --git a/nihav-indeo/src/codecs/imc.rs b/nihav-indeo/src/codecs/imc.rs index e49da70..cc801b5 100644 --- a/nihav-indeo/src/codecs/imc.rs +++ b/nihav-indeo/src/codecs/imc.rs @@ -7,8 +7,8 @@ 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::*; +use nihav_codec_support::dsp::fft::*; +use nihav_codec_support::dsp::window::*; const BANDS: usize = 32; const COEFFS: usize = 256; diff --git a/nihav-indeo/src/codecs/indeo2.rs b/nihav-indeo/src/codecs/indeo2.rs index 2e1d7c6..e1571fc 100644 --- a/nihav-indeo/src/codecs/indeo2.rs +++ b/nihav-indeo/src/codecs/indeo2.rs @@ -2,6 +2,7 @@ use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::formats; use nihav_core::codecs::*; +use nihav_codec_support::codecs::HAMShuffler; static INDEO2_DELTA_TABLE: [[u8; 256]; 4] = [ [ diff --git a/nihav-indeo/src/codecs/indeo4.rs b/nihav-indeo/src/codecs/indeo4.rs index 9ae4158..3fe3f2b 100644 --- a/nihav-indeo/src/codecs/indeo4.rs +++ b/nihav-indeo/src/codecs/indeo4.rs @@ -2,6 +2,7 @@ use nihav_core::io::bitreader::*; use nihav_core::formats; use nihav_core::frame::*; use nihav_core::codecs::*; +use nihav_codec_support::codecs::ZIGZAG; use super::ivi::*; use super::ivibr::*; diff --git a/nihav-indeo/src/codecs/indeo5.rs b/nihav-indeo/src/codecs/indeo5.rs index 933958d..ba64e6b 100644 --- a/nihav-indeo/src/codecs/indeo5.rs +++ b/nihav-indeo/src/codecs/indeo5.rs @@ -2,6 +2,7 @@ use nihav_core::io::bitreader::*; use nihav_core::formats; use nihav_core::frame::*; use nihav_core::codecs::*; +use nihav_codec_support::codecs::ZIGZAG; use super::ivi::*; use super::ivibr::*; diff --git a/nihav-indeo/src/codecs/intel263.rs b/nihav-indeo/src/codecs/intel263.rs index 18c759d..b003b67 100644 --- a/nihav-indeo/src/codecs/intel263.rs +++ b/nihav-indeo/src/codecs/intel263.rs @@ -3,10 +3,11 @@ 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; +use nihav_codec_support::codecs::{MV, ZIGZAG}; +use nihav_codec_support::codecs::h263::*; +use nihav_codec_support::codecs::h263::decoder::*; +use nihav_codec_support::codecs::h263::data::*; +use nihav_codec_support::codecs::h263::code::H263BlockDSP; #[allow(dead_code)] struct Tables { diff --git a/nihav-indeo/src/lib.rs b/nihav-indeo/src/lib.rs index 1ceba4e..844b69f 100644 --- a/nihav-indeo/src/lib.rs +++ b/nihav-indeo/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; #[allow(clippy::collapsible_if)] #[allow(clippy::identity_op)] diff --git a/nihav-rad/Cargo.toml b/nihav-rad/Cargo.toml index 0fe0993..d155427 100644 --- a/nihav-rad/Cargo.toml +++ b/nihav-rad/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" [dependencies.nihav_core] path = "../nihav-core" + +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" features = ["dct", "fft"] [features] diff --git a/nihav-rad/src/codecs/bink2.rs b/nihav-rad/src/codecs/bink2.rs index 5f1fefd..c78a5d6 100644 --- a/nihav-rad/src/codecs/bink2.rs +++ b/nihav-rad/src/codecs/bink2.rs @@ -4,6 +4,7 @@ use nihav_core::io::byteio::*; use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::io::intcode::*; +use nihav_codec_support::codecs::{IPShuffler, MV, ZERO_MV}; macro_rules! mktag { ($a:expr, $b:expr, $c:expr, $d:expr) => ({ diff --git a/nihav-rad/src/codecs/binkaud.rs b/nihav-rad/src/codecs/binkaud.rs index 7e34739..29b8f98 100644 --- a/nihav-rad/src/codecs/binkaud.rs +++ b/nihav-rad/src/codecs/binkaud.rs @@ -1,6 +1,6 @@ use nihav_core::codecs::*; -use nihav_core::dsp::dct::*; -use nihav_core::dsp::fft::*; +use nihav_codec_support::dsp::dct::*; +use nihav_codec_support::dsp::fft::*; use nihav_core::io::bitreader::*; use std::f32::consts; use std::str::FromStr; diff --git a/nihav-rad/src/codecs/binkvid.rs b/nihav-rad/src/codecs/binkvid.rs index 920d8d5..12ad2cd 100644 --- a/nihav-rad/src/codecs/binkvid.rs +++ b/nihav-rad/src/codecs/binkvid.rs @@ -3,6 +3,7 @@ use nihav_core::codecs::*; use nihav_core::io::byteio::*; use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; +use nihav_codec_support::codecs::{IPShuffler, HAMShuffler}; const SKIP_BLOCK: u8 = 0; const SCALED_BLOCK: u8 = 1; diff --git a/nihav-rad/src/lib.rs b/nihav-rad/src/lib.rs index 604d0ca..21ef166 100644 --- a/nihav-rad/src/lib.rs +++ b/nihav-rad/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; #[cfg(feature="decoders")] #[allow(clippy::cast_lossless)] diff --git a/nihav-realmedia/Cargo.toml b/nihav-realmedia/Cargo.toml index 57db271..dc3c0d6 100644 --- a/nihav-realmedia/Cargo.toml +++ b/nihav-realmedia/Cargo.toml @@ -6,6 +6,9 @@ edition = "2018" [dependencies.nihav_core] path = "../nihav-core" + +[dependencies.nihav_codec_support] +path = "../nihav-codec-support" features = ["h263", "mdct", "blockdsp"] [features] diff --git a/nihav-realmedia/src/codecs/cook.rs b/nihav-realmedia/src/codecs/cook.rs index 85c8853..a48cf84 100644 --- a/nihav-realmedia/src/codecs/cook.rs +++ b/nihav-realmedia/src/codecs/cook.rs @@ -1,7 +1,7 @@ use nihav_core::formats::*; use nihav_core::frame::*; use nihav_core::codecs::*; -use nihav_core::dsp::mdct::IMDCT; +use nihav_codec_support::dsp::mdct::IMDCT; use nihav_core::io::bitreader::*; use nihav_core::io::byteio::{ByteReader, MemoryReader}; use nihav_core::io::codebook::*; diff --git a/nihav-realmedia/src/codecs/rv10.rs b/nihav-realmedia/src/codecs/rv10.rs index 320968a..0e2ad98 100644 --- a/nihav-realmedia/src/codecs/rv10.rs +++ b/nihav-realmedia/src/codecs/rv10.rs @@ -3,10 +3,11 @@ 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::*; +use nihav_codec_support::codecs::{MV, ZIGZAG}; +use nihav_codec_support::codecs::h263::*; +use nihav_codec_support::codecs::h263::code::H263BlockDSP; +use nihav_codec_support::codecs::h263::decoder::*; +use nihav_codec_support::codecs::h263::data::*; #[allow(dead_code)] struct Tables { diff --git a/nihav-realmedia/src/codecs/rv20.rs b/nihav-realmedia/src/codecs/rv20.rs index b3f1e56..4fae009 100644 --- a/nihav-realmedia/src/codecs/rv20.rs +++ b/nihav-realmedia/src/codecs/rv20.rs @@ -3,10 +3,11 @@ 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::*; +use nihav_codec_support::codecs::{MV, ZIGZAG}; +use nihav_codec_support::codecs::h263::*; +use nihav_codec_support::codecs::h263::code::H263BlockDSP; +use nihav_codec_support::codecs::h263::decoder::*; +use nihav_codec_support::codecs::h263::data::*; #[allow(dead_code)] diff --git a/nihav-realmedia/src/codecs/rv30.rs b/nihav-realmedia/src/codecs/rv30.rs index e38c89c..e005e90 100644 --- a/nihav-realmedia/src/codecs/rv30.rs +++ b/nihav-realmedia/src/codecs/rv30.rs @@ -3,6 +3,7 @@ use nihav_core::io::bitreader::*; use nihav_core::io::intcode::*; use nihav_core::frame::*; use nihav_core::codecs::*; +use nihav_codec_support::codecs::{MV, ZERO_MV}; use super::rv3040::*; use super::rv30dsp::*; diff --git a/nihav-realmedia/src/codecs/rv3040.rs b/nihav-realmedia/src/codecs/rv3040.rs index f3d1743..d2ff139 100644 --- a/nihav-realmedia/src/codecs/rv3040.rs +++ b/nihav-realmedia/src/codecs/rv3040.rs @@ -1,9 +1,10 @@ use nihav_core::formats::YUV420_FORMAT; use nihav_core::frame::{NABufferType, NAVideoInfo, NAVideoBuffer, NAVideoBufferRef, FrameType, alloc_video_buffer}; -use nihav_core::codecs::{NADecoderSupport, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler}; +use nihav_core::codecs::{NADecoderSupport, DecoderError, DecoderResult}; +use nihav_codec_support::codecs::{MV, ZERO_MV, IPBShuffler}; use nihav_core::io::bitreader::{BitReader,BitReaderMode}; use nihav_core::io::intcode::*; -use nihav_core::data::GenericCache; +use nihav_codec_support::data::GenericCache; use std::mem; use super::rv34codes::*; diff --git a/nihav-realmedia/src/codecs/rv30dsp.rs b/nihav-realmedia/src/codecs/rv30dsp.rs index 86e8488..1961890 100644 --- a/nihav-realmedia/src/codecs/rv30dsp.rs +++ b/nihav-realmedia/src/codecs/rv30dsp.rs @@ -1,6 +1,6 @@ use nihav_core::frame::{FrameType, NAVideoBuffer}; -use nihav_core::codecs::MV; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::MV; +use nihav_codec_support::codecs::blockdsp::edge_emu; use super::rv3040::{RV34DSP, RV34MBInfo}; fn clip8(a: i16) -> u8 { diff --git a/nihav-realmedia/src/codecs/rv40.rs b/nihav-realmedia/src/codecs/rv40.rs index 5f95f0a..bddb355 100644 --- a/nihav-realmedia/src/codecs/rv40.rs +++ b/nihav-realmedia/src/codecs/rv40.rs @@ -4,6 +4,7 @@ use nihav_core::io::bitreader::*; use nihav_core::io::codebook::*; use nihav_core::io::intcode::*; use nihav_core::codecs::*; +use nihav_codec_support::codecs::{MV, ZERO_MV}; use super::rv3040::*; use super::rv40dsp::*; diff --git a/nihav-realmedia/src/codecs/rv40dsp.rs b/nihav-realmedia/src/codecs/rv40dsp.rs index 66c3e96..0dfec47 100644 --- a/nihav-realmedia/src/codecs/rv40dsp.rs +++ b/nihav-realmedia/src/codecs/rv40dsp.rs @@ -1,6 +1,6 @@ use nihav_core::frame::{FrameType, NAVideoBuffer}; -use nihav_core::codecs::MV; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::MV; +use nihav_codec_support::codecs::blockdsp::edge_emu; use super::rv3040::{RV34DSP, RV34MBInfo}; fn clip8(a: i16) -> u8 { diff --git a/nihav-realmedia/src/codecs/rv60.rs b/nihav-realmedia/src/codecs/rv60.rs index 801f8c2..9dbedef 100644 --- a/nihav-realmedia/src/codecs/rv60.rs +++ b/nihav-realmedia/src/codecs/rv60.rs @@ -1,6 +1,7 @@ use nihav_core::formats::YUV420_FORMAT; use nihav_core::frame::*; -use nihav_core::codecs::{NADecoder, NADecoderSupport, MV, ZERO_MV, DecoderError, DecoderResult, IPBShuffler}; +use nihav_core::codecs::{NADecoder, NADecoderSupport, DecoderError, DecoderResult}; +use nihav_codec_support::codecs::{MV, ZERO_MV, IPBShuffler}; use nihav_core::io::byteio::{MemoryReader,ByteReader}; use nihav_core::io::bitreader::{BitReader,BitReaderMode}; use nihav_core::io::intcode::*; diff --git a/nihav-realmedia/src/codecs/rv60dsp.rs b/nihav-realmedia/src/codecs/rv60dsp.rs index a5ec0c8..c62e212 100644 --- a/nihav-realmedia/src/codecs/rv60dsp.rs +++ b/nihav-realmedia/src/codecs/rv60dsp.rs @@ -1,6 +1,6 @@ use nihav_core::frame::{NAVideoBuffer, NASimpleVideoFrame}; -use nihav_core::codecs::MV; -use nihav_core::codecs::blockdsp::edge_emu; +use nihav_codec_support::codecs::MV; +use nihav_codec_support::codecs::blockdsp::edge_emu; fn clip8(val: i16) -> u8 { val.min(255).max(0) as u8 } diff --git a/nihav-realmedia/src/lib.rs b/nihav-realmedia/src/lib.rs index 66e001a..944711e 100644 --- a/nihav-realmedia/src/lib.rs +++ b/nihav-realmedia/src/lib.rs @@ -1,4 +1,5 @@ extern crate nihav_core; +extern crate nihav_codec_support; #[cfg(feature="decoders")] #[allow(clippy::cast_lossless)] |