1 | use super::Id; |
2 | use ffi::*; |
3 | use libc::c_int; |
4 | |
5 | #[allow (non_camel_case_types)] |
6 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
7 | pub enum Profile { |
8 | Unknown, |
9 | Reserved, |
10 | |
11 | AAC(AAC), |
12 | MPEG2(MPEG2), |
13 | DTS(DTS), |
14 | H264(H264), |
15 | VC1(VC1), |
16 | MPEG4(MPEG4), |
17 | JPEG2000(JPEG2000), |
18 | HEVC(HEVC), |
19 | VP9(VP9), |
20 | } |
21 | |
22 | #[allow (non_camel_case_types)] |
23 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
24 | pub enum AAC { |
25 | Main, |
26 | Low, |
27 | SSR, |
28 | LTP, |
29 | HE, |
30 | HEv2, |
31 | LD, |
32 | ELD, |
33 | |
34 | MPEG2Low, |
35 | MPEG2HE, |
36 | } |
37 | |
38 | #[allow (non_camel_case_types)] |
39 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
40 | pub enum DTS { |
41 | Default, |
42 | ES, |
43 | _96_24, |
44 | HD_HRA, |
45 | HD_MA, |
46 | Express, |
47 | } |
48 | |
49 | #[allow (non_camel_case_types)] |
50 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
51 | pub enum MPEG2 { |
52 | _422, |
53 | High, |
54 | SS, |
55 | SNRScalable, |
56 | Main, |
57 | Simple, |
58 | } |
59 | |
60 | #[allow (non_camel_case_types)] |
61 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
62 | pub enum H264 { |
63 | Constrained, |
64 | Intra, |
65 | Baseline, |
66 | ConstrainedBaseline, |
67 | Main, |
68 | Extended, |
69 | High, |
70 | High10, |
71 | High10Intra, |
72 | High422, |
73 | High422Intra, |
74 | High444, |
75 | High444Predictive, |
76 | High444Intra, |
77 | CAVLC444, |
78 | } |
79 | |
80 | #[allow (non_camel_case_types)] |
81 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
82 | pub enum VC1 { |
83 | Simple, |
84 | Main, |
85 | Complex, |
86 | Advanced, |
87 | } |
88 | |
89 | #[allow (non_camel_case_types)] |
90 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
91 | pub enum MPEG4 { |
92 | Simple, |
93 | SimpleScalable, |
94 | Core, |
95 | Main, |
96 | NBit, |
97 | ScalableTexture, |
98 | SimpleFaceAnimation, |
99 | BasicAnimatedTexture, |
100 | Hybrid, |
101 | AdvancedRealTime, |
102 | CoreScalable, |
103 | AdvancedCoding, |
104 | AdvancedCore, |
105 | AdvancedScalableTexture, |
106 | SimpleStudio, |
107 | AdvancedSimple, |
108 | } |
109 | |
110 | #[allow (non_camel_case_types)] |
111 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
112 | pub enum JPEG2000 { |
113 | CStreamRestriction0, |
114 | CStreamRestriction1, |
115 | CStreamNoRestriction, |
116 | DCinema2K, |
117 | DCinema4K, |
118 | } |
119 | |
120 | #[allow (non_camel_case_types)] |
121 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
122 | pub enum HEVC { |
123 | Main, |
124 | Main10, |
125 | MainStillPicture, |
126 | Rext, |
127 | } |
128 | |
129 | #[allow (non_camel_case_types)] |
130 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
131 | pub enum VP9 { |
132 | _0, |
133 | _1, |
134 | _2, |
135 | _3, |
136 | } |
137 | |
138 | impl From<(Id, c_int)> for Profile { |
139 | fn from((id, value): (Id, c_int)) -> Profile { |
140 | if value == FF_PROFILE_UNKNOWN { |
141 | return Profile::Unknown; |
142 | } |
143 | |
144 | if value == FF_PROFILE_RESERVED { |
145 | return Profile::Reserved; |
146 | } |
147 | |
148 | match id { |
149 | Id::AAC => match value { |
150 | FF_PROFILE_AAC_MAIN => Profile::AAC(AAC::Main), |
151 | FF_PROFILE_AAC_LOW => Profile::AAC(AAC::Low), |
152 | FF_PROFILE_AAC_SSR => Profile::AAC(AAC::SSR), |
153 | FF_PROFILE_AAC_LTP => Profile::AAC(AAC::LTP), |
154 | FF_PROFILE_AAC_HE => Profile::AAC(AAC::HE), |
155 | FF_PROFILE_AAC_HE_V2 => Profile::AAC(AAC::HEv2), |
156 | FF_PROFILE_AAC_LD => Profile::AAC(AAC::LD), |
157 | FF_PROFILE_AAC_ELD => Profile::AAC(AAC::ELD), |
158 | |
159 | FF_PROFILE_MPEG2_AAC_LOW => Profile::AAC(AAC::MPEG2Low), |
160 | FF_PROFILE_MPEG2_AAC_HE => Profile::AAC(AAC::MPEG2HE), |
161 | |
162 | _ => Profile::Unknown, |
163 | }, |
164 | |
165 | Id::DTS => match value { |
166 | FF_PROFILE_DTS => Profile::DTS(DTS::Default), |
167 | FF_PROFILE_DTS_ES => Profile::DTS(DTS::ES), |
168 | FF_PROFILE_DTS_96_24 => Profile::DTS(DTS::_96_24), |
169 | FF_PROFILE_DTS_HD_HRA => Profile::DTS(DTS::HD_HRA), |
170 | FF_PROFILE_DTS_HD_MA => Profile::DTS(DTS::HD_MA), |
171 | FF_PROFILE_DTS_EXPRESS => Profile::DTS(DTS::Express), |
172 | |
173 | _ => Profile::Unknown, |
174 | }, |
175 | |
176 | Id::MPEG2VIDEO => match value { |
177 | FF_PROFILE_MPEG2_422 => Profile::MPEG2(MPEG2::_422), |
178 | FF_PROFILE_MPEG2_HIGH => Profile::MPEG2(MPEG2::High), |
179 | FF_PROFILE_MPEG2_SS => Profile::MPEG2(MPEG2::SS), |
180 | FF_PROFILE_MPEG2_SNR_SCALABLE => Profile::MPEG2(MPEG2::SNRScalable), |
181 | FF_PROFILE_MPEG2_MAIN => Profile::MPEG2(MPEG2::Main), |
182 | FF_PROFILE_MPEG2_SIMPLE => Profile::MPEG2(MPEG2::Simple), |
183 | |
184 | _ => Profile::Unknown, |
185 | }, |
186 | |
187 | Id::H264 => match value { |
188 | FF_PROFILE_H264_CONSTRAINED => Profile::H264(H264::Constrained), |
189 | FF_PROFILE_H264_INTRA => Profile::H264(H264::Intra), |
190 | FF_PROFILE_H264_BASELINE => Profile::H264(H264::Baseline), |
191 | FF_PROFILE_H264_CONSTRAINED_BASELINE => Profile::H264(H264::ConstrainedBaseline), |
192 | FF_PROFILE_H264_MAIN => Profile::H264(H264::Main), |
193 | FF_PROFILE_H264_EXTENDED => Profile::H264(H264::Extended), |
194 | FF_PROFILE_H264_HIGH => Profile::H264(H264::High), |
195 | FF_PROFILE_H264_HIGH_10 => Profile::H264(H264::High10), |
196 | FF_PROFILE_H264_HIGH_10_INTRA => Profile::H264(H264::High10Intra), |
197 | FF_PROFILE_H264_HIGH_422 => Profile::H264(H264::High422), |
198 | FF_PROFILE_H264_HIGH_422_INTRA => Profile::H264(H264::High422Intra), |
199 | FF_PROFILE_H264_HIGH_444 => Profile::H264(H264::High444), |
200 | FF_PROFILE_H264_HIGH_444_PREDICTIVE => Profile::H264(H264::High444Predictive), |
201 | FF_PROFILE_H264_HIGH_444_INTRA => Profile::H264(H264::High444Intra), |
202 | FF_PROFILE_H264_CAVLC_444 => Profile::H264(H264::CAVLC444), |
203 | |
204 | _ => Profile::Unknown, |
205 | }, |
206 | |
207 | Id::VC1 => match value { |
208 | FF_PROFILE_VC1_SIMPLE => Profile::VC1(VC1::Simple), |
209 | FF_PROFILE_VC1_MAIN => Profile::VC1(VC1::Main), |
210 | FF_PROFILE_VC1_COMPLEX => Profile::VC1(VC1::Complex), |
211 | FF_PROFILE_VC1_ADVANCED => Profile::VC1(VC1::Advanced), |
212 | |
213 | _ => Profile::Unknown, |
214 | }, |
215 | |
216 | Id::MPEG4 => match value { |
217 | FF_PROFILE_MPEG4_SIMPLE => Profile::MPEG4(MPEG4::Simple), |
218 | FF_PROFILE_MPEG4_SIMPLE_SCALABLE => Profile::MPEG4(MPEG4::SimpleScalable), |
219 | FF_PROFILE_MPEG4_CORE => Profile::MPEG4(MPEG4::Core), |
220 | FF_PROFILE_MPEG4_MAIN => Profile::MPEG4(MPEG4::Main), |
221 | FF_PROFILE_MPEG4_N_BIT => Profile::MPEG4(MPEG4::NBit), |
222 | FF_PROFILE_MPEG4_SCALABLE_TEXTURE => Profile::MPEG4(MPEG4::ScalableTexture), |
223 | FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION => { |
224 | Profile::MPEG4(MPEG4::SimpleFaceAnimation) |
225 | } |
226 | FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE => { |
227 | Profile::MPEG4(MPEG4::BasicAnimatedTexture) |
228 | } |
229 | FF_PROFILE_MPEG4_HYBRID => Profile::MPEG4(MPEG4::Hybrid), |
230 | FF_PROFILE_MPEG4_ADVANCED_REAL_TIME => Profile::MPEG4(MPEG4::AdvancedRealTime), |
231 | FF_PROFILE_MPEG4_CORE_SCALABLE => Profile::MPEG4(MPEG4::CoreScalable), |
232 | FF_PROFILE_MPEG4_ADVANCED_CODING => Profile::MPEG4(MPEG4::AdvancedCoding), |
233 | FF_PROFILE_MPEG4_ADVANCED_CORE => Profile::MPEG4(MPEG4::AdvancedCore), |
234 | FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE => { |
235 | Profile::MPEG4(MPEG4::AdvancedScalableTexture) |
236 | } |
237 | FF_PROFILE_MPEG4_SIMPLE_STUDIO => Profile::MPEG4(MPEG4::SimpleStudio), |
238 | FF_PROFILE_MPEG4_ADVANCED_SIMPLE => Profile::MPEG4(MPEG4::AdvancedSimple), |
239 | |
240 | _ => Profile::Unknown, |
241 | }, |
242 | |
243 | Id::JPEG2000 => match value { |
244 | FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 => { |
245 | Profile::JPEG2000(JPEG2000::CStreamRestriction0) |
246 | } |
247 | FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 => { |
248 | Profile::JPEG2000(JPEG2000::CStreamRestriction1) |
249 | } |
250 | FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION => { |
251 | Profile::JPEG2000(JPEG2000::CStreamNoRestriction) |
252 | } |
253 | FF_PROFILE_JPEG2000_DCINEMA_2K => Profile::JPEG2000(JPEG2000::DCinema2K), |
254 | FF_PROFILE_JPEG2000_DCINEMA_4K => Profile::JPEG2000(JPEG2000::DCinema4K), |
255 | |
256 | _ => Profile::Unknown, |
257 | }, |
258 | |
259 | Id::HEVC => match value { |
260 | FF_PROFILE_HEVC_MAIN => Profile::HEVC(HEVC::Main), |
261 | FF_PROFILE_HEVC_MAIN_10 => Profile::HEVC(HEVC::Main10), |
262 | FF_PROFILE_HEVC_MAIN_STILL_PICTURE => Profile::HEVC(HEVC::MainStillPicture), |
263 | FF_PROFILE_HEVC_REXT => Profile::HEVC(HEVC::Rext), |
264 | |
265 | _ => Profile::Unknown, |
266 | }, |
267 | |
268 | Id::VP9 => match value { |
269 | FF_PROFILE_VP9_0 => Profile::VP9(VP9::_0), |
270 | FF_PROFILE_VP9_1 => Profile::VP9(VP9::_1), |
271 | FF_PROFILE_VP9_2 => Profile::VP9(VP9::_2), |
272 | FF_PROFILE_VP9_3 => Profile::VP9(VP9::_3), |
273 | |
274 | _ => Profile::Unknown, |
275 | }, |
276 | |
277 | _ => Profile::Unknown, |
278 | } |
279 | } |
280 | } |
281 | |
282 | impl From<Profile> for c_int { |
283 | fn from(value: Profile) -> c_int { |
284 | match value { |
285 | Profile::Unknown => FF_PROFILE_UNKNOWN, |
286 | Profile::Reserved => FF_PROFILE_RESERVED, |
287 | |
288 | Profile::AAC(AAC::Main) => FF_PROFILE_AAC_MAIN, |
289 | Profile::AAC(AAC::Low) => FF_PROFILE_AAC_LOW, |
290 | Profile::AAC(AAC::SSR) => FF_PROFILE_AAC_SSR, |
291 | Profile::AAC(AAC::LTP) => FF_PROFILE_AAC_LTP, |
292 | Profile::AAC(AAC::HE) => FF_PROFILE_AAC_HE, |
293 | Profile::AAC(AAC::HEv2) => FF_PROFILE_AAC_HE_V2, |
294 | Profile::AAC(AAC::LD) => FF_PROFILE_AAC_LD, |
295 | Profile::AAC(AAC::ELD) => FF_PROFILE_AAC_ELD, |
296 | |
297 | Profile::AAC(AAC::MPEG2Low) => FF_PROFILE_MPEG2_AAC_LOW, |
298 | Profile::AAC(AAC::MPEG2HE) => FF_PROFILE_MPEG2_AAC_HE, |
299 | |
300 | Profile::DTS(DTS::Default) => FF_PROFILE_DTS, |
301 | Profile::DTS(DTS::ES) => FF_PROFILE_DTS_ES, |
302 | Profile::DTS(DTS::_96_24) => FF_PROFILE_DTS_96_24, |
303 | Profile::DTS(DTS::HD_HRA) => FF_PROFILE_DTS_HD_HRA, |
304 | Profile::DTS(DTS::HD_MA) => FF_PROFILE_DTS_HD_MA, |
305 | Profile::DTS(DTS::Express) => FF_PROFILE_DTS_EXPRESS, |
306 | |
307 | Profile::MPEG2(MPEG2::_422) => FF_PROFILE_MPEG2_422, |
308 | Profile::MPEG2(MPEG2::High) => FF_PROFILE_MPEG2_HIGH, |
309 | Profile::MPEG2(MPEG2::SS) => FF_PROFILE_MPEG2_SS, |
310 | Profile::MPEG2(MPEG2::SNRScalable) => FF_PROFILE_MPEG2_SNR_SCALABLE, |
311 | Profile::MPEG2(MPEG2::Main) => FF_PROFILE_MPEG2_MAIN, |
312 | Profile::MPEG2(MPEG2::Simple) => FF_PROFILE_MPEG2_SIMPLE, |
313 | |
314 | Profile::H264(H264::Constrained) => FF_PROFILE_H264_CONSTRAINED, |
315 | Profile::H264(H264::Intra) => FF_PROFILE_H264_INTRA, |
316 | Profile::H264(H264::Baseline) => FF_PROFILE_H264_BASELINE, |
317 | Profile::H264(H264::ConstrainedBaseline) => FF_PROFILE_H264_CONSTRAINED_BASELINE, |
318 | Profile::H264(H264::Main) => FF_PROFILE_H264_MAIN, |
319 | Profile::H264(H264::Extended) => FF_PROFILE_H264_EXTENDED, |
320 | Profile::H264(H264::High) => FF_PROFILE_H264_HIGH, |
321 | Profile::H264(H264::High10) => FF_PROFILE_H264_HIGH_10, |
322 | Profile::H264(H264::High10Intra) => FF_PROFILE_H264_HIGH_10_INTRA, |
323 | Profile::H264(H264::High422) => FF_PROFILE_H264_HIGH_422, |
324 | Profile::H264(H264::High422Intra) => FF_PROFILE_H264_HIGH_422_INTRA, |
325 | Profile::H264(H264::High444) => FF_PROFILE_H264_HIGH_444, |
326 | Profile::H264(H264::High444Predictive) => FF_PROFILE_H264_HIGH_444_PREDICTIVE, |
327 | Profile::H264(H264::High444Intra) => FF_PROFILE_H264_HIGH_444_INTRA, |
328 | Profile::H264(H264::CAVLC444) => FF_PROFILE_H264_CAVLC_444, |
329 | |
330 | Profile::VC1(VC1::Simple) => FF_PROFILE_VC1_SIMPLE, |
331 | Profile::VC1(VC1::Main) => FF_PROFILE_VC1_MAIN, |
332 | Profile::VC1(VC1::Complex) => FF_PROFILE_VC1_COMPLEX, |
333 | Profile::VC1(VC1::Advanced) => FF_PROFILE_VC1_ADVANCED, |
334 | |
335 | Profile::MPEG4(MPEG4::Simple) => FF_PROFILE_MPEG4_SIMPLE, |
336 | Profile::MPEG4(MPEG4::SimpleScalable) => FF_PROFILE_MPEG4_SIMPLE_SCALABLE, |
337 | Profile::MPEG4(MPEG4::Core) => FF_PROFILE_MPEG4_CORE, |
338 | Profile::MPEG4(MPEG4::Main) => FF_PROFILE_MPEG4_MAIN, |
339 | Profile::MPEG4(MPEG4::NBit) => FF_PROFILE_MPEG4_N_BIT, |
340 | Profile::MPEG4(MPEG4::ScalableTexture) => FF_PROFILE_MPEG4_SCALABLE_TEXTURE, |
341 | Profile::MPEG4(MPEG4::SimpleFaceAnimation) => FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION, |
342 | Profile::MPEG4(MPEG4::BasicAnimatedTexture) => FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE, |
343 | Profile::MPEG4(MPEG4::Hybrid) => FF_PROFILE_MPEG4_HYBRID, |
344 | Profile::MPEG4(MPEG4::AdvancedRealTime) => FF_PROFILE_MPEG4_ADVANCED_REAL_TIME, |
345 | Profile::MPEG4(MPEG4::CoreScalable) => FF_PROFILE_MPEG4_CORE_SCALABLE, |
346 | Profile::MPEG4(MPEG4::AdvancedCoding) => FF_PROFILE_MPEG4_ADVANCED_CODING, |
347 | Profile::MPEG4(MPEG4::AdvancedCore) => FF_PROFILE_MPEG4_ADVANCED_CORE, |
348 | Profile::MPEG4(MPEG4::AdvancedScalableTexture) => { |
349 | FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE |
350 | } |
351 | Profile::MPEG4(MPEG4::SimpleStudio) => FF_PROFILE_MPEG4_SIMPLE_STUDIO, |
352 | Profile::MPEG4(MPEG4::AdvancedSimple) => FF_PROFILE_MPEG4_ADVANCED_SIMPLE, |
353 | |
354 | Profile::JPEG2000(JPEG2000::CStreamRestriction0) => { |
355 | FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 |
356 | } |
357 | Profile::JPEG2000(JPEG2000::CStreamRestriction1) => { |
358 | FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 |
359 | } |
360 | Profile::JPEG2000(JPEG2000::CStreamNoRestriction) => { |
361 | FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION |
362 | } |
363 | Profile::JPEG2000(JPEG2000::DCinema2K) => FF_PROFILE_JPEG2000_DCINEMA_2K, |
364 | Profile::JPEG2000(JPEG2000::DCinema4K) => FF_PROFILE_JPEG2000_DCINEMA_4K, |
365 | |
366 | Profile::HEVC(HEVC::Main) => FF_PROFILE_HEVC_MAIN, |
367 | Profile::HEVC(HEVC::Main10) => FF_PROFILE_HEVC_MAIN_10, |
368 | Profile::HEVC(HEVC::MainStillPicture) => FF_PROFILE_HEVC_MAIN_STILL_PICTURE, |
369 | Profile::HEVC(HEVC::Rext) => FF_PROFILE_HEVC_REXT, |
370 | |
371 | Profile::VP9(VP9::_0) => FF_PROFILE_VP9_0, |
372 | Profile::VP9(VP9::_1) => FF_PROFILE_VP9_1, |
373 | Profile::VP9(VP9::_2) => FF_PROFILE_VP9_2, |
374 | Profile::VP9(VP9::_3) => FF_PROFILE_VP9_3, |
375 | } |
376 | } |
377 | } |
378 | |