mediaframe/source/x2rgb10.rs
1//! Packed **X2RGB10** source (`AV_PIX_FMT_X2RGB10{LE,BE}`) — 10 bits per
2//! channel, 32-bit word with `(MSB) 2X | 10R | 10G | 10B (LSB)`. The 2
3//! leading bits are **ignored padding**.
4//!
5//! The marker carries `<const BE: bool = false>`: `X2Rgb10` (= `X2Rgb10<false>`)
6//! is the LE source; `X2Rgb10<true>` is the BE source. The walker
7//! [`x2rgb10_to::<BE>`] propagates `BE` from [`X2Rgb10Frame<'_, BE>`] into the
8//! sinker dispatch.
9//!
10//! Outputs (Ship 9e):
11//! - `with_rgb` — `x2rgb10_to_rgb_row` (down-shift each 10-bit
12//! channel to 8 bits and pack as `R, G, B`).
13//! - `with_rgba` — `x2rgb10_to_rgba_row` (same down-shift + force
14//! alpha to `0xFF`).
15//! - `with_rgb_u16` — `x2rgb10_to_rgb_u16_row` (native 10-bit
16//! precision, low-bit aligned in `u16`; max value `1023`).
17//! - `with_luma` — drop padding into the u8 RGB scratch, then
18//! `rgb_to_luma_row`.
19//! - `with_hsv` — same scratch path, then `rgb_to_hsv_row`.
20
21use crate::frame::X2Rgb10Frame;
22
23walker! {
24 packed_be {
25 /// Zero‑sized marker for the packed **X2RGB10** source format
26 /// (`AV_PIX_FMT_X2RGB10{LE,BE}`). `<const BE: bool>` defaults to `false`
27 /// (LE); the alias `X2Rgb10` resolves to `X2Rgb10<false>`.
28 #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
29 marker: X2Rgb10,
30 frame: X2Rgb10Frame,
31 row: X2Rgb10Row,
32 sink: X2Rgb10Sink,
33 walker: x2rgb10_to,
34 walker_endian: x2rgb10_to_endian,
35 buf_field: x2rgb10,
36 elem_type: u8,
37 row_elems: |w| w * 4,
38 row_doc: concat!(
39 "One output row of an [`X2Rgb10`] source — `width * 4` bytes\n",
40 "laid out as `width` `u32` pixels with packing\n",
41 "`(MSB) 2X | 10R | 10G | 10B (LSB)`. The byte order of each\n",
42 "32-bit word is selected by the parent\n",
43 "[`X2Rgb10Frame<'_, BE>`] / sinker `<const BE>` parameter.\n",
44 "\n",
45 "Bit layout per 32-bit word:\n",
46 "\n",
47 "| Bits | Field |\n",
48 "|--------|-------|\n",
49 "| 31:30 | padding (ignored on read; RGBA outputs force α=`0xFF`) |\n",
50 "| 29:20 | R (10 bits) |\n",
51 "| 19:10 | G (10 bits) |\n",
52 "| 9:0 | B (10 bits) |\n",
53 "\n",
54 "Sink authors: each pixel is one `u32` reconstructed from 4\n",
55 "consecutive bytes of the slice in the BE-or-LE order set by the\n",
56 "Frame. Each 10-bit channel ranges `[0, 1023]`.",
57 ),
58 walker_doc: "Walks an [`X2Rgb10Frame<'_, BE>`] row by row into the sink. \
59 Propagates `<const BE: bool>` from the frame into \
60 [`X2Rgb10Sink<BE>`].",
61 }
62}