]> git.nihav.org Git - nihav.git/blob - nihav-realmedia/src/codecs/mod.rs
core/soundcvt: add resampling support
[nihav.git] / nihav-realmedia / src / codecs / mod.rs
1 use nihav_core::codecs::*;
2
3 #[cfg(debug_assertions)]
4 macro_rules! validate {
5 ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
6 }
7 #[cfg(not(debug_assertions))]
8 macro_rules! validate {
9 ($a:expr) => { if !$a { return Err(DecoderError::InvalidData); } };
10 }
11
12 #[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
13 mod rv3040;
14 #[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4", feature="encoder_realvideo4"))]
15 #[allow(clippy::erasing_op)]
16 mod rv34codes;
17 #[cfg(any(feature="decoder_realvideo3", feature="decoder_realvideo4"))]
18 #[allow(clippy::erasing_op)]
19 #[allow(clippy::many_single_char_names)]
20 mod rv34dsp;
21
22 #[cfg(feature="decoder_realvideo1")]
23 pub mod rv10;
24 #[cfg(feature="decoder_realvideo2")]
25 pub mod rv20;
26 #[cfg(feature="decoder_realvideo3")]
27 pub mod rv30;
28 #[cfg(feature="decoder_realvideo3")]
29 #[allow(clippy::erasing_op)]
30 #[allow(clippy::many_single_char_names)]
31 #[allow(clippy::neg_multiply)]
32 pub mod rv30dsp;
33 #[cfg(feature="decoder_realvideo4")]
34 pub mod rv40;
35 #[cfg(any(feature="decoder_realvideo4", feature="encoder_realvideo4"))]
36 pub mod rv40data;
37 #[cfg(feature="decoder_realvideo4")]
38 #[allow(clippy::erasing_op)]
39 #[allow(clippy::many_single_char_names)]
40 pub mod rv40dsp;
41 #[cfg(feature="decoder_realvideo6")]
42 pub mod rv60;
43 #[cfg(feature="decoder_realvideo6")]
44 pub mod rv60codes;
45 #[cfg(feature="decoder_realvideo6")]
46 #[allow(clippy::erasing_op)]
47 #[allow(clippy::many_single_char_names)]
48 pub mod rv60dsp;
49
50 #[cfg(feature="decoder_realaudio144")]
51 #[allow(clippy::manual_memcpy)]
52 pub mod ra144;
53 #[cfg(feature="decoder_realaudio288")]
54 pub mod ra288;
55 #[cfg(feature="decoder_cook")]
56 pub mod cook;
57 #[cfg(any(feature="decoder_cook", feature="encoder_cook"))]
58 pub mod cookdata;
59 #[cfg(feature="decoder_ralf")]
60 pub mod ralf;
61
62 const RM_CODECS: &[DecoderInfo] = &[
63 #[cfg(feature="decoder_realvideo1")]
64 DecoderInfo { name: "realvideo1", get_decoder: rv10::get_decoder },
65 #[cfg(feature="decoder_realvideo2")]
66 DecoderInfo { name: "realvideo2", get_decoder: rv20::get_decoder },
67 #[cfg(feature="decoder_realvideo3")]
68 DecoderInfo { name: "realvideo3", get_decoder: rv30::get_decoder },
69 #[cfg(feature="decoder_realvideo4")]
70 DecoderInfo { name: "realvideo4", get_decoder: rv40::get_decoder },
71 #[cfg(feature="decoder_realvideo6")]
72 DecoderInfo { name: "realvideo6", get_decoder: rv60::get_decoder },
73
74 #[cfg(feature="decoder_realaudio144")]
75 DecoderInfo { name: "ra14.4", get_decoder: ra144::get_decoder },
76 #[cfg(feature="decoder_realaudio288")]
77 DecoderInfo { name: "ra28.8", get_decoder: ra288::get_decoder },
78 #[cfg(feature="decoder_cook")]
79 DecoderInfo { name: "cook", get_decoder: cook::get_decoder },
80 #[cfg(feature="decoder_ralf")]
81 DecoderInfo { name: "ralf", get_decoder: ralf::get_decoder },
82 ];
83
84 /// Registers all available codecs provided by this crate.
85 pub fn realmedia_register_all_decoders(rd: &mut RegisteredDecoders) {
86 for decoder in RM_CODECS.iter() {
87 rd.add_decoder(*decoder);
88 }
89 }
90
91 #[cfg(feature="encoder_cook")]
92 mod cookenc;
93
94 #[cfg(feature="encoder_rv40")]
95 mod rv40enc;
96
97 #[cfg(feature="encoders")]
98 const ENCODERS: &[EncoderInfo] = &[
99 #[cfg(feature="encoder_cook")]
100 EncoderInfo { name: "cook", get_encoder: cookenc::get_encoder },
101
102 #[cfg(feature="encoder_rv40")]
103 EncoderInfo { name: "realvideo4", get_encoder: rv40enc::get_encoder },
104 ];
105
106 /// Registers all available encoders provided by this crate.
107 #[cfg(feature="encoders")]
108 pub fn realmedia_register_all_encoders(re: &mut RegisteredEncoders) {
109 for encoder in ENCODERS.iter() {
110 re.add_encoder(*encoder);
111 }
112 }