fix: handle FPGA Y210 payload and correct chroma order

- treat FPGA v210 format marker as Y210 payload
- calculate Y210 DMA frame size as width * height * 4
- route CaptureDemo preview frames through the Y210 path
- normalize FPGA Y0/V/Y1/U data to standard Y0/U/Y1/V
- apply the same chroma correction to preview and frame conversion
- reallocate capture buffers using the detected pixel format
This commit is contained in:
Mark.lin
2026-07-20 16:24:06 +08:00
parent 5a143a4743
commit f7e5d20068
5 changed files with 52 additions and 17 deletions
+5 -2
View File
@@ -275,10 +275,13 @@ namespace
for (int x = 0; x < src.width; x += 2)
{
const int sx = x * 2;
// Standard Y210 is Y0, Cb(U), Y1, Cr(V). Normalize the
// current FPGA DMA order Y0, Cr(V), Y1, Cb(U) before RGB
// conversion so snapshots match the preview path.
const uint16_t y0 = y210_word_to_10bit(srcRow[sx + 0]);
const uint16_t u = y210_word_to_10bit(srcRow[sx + 1]);
const uint16_t v = y210_word_to_10bit(srcRow[sx + 1]);
const uint16_t y1 = (x + 1 < src.width) ? y210_word_to_10bit(srcRow[sx + 2]) : y0;
const uint16_t v = (x + 1 < src.width) ? y210_word_to_10bit(srcRow[sx + 3]) : u;
const uint16_t u = (x + 1 < src.width) ? y210_word_to_10bit(srcRow[sx + 3]) : v;
double r = 0.0, g = 0.0, b = 0.0;
yuv709_limited_to_rgb01(static_cast<double>(y0) / 1023.0,
@@ -1094,10 +1094,12 @@ bool D3DPreviewPipeline::upload_y210_frame(const uint8_t *data, int src_stride,
for (int x = 0; x < w2; ++x)
{
const int srcX = x * 4;
// Standard Y210 is Y0, Cb(U), Y1, Cr(V). The current FPGA DMA
// payload arrives as Y0, Cr(V), Y1, Cb(U), so normalize it here.
const uint16_t Y0 = normalize_y210_word_for_upload(src16[srcX + 0]);
const uint16_t U = normalize_y210_word_for_upload(src16[srcX + 1]);
const uint16_t V = normalize_y210_word_for_upload(src16[srcX + 1]);
const uint16_t Y1 = (srcX + 2 < rowWords) ? normalize_y210_word_for_upload(src16[srcX + 2]) : Y0;
const uint16_t V = (srcX + 3 < rowWords) ? normalize_y210_word_for_upload(src16[srcX + 3]) : U;
const uint16_t U = (srcX + 3 < rowWords) ? normalize_y210_word_for_upload(src16[srcX + 3]) : V;
uint16_t *d4 = dst16 + x * 4;
d4[0] = Y0;