scuffle_ffmpeg/enums/av_pkt_flags.rs
1use nutype_enum::{bitwise_enum, nutype_enum};
2
3use crate::ffi::*;
4
5const _: () = {
6 assert!(std::mem::size_of::<AVPktFlags>() == std::mem::size_of_val(&AV_PKT_FLAG_KEY));
7};
8
9nutype_enum! {
10 /// Packet flags used in FFmpeg's `AVPacket`.
11 ///
12 /// These flags describe metadata about a packet, such as whether it is a keyframe or corrupt.
13 ///
14 /// See the official FFmpeg documentation:
15 /// <https://ffmpeg.org/doxygen/trunk/avcodec_8h.html>
16 pub enum AVPktFlags(i32) {
17 /// This packet contains a **keyframe**.
18 /// - **Used for**: Identifying keyframes in video streams.
19 /// - **Binary representation**: `0b00001`
20 /// - **Equivalent to**: `AV_PKT_FLAG_KEY`
21 Key = AV_PKT_FLAG_KEY as _,
22
23 /// This packet is **corrupt**.
24 /// - **Used for**: Marking damaged or incomplete data.
25 /// - **Binary representation**: `0b00010`
26 /// - **Equivalent to**: `AV_PKT_FLAG_CORRUPT`
27 Corrupt = AV_PKT_FLAG_CORRUPT as _,
28
29 /// This packet should be **discarded**.
30 /// - **Used for**: Frames that should be ignored by decoders.
31 /// - **Binary representation**: `0b00100`
32 /// - **Equivalent to**: `AV_PKT_FLAG_DISCARD`
33 Discard = AV_PKT_FLAG_DISCARD as _,
34
35 /// This packet comes from a **trusted source**.
36 /// - **Used for**: Security and validation checks.
37 /// - **Binary representation**: `0b01000`
38 /// - **Equivalent to**: `AV_PKT_FLAG_TRUSTED`
39 Trusted = AV_PKT_FLAG_TRUSTED as _,
40
41 /// This packet is **disposable** (e.g., non-reference frames).
42 /// - **Used for**: Frames that can be dropped without affecting playback.
43 /// - **Binary representation**: `0b10000`
44 /// - **Equivalent to**: `AV_PKT_FLAG_DISPOSABLE`
45 Disposable = AV_PKT_FLAG_DISPOSABLE as _,
46 }
47}
48
49bitwise_enum!(AVPktFlags);
50
51impl PartialEq<i32> for AVPktFlags {
52 fn eq(&self, other: &i32) -> bool {
53 self.0 == *other
54 }
55}
56
57impl From<u32> for AVPktFlags {
58 fn from(value: u32) -> Self {
59 AVPktFlags(value as _)
60 }
61}
62
63impl From<AVPktFlags> for u32 {
64 fn from(value: AVPktFlags) -> Self {
65 value.0 as u32
66 }
67}