scuffle_ffmpeg/enums/
av_pkt_flags.rs

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