Skip to content

feat(sinker): Ship 8 — Yuv440p RGBA wiring (reuses Yuv444p kernels)#22

Merged
uqio merged 1 commit intomainfrom
feat/ship8-rgba-yuv440p
Apr 26, 2026
Merged

feat(sinker): Ship 8 — Yuv440p RGBA wiring (reuses Yuv444p kernels)#22
uqio merged 1 commit intomainfrom
feat/ship8-rgba-yuv440p

Conversation

@uqio
Copy link
Copy Markdown
Collaborator

@uqio uqio commented Apr 26, 2026

Tranche 4c of Ship 8 sink-side RGBA. Wiring-only PR — adds Yuv440p (4:4:0 planar, 8-bit) RGBA output by reusing the yuv_444_to_rgba_row dispatcher that shipped in PR #19. No new kernel code anywhere in the crate; per-row math is identical to 4:4:4 (full-width chroma) — only the walker reads chroma row r / 2.

Smallest tranche of Ship 8 so far: 2 files modified, +222 / -9 net.

Scope

# Tranche Formats Status
1 4:2:0 planar Yuv420p ✅ shipped (PR #16)
2 4:2:0 semi-planar Nv12, Nv21 ✅ shipped (PR #17)
3 4:2:2 planar + semi-planar Yuv422p, Nv16 ✅ shipped (PR #18)
4a 4:4:4 planar Yuv444p ✅ shipped (PR #19)
4b 4:4:4 semi-planar Nv24, Nv42 ✅ shipped (PR #20) — also retro-applied Strategy A combined RGB+RGBA fan-out to all 8 wired families
4c 4:4:0 planar Yuv440p this PR — wiring-only (reuses yuv_444_to_rgba_row from PR #19)
5 High-bit-depth 4:2:0 Yuv420p9/10/12/14/16, P010/P012/P016 next
6 High-bit-depth 4:2:2 Yuv422p9/10/12/14/16, Yuv440p10/12, P210/P212/P216
7 High-bit-depth 4:4:4 Yuv444p9/10/12/14/16, P410/P412/P416

Usage:

```rust
use colconv::{
frame::Yuv440pFrame,
sinker::MixedSinker,
yuv::{Yuv440p, yuv440p_to},
ColorMatrix,
};

let frame = Yuv440pFrame::new(&y_plane, &u_plane, &v_plane, w, h, w, w, w);
let mut rgb = vec![0u8; (w * h * 3) as usize];
let mut rgba = vec![0u8; (w * h * 4) as usize];
let mut sinker = MixedSinker::::new(w as usize, h as usize)
.with_rgb(&mut rgb)?
.with_rgba(&mut rgba)?;

// Both buffers requested → YUV→RGB math runs once via yuv_444_to_rgb_row,
// RGBA derived via expand_rgb_to_rgba_row (Strategy A from PR #20).
yuv440p_to(&frame, /full_range=/ true, ColorMatrix::Bt709, &mut sinker)?;
```

What's in this PR

Public API

Kernel work

Zero. 4:4:0 reuses the existing 4:4:4 dispatchers because the per-row math is identical (full-width chroma; the half-height layout is a walker concern — yuv440p_to reads chroma row r / 2 and feeds Yuv440pRow to process, which receives full-width U/V slices indistinguishable from 4:4:4 to the kernel).

Reused dispatcher Used for
`row::yuv_444_to_rgb_row` RGB-only and HSV-only paths (already in use pre-PR)
`row::yuv_444_to_rgba_row` RGBA-only path (new — reused from PR #19's tranche 4a)
`row::scalar::expand_rgb_to_rgba_row` RGB+RGBA both-buffers path (Strategy A fan-out from PR #20)

MixedSinker integration

`MixedSinker::process` rewritten for Strategy A output mode resolution (mirrors the pattern landed in PR #20 across all 8 prior wired families):

  • RGBA-only (no RGB / HSV): dedicated `yuv_444_to_rgba_row` directly into the output buffer.
  • RGB / HSV (± RGBA): `yuv_444_to_rgb_row` once into `rgb_row` (or `rgb_scratch`), then HSV derivation if requested, then `expand_rgb_to_rgba_row` if RGBA also requested.

The `compile_fail` doctest negative example moved forward from `MixedSinker::::with_rgba` to `MixedSinker::::with_rgba` (next not-yet-wired format — Tranche 5 high-bit-depth 4:2:0).

Doc updates

`docs/color-conversion-functions.md` § Ship 8 tranche tracker — mark 4c as the active PR, 4b as ✅ shipped (PR #20), promote tranche 5 to "next".

Tests

+4 lib tests on aarch64 (479 vs. 475 in PR #21):

Layer Tests added
Format-level Yuv440p RGBA 4: gray-to-gray + opaque alpha, RGB-byte invariant, buffer-too-short, random-YUV SIMD parity (1922×4 frame, all 4 matrices × both ranges)
Cross-format Strategy A umbrella extended in-place: `strategy_a_rgb_and_rgba_byte_identical_for_all_wired_families` now exercises 9 `process` impls (added Yuv440p block)

No per-backend equivalence tests added — the SIMD paths exercised here are the existing `yuv_444_to_rgba_row` family, already covered by PR #19's per-backend Yuv444p RGBA tests across all 5 SIMD backends.

Local results (aarch64 macOS): 479 lib tests + 1 doctest pass; wasm32 + x86_64 cross-targets compile clean; clippy reports zero warnings.

What's deferred

Test plan

  • CI green on `test`, `test-sde-avx512`, `cross`, `coverage`, `clippy`, `build`, `miri-*` jobs.
  • Per-tier coverage matrix exercises SSE4.1 / AVX2 / scalar paths via existing `colconv_disable_*` rustflags (no new SIMD code, but the dispatcher routes through the same Yuv444p backends).
  • Verify Yuv440p → both-buffers (RGB + RGBA) pipeline end-to-end with a real frame (gray + non-gray patches).
  • `cargo doc --lib --no-deps` clean (no new doc warnings vs. main).

🤖 Generated with Claude Code

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR wires RGBA output support for the Yuv440p (4:4:0 planar 8-bit) path in MixedSinker, and expands the test suite to validate RGBA behavior and Strategy A invariants across formats.

Changes:

  • Add with_rgba / set_rgba APIs for MixedSinker<Yuv440p> and implement RGBA emission in the PixelSink row-processing logic.
  • Extend cross-format Strategy A tests to include Yuv440p (now 9 wired families).
  • Add a dedicated Yuv440p RGBA test group (gray correctness + opaque alpha, RGB/RGBA byte identity, buffer-too-short error, SIMD vs scalar parity).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/sinker/mixed/planar_8bit.rs Adds RGBA buffer attachment APIs for Yuv440p and updates the row dispatcher to output RGBA directly (RGBA-only) or via RGB expansion (RGB+RGBA Strategy A).
src/sinker/mixed/tests.rs Updates Strategy A invariant text/count and adds Yuv440p RGBA coverage (correctness, error handling, SIMD/scalar equivalence).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@al8n al8n changed the title update feat(sinker): Ship 8 — Yuv440p RGBA wiring (reuses Yuv444p kernels) Apr 26, 2026
@uqio uqio merged commit ab4c593 into main Apr 26, 2026
5 of 70 checks passed
@uqio uqio deleted the feat/ship8-rgba-yuv440p branch April 26, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants