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