Confirm single-image presents and require whole YUY2 macropixels in preview rows

- gvfg_playback_present_image compares the preview's presented count before and after rendering, and returns GVFG_PLAYBACK_EOUTPUT when the image was not actually presented.
- Compute the minimum YUY2 row size from whole 4-byte macropixels, so an odd-width row that is 2 bytes short is rejected instead of read past its end.

Validation: git diff --cached --check passed. The MSVC Release SDK build with these changes and 1d89392 passed. On a GIGABYTE SDI VFG100 with a 1080p60 SDI signal, the Viewer capture journey (live preview, snapshot, stop, restart, recording) passed with that SDK. gvfg_playback_present_image and odd-width YUY2 frames were not exercised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 16:50:43 +08:00
co-authored by Claude Opus 5.5
parent 208fb6c811
commit 02c7004e8c
2 changed files with 6 additions and 2 deletions
@@ -507,10 +507,14 @@ gvfg_playback_status_t gvfg_playback_present_image(gvfg_playback p, const gvfg_p
} }
// Like attach/start/stop, callers serialize this control operation. Do not // Like attach/start/stop, callers serialize this control operation. Do not
// hold the playback mutex while DXGI can send synchronous HWND messages. // hold the playback mutex while DXGI can send synchronous HWND messages.
gvfg_preview_delivery_stats_t before{}, after{};
if (gvfg_preview_wait_idle(preview, 2000) != GVFG_PREVIEW_OK || if (gvfg_preview_wait_idle(preview, 2000) != GVFG_PREVIEW_OK ||
gvfg_preview_prepare(preview, image->width, image->height, image->bit_depth) != GVFG_PREVIEW_OK || gvfg_preview_prepare(preview, image->width, image->height, image->bit_depth) != GVFG_PREVIEW_OK ||
gvfg_preview_get_delivery_stats(preview, &before) != GVFG_PREVIEW_OK ||
gvfg_preview_render_frame(preview, image) != GVFG_PREVIEW_OK || gvfg_preview_render_frame(preview, image) != GVFG_PREVIEW_OK ||
gvfg_preview_wait_idle(preview, 2000) != GVFG_PREVIEW_OK) gvfg_preview_wait_idle(preview, 2000) != GVFG_PREVIEW_OK ||
gvfg_preview_get_delivery_stats(preview, &after) != GVFG_PREVIEW_OK ||
after.presented == before.presented)
return GVFG_PLAYBACK_EOUTPUT; return GVFG_PLAYBACK_EOUTPUT;
return GVFG_PLAYBACK_OK; return GVFG_PLAYBACK_OK;
} }
@@ -843,7 +843,7 @@ extern "C"
switch (frame->pixel_format) switch (frame->pixel_format)
{ {
case GVFG_PREVIEW_PIXFMT_YUY2: case GVFG_PREVIEW_PIXFMT_YUY2:
minimumRowBytes = static_cast<uint64_t>(frame->width) * 2u; minimumRowBytes = (static_cast<uint64_t>(frame->width) + 1u) / 2u * 4u;
break; break;
case GVFG_PREVIEW_PIXFMT_Y210: case GVFG_PREVIEW_PIXFMT_Y210:
minimumRowBytes = static_cast<uint64_t>(frame->width) * 4u; minimumRowBytes = static_cast<uint64_t>(frame->width) * 4u;