Simplify GVFG API and frame diagnostics
This commit is contained in:
@@ -35,15 +35,11 @@ typedef struct gvfg_convert_frame_t *gvfg_convert_frame;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t struct_size; /* Set to sizeof(gvfg_convert_frame_desc_t) before calling. */
|
||||
int width; /* Frame width in pixels. Use 0 to size from source during conversion. */
|
||||
int height; /* Frame height in pixels. Use 0 to size from source during conversion. */
|
||||
int pixel_format; /* gvfg_convert_format_t destination format. */
|
||||
int row_bytes; /* Destination row stride in bytes. Use 0 for helper default. */
|
||||
uint32_t flags; /* Reserved for future conversion options. Must be 0. */
|
||||
uint32_t reserved0; /* Reserved. Must be 0. */
|
||||
uint64_t data_size; /* Output buffer size in bytes, filled after create/convert. */
|
||||
uint64_t reserved[8]; /* Reserved for future helper metadata. Must be ignored. */
|
||||
} gvfg_convert_frame_desc_t;
|
||||
|
||||
GVFG_CONVERT_API gvfg_status_t gvfg_convert_create_frame(
|
||||
@@ -59,7 +55,7 @@ GVFG_CONVERT_API gvfg_status_t gvfg_convert_frame_from_capture(
|
||||
|
||||
GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_frame_desc(
|
||||
_In_ gvfg_convert_frame frame,
|
||||
_Inout_ gvfg_convert_frame_desc_t *out_desc);
|
||||
_Out_ gvfg_convert_frame_desc_t *out_desc);
|
||||
|
||||
GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_buffer(
|
||||
_In_ gvfg_convert_frame frame,
|
||||
@@ -68,7 +64,7 @@ GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_buffer(
|
||||
|
||||
GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_layout(
|
||||
_In_ gvfg_convert_frame frame,
|
||||
_Inout_ gvfg_frame_layout_t *out_layout);
|
||||
_Out_ gvfg_frame_layout_t *out_layout);
|
||||
|
||||
GVFG_CONVERT_API const char *gvfg_convert_strerror(
|
||||
_In_ gvfg_status_t status);
|
||||
|
||||
@@ -160,7 +160,6 @@ struct gvfg_convert_frame_t
|
||||
}
|
||||
|
||||
layout = {};
|
||||
layout.struct_size = sizeof(layout);
|
||||
layout.plane_count = 1;
|
||||
layout.plane_data[0] = buffer.data();
|
||||
layout.plane_stride[0] = actualStride;
|
||||
@@ -323,17 +322,13 @@ extern "C"
|
||||
return GVFG_EINVAL;
|
||||
*out_frame = nullptr;
|
||||
|
||||
if (desc->struct_size < sizeof(gvfg_convert_frame_desc_t) ||
|
||||
desc->flags != 0 ||
|
||||
desc->reserved0 != 0 ||
|
||||
convert_format_bytes_per_pixel(desc->pixel_format) <= 0)
|
||||
if (convert_format_bytes_per_pixel(desc->pixel_format) <= 0)
|
||||
return GVFG_EINVAL;
|
||||
if (desc->width < 0 || desc->height < 0 || desc->row_bytes < 0)
|
||||
return GVFG_EINVAL;
|
||||
|
||||
auto frame = std::make_unique<gvfg_convert_frame_t>();
|
||||
frame->request = {};
|
||||
frame->request.struct_size = sizeof(gvfg_convert_frame_desc_t);
|
||||
frame->request.width = desc->width;
|
||||
frame->request.height = desc->height;
|
||||
frame->request.pixel_format = desc->pixel_format;
|
||||
@@ -374,7 +369,6 @@ extern "C"
|
||||
return cfg;
|
||||
|
||||
gvfg_frame_layout_t srcLayout{};
|
||||
srcLayout.struct_size = sizeof(srcLayout);
|
||||
const gvfg_status_t layoutStatus = gvfg_get_frame_layout(src, &srcLayout);
|
||||
if (layoutStatus != GVFG_OK)
|
||||
return layoutStatus;
|
||||
@@ -395,13 +389,7 @@ extern "C"
|
||||
{
|
||||
if (!frame || !out_desc)
|
||||
return GVFG_EINVAL;
|
||||
if (out_desc->struct_size < sizeof(gvfg_convert_frame_desc_t))
|
||||
return GVFG_EINVAL;
|
||||
|
||||
const uint32_t callerSize = out_desc->struct_size;
|
||||
std::memset(out_desc, 0, sizeof(*out_desc));
|
||||
*out_desc = frame->desc;
|
||||
out_desc->struct_size = callerSize;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -421,15 +409,10 @@ extern "C"
|
||||
{
|
||||
if (!frame || !out_layout)
|
||||
return GVFG_EINVAL;
|
||||
if (out_layout->struct_size < sizeof(gvfg_frame_layout_t))
|
||||
return GVFG_EINVAL;
|
||||
if (frame->buffer.empty() || frame->layout.plane_count <= 0)
|
||||
return GVFG_ESTATE;
|
||||
|
||||
const uint32_t callerSize = out_layout->struct_size;
|
||||
std::memset(out_layout, 0, sizeof(*out_layout));
|
||||
*out_layout = frame->layout;
|
||||
out_layout->struct_size = callerSize;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user