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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#[cfg(test)]
mod tests;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Rational frame rate.
pub struct Framerate {
/// Frame-rate numerator.
pub numerator: u64,
/// Frame-rate denominator.
pub denominator: u64,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Supported plane families for host-neutral video descriptions.
pub enum ColorFamily {
/// Single-plane luma or grayscale data.
Gray,
/// Three-plane YUV data.
Yuv,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Supported sample storage types.
pub enum SampleType {
/// Integer-valued samples.
Integer,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Frame dimensions in pixels.
pub struct Resolution {
/// Frame width.
pub width: usize,
/// Frame height.
pub height: usize,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Static pixel-format metadata shared by all frames in a clip.
pub struct VideoFormat {
/// Plane family used by the clip.
pub color_family: ColorFamily,
/// Sample storage type for each plane.
pub sample_type: SampleType,
/// Significant bits stored in each sample.
pub bits_per_sample: std::num::NonZeroU8,
/// Bytes used to store each sample.
pub bytes_per_sample: std::num::NonZeroU8,
/// Horizontal chroma subsampling shift relative to luma.
pub sub_sampling_w: u8,
/// Vertical chroma subsampling shift relative to luma.
pub sub_sampling_h: u8,
}
impl VideoFormat {
/// Returns the number of planes required by this format.
#[must_use]
#[inline]
pub const fn plane_count(self) -> usize {
match self.color_family {
ColorFamily::Gray => 1,
ColorFamily::Yuv => 3,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
/// Clip-wide video metadata.
pub struct VideoInfo {
/// Pixel-format metadata shared by all frames.
pub format: VideoFormat,
/// Constant frame dimensions.
pub resolution: Resolution,
/// Total number of frames in the clip.
pub num_frames: usize,
}