aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-mpeg/src/codecs/mod.rs
blob: f6fb31cd6301e48f3331cffb41a59362fae4a1ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use nihav_core::codecs::*;

#[cfg(debug_assertions)]
macro_rules! validate {
    ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
}
#[cfg(not(debug_assertions))]
macro_rules! validate {
    ($a:expr) => { if !$a { return Err(DecoderError::InvalidData); } };
}

#[cfg(feature="decoder_aac")]
#[allow(clippy::comparison_chain)]
#[allow(clippy::excessive_precision)]
#[allow(clippy::manual_memcpy)]
#[allow(clippy::useless_let_if_seq)]
mod aac;
#[cfg(feature="decoder_mpa")]
#[allow(clippy::excessive_precision)]
mod mpegaudio;

const DECODERS: &[DecoderInfo] = &[
#[cfg(feature="decoder_aac")]
    DecoderInfo { name: "aac", get_decoder: aac::get_decoder },
#[cfg(feature="decoder_mpa")]
    DecoderInfo { name: "mp2", get_decoder: mpegaudio::get_decoder_mp2 },
#[cfg(feature="decoder_mpa")]
    DecoderInfo { name: "mp3", get_decoder: mpegaudio::get_decoder_mp3 },
];

/// Registers all available codecs provided by this crate.
pub fn mpeg_register_all_decoders(rd: &mut RegisteredDecoders) {
    for decoder in DECODERS.iter() {
        rd.add_decoder(*decoder);
    }
}

const PACKETISERS: &[PacketiserInfo] = &[
#[cfg(feature="decoder_mpa")]
    PacketiserInfo { name: "mpa", get_packetiser: mpegaudio::get_packetiser },
];

/// Registers all available packetisers provided by this crate.
pub fn mpeg_register_all_packetisers(rp: &mut RegisteredPacketisers) {
    for packetiser in PACKETISERS.iter() {
        rp.add_packetiser(*packetiser);
    }
}