feat: align GVFG output with YUY2

- expose YUY2 across the public API, preview helper, backend, and GPU conversion paths while translating the legacy FPGA format value internally
- correct YUY2 chroma byte interpretation and update customer/internal documentation
- centralize the Standalone SDK version and expose it through gvfg_get_version
- show the SDK version in the sample and enable preview-window controls only after the first valid frame
- close and disable external preview windows when capture stops
This commit is contained in:
Mark.lin
2026-08-13 16:14:16 +08:00
parent a5b86e5872
commit 17fb9bfabd
20 changed files with 302 additions and 63 deletions
+6 -6
View File
@@ -51,12 +51,12 @@ VSOut main(VSIn i){
}
)";
// YVYU 4:2:2 packed input.
// YUY2 4:2:2 packed input (byte order Y0 U0 Y1 V0).
// Each upload texture texel stores two pixels as R=Y0, G=U, B=Y1, A=V.
// R=Y0, G=U, B=Y1, A=V
// texture width = ceil(w/2)
static const char *g_ps_yuy2 = R"(
// YVYU (4:2:2 packed):
// YUY2 (4:2:2 packed):
// Each texel packs 2 pixels: R=Y0, G=U, B=Y1, A=V
// texture width = ceil(w/2)
Texture2D<uint4> texP : register(t0);
@@ -132,8 +132,8 @@ float2 loadUV01(int x, int y)
x = clamp(x, 0, (int)width - 1);
y = clamp(y, 0, (int)height - 1);
uint4 p = texP.Load(int3(x >> 1, y, 0));
float u = (float)p.a / 255.0;
float v = (float)p.g / 255.0;
float u = (float)p.g / 255.0;
float v = (float)p.a / 255.0;
return float2(u, v);
}
@@ -979,7 +979,7 @@ bool D3DPreviewPipeline::upload_y210_frame(const uint8_t *data, int src_stride,
bool D3DPreviewPipeline::render_uploaded_yuv_to_fp16(gvfg_render_pixfmt_t fmt, int frame_w, int frame_h)
{
ID3D11Texture2D *texture = fmt == GVFG_RENDER_FMT_YVYU
ID3D11Texture2D *texture = fmt == GVFG_RENDER_FMT_YUY2
? upload_yuy2_packed_.Get()
: upload_y210_packed_.Get();
return render_texture_to_fp16(texture, fmt, frame_w, frame_h);
@@ -995,7 +995,7 @@ bool D3DPreviewPipeline::render_texture_to_fp16(ID3D11Texture2D *texture,
ID3D11PixelShader *ps = nullptr;
ComPtr<ID3D11ShaderResourceView> srv0;
if (fmt == GVFG_RENDER_FMT_YVYU)
if (fmt == GVFG_RENDER_FMT_YUY2)
{
if (!texture)
return false;
+1 -1
View File
@@ -11,7 +11,7 @@ namespace gvfg::internal
typedef enum
{
GVFG_RENDER_FMT_Y210,
GVFG_RENDER_FMT_YVYU
GVFG_RENDER_FMT_YUY2
} gvfg_render_pixfmt_t;
typedef enum
+4 -4
View File
@@ -45,8 +45,8 @@ public:
const auto *data = static_cast<const uint8_t *>(source.data);
switch (source.pixel_format)
{
case GVFG_PIXFMT_YVYU:
renderFormat = gvfg::internal::GVFG_RENDER_FMT_YVYU;
case GVFG_PIXFMT_YUY2:
renderFormat = gvfg::internal::GVFG_RENDER_FMT_YUY2;
uploaded = pipeline_->upload_packed_422_frame(data,
source.row_stride_bytes,
source.width,
@@ -170,7 +170,7 @@ bool checkedFrameLayout(const gvfg_frame_t &source)
uint64_t minimumRowBytes = 0;
switch (source.pixel_format)
{
case GVFG_PIXFMT_YVYU:
case GVFG_PIXFMT_YUY2:
minimumRowBytes = static_cast<uint64_t>(source.width) * 2u;
break;
case GVFG_PIXFMT_Y210:
@@ -203,7 +203,7 @@ extern "C" GVFG_API gvfg_status_t gvfg_gpu_convert_to_buffer(
output->row_bytes <= 0)
return GVFG_EINVAL;
if (source->pixel_format != GVFG_PIXFMT_YVYU &&
if (source->pixel_format != GVFG_PIXFMT_YUY2 &&
source->pixel_format != GVFG_PIXFMT_Y210)
return GVFG_ENOTSUP;
if (output->pixel_format != GVFG_GPU_OUTPUT_BGRA8 &&