scuffle_ffmpeg/enums/
av_fmt_flags.rs

1use nutype_enum::{bitwise_enum, nutype_enum};
2
3use crate::ffi::*;
4
5nutype_enum! {
6    /// Format flags used in FFmpeg's `AVFormatContext` configuration.
7    ///
8    /// These flags are **format-specific capabilities** that describe the inherent
9    /// characteristics and limitations of a format (container). They are read-only
10    /// properties that indicate what features a format supports or doesn't support.
11    ///
12    /// For example, `NoFile` indicates the format doesn't need a regular file (like
13    /// network protocols), while `GlobalHeader` indicates the format uses global codec
14    /// headers.
15    ///
16    /// See the official FFmpeg documentation:
17    /// <https://ffmpeg.org/doxygen/trunk/avformat_8h.html>
18    pub enum AVFormatFlags(i32) {
19        /// The format does not require a file to be opened explicitly.
20        /// - **Used for**: Protocol-based formats like `rtmp://`, `http://`
21        /// - **Equivalent to**: `AVFMT_NOFILE`
22        NoFile = AVFMT_NOFILE as i32,
23
24        /// Requires a numbered sequence of files (e.g., `%03d` in filenames).
25        /// - **Used for**: Image sequences, segment-based formats.
26        /// - **Equivalent to**: `AVFMT_NEEDNUMBER`
27        NeedNumber = AVFMT_NEEDNUMBER as i32,
28
29        /// The format is experimental and may be subject to changes.
30        /// - **Used for**: Newer formats that are not yet stable.
31        /// - **Equivalent to**: `AVFMT_EXPERIMENTAL`
32        Experimental = AVFMT_EXPERIMENTAL as i32,
33
34        /// Displays stream identifiers when logging or printing metadata.
35        /// - **Equivalent to**: `AVFMT_SHOW_IDS`
36        ShowIds = AVFMT_SHOW_IDS as i32,
37
38        /// Uses a global header instead of individual packet headers.
39        /// - **Used for**: Codecs that require an extradata header (e.g., H.264, AAC in MP4).
40        /// - **Equivalent to**: `AVFMT_GLOBALHEADER`
41        GlobalHeader = AVFMT_GLOBALHEADER as i32,
42
43        /// The format does not store timestamps.
44        /// - **Used for**: Raw formats (e.g., raw audio, raw video).
45        /// - **Equivalent to**: `AVFMT_NOTIMESTAMPS`
46        NoTimestamps = AVFMT_NOTIMESTAMPS as i32,
47
48        /// The format has a generic index.
49        /// - **Used for**: Formats that require seeking but don't use timestamp-based indexing.
50        /// - **Equivalent to**: `AVFMT_GENERIC_INDEX`
51        GenericIndex = AVFMT_GENERIC_INDEX as i32,
52
53        /// The format supports discontinuous timestamps.
54        /// - **Used for**: Live streams where timestamps may reset (e.g., HLS, RTSP).
55        /// - **Equivalent to**: `AVFMT_TS_DISCONT`
56        TsDiscontinuous = AVFMT_TS_DISCONT as i32,
57
58        /// The format supports variable frame rates.
59        /// - **Used for**: Video formats where frame duration varies (e.g., MKV, MP4).
60        /// - **Equivalent to**: `AVFMT_VARIABLE_FPS`
61        VariableFps = AVFMT_VARIABLE_FPS as i32,
62
63        /// The format does not store dimensions (width & height).
64        /// - **Used for**: Audio-only formats, raw formats.
65        /// - **Equivalent to**: `AVFMT_NODIMENSIONS`
66        NoDimensions = AVFMT_NODIMENSIONS as i32,
67
68        /// The format does not contain any stream information.
69        /// - **Used for**: Metadata-only containers.
70        /// - **Equivalent to**: `AVFMT_NOSTREAMS`
71        NoStreams = AVFMT_NOSTREAMS as i32,
72
73        /// The format does not support binary search for seeking.
74        /// - **Used for**: Formats where linear scanning is required (e.g., live streams).
75        /// - **Equivalent to**: `AVFMT_NOBINSEARCH`
76        NoBinarySearch = AVFMT_NOBINSEARCH as i32,
77
78        /// The format does not support generic stream search.
79        /// - **Used for**: Specialized formats that require specific handling.
80        /// - **Equivalent to**: `AVFMT_NOGENSEARCH`
81        NoGenericSearch = AVFMT_NOGENSEARCH as i32,
82
83        /// The format does not support byte-based seeking.
84        /// - **Used for**: Formats that only support timestamp-based seeking.
85        /// - **Equivalent to**: `AVFMT_NO_BYTE_SEEK`
86        NoByteSeek = AVFMT_NO_BYTE_SEEK as i32,
87
88        /// Allows flushing of buffered data.
89        /// - **Used for**: Streaming formats that support mid-stream flushing.
90        /// - **Equivalent to**: `AVFMT_ALLOW_FLUSH`
91        AllowFlush = AVFMT_ALLOW_FLUSH as i32,
92
93        /// The format does not require strict timestamp ordering.
94        /// - **Used for**: Formats where out-of-order timestamps are common.
95        /// - **Equivalent to**: `AVFMT_TS_NONSTRICT`
96        TsNonStrict = AVFMT_TS_NONSTRICT as i32,
97
98        /// The format allows negative timestamps.
99        /// - **Used for**: Certain formats that support negative PTS/DTS.
100        /// - **Equivalent to**: `AVFMT_TS_NEGATIVE`
101        TsNegative = AVFMT_TS_NEGATIVE as i32,
102
103        /// Seeks are performed relative to presentation timestamps (PTS).
104        /// - **Used for**: Formats that use PTS instead of DTS for seeking.
105        /// - **Equivalent to**: `AVFMT_SEEK_TO_PTS`
106        SeekToPts = AVFMT_SEEK_TO_PTS as i32,
107    }
108}
109
110bitwise_enum!(AVFormatFlags);
111
112impl PartialEq<i32> for AVFormatFlags {
113    fn eq(&self, other: &i32) -> bool {
114        self.0 == *other
115    }
116}
117
118impl From<u32> for AVFormatFlags {
119    fn from(value: u32) -> Self {
120        AVFormatFlags(value as i32)
121    }
122}
123
124impl From<AVFormatFlags> for u32 {
125    fn from(value: AVFormatFlags) -> Self {
126        value.0 as u32
127    }
128}
129
130nutype_enum! {
131    /// Format flags used in FFmpeg's `AVFormatContext`.
132    ///
133    /// These flags are **user-configurable options** that control how FFmpeg should
134    /// behave when reading or writing media. Unlike `AVFormatFlags` which describe
135    /// format capabilities, these flags modify the runtime behavior of demuxers and
136    /// muxers.
137    ///
138    /// For example, `GenPts` tells FFmpeg to generate missing timestamps, while
139    /// `FastSeek` enables optimized seeking behavior.
140    ///
141    /// See the official FFmpeg documentation:
142    /// <https://ffmpeg.org/doxygen/trunk/avformat_8h.html>
143    pub enum AVFmtFlags(i32) {
144        /// Generate **Presentation Timestamps (PTS)** if they are missing.
145        /// - **Used for**: Formats that may not provide timestamps.
146        /// - **Binary representation**: `0b0000000000000001`
147        /// - **Equivalent to**: `AVFMT_FLAG_GENPTS`
148        GenPts = AVFMT_FLAG_GENPTS as i32,
149
150        /// Ignore the index when seeking.
151        /// - **Used for**: Faster seeking in formats that rely on indexes.
152        /// - **Binary representation**: `0b0000000000000010`
153        /// - **Equivalent to**: `AVFMT_FLAG_IGNIDX`
154        IgnoreIndex = AVFMT_FLAG_IGNIDX as i32,
155
156        /// Open input in **non-blocking mode**.
157        /// - **Used for**: Asynchronous reading.
158        /// - **Binary representation**: `0b0000000000000100`
159        /// - **Equivalent to**: `AVFMT_FLAG_NONBLOCK`
160        NonBlock = AVFMT_FLAG_NONBLOCK as i32,
161
162        /// Ignore **Decoding Timestamps (DTS)**.
163        /// - **Used for**: Cases where only PTS is needed.
164        /// - **Binary representation**: `0b0000000000001000`
165        /// - **Equivalent to**: `AVFMT_FLAG_IGNDTS`
166        IgnoreDts = AVFMT_FLAG_IGNDTS as i32,
167
168        /// Do not fill in missing information in streams.
169        /// - **Used for**: Avoiding unwanted automatic corrections.
170        /// - **Binary representation**: `0b0000000000010000`
171        /// - **Equivalent to**: `AVFMT_FLAG_NOFILLIN`
172        NoFillIn = AVFMT_FLAG_NOFILLIN as i32,
173
174        /// Do not parse frames.
175        /// - **Used for**: Formats where parsing is unnecessary.
176        /// - **Binary representation**: `0b0000000000100000`
177        /// - **Equivalent to**: `AVFMT_FLAG_NOPARSE`
178        NoParse = AVFMT_FLAG_NOPARSE as i32,
179
180        /// Disable internal buffering.
181        /// - **Used for**: Real-time applications requiring low latency.
182        /// - **Binary representation**: `0b0000000001000000`
183        /// - **Equivalent to**: `AVFMT_FLAG_NOBUFFER`
184        NoBuffer = AVFMT_FLAG_NOBUFFER as i32,
185
186        /// Use **custom I/O** instead of standard file I/O.
187        /// - **Used for**: Implementing custom read/write operations.
188        /// - **Binary representation**: `0b0000000010000000`
189        /// - **Equivalent to**: `AVFMT_FLAG_CUSTOM_IO`
190        CustomIO = AVFMT_FLAG_CUSTOM_IO as i32,
191
192        /// Discard **corrupt** frames.
193        /// - **Used for**: Ensuring only valid frames are processed.
194        /// - **Binary representation**: `0b0000000100000000`
195        /// - **Equivalent to**: `AVFMT_FLAG_DISCARD_CORRUPT`
196        DiscardCorrupt = AVFMT_FLAG_DISCARD_CORRUPT as i32,
197
198        /// **Flush packets** after writing.
199        /// - **Used for**: Streaming to avoid buffering delays.
200        /// - **Binary representation**: `0b0000001000000000`
201        /// - **Equivalent to**: `AVFMT_FLAG_FLUSH_PACKETS`
202        FlushPackets = AVFMT_FLAG_FLUSH_PACKETS as i32,
203
204        /// Ensure **bit-exact** output.
205        /// - **Used for**: Regression testing, avoiding encoding variations.
206        /// - **Binary representation**: `0b0000010000000000`
207        /// - **Equivalent to**: `AVFMT_FLAG_BITEXACT`
208        BitExact = AVFMT_FLAG_BITEXACT as i32,
209
210        /// Sort packets by **Decoding Timestamp (DTS)**.
211        /// - **Used for**: Ensuring ordered input.
212        /// - **Binary representation**: `0b0001000000000000`
213        /// - **Equivalent to**: `AVFMT_FLAG_SORT_DTS`
214        SortDts = AVFMT_FLAG_SORT_DTS as i32,
215
216        /// Enable **fast seeking**.
217        /// - **Used for**: Improving seek performance in large files.
218        /// - **Binary representation**: `0b0010000000000000`
219        /// - **Equivalent to**: `AVFMT_FLAG_FAST_SEEK`
220        FastSeek = AVFMT_FLAG_FAST_SEEK as i32,
221
222        /// Stop **decoding at the shortest stream**.
223        /// - **Used for**: Ensuring synchronization in multi-stream files.
224        /// - **Binary representation**: `0b0100000000000000`
225        /// - **Equivalent to**: `AVFMT_FLAG_SHORTEST`
226        Shortest = AVFMT_FLAG_SHORTEST as i32,
227
228        /// **Automatically apply bitstream filters**.
229        /// - **Used for**: Simplifying format conversions.
230        /// - **Binary representation**: `0b1000000000000000`
231        /// - **Equivalent to**: `AVFMT_FLAG_AUTO_BSF`
232        AutoBsf = AVFMT_FLAG_AUTO_BSF as i32,
233    }
234}
235
236bitwise_enum!(AVFmtFlags);
237
238impl PartialEq<i32> for AVFmtFlags {
239    fn eq(&self, other: &i32) -> bool {
240        self.0 == *other
241    }
242}
243
244impl From<u32> for AVFmtFlags {
245    fn from(value: u32) -> Self {
246        AVFmtFlags(value as i32)
247    }
248}
249
250impl From<AVFmtFlags> for u32 {
251    fn from(value: AVFmtFlags) -> Self {
252        value.0 as u32
253    }
254}