projects
/
nihav.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
820b433
)
add enabling/disabling features for files with both encoder and decoder
author
Kostya Shishkov
<kostya.shishkov@gmail.com>
Wed, 17 Nov 2021 13:46:04 +0000
(14:46 +0100)
committer
Kostya Shishkov
<kostya.shishkov@gmail.com>
Wed, 17 Nov 2021 13:46:04 +0000
(14:46 +0100)
nihav-commonfmt/src/codecs/pcm.rs
patch
|
blob
|
blame
|
history
nihav-game/src/codecs/futurevision.rs
patch
|
blob
|
blame
|
history
nihav-game/src/codecs/mod.rs
patch
|
blob
|
blame
|
history
nihav-ms/src/codecs/msadpcm.rs
patch
|
blob
|
blame
|
history
diff --git
a/nihav-commonfmt/src/codecs/pcm.rs
b/nihav-commonfmt/src/codecs/pcm.rs
index 46b19928b1436ec1496696356404570277917b28..29926a557e63b6918115ad2b9a2b03ef36524c34 100644
(file)
--- a/
nihav-commonfmt/src/codecs/pcm.rs
+++ b/
nihav-commonfmt/src/codecs/pcm.rs
@@
-1,19
+1,23
@@
use nihav_core::formats::*;
use nihav_core::codecs::*;
use nihav_core::formats::*;
use nihav_core::codecs::*;
+#[cfg(feature="encoder_pcm")]
use nihav_core::io::byteio::*;
#[derive(Clone,Copy,Debug,PartialEq)]
use nihav_core::io::byteio::*;
#[derive(Clone,Copy,Debug,PartialEq)]
+#[cfg(feature="decoder_pcm")]
enum PCMMode {
Infinity,
ALaw,
MuLaw,
}
enum PCMMode {
Infinity,
ALaw,
MuLaw,
}
+#[cfg(feature="decoder_pcm")]
struct PCMDecoder {
chmap: NAChannelMap,
mode: PCMMode,
}
struct PCMDecoder {
chmap: NAChannelMap,
mode: PCMMode,
}
+#[cfg(feature="decoder_pcm")]
fn cvt_alaw(val: u8) -> i16 {
let val = val ^ 0x55;
let sign = (val & 0x80) != 0;
fn cvt_alaw(val: u8) -> i16 {
let val = val ^ 0x55;
let sign = (val & 0x80) != 0;
@@
-23,6
+27,7
@@
fn cvt_alaw(val: u8) -> i16 {
if sign { aval } else { -aval }
}
if sign { aval } else { -aval }
}
+#[cfg(feature="decoder_pcm")]
fn cvt_mulaw(val: u8) -> i16 {
let val = !val;
let sign = (val & 0x80) != 0;
fn cvt_mulaw(val: u8) -> i16 {
let val = !val;
let sign = (val & 0x80) != 0;
@@
-32,6
+37,7
@@
fn cvt_mulaw(val: u8) -> i16 {
if !sign { aval } else { -aval }
}
if !sign { aval } else { -aval }
}
+#[cfg(feature="decoder_pcm")]
impl PCMDecoder {
fn new(mode: PCMMode) -> Self {
PCMDecoder { chmap: NAChannelMap::new(), mode }
impl PCMDecoder {
fn new(mode: PCMMode) -> Self {
PCMDecoder { chmap: NAChannelMap::new(), mode }
@@
-55,9
+61,12
@@
impl PCMDecoder {
}
}
}
}
+#[cfg(feature="decoder_pcm")]
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
+#[cfg(feature="decoder_pcm")]
const CHMAP_STEREO: [NAChannelType; 2] = [NAChannelType::L, NAChannelType::R];
const CHMAP_STEREO: [NAChannelType; 2] = [NAChannelType::L, NAChannelType::R];
+#[cfg(feature="decoder_pcm")]
fn get_default_chmap(nch: u8) -> NAChannelMap {
let mut chmap = NAChannelMap::new();
match nch {
fn get_default_chmap(nch: u8) -> NAChannelMap {
let mut chmap = NAChannelMap::new();
match nch {
@@
-68,6
+77,7
@@
fn get_default_chmap(nch: u8) -> NAChannelMap {
chmap
}
chmap
}
+#[cfg(feature="decoder_pcm")]
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
if duration == None {
let size_bits = (data_size as u64) * 8;
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) -> u64 {
if duration == None {
let size_bits = (data_size as u64) * 8;
@@
-78,6
+88,7
@@
fn get_duration(ainfo: &NAAudioInfo, duration: Option<u64>, data_size: usize) ->
}
}
}
}
+#[cfg(feature="decoder_pcm")]
impl NADecoder for PCMDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
impl NADecoder for PCMDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
@@
-109,29
+120,35
@@
impl NADecoder for PCMDecoder {
}
}
}
}
+#[cfg(feature="decoder_pcm")]
impl NAOptionHandler for PCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for PCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="decoder_pcm")]
pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::Infinity))
}
pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::Infinity))
}
+#[cfg(feature="decoder_pcm")]
pub fn get_a_law_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::ALaw))
}
pub fn get_a_law_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::ALaw))
}
+#[cfg(feature="decoder_pcm")]
pub fn get_mu_law_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::MuLaw))
}
pub fn get_mu_law_decoder() -> Box<dyn NADecoder + Send> {
Box::new(PCMDecoder::new(PCMMode::MuLaw))
}
+#[cfg(feature="encoder_pcm")]
struct PCMEncoder {
stream: Option<NAStreamRef>,
pkt: Option<NAPacket>,
}
struct PCMEncoder {
stream: Option<NAStreamRef>,
pkt: Option<NAPacket>,
}
+#[cfg(feature="encoder_pcm")]
impl PCMEncoder {
fn new() -> Self {
PCMEncoder {
impl PCMEncoder {
fn new() -> Self {
PCMEncoder {
@@
-141,6
+158,7
@@
impl PCMEncoder {
}
}
}
}
+#[allow(unused_macros)]
macro_rules! write_buffer {
($abuf: expr, $dvec: expr, $write_be: ident, $write_le: ident, $dtype: tt) => {
let info = $abuf.get_info();
macro_rules! write_buffer {
($abuf: expr, $dvec: expr, $write_be: ident, $write_le: ident, $dtype: tt) => {
let info = $abuf.get_info();
@@
-166,6
+184,7
@@
macro_rules! write_buffer {
}
}
}
}
+#[cfg(feature="encoder_pcm")]
impl NAEncoder for PCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
impl NAEncoder for PCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
@@
-246,12
+265,14
@@
impl NAEncoder for PCMEncoder {
}
}
}
}
+#[cfg(feature="encoder_pcm")]
impl NAOptionHandler for PCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for PCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="encoder_pcm")]
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(PCMEncoder::new())
}
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(PCMEncoder::new())
}
diff --git
a/nihav-game/src/codecs/futurevision.rs
b/nihav-game/src/codecs/futurevision.rs
index c59e9bb41581dbf72791fb83fb687885e2f3ff57..814039124a55ac8f3fa2095c5a5c5595eff154b1 100644
(file)
--- a/
nihav-game/src/codecs/futurevision.rs
+++ b/
nihav-game/src/codecs/futurevision.rs
@@
-1,10
+1,14
@@
use nihav_core::frame::*;
use nihav_core::formats;
use nihav_core::frame::*;
use nihav_core::formats;
+#[cfg(feature="decoder_fstaud")]
use nihav_core::formats::NAChannelMap;
use nihav_core::codecs::*;
use nihav_core::formats::NAChannelMap;
use nihav_core::codecs::*;
+#[cfg(feature="decoder_fstvid")]
use nihav_core::io::byteio::*;
use nihav_core::io::byteio::*;
+#[cfg(feature="decoder_fstaud")]
use nihav_codec_support::codecs::imaadpcm::IMAState;
use nihav_codec_support::codecs::imaadpcm::IMAState;
+#[cfg(feature="decoder_fstvid")]
struct FutureVisionVideoDecoder {
info: NACodecInfoRef,
pal: [u8; 768],
struct FutureVisionVideoDecoder {
info: NACodecInfoRef,
pal: [u8; 768],
@@
-13,6
+17,7
@@
struct FutureVisionVideoDecoder {
h: usize,
}
h: usize,
}
+#[cfg(feature="decoder_fstvid")]
struct Bits8<'a> {
src: &'a [u8],
pos: usize,
struct Bits8<'a> {
src: &'a [u8],
pos: usize,
@@
-20,6
+25,7
@@
struct Bits8<'a> {
bit: u8,
}
bit: u8,
}
+#[cfg(feature="decoder_fstvid")]
impl<'a> Bits8<'a> {
fn new(src: &'a [u8]) -> Self { Bits8 { src, pos: 0, buf: 0, bit: 0 } }
fn read_bit(&mut self) -> ByteIOResult<bool> {
impl<'a> Bits8<'a> {
fn new(src: &'a [u8]) -> Self { Bits8 { src, pos: 0, buf: 0, bit: 0 } }
fn read_bit(&mut self) -> ByteIOResult<bool> {
@@
-39,6
+45,7
@@
impl<'a> Bits8<'a> {
}
}
}
}
+#[cfg(feature="decoder_fstvid")]
impl FutureVisionVideoDecoder {
fn new() -> Self {
FutureVisionVideoDecoder {
impl FutureVisionVideoDecoder {
fn new() -> Self {
FutureVisionVideoDecoder {
@@
-65,6
+72,7
@@
impl FutureVisionVideoDecoder {
}
}
}
}
+#[cfg(feature="decoder_fstvid")]
impl NADecoder for FutureVisionVideoDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
impl NADecoder for FutureVisionVideoDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Video(vinfo) = info.get_properties() {
@@
-143,16
+151,19
@@
impl NADecoder for FutureVisionVideoDecoder {
}
}
}
}
+#[cfg(feature="decoder_fstvid")]
impl NAOptionHandler for FutureVisionVideoDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for FutureVisionVideoDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="decoder_fstvid")]
pub fn get_decoder_video() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionVideoDecoder::new())
}
pub fn get_decoder_video() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionVideoDecoder::new())
}
+#[cfg(feature="decoder_fstaud")]
struct FutureVisionAudioDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
struct FutureVisionAudioDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
@@
-160,6
+171,7
@@
struct FutureVisionAudioDecoder {
count: usize,
}
count: usize,
}
+#[cfg(feature="decoder_fstaud")]
impl FutureVisionAudioDecoder {
fn new() -> Self {
FutureVisionAudioDecoder {
impl FutureVisionAudioDecoder {
fn new() -> Self {
FutureVisionAudioDecoder {
@@
-171,6
+183,7
@@
impl FutureVisionAudioDecoder {
}
}
}
}
+#[cfg(feature="decoder_fstaud")]
impl NADecoder for FutureVisionAudioDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
impl NADecoder for FutureVisionAudioDecoder {
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() {
@@
-209,12
+222,14
@@
impl NADecoder for FutureVisionAudioDecoder {
}
}
}
}
+#[cfg(feature="decoder_fstaud")]
impl NAOptionHandler for FutureVisionAudioDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for FutureVisionAudioDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="decoder_fstaud")]
pub fn get_decoder_audio() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionAudioDecoder::new())
}
pub fn get_decoder_audio() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionAudioDecoder::new())
}
diff --git
a/nihav-game/src/codecs/mod.rs
b/nihav-game/src/codecs/mod.rs
index 8e735f20b77fe23df6016f5c0165f3be137c8914..f5e9532b41c3f2eb2ab9c0ba4a59f17d7126629c 100644
(file)
--- a/
nihav-game/src/codecs/mod.rs
+++ b/
nihav-game/src/codecs/mod.rs
@@
-1,5
+1,6
@@
use nihav_core::codecs::*;
use nihav_core::codecs::*;
+#[allow(unused_macros)]
macro_rules! validate {
($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
}
macro_rules! validate {
($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
}
diff --git
a/nihav-ms/src/codecs/msadpcm.rs
b/nihav-ms/src/codecs/msadpcm.rs
index a63f4e5a4b9d5661885564d25e5d9ba3199e6f8c..068dd410fe7708a8a7ca2c5ffb5b348d40140ec2 100644
(file)
--- a/
nihav-ms/src/codecs/msadpcm.rs
+++ b/
nihav-ms/src/codecs/msadpcm.rs
@@
-37,6
+37,7
@@
impl Predictor {
}
}
}
}
+#[cfg(feature="decoder_ms_adpcm")]
struct MSADPCMDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
struct MSADPCMDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
@@
-45,6
+46,7
@@
struct MSADPCMDecoder {
block_samps: usize,
}
block_samps: usize,
}
+#[cfg(feature="decoder_ms_adpcm")]
impl MSADPCMDecoder {
fn new() -> Self {
Self {
impl MSADPCMDecoder {
fn new() -> Self {
Self {
@@
-57,6
+59,7
@@
impl MSADPCMDecoder {
}
}
}
}
+#[cfg(feature="decoder_ms_adpcm")]
impl NADecoder for MSADPCMDecoder {
#[allow(clippy::int_plus_one)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
impl NADecoder for MSADPCMDecoder {
#[allow(clippy::int_plus_one)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
@@
-162,17
+165,20
@@
impl NADecoder for MSADPCMDecoder {
}
}
}
}
+#[cfg(feature="decoder_ms_adpcm")]
impl NAOptionHandler for MSADPCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for MSADPCMDecoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="decoder_ms_adpcm")]
pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(MSADPCMDecoder::new())
}
#[derive(Default)]
pub fn get_decoder() -> Box<dyn NADecoder + Send> {
Box::new(MSADPCMDecoder::new())
}
#[derive(Default)]
+#[cfg(feature="encoder_ms_adpcm")]
struct MSADPCMEncoder {
stream: Option<NAStreamRef>,
samples: Vec<i16>,
struct MSADPCMEncoder {
stream: Option<NAStreamRef>,
samples: Vec<i16>,
@@
-182,8
+188,10
@@
struct MSADPCMEncoder {
srate: u32,
}
srate: u32,
}
+#[cfg(feature="encoder_ms_adpcm")]
const DEFAULT_BLOCK_LEN: usize = 256;
const DEFAULT_BLOCK_LEN: usize = 256;
+#[cfg(feature="encoder_ms_adpcm")]
impl MSADPCMEncoder {
fn new() -> Self { Self::default() }
fn encode_packet(&mut self) -> EncoderResult<NAPacket> {
impl MSADPCMEncoder {
fn new() -> Self { Self::default() }
fn encode_packet(&mut self) -> EncoderResult<NAPacket> {
@@
-297,6
+305,7
@@
impl MSADPCMEncoder {
}
}
}
}
+#[cfg(feature="encoder_ms_adpcm")]
impl NAEncoder for MSADPCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
impl NAEncoder for MSADPCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
@@
-394,12
+403,14
@@
impl NAEncoder for MSADPCMEncoder {
}
}
}
}
+#[cfg(feature="encoder_ms_adpcm")]
impl NAOptionHandler for MSADPCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
impl NAOptionHandler for MSADPCMEncoder {
fn get_supported_options(&self) -> &[NAOptionDefinition] { &[] }
fn set_options(&mut self, _options: &[NAOption]) { }
fn query_option_value(&self, _name: &str) -> Option<NAValue> { None }
}
+#[cfg(feature="encoder_ms_adpcm")]
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(MSADPCMEncoder::new())
}
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(MSADPCMEncoder::new())
}