use nihav_core::formats::*;
use nihav_core::codecs::*;
+#[cfg(feature="encoder_pcm")]
use nihav_core::io::byteio::*;
#[derive(Clone,Copy,Debug,PartialEq)]
+#[cfg(feature="decoder_pcm")]
enum PCMMode {
Infinity,
ALaw,
MuLaw,
}
+#[cfg(feature="decoder_pcm")]
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;
if sign { aval } else { -aval }
}
+#[cfg(feature="decoder_pcm")]
fn cvt_mulaw(val: u8) -> i16 {
let val = !val;
let sign = (val & 0x80) != 0;
if !sign { aval } else { -aval }
}
+#[cfg(feature="decoder_pcm")]
impl PCMDecoder {
fn new(mode: PCMMode) -> Self {
PCMDecoder { chmap: NAChannelMap::new(), mode }
}
}
+#[cfg(feature="decoder_pcm")]
const CHMAP_MONO: [NAChannelType; 1] = [NAChannelType::C];
+#[cfg(feature="decoder_pcm")]
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 {
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;
}
}
+#[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() {
}
}
+#[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 }
}
+#[cfg(feature="decoder_pcm")]
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))
}
+#[cfg(feature="decoder_pcm")]
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>,
}
+#[cfg(feature="encoder_pcm")]
impl PCMEncoder {
fn new() -> Self {
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();
}
}
+#[cfg(feature="encoder_pcm")]
impl NAEncoder for PCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
}
}
+#[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 }
}
+#[cfg(feature="encoder_pcm")]
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(PCMEncoder::new())
}
use nihav_core::frame::*;
use nihav_core::formats;
+#[cfg(feature="decoder_fstaud")]
use nihav_core::formats::NAChannelMap;
use nihav_core::codecs::*;
+#[cfg(feature="decoder_fstvid")]
use nihav_core::io::byteio::*;
+#[cfg(feature="decoder_fstaud")]
use nihav_codec_support::codecs::imaadpcm::IMAState;
+#[cfg(feature="decoder_fstvid")]
struct FutureVisionVideoDecoder {
info: NACodecInfoRef,
pal: [u8; 768],
h: usize,
}
+#[cfg(feature="decoder_fstvid")]
struct Bits8<'a> {
src: &'a [u8],
pos: usize,
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> {
}
}
+#[cfg(feature="decoder_fstvid")]
impl FutureVisionVideoDecoder {
fn new() -> Self {
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() {
}
}
+#[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 }
}
+#[cfg(feature="decoder_fstvid")]
pub fn get_decoder_video() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionVideoDecoder::new())
}
+#[cfg(feature="decoder_fstaud")]
struct FutureVisionAudioDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
count: usize,
}
+#[cfg(feature="decoder_fstaud")]
impl FutureVisionAudioDecoder {
fn new() -> Self {
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() {
}
}
+#[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 }
}
+#[cfg(feature="decoder_fstaud")]
pub fn get_decoder_audio() -> Box<dyn NADecoder + Send> {
Box::new(FutureVisionAudioDecoder::new())
}
use nihav_core::codecs::*;
+#[allow(unused_macros)]
macro_rules! validate {
($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
}
}
}
+#[cfg(feature="decoder_ms_adpcm")]
struct MSADPCMDecoder {
ainfo: NAAudioInfo,
chmap: NAChannelMap,
block_samps: usize,
}
+#[cfg(feature="decoder_ms_adpcm")]
impl MSADPCMDecoder {
fn new() -> Self {
Self {
}
}
+#[cfg(feature="decoder_ms_adpcm")]
impl NADecoder for MSADPCMDecoder {
#[allow(clippy::int_plus_one)]
fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> {
}
}
+#[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 }
}
+#[cfg(feature="decoder_ms_adpcm")]
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>,
srate: u32,
}
+#[cfg(feature="encoder_ms_adpcm")]
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> {
}
}
+#[cfg(feature="encoder_ms_adpcm")]
impl NAEncoder for MSADPCMEncoder {
fn negotiate_format(&self, encinfo: &EncodeParameters) -> EncoderResult<EncodeParameters> {
match encinfo.format {
}
}
+#[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 }
}
+#[cfg(feature="encoder_ms_adpcm")]
pub fn get_encoder() -> Box<dyn NAEncoder + Send> {
Box::new(MSADPCMEncoder::new())
}