1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Checked conversions from raw FFmpeg `c_int` format values to their typed
//! enums.
//!
//! `AVFrame.format`, `AVCodecContext.pix_fmt`/`sample_fmt` and friends are
//! stored as plain `c_int`. Turning one into an `AVPixelFormat` /
//! `AVSampleFormat` with a bare `std::mem::transmute` is **undefined behavior**
//! whenever the integer is outside the enum's valid discriminant range (a
//! corrupt/adversarial input frame, or a format value from a newer FFmpeg than
//! the one we were built against).
//!
//! These helpers centralize the range check that must precede any such
//! conversion, replacing the ad-hoc `transmute` call sites scattered across the
//! scheduler. They mirror the already-safe pattern in
//! [`crate::util::frame_utils::ensure_software_format`].
// Callers live in the FFI-only scheduler, which is compiled out on docs.rs
// (the `docsrs` cfg); suppress the resulting dead-code noise there.
use ;
/// Converts a raw `AVFrame.format` / `AVCodecContext.pix_fmt` integer into a
/// typed [`AVPixelFormat`], returning `None` when the value is outside the
/// enum's valid discriminant range (`0..AV_PIX_FMT_NB`).
pub
/// Converts a raw `AVFrame.format` / `AVCodecContext.sample_fmt` integer into a
/// typed [`AVSampleFormat`], returning `None` when the value is outside the
/// enum's valid discriminant range (`0..AV_SAMPLE_FMT_NB`).
pub
/// Checked pixel-format descriptor lookup. Returns a `'static` reference to
/// FFmpeg's descriptor table entry, or `None` for an out-of-range format value
/// or one FFmpeg has no descriptor for — instead of dereferencing a null
/// descriptor pointer.
pub