aboutsummaryrefslogtreecommitdiffstats
path: root/nihav-commonfmt/src/codecs/mod.rs
blob: f69fc6441e5b6c70627713f2eed1350645bb33d5 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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_cinepak")]
mod cinepak;
#[cfg(feature="decoder_clearvideo")]
mod clearvideo;
#[cfg(feature="decoder_jpeg")]
mod jpeg;
#[cfg(feature="decoder_rawvideo")]
mod rawvideo;
#[cfg(feature="decoder_rawvideo_ms")]
mod rawvideo_ms;
#[cfg(feature="decoder_zmbv")]
mod zmbv;

#[cfg(feature="decoder_atrac3")]
#[allow(clippy::identity_op)]
#[allow(clippy::useless_let_if_seq)]
mod atrac3;
#[cfg(any(feature="decoder_pcm",feature="encoder_pcm"))]
mod pcm;
#[cfg(feature="decoder_sipro")]
#[allow(clippy::collapsible_if)]
#[allow(clippy::identity_op)]
#[allow(clippy::manual_memcpy)]
mod sipro;
#[cfg(feature="decoder_ts102366")]
mod ts102366;

#[cfg(feature="decoders")]
const DECODERS: &[DecoderInfo] = &[
#[cfg(feature="decoder_cinepak")]
    DecoderInfo { name: "cinepak", get_decoder: cinepak::get_decoder },
#[cfg(feature="decoder_clearvideo")]
    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_jpeg")]
    DecoderInfo { name: "jpeg", get_decoder: jpeg::get_decoder },
#[cfg(feature="decoder_rawvideo")]
    DecoderInfo { name: "rawvideo", get_decoder: rawvideo::get_decoder },
#[cfg(feature="decoder_rawvideo_ms")]
    DecoderInfo { name: "rawvideo-ms", get_decoder: rawvideo_ms::get_decoder },
#[cfg(feature="decoder_zmbv")]
    DecoderInfo { name: "zmbv", get_decoder: zmbv::get_decoder },

#[cfg(feature="decoder_pcm")]
    DecoderInfo { name: "pcm", get_decoder: pcm::get_decoder },
#[cfg(feature="decoder_pcm")]
    DecoderInfo { name: "alaw", get_decoder: pcm::get_a_law_decoder },
#[cfg(feature="decoder_pcm")]
    DecoderInfo { name: "ulaw", get_decoder: pcm::get_mu_law_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_atrac3")]
    DecoderInfo { name: "atrac3", get_decoder: atrac3::get_decoder },
];

/// Registers all available codecs provided by this crate.
#[cfg(feature="decoders")]
pub fn generic_register_all_decoders(rd: &mut RegisteredDecoders) {
    for decoder in DECODERS.iter() {
        rd.add_decoder(*decoder);
    }
}

#[cfg(feature="encoder_cinepak")]
mod cinepakenc;
#[cfg(feature="encoder_zmbv")]
mod zmbvenc;

#[cfg(feature="encoders")]
const ENCODERS: &[EncoderInfo] = &[
#[cfg(feature="encoder_cinepak")]
    EncoderInfo { name: "cinepak", get_encoder: cinepakenc::get_encoder },
#[cfg(feature="encoder_zmbv")]
    EncoderInfo { name: "zmbv", get_encoder: zmbvenc::get_encoder },

#[cfg(feature="encoder_pcm")]
    EncoderInfo { name: "pcm", get_encoder: pcm::get_encoder },
];

/// Registers all available encoders provided by this crate.
#[cfg(feature="encoders")]
pub fn generic_register_all_encoders(re: &mut RegisteredEncoders) {
    for encoder in ENCODERS.iter() {
        re.add_encoder(*encoder);
    }
}