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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! L2 shared chroma-reconstruction stage (RFC #238).
//!
//! The element-generic **centered** (#302 phase-0.5) chroma reconstruction that
//! the `Yuv422p` identity decode — and, in later RFC #238 PRs, every centered
//! resample arm plus the other subsampled layouts — funnels through, so one
//! siting implementation serves them all. [`reconstruct_chroma`] stages the
//! half-width `U` / `V` planes into the caller's already-reserved full-width
//! scratch by reusing the shipped #302 scalar upsamplers (it does **not**
//! re-implement the `1/4`–`3/4` MPEG-1 / JPEG math); the per-element /
//! per-layout differences live behind the [`ChromaCenterUpsampler`] trait, so a
//! new chroma element type or memory layout extends the stage with one trait
//! impl rather than another copy of the buffer-splitting wrapper.
//!
//! Wired today for the 8-bit ([`ChromaU8`]) and high-bit ([`ChromaU16`]) planar
//! 4:2:2 identity paths. The designed extension axes (later PRs, hence the
//! trait rather than two free functions):
//!
//! - **new element / layout kernels** — a [`ChromaCenterUpsampler`] impl over
//! the semi-planar `_p0xx` interleaved-UV upsampler
//! ([`chroma_upsample_2to1_center_h_p0xx`](crate::row::scalar::chroma_upsample_2to1_center_h_p0xx))
//! or a packed-YUV kernel, reachable from the matching identity / resample
//! arms;
//! - **the vertical delay-line** — the bottom-sited (`AVCHROMA_LOC_BOTTOM`)
//! 4:2:0 even-row vertical box-blend
//! ([`chroma_upsample_420_bottom_even_h`](crate::row::scalar::chroma_upsample_420_bottom_even_h))
//! and its one-row chroma lookback, threaded as a row-index + `&mut state`
//! extension of [`reconstruct_chroma`]. 4:2:2 is subsampled horizontally only
//! — its siting reduces to the horizontal axis (cf.
//! [`chroma_422_center_sited_h`](super::chroma_422_center_sited_h)) — so this
//! first cut carries no vertical phase.
/// One chroma element type's **centered horizontal** (#302 phase-0.5)
/// reconstruction primitive — the per-element knob the element-generic
/// [`reconstruct_chroma`] L2 stage turns. Each impl delegates to the matching
/// shipped #302 scalar upsampler, so the `1/4`–`3/4` reconstruction (and its
/// edge clamp, wire byte order, and low-`BITS` masking) lives in exactly one
/// place per element type.
pub
/// 8-bit planar centered chroma upsampler — delegates to
/// [`chroma_upsample_2to1_center_h`](crate::row::scalar::chroma_upsample_2to1_center_h).
/// The shared separate-plane `u8` kernel the planar (and, once later PRs
/// repoint them, the de-interleaved semi-planar / packed) 4:2:x centered paths
/// reach.
pub ;
/// 8-bit planar centered chroma upsampler for the `1→4` subsampled layouts
/// (4:1:1 / 4:1:0) — delegates to the SIMD-dispatched
/// [`chroma_upsample_4to1_center_h_row`](crate::row::chroma_upsample_4to1_center_h_row)
/// (byte-identical to the scalar
/// [`chroma_upsample_4to1_center_h`](crate::row::scalar::chroma_upsample_4to1_center_h)
/// per tier). The quarter-width sibling of [`ChromaU8`]: the trait's `half`
/// argument carries the quarter-width chroma plane, reconstructed to `width`
/// full-width samples.
pub ;
/// High-bit (`9`…`16`-bit low-packed) planar centered chroma upsampler —
/// delegates to
/// [`chroma_upsample_2to1_center_h_u16`](crate::row::scalar::chroma_upsample_2to1_center_h_u16),
/// masking each sample to the low `BITS` and operating in the source's wire
/// byte order (`big_endian`) so the reconstructed full-width chroma feeds the
/// matching high-bit 4:4:4 decode kernel bit-identically per tier. `BITS` is a
/// const generic (threaded into the per-sample mask, `u16::MAX` / a no-op at
/// `BITS = 16`); the endianness is the one runtime knob the `u8` sibling lacks.
pub
/// Element-generic L2 chroma reconstruction (RFC #238): horizontally
/// reconstructs the half-width `u_half` / `v_half` chroma planes of a
/// **centered-sited** 4:2:x source to full width into the already-reserved
/// `chroma_full` scratch, returning the two full-width slices
/// `(u_full, v_full)` the 4:4:4 decode reads. The buffer is split
/// `[0..width]` = U, `[width..2*width]` = V; each half is filled by `kernel`'s
/// [`ChromaCenterUpsampler::upsample_center_h`] (the shipped #302 phase-0.5
/// upsampler for that element type) — so this stage owns only the shared buffer
/// geometry, never the siting math.
///
/// **Infallible**: the caller must have grown `chroma_full` to `>= 2 * width`
/// up front (every centered identity path reserves it before writing any output
/// row — the crate's #180 / #314 preflight-ordering atomicity contract), so the
/// split below cannot panic and `2 * width` cannot overflow here.
pub