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
use crateVTFormat;
/// CPU-side pixel buffers passed to [`crate::VTImage::from_cpu`].
///
/// Each variant stores plane pointers and **row stride in bytes** (not always `width * bytes_per_pixel`).
///
/// # Example (YUV420P / I420)
///
/// ```
/// use vtsampler::PixelData;
///
/// let width = 1920u32;
/// let height = 1080u32;
/// let y_size = (width * height) as usize;
/// let uv_size = (width as usize / 2 * height as usize / 2);
/// # let y_plane = vec![0u8; y_size];
/// # let u_plane = vec![0u8; uv_size];
/// # let v_plane = vec![0u8; uv_size];
///
/// let data = PixelData::YUV420P {
/// buffer: [&y_plane, &u_plane, &v_plane],
/// stride: [width as usize, width as usize / 2, width as usize / 2],
/// };
/// assert_eq!(data.format(), vtsampler::VTFormat::YUV420P);
/// ```