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:
@@ -18,7 +18,7 @@ typedef enum pcies2mm_pixel_format_t
|
||||
{
|
||||
PCIES2MM_PIXFMT_UNKNOWN = 0,
|
||||
PCIES2MM_PIXFMT_Y210 = 2,
|
||||
PCIES2MM_PIXFMT_YVYU = 3
|
||||
PCIES2MM_PIXFMT_YUY2 = 3
|
||||
} pcies2mm_pixel_format_t;
|
||||
|
||||
typedef enum pcies2mm_stream_state_t
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace gvfg::internal
|
||||
{
|
||||
stream_desc_.width = kDefaultWidth;
|
||||
stream_desc_.height = kDefaultHeight;
|
||||
stream_desc_.pixel_format = PCIES2MM_PIXFMT_YVYU;
|
||||
stream_desc_.pixel_format = PCIES2MM_PIXFMT_YUY2;
|
||||
stream_desc_.buffer_count = kDefaultRingBufferCount;
|
||||
stream_bit_depth_ = 8;
|
||||
reset_stats(stats_, PCIES2MM_STREAM_STOPPED);
|
||||
@@ -270,10 +270,10 @@ namespace gvfg::internal
|
||||
if (desc.width == 0 || desc.height == 0)
|
||||
return PCIES2MM_EINVAL;
|
||||
|
||||
pcies2mm_pixel_format_t fmt = desc.pixel_format == PCIES2MM_PIXFMT_UNKNOWN ? PCIES2MM_PIXFMT_YVYU : desc.pixel_format;
|
||||
pcies2mm_pixel_format_t fmt = desc.pixel_format == PCIES2MM_PIXFMT_UNKNOWN ? PCIES2MM_PIXFMT_YUY2 : desc.pixel_format;
|
||||
switch (fmt)
|
||||
{
|
||||
case PCIES2MM_PIXFMT_YVYU:
|
||||
case PCIES2MM_PIXFMT_YUY2:
|
||||
case PCIES2MM_PIXFMT_Y210:
|
||||
break;
|
||||
default:
|
||||
@@ -1151,8 +1151,8 @@ namespace gvfg::internal
|
||||
const char *decodedFormat = "UNKNOWN";
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case PCIES2MM_PIXFMT_YVYU:
|
||||
decodedFormat = "YVYU";
|
||||
case PCIES2MM_PIXFMT_YUY2:
|
||||
decodedFormat = "YUY2";
|
||||
break;
|
||||
case PCIES2MM_PIXFMT_Y210:
|
||||
decodedFormat = "Y210";
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
// This board revision can report v210 even though its DMA payload is Y210
|
||||
// (16-bit containers with 10 valid bits).
|
||||
constexpr uint32_t kRegisterDisplayYvyu = 0x59565955u;
|
||||
// Legacy firmware reports YVYU for the 8-bit stream even though the DMA
|
||||
// payload is YUY2 (byte order Y0 U0 Y1 V0). Keep accepting that register
|
||||
// value until FPGA firmware is corrected.
|
||||
constexpr uint32_t kLegacyRegisterDisplayYvyu = 0x59565955u;
|
||||
constexpr uint32_t kRegisterDisplayV210 = 0x76323130u;
|
||||
constexpr uint32_t kRegisterDisplayY210 = 0x59323130u;
|
||||
|
||||
@@ -23,8 +24,8 @@ namespace gvfg::internal
|
||||
{
|
||||
// Current firmware writes character codes in display order. Normalize
|
||||
// those values here so no register naming leaks into the SDK formats.
|
||||
if (registerValue == kRegisterDisplayYvyu)
|
||||
return PCIES2MM_PIXFMT_YVYU;
|
||||
if (registerValue == kLegacyRegisterDisplayYvyu)
|
||||
return PCIES2MM_PIXFMT_YUY2;
|
||||
if (registerValue == kRegisterDisplayV210 || registerValue == kRegisterDisplayY210)
|
||||
return PCIES2MM_PIXFMT_Y210;
|
||||
|
||||
@@ -32,7 +33,8 @@ namespace gvfg::internal
|
||||
switch (registerValue)
|
||||
{
|
||||
case fourcc('Y', 'V', 'Y', 'U'):
|
||||
return PCIES2MM_PIXFMT_YVYU;
|
||||
case fourcc('Y', 'U', 'Y', '2'):
|
||||
return PCIES2MM_PIXFMT_YUY2;
|
||||
case fourcc('v', '2', '1', '0'):
|
||||
case fourcc('Y', '2', '1', '0'):
|
||||
return PCIES2MM_PIXFMT_Y210;
|
||||
@@ -43,7 +45,7 @@ namespace gvfg::internal
|
||||
|
||||
uint32_t bit_depth_for_pixfmt(pcies2mm_pixel_format_t format)
|
||||
{
|
||||
if (format == PCIES2MM_PIXFMT_YVYU)
|
||||
if (format == PCIES2MM_PIXFMT_YUY2)
|
||||
return 8;
|
||||
if (format == PCIES2MM_PIXFMT_Y210)
|
||||
return 10;
|
||||
@@ -53,7 +55,7 @@ namespace gvfg::internal
|
||||
size_t bytes_per_frame(uint32_t width, uint32_t height, pcies2mm_pixel_format_t format)
|
||||
{
|
||||
const size_t pixels = static_cast<size_t>(width) * static_cast<size_t>(height);
|
||||
if (format == PCIES2MM_PIXFMT_YVYU)
|
||||
if (format == PCIES2MM_PIXFMT_YUY2)
|
||||
return pixels * 2u;
|
||||
if (format == PCIES2MM_PIXFMT_Y210)
|
||||
return pixels * 4u;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#ifndef GVFG_VERSION_STRING
|
||||
#define GVFG_VERSION_STRING "0.0.0"
|
||||
#endif
|
||||
|
||||
using namespace gvfg::internal;
|
||||
|
||||
namespace
|
||||
@@ -137,8 +141,8 @@ namespace
|
||||
{
|
||||
switch (fmt)
|
||||
{
|
||||
case PCIES2MM_PIXFMT_YVYU:
|
||||
return GVFG_PIXFMT_YVYU;
|
||||
case PCIES2MM_PIXFMT_YUY2:
|
||||
return GVFG_PIXFMT_YUY2;
|
||||
case PCIES2MM_PIXFMT_Y210:
|
||||
return GVFG_PIXFMT_Y210;
|
||||
default:
|
||||
@@ -150,8 +154,8 @@ namespace
|
||||
{
|
||||
switch (fmt)
|
||||
{
|
||||
case GVFG_PIXFMT_YVYU:
|
||||
return "YVYU";
|
||||
case GVFG_PIXFMT_YUY2:
|
||||
return "YUY2";
|
||||
case GVFG_PIXFMT_Y210:
|
||||
return "Y210";
|
||||
default:
|
||||
@@ -172,7 +176,7 @@ namespace
|
||||
int &outStride)
|
||||
{
|
||||
uint64_t bytesPerPixel = 0;
|
||||
if (pixelFormat == PCIES2MM_PIXFMT_YVYU)
|
||||
if (pixelFormat == PCIES2MM_PIXFMT_YUY2)
|
||||
bytesPerPixel = 2;
|
||||
else if (pixelFormat == PCIES2MM_PIXFMT_Y210)
|
||||
bytesPerPixel = 4;
|
||||
@@ -386,7 +390,7 @@ struct gvfg_handle_t
|
||||
const uint32_t configureWidth = waitingForSignal ? 2 : width;
|
||||
const uint32_t configureHeight = waitingForSignal ? 1 : height;
|
||||
const pcies2mm_pixel_format_t configureFormat =
|
||||
waitingForSignal || pixelFormat == PCIES2MM_PIXFMT_UNKNOWN ? PCIES2MM_PIXFMT_YVYU : pixelFormat;
|
||||
waitingForSignal || pixelFormat == PCIES2MM_PIXFMT_UNKNOWN ? PCIES2MM_PIXFMT_YUY2 : pixelFormat;
|
||||
|
||||
pcies2mm_stream_desc_t desc{};
|
||||
desc.width = configureWidth;
|
||||
@@ -849,6 +853,11 @@ extern "C"
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
const char *gvfg_get_version(void)
|
||||
{
|
||||
return GVFG_VERSION_STRING;
|
||||
}
|
||||
|
||||
const char *gvfg_pixel_format_name(int pixel_format)
|
||||
{
|
||||
return pixel_format_name(pixel_format);
|
||||
|
||||
Reference in New Issue
Block a user