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
use nutype_enum::{bitwise_enum, nutype_enum};
use crate::ffi::*;
const _: () = {
assert!(std::mem::size_of::<AVDiscard>() == std::mem::size_of_val(&AVDISCARD_NONE));
};
nutype_enum! {
/// Discard levels used in FFmpeg's `AVDiscard`.
///
/// These values specify how much of the input stream should be discarded.
///
/// See the official FFmpeg documentation:
/// <https://ffmpeg.org/doxygen/trunk/avcodec_8h.html>
pub enum AVDiscard(i32) {
/// **Discard nothing** (decode everything).
/// - **Used for**: Keeping all packets.
/// - **Binary representation**: `-0b10000`
/// - **Equivalent to**: `AVDISCARD_NONE`
None = AVDISCARD_NONE as _,
/// **Discard useless packets** (e.g., zero-size packets in AVI).
/// - **Used for**: Cleaning up unnecessary data.
/// - **Binary representation**: `0b00000`
/// - **Equivalent to**: `AVDISCARD_DEFAULT`
Default = AVDISCARD_DEFAULT as _,
/// **Discard all non-reference frames**.
/// - **Used for**: Reducing decoding load while keeping keyframe accuracy.
/// - **Binary representation**: `0b01000`
/// - **Equivalent to**: `AVDISCARD_NONREF`
NonRef = AVDISCARD_NONREF as _,
/// **Discard all bidirectional (B) frames**.
/// - **Used for**: Lower latency decoding, reducing memory usage.
/// - **Binary representation**: `0b10000`
/// - **Equivalent to**: `AVDISCARD_BIDIR`
Bidir = AVDISCARD_BIDIR as _,
/// **Discard all non-intra frames**.
/// - **Used for**: Keeping only intra-coded frames (I-frames).
/// - **Binary representation**: `0b11000`
/// - **Equivalent to**: `AVDISCARD_NONINTRA`
NonIntra = AVDISCARD_NONINTRA as _,
/// **Discard all frames except keyframes**.
/// - **Used for**: Extracting only keyframes from a stream.
/// - **Binary representation**: `0b100000`
/// - **Equivalent to**: `AVDISCARD_NONKEY`
NonKey = AVDISCARD_NONKEY as _,
/// **Discard all frames** (decode nothing).
/// - **Used for**: Disabling decoding entirely.
/// - **Binary representation**: `0b110000`
/// - **Equivalent to**: `AVDISCARD_ALL`
All = AVDISCARD_ALL as _,
}
}
bitwise_enum!(AVDiscard);
impl PartialEq<i32> for AVDiscard {
fn eq(&self, other: &i32) -> bool {
self.0 == *other
}
}
impl From<u32> for AVDiscard {
fn from(value: u32) -> Self {
AVDiscard(value as i32)
}
}
impl From<AVDiscard> for u32 {
fn from(value: AVDiscard) -> Self {
value.0 as u32
}
}