scuffle_ffmpeg/enums/av_discard.rs
1use nutype_enum::{bitwise_enum, nutype_enum};
2
3use crate::ffi::*;
4
5const _: () = {
6 assert!(std::mem::size_of::<AVDiscard>() == std::mem::size_of_val(&AVDISCARD_NONE));
7};
8
9nutype_enum! {
10 /// Discard levels used in FFmpeg's `AVDiscard`.
11 ///
12 /// These values specify how much of the input stream should be discarded.
13 ///
14 /// See the official FFmpeg documentation:
15 /// <https://ffmpeg.org/doxygen/trunk/avcodec_8h.html>
16 pub enum AVDiscard(i32) {
17 /// **Discard nothing** (decode everything).
18 /// - **Used for**: Keeping all packets.
19 /// - **Binary representation**: `-0b10000`
20 /// - **Equivalent to**: `AVDISCARD_NONE`
21 None = AVDISCARD_NONE as _,
22
23 /// **Discard useless packets** (e.g., zero-size packets in AVI).
24 /// - **Used for**: Cleaning up unnecessary data.
25 /// - **Binary representation**: `0b00000`
26 /// - **Equivalent to**: `AVDISCARD_DEFAULT`
27 Default = AVDISCARD_DEFAULT as _,
28
29 /// **Discard all non-reference frames**.
30 /// - **Used for**: Reducing decoding load while keeping keyframe accuracy.
31 /// - **Binary representation**: `0b01000`
32 /// - **Equivalent to**: `AVDISCARD_NONREF`
33 NonRef = AVDISCARD_NONREF as _,
34
35 /// **Discard all bidirectional (B) frames**.
36 /// - **Used for**: Lower latency decoding, reducing memory usage.
37 /// - **Binary representation**: `0b10000`
38 /// - **Equivalent to**: `AVDISCARD_BIDIR`
39 Bidir = AVDISCARD_BIDIR as _,
40
41 /// **Discard all non-intra frames**.
42 /// - **Used for**: Keeping only intra-coded frames (I-frames).
43 /// - **Binary representation**: `0b11000`
44 /// - **Equivalent to**: `AVDISCARD_NONINTRA`
45 NonIntra = AVDISCARD_NONINTRA as _,
46
47 /// **Discard all frames except keyframes**.
48 /// - **Used for**: Extracting only keyframes from a stream.
49 /// - **Binary representation**: `0b100000`
50 /// - **Equivalent to**: `AVDISCARD_NONKEY`
51 NonKey = AVDISCARD_NONKEY as _,
52
53 /// **Discard all frames** (decode nothing).
54 /// - **Used for**: Disabling decoding entirely.
55 /// - **Binary representation**: `0b110000`
56 /// - **Equivalent to**: `AVDISCARD_ALL`
57 All = AVDISCARD_ALL as _,
58 }
59}
60
61bitwise_enum!(AVDiscard);
62
63impl PartialEq<i32> for AVDiscard {
64 fn eq(&self, other: &i32) -> bool {
65 self.0 == *other
66 }
67}
68
69impl From<u32> for AVDiscard {
70 fn from(value: u32) -> Self {
71 AVDiscard(value as i32)
72 }
73}
74
75impl From<AVDiscard> for u32 {
76 fn from(value: AVDiscard) -> Self {
77 value.0 as u32
78 }
79}