mediaframe/source/ya16/mod.rs
1//! Walker spec for the `Ya16` source format
2//! (FFmpeg `ya16{le,be}` / `AV_PIX_FMT_YA16{LE,BE}`).
3//!
4//! Single `u16` plane packed as `[Y0, A0, Y1, A1, ...]`. Each pixel occupies
5//! 2 u16 elements; stride is in u16 elements and must be `≥ width × 2` (may
6//! include row padding). Alpha is real source α at element slot 1 of every
7//! pixel pair.
8//!
9//! The marker carries `<const BE: bool = false>`: `Ya16` (= `Ya16<false>`) is
10//! the LE source; `Ya16<true>` is the BE source. Two walker entry points are
11//! emitted: [`ya16_to`] is an LE-only compatibility wrapper preserving the
12//! single-generic signature `ya16_to::<S>`; [`ya16_to_endian::<S, BE>`] is
13//! the const-generic entry point for BE-aware callers, propagating `BE`
14//! from [`Ya16Frame<'_, BE>`] into the sinker dispatch.
15
16use crate::frame::Ya16Frame;
17
18walker! {
19 packed_be {
20 /// Marker type for the `Ya16` source format (16-bit gray + alpha,
21 /// 2 u16/pixel). `<const BE: bool>` defaults to `false` (LE).
22 ///
23 /// Packed layout per pixel: `[Y(16), A(16)]`. Alpha is real source
24 /// transparency and is passed through to RGBA outputs (depth-converted
25 /// to u8 via `>> 8` for 8-bit RGBA output).
26 #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
27 marker: Ya16,
28 frame: Ya16Frame,
29 row: Ya16Row,
30 sink: Ya16Sink,
31 walker: ya16_to,
32 walker_endian: ya16_to_endian,
33 buf_field: packed,
34 elem_type: u16,
35 row_elems: |w| w * 2,
36 row_doc: concat!(
37 "One row of a [`Ya16`] source — `width × 2` u16 elements (2 u16 per pixel:\n",
38 "Y then A).\n",
39 "\n",
40 "u16 slot layout per pixel:\n",
41 "\n",
42 "| u16 slot | Field |\n",
43 "|----------|-------|\n",
44 "| 0 | Y (luma, 16-bit native) |\n",
45 "| 1 | A (real α, 16-bit native) |\n",
46 "\n",
47 "The walker does not interpret the u16 elements — it passes the raw packed\n",
48 "slice to the sink. Endianness is recorded on the parent\n",
49 "[`Ya16Frame<'_, BE>`] / sinker, not on the Row itself — the kernel\n",
50 "monomorphizes on `BE` at the sinker dispatch.",
51 ),
52 walker_doc: "Walks a [`Ya16Frame<'_, BE>`] row by row into the sink. \
53 Propagates `<const BE: bool>` from the frame into \
54 [`Ya16Sink<BE>`].",
55 }
56}
57
58#[cfg(all(test, feature = "std"))]
59mod tests;