Skip to main content

mediaframe/source/vuyx/
mod.rs

1//! Packed YUV 4:4:4 8-bit `VUYX` source — display-compose capture
2//! format (FFmpeg `AV_PIX_FMT_VUYX`). Each pixel is a u8 quadruple
3//! `V(8) ‖ U(8) ‖ Y(8) ‖ A(8)` where the A byte is **padding**
4//! (not real alpha). The A byte is read but discarded; RGBA outputs
5//! always force α=`0xFF`. See [`VuyxFrame`](crate::frame::VuyxFrame) for layout
6//! details. For the source-α sibling, see [`crate::source::Vuya`].
7//!
8//! Outputs are produced via:
9//! - `with_rgb` — packed YUV → RGB 8-bit pipeline; padding discarded.
10//! - `with_rgba` — packed YUV → RGBA 8-bit pipeline; α ignored on
11//!   read; α forced to `0xFF`.
12//! - `with_luma` — extracts the Y byte (byte 2 of each pixel)
13//!   directly.
14//! - `with_hsv` — stages an internal RGB scratch and runs the
15//!   existing `rgb_to_hsv_row` kernel.
16//!
17//! VUYX has no u16 output paths — it is an 8-bit source.
18
19use crate::frame::VuyxFrame;
20
21walker! {
22  packed {
23    /// Zero-sized marker for the packed **VUYX** source format.
24    #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
25    marker: Vuyx,
26    frame: VuyxFrame<'_>,
27    row: VuyxRow,
28    sink: VuyxSink,
29    walker: vuyx_to,
30    buf_field: packed,
31    elem_type: u8,
32    row_elems: |w| w * 4,
33    row_doc: concat!(
34      "One row of a [`Vuyx`] source — `width × 4` bytes (4 channels per\n",
35      "pixel: V, U, Y, A; the A byte is padding and is ignored on read).\n",
36      "\n",
37      "Byte layout per pixel:\n",
38      "\n",
39      "| Byte offset | Field |\n",
40      "|-------------|-------|\n",
41      "| 0           | V     |\n",
42      "| 1           | U     |\n",
43      "| 2           | Y     |\n",
44      "| 3           | A (padding — ignored on read; RGBA outputs force α=`0xFF`) |\n",
45      "\n",
46      "The walker does not interpret the bytes — it passes the raw packed\n",
47      "slice to the sink. Byte-level channel extraction happens in the\n",
48      "row-kernel layer.\n",
49      "\n",
50      "Full range: `[0, 255]` (8-bit). Limited range Y: `[16, 235]`,\n",
51      "limited range chroma: `[16, 240]`.",
52    ),
53    walker_doc: "Walks a [`VuyxFrame`](crate::frame::VuyxFrame) row by row into the sink.",
54  }
55}
56
57#[cfg(all(test, feature = "std"))]
58mod tests;