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