]> git.nihav.org Git - nihav.git/blame - nihav-duck/src/codecs/mod.rs
add MPEG-4 ASP decoder
[nihav.git] / nihav-duck / src / codecs / mod.rs
CommitLineData
1b8522d6
KS
1use nihav_core::codecs::*;
2
71d7f397 3#[cfg(debug_assertions)]
1b8522d6
KS
4macro_rules! validate {
5 ($a:expr) => { if !$a { println!("check failed at {}:{}", file!(), line!()); return Err(DecoderError::InvalidData); } };
6}
71d7f397
KS
7#[cfg(not(debug_assertions))]
8macro_rules! validate {
9 ($a:expr) => { if !$a { return Err(DecoderError::InvalidData); } };
10}
1b8522d6
KS
11
12#[cfg(feature="decoder_truemotion1")]
13mod truemotion1;
0774ed3d 14#[cfg(any(feature="decoder_truemotion1", feature="encoder_truemotion1"))]
fafc32ef 15mod truemotion1data;
1b8522d6
KS
16#[cfg(feature="decoder_truemotionrt")]
17mod truemotionrt;
18#[cfg(feature="decoder_truemotion2")]
47933c6d 19#[allow(clippy::needless_range_loop)]
1b8522d6
KS
20mod truemotion2;
21#[cfg(feature="decoder_truemotion2x")]
22mod truemotion2x;
3584b223
KS
23#[cfg(any(feature="decoder_vp3", feature="decoder_vp4", feature="decoder_vp5", feature="decoder_vp6", feature="decoder_vp7"))]
24#[macro_use]
47933c6d
KS
25#[allow(clippy::erasing_op)]
26#[allow(clippy::needless_range_loop)]
27#[allow(clippy::too_many_arguments)]
28#[allow(clippy::useless_let_if_seq)]
3584b223 29mod vpcommon;
40e95291 30#[cfg(any(feature="decoder_vp3", feature="decoder_vp4"))]
47933c6d
KS
31#[allow(clippy::needless_range_loop)]
32#[allow(clippy::too_many_arguments)]
40e95291
KS
33mod vp3;
34#[cfg(any(feature="decoder_vp5", feature="decoder_vp6"))]
47933c6d
KS
35#[allow(clippy::needless_range_loop)]
36#[allow(clippy::useless_let_if_seq)]
37#[allow(clippy::too_many_arguments)]
40e95291 38mod vp56;
3584b223 39#[cfg(feature="decoder_vp5")]
47933c6d 40#[allow(clippy::needless_range_loop)]
3584b223 41mod vp5;
3952bfd9 42#[cfg(any(feature="decoder_vp6", feature="encoder_vp6"))]
01551716 43mod vp6data;
3952bfd9
KS
44#[cfg(any(feature="decoder_vp6", feature="encoder_vp6"))]
45mod vp6dsp;
01551716 46#[cfg(feature="decoder_vp6")]
47933c6d 47#[allow(clippy::needless_range_loop)]
3584b223 48mod vp6;
40e95291 49#[cfg(feature="decoder_vp7")]
47933c6d
KS
50#[allow(clippy::needless_range_loop)]
51#[allow(clippy::useless_let_if_seq)]
40e95291 52mod vp7;
c5d5793c 53#[cfg(any(feature="decoder_vp7", feature="encoder_vp7"))]
b922b48d 54mod vp7data;
d0d21988 55#[cfg(any(feature="decoder_vp7", feature="decoder_vp8"))]
0cc75664 56mod vp78data;
587a6d78 57#[cfg(feature="decoder_vp7")]
47933c6d
KS
58#[allow(clippy::erasing_op)]
59#[allow(clippy::needless_range_loop)]
60#[allow(clippy::too_many_arguments)]
61#[allow(clippy::useless_let_if_seq)]
587a6d78 62mod vp7dsp;
c5d5793c 63#[cfg(any(feature="decoder_vp7", feature="decoder_vp8", feature="encoder_vp7"))]
0cc75664
KS
64#[allow(clippy::needless_range_loop)]
65#[allow(clippy::useless_let_if_seq)]
66mod vp78;
c5d5793c 67#[cfg(any(feature="decoder_vp7", feature="decoder_vp8", feature="encoder_vp7"))]
0cc75664
KS
68#[allow(clippy::erasing_op)]
69#[allow(clippy::needless_range_loop)]
70#[allow(clippy::too_many_arguments)]
71#[allow(clippy::useless_let_if_seq)]
72mod vp78dsp;
d0d21988
KS
73#[cfg(feature="decoder_vp8")]
74#[allow(clippy::needless_range_loop)]
75#[allow(clippy::useless_let_if_seq)]
76mod vp8;
77#[cfg(feature="decoder_vp8")]
78#[allow(clippy::erasing_op)]
79#[allow(clippy::needless_range_loop)]
80#[allow(clippy::too_many_arguments)]
81mod vp8dsp;
1b8522d6 82
029d2552
KS
83#[cfg(any(feature="decoder_dk3_adpcm", feature="decoder_dk4_adpcm"))]
84mod dkadpcm;
1b8522d6 85#[cfg(feature="decoder_on2avc")]
47933c6d
KS
86#[allow(clippy::manual_memcpy)]
87#[allow(clippy::needless_range_loop)]
88#[allow(clippy::too_many_arguments)]
1b8522d6 89mod on2avc;
6a494288
KS
90#[cfg(feature="decoder_on2avc")]
91mod on2avcdata;
1b8522d6
KS
92
93const DUCK_CODECS: &[DecoderInfo] = &[
94#[cfg(feature="decoder_truemotion1")]
95 DecoderInfo { name: "truemotion1", get_decoder: truemotion1::get_decoder },
96#[cfg(feature="decoder_truemotionrt")]
97 DecoderInfo { name: "truemotionrt", get_decoder: truemotionrt::get_decoder },
98#[cfg(feature="decoder_truemotion2")]
99 DecoderInfo { name: "truemotion2", get_decoder: truemotion2::get_decoder },
100#[cfg(feature="decoder_truemotion2x")]
101 DecoderInfo { name: "truemotion2x", get_decoder: truemotion2x::get_decoder },
40e95291
KS
102#[cfg(feature="decoder_vp3")]
103 DecoderInfo { name: "vp3", get_decoder: vp3::get_decoder_vp3 },
104#[cfg(feature="decoder_vp4")]
105 DecoderInfo { name: "vp4", get_decoder: vp3::get_decoder_vp4 },
106#[cfg(feature="decoder_vp5")]
3584b223
KS
107 DecoderInfo { name: "vp5", get_decoder: vp5::get_decoder },
108#[cfg(feature="decoder_vp6")]
109 DecoderInfo { name: "vp6", get_decoder: vp6::get_decoder_vp6 },
92d9fb69
KS
110#[cfg(feature="decoder_vp6")]
111 DecoderInfo { name: "vp6f", get_decoder: vp6::get_decoder_vp6f },
40e95291 112#[cfg(feature="decoder_vp6")]
3584b223 113 DecoderInfo { name: "vp6a", get_decoder: vp6::get_decoder_vp6_alpha },
40e95291
KS
114#[cfg(feature="decoder_vp7")]
115 DecoderInfo { name: "vp7", get_decoder: vp7::get_decoder },
d0d21988
KS
116#[cfg(feature="decoder_vp8")]
117 DecoderInfo { name: "vp8", get_decoder: vp8::get_decoder },
1b8522d6 118
029d2552
KS
119#[cfg(feature="decoder_dk3_adpcm")]
120 DecoderInfo { name: "adpcm-dk3", get_decoder: dkadpcm::get_decoder_dk3 },
121#[cfg(feature="decoder_dk4_adpcm")]
122 DecoderInfo { name: "adpcm-dk4", get_decoder: dkadpcm::get_decoder_dk4 },
1b8522d6
KS
123#[cfg(feature="decoder_on2avc")]
124 DecoderInfo { name: "on2avc-500", get_decoder: on2avc::get_decoder_500 },
125#[cfg(feature="decoder_on2avc")]
126 DecoderInfo { name: "on2avc-501", get_decoder: on2avc::get_decoder_501 },
127];
128
e64739f8 129/// Registers all available codecs provided by this crate.
78fb6560 130pub fn duck_register_all_decoders(rd: &mut RegisteredDecoders) {
8a7352c0 131 for decoder in DUCK_CODECS.iter() {
b7c882c1 132 rd.add_decoder(*decoder);
1b8522d6
KS
133 }
134}
3952bfd9 135
0774ed3d
KS
136#[cfg(feature="encoder_truemotion1")]
137mod truemotion1enc;
7f839ae7
KS
138#[cfg(feature="encoder_truemotionrt")]
139mod truemotionrtenc;
19cfcd2f
KS
140#[cfg(feature="encoder_vp6")]
141#[macro_use]
142mod vpenc;
3952bfd9
KS
143#[cfg(feature="encoder_vp6")]
144#[allow(clippy::needless_range_loop)]
145mod vp6enc;
c5d5793c
KS
146#[cfg(feature="encoder_vp7")]
147#[allow(clippy::needless_range_loop)]
148mod vp7enc;
3952bfd9
KS
149
150const DUCK_ENCODERS: &[EncoderInfo] = &[
0774ed3d
KS
151#[cfg(feature="encoder_truemotion1")]
152 EncoderInfo { name: "truemotion1", get_encoder: truemotion1enc::get_encoder },
7f839ae7
KS
153#[cfg(feature="encoder_truemotionrt")]
154 EncoderInfo { name: "truemotionrt", get_encoder: truemotionrtenc::get_encoder },
3952bfd9
KS
155#[cfg(feature="encoder_vp6")]
156 EncoderInfo { name: "vp6", get_encoder: vp6enc::get_encoder },
92d9fb69
KS
157#[cfg(feature="encoder_vp6")]
158 EncoderInfo { name: "vp6f", get_encoder: vp6enc::get_encoder_flv },
c5d5793c
KS
159#[cfg(feature="encoder_vp7")]
160 EncoderInfo { name: "vp7", get_encoder: vp7enc::get_encoder },
3952bfd9
KS
161];
162
163/// Registers all available encoders provided by this crate.
164pub fn duck_register_all_encoders(re: &mut RegisteredEncoders) {
165 for encoder in DUCK_ENCODERS.iter() {
166 re.add_encoder(*encoder);
167 }
168}