also looking at this
feat(video): add checked capture plane packing
#915
3 files
+68
-0
| @@ -0,0 +1,23 @@ | ||
| 1 | # Packing captured image planes | |
| 2 | ||
| 3 | `core/plane_pack.zig` provides allocation-free checked copies for capture buffers | |
| 4 | whose row padding is not part of the image. It is also exported as | |
| 5 | `video.plane_pack`. | |
| 6 | ||
| 7 | - `rows(source, stride, active_row_bytes, height, destination)` copies active bytes. | |
| 8 | - `packI420(planes, strides, width, height, destination)` packs separate Y, U, V | |
| 9 | planes into tight I420; each source plane can have its own stride. | |
| 10 | ||
| 11 | Both validate sizes with checked arithmetic before writing. Final row padding | |
| 12 | need not be present. I420 requires positive even dimensions. Truncated chroma, | |
| 13 | undersized output and overflow are errors; the destination remains unchanged. | |
| 14 | Sources remain borrowed, the caller owns the destination, and source and output | |
| 15 | must not overlap. These helpers do not convert color, resize, or synchronize DMA. | |
| 16 | ||
| 17 | zig-camera uses these helpers after beginning CPU access to a leased DMA buffer. | |
| 18 | The camera ISP produces its low-resolution stream; packing only happens for an | |
| 19 | explicit owned copy. A mapped view keeps the original padding and ownership. | |
| 20 | ||
| 21 | Focused validation: `zig test packages/video/src/core/plane_pack.zig` on Zig | |
| 22 | 0.15.2 and Home's 0.17 development toolchain. This does not establish correctness | |
| 23 | of the entire video package's unrelated codecs or conversion paths. | |