mediaframe/source/gbrp10_msb/mod.rs
1//! MSB-packed planar GBR 10-bit (`AV_PIX_FMT_GBRP10MSB{LE,BE}`) — three
2//! full-resolution `u16` planes in **G, B, R** order (FFmpeg convention).
3//!
4//! Samples are stored in the **high** 10 bits of each `u16` element (low 6
5//! bits zero), matching FFmpeg's `gbrp10msb{le,be}` descriptors (`shift = 6`).
6//! This is the exact inverse of the low-bit-packed [`super::Gbrp10`]
7//! (`gbrp10{le,be}`, samples in the low 10), so it carries a **dedicated**
8//! [`GbrpMsbFrame`](crate::frame::GbrpMsbFrame) whose
9//! [`try_new_checked`](crate::frame::GbrpMsbFrame::try_new_checked) rejects
10//! stray **low** bits.
11//!
12//! The marker carries `<const BE: bool = false>`: `Gbrp10Msb`
13//! (= `Gbrp10Msb<false>`) is the LE source; `Gbrp10Msb<true>` is the BE
14//! source. The walker [`gbrp10_msb_to::<BE>`] propagates `BE` from
15//! [`Gbrp10MsbFrame<'_, BE>`](crate::frame::Gbrp10MsbFrame) into the sinker
16//! dispatch.
17
18use crate::frame::{Gbrp10MsbFrame, GbrpMsbFrame};
19
20walker! {
21 planar3_bits_be {
22 /// Zero-sized marker for the MSB-packed planar GBR 10-bit source format
23 /// (`AV_PIX_FMT_GBRP10MSB{LE,BE}`). `<const BE: bool>` defaults to `false`.
24 #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
25 marker: Gbrp10Msb,
26 frame: Gbrp10MsbFrame,
27 generic_frame: GbrpMsbFrame,
28 bits: 10,
29 row: Gbrp10MsbRow,
30 sink: Gbrp10MsbSink,
31 walker: gbrp10_msb_to,
32 walker_endian: gbrp10_msb_to_endian,
33 walker_inner: gbrp10_msb_walker,
34 elem_type: u16,
35 row_doc: "One output row of a [`Gbrp10Msb`] source — three full-width\n\
36 `u16` planes in G / B / R order (samples in the high 10 bits,\n\
37 low 6 zero).",
38 walker_doc: "Walks a [`Gbrp10MsbFrame<'_, BE>`](crate::frame::Gbrp10MsbFrame) row by row into the sink.",
39 }
40}
41
42impl<'a> Gbrp10MsbRow<'a> {
43 /// Green plane row — full width, 10 active bits in the high 10 of each `u16`.
44 #[cfg_attr(not(tarpaulin), inline(always))]
45 pub fn g(&self) -> &'a [u16] {
46 self.y()
47 }
48 /// Blue plane row — full width.
49 #[cfg_attr(not(tarpaulin), inline(always))]
50 pub fn b(&self) -> &'a [u16] {
51 self.u()
52 }
53 /// Red plane row — full width.
54 #[cfg_attr(not(tarpaulin), inline(always))]
55 pub fn r(&self) -> &'a [u16] {
56 self.v()
57 }
58}
59
60#[cfg(all(test, feature = "std"))]
61mod tests;