Simplify frame layout metadata
This commit is contained in:
+16
-46
@@ -126,49 +126,34 @@ typedef struct
|
||||
uint64_t data_size;
|
||||
int width;
|
||||
int height;
|
||||
int row_stride_bytes;
|
||||
int pixel_format;
|
||||
int bit_depth;
|
||||
uint64_t frame_id;
|
||||
} gvfg_frame_t;
|
||||
```
|
||||
|
||||
`gvfg_frame_t` 只保存每張 frame 必定存在的核心欄位;stable release 後凍結此 ABI。
|
||||
Memory layout、color metadata 與 timestamp metadata 不會繼續塞進這個 struct,而是
|
||||
分別透過 query API 取得。
|
||||
|
||||
### `gvfg_frame_layout_t`
|
||||
|
||||
由 `gvfg_get_frame_layout()` 回傳的 optional per-plane layout。
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
int plane_count;
|
||||
const void *plane_data[GVFG_MAX_PLANES];
|
||||
int plane_stride[GVFG_MAX_PLANES];
|
||||
uint64_t plane_size[GVFG_MAX_PLANES];
|
||||
} gvfg_frame_layout_t;
|
||||
```
|
||||
|
||||
需要 row pitch 或 plane offset 的 application,應該在 `gvfg_read_frame()` 後呼叫
|
||||
`gvfg_get_frame_layout()`,並使用 `plane_data[]`、`plane_stride[]`、
|
||||
`plane_size[]`,不要自己用 width 和 pixel format 猜 stride。
|
||||
`row_stride_bytes` 是相鄰兩列起點之間的 byte 距離。Application 應使用此欄位
|
||||
逐列存取影像,不要自行用 width 和 pixel format 猜 stride。`data`、
|
||||
`data_size` 與 `row_stride_bytes` 都由 SDK 填入。
|
||||
|
||||
### ABI 與 metadata 擴充規則
|
||||
|
||||
- `gvfg_handle` 永遠保持 opaque。
|
||||
- `gvfg_frame_t` 保持極小,stable release 後凍結。
|
||||
- 第一版 API 不做跨版本 struct 相容;DLL、header 與 application 必須整套更新。
|
||||
- Layout 使用 `gvfg_get_frame_layout()`。
|
||||
- 現行 native formats 都是 single-plane packed buffers;row stride 直接放在
|
||||
`gvfg_frame_t`。
|
||||
- 未來真的加入 multi-plane format 時,再新增獨立 plane-layout API。
|
||||
- 未來 color metadata 使用獨立的 `gvfg_get_frame_color_info()`。
|
||||
- 未來 timestamp metadata 使用獨立的 `gvfg_get_frame_timestamp_info()`。
|
||||
- Metadata 類型真的大量增加時,才考慮 side data。
|
||||
- 只有 major version 可以破壞既有 ABI。
|
||||
|
||||
板子只提供兩種 native capture layout:
|
||||
板子只提供兩種 tightly packed native capture layout:
|
||||
|
||||
- `YUY2`:one plane,`plane_stride[0] = width * 2`。
|
||||
- `Y210`:one plane,`plane_stride[0] = width * 4`。
|
||||
- `YUY2`:`row_stride_bytes = width * 2`。
|
||||
- `Y210`:`row_stride_bytes = width * 4`。
|
||||
|
||||
其他 native input format 不在 SDK 支援範圍,會回傳 `GVFG_ENOTSUP`。
|
||||
|
||||
@@ -286,22 +271,6 @@ gvfg_status_t gvfg_read_frame(gvfg_handle handle,
|
||||
- `GVFG_ETIMEOUT`:timeout 前沒有 frame。
|
||||
- `GVFG_ESTATE`:capture 尚未 running,或上一個 frame 還沒 release。
|
||||
|
||||
### `gvfg_get_frame_layout`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_get_frame_layout(const gvfg_frame_t *frame,
|
||||
gvfg_frame_layout_t *out_layout);
|
||||
```
|
||||
|
||||
回傳 `gvfg_read_frame()` 取得 frame 的 per-plane layout。
|
||||
|
||||
```c
|
||||
gvfg_frame_layout_t layout = {};
|
||||
gvfg_get_frame_layout(&frame, &layout);
|
||||
```
|
||||
|
||||
回傳的 `plane_data[]` pointers 只在 `gvfg_release_frame()` 前有效。
|
||||
|
||||
### `gvfg_convert_create_frame` / `gvfg_convert_destroy_frame`
|
||||
|
||||
```c
|
||||
@@ -341,7 +310,9 @@ if (gvfg_read_frame(h, &frame, 1000) == GVFG_OK) {
|
||||
const void *data = NULL;
|
||||
uint64_t size = 0;
|
||||
gvfg_convert_get_buffer(image, &data, &size);
|
||||
/* data contains RGB48 rows; query layout for row_bytes. */
|
||||
gvfg_convert_frame_desc_t actual = {};
|
||||
gvfg_convert_get_frame_desc(image, &actual);
|
||||
/* data contains RGB48 rows using actual.row_bytes. */
|
||||
}
|
||||
|
||||
gvfg_convert_destroy_frame(image);
|
||||
@@ -349,7 +320,7 @@ if (gvfg_read_frame(h, &frame, 1000) == GVFG_OK) {
|
||||
}
|
||||
```
|
||||
|
||||
### `gvfg_convert_get_frame_desc` / `gvfg_convert_get_buffer` / `gvfg_convert_get_layout`
|
||||
### `gvfg_convert_get_frame_desc` / `gvfg_convert_get_buffer`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_convert_get_frame_desc(gvfg_convert_frame frame,
|
||||
@@ -357,12 +328,11 @@ gvfg_status_t gvfg_convert_get_frame_desc(gvfg_convert_frame frame,
|
||||
gvfg_status_t gvfg_convert_get_buffer(gvfg_convert_frame frame,
|
||||
const void **out_data,
|
||||
uint64_t *out_size);
|
||||
gvfg_status_t gvfg_convert_get_layout(gvfg_convert_frame frame,
|
||||
gvfg_frame_layout_t *out_layout);
|
||||
```
|
||||
|
||||
在 `gvfg_convert_frame_from_capture()` 後,用這些 API 取得 converted image
|
||||
buffer、metadata 和 row stride。
|
||||
buffer;width、height、format、`row_bytes` 與 data size 由 frame descriptor
|
||||
提供。
|
||||
|
||||
### `gvfg_release_frame`
|
||||
|
||||
|
||||
@@ -201,17 +201,16 @@ Released : ready=false, in_use=false
|
||||
|
||||
- `gvfg_read_frame()` 回傳一個 SDK-owned frame buffer。
|
||||
- `frame.data` 在 `gvfg_release_frame()` 前有效。
|
||||
- `gvfg_frame_t` 要保持 ABI-stable;不要為了 layout 直接 append fields。
|
||||
- `frame.row_stride_bytes` 是相鄰兩列起點之間的 byte 距離;consumer 不應自行
|
||||
由 width/format 猜 stride。
|
||||
- 現行 YUY2/Y210 都是 single-plane packed buffers,因此不公開 plane-layout API。
|
||||
- 未來真的加入 multi-plane format 時,再新增獨立的 plane-layout query。
|
||||
- `gvfg_handle` 永遠 opaque;stable release 後 `gvfg_frame_t` 凍結,只有 major
|
||||
version 可以破壞既有 ABI。
|
||||
- `gvfg_get_frame_layout()` 回傳 SDK-filled layout metadata:`plane_data`、
|
||||
`plane_stride`、`plane_size`。目前 PCIES2MM backend 使用
|
||||
width/height/format 推導 tightly packed layout。
|
||||
- 未來 color/timestamp metadata 應新增獨立的 query output,例如
|
||||
`gvfg_get_frame_color_info()` 與 `gvfg_get_frame_timestamp_info()`。不要預先在每個
|
||||
struct 放大型 reserved array;等 metadata 類型真的很多再考慮 side data。
|
||||
- `gvfg_preview.dll` 應優先吃 `gvfg_get_frame_layout()`;layout query 不可用時才
|
||||
fallback 到 width-derived stride。
|
||||
- `gvfg_preview.dll` 直接使用 capture frame 的 `row_stride_bytes`。
|
||||
- `gvfg_convert.dll` 負責 explicit snapshot/export conversion。不要把 color
|
||||
conversion、image export、GPU conversion policy 搬進 `gvfg.dll`。
|
||||
- 同一個 handle 一次最多 hold 一個 frame。
|
||||
|
||||
@@ -62,10 +62,6 @@ GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_buffer(
|
||||
_Out_ const void **out_data,
|
||||
_Out_ uint64_t *out_size);
|
||||
|
||||
GVFG_CONVERT_API gvfg_status_t gvfg_convert_get_layout(
|
||||
_In_ gvfg_convert_frame frame,
|
||||
_Out_ gvfg_frame_layout_t *out_layout);
|
||||
|
||||
GVFG_CONVERT_API const char *gvfg_convert_strerror(
|
||||
_In_ gvfg_status_t status);
|
||||
|
||||
|
||||
@@ -113,7 +113,6 @@ struct gvfg_convert_frame_t
|
||||
{
|
||||
gvfg_convert_frame_desc_t request{};
|
||||
gvfg_convert_frame_desc_t desc{};
|
||||
gvfg_frame_layout_t layout{};
|
||||
std::vector<uint8_t> buffer;
|
||||
|
||||
gvfg_status_t configure(int width, int height, int pixelFormat, int rowBytes)
|
||||
@@ -159,11 +158,6 @@ struct gvfg_convert_frame_t
|
||||
return GVFG_EIO;
|
||||
}
|
||||
|
||||
layout = {};
|
||||
layout.plane_count = 1;
|
||||
layout.plane_data[0] = buffer.data();
|
||||
layout.plane_stride[0] = actualStride;
|
||||
layout.plane_size[0] = size;
|
||||
return GVFG_OK;
|
||||
}
|
||||
};
|
||||
@@ -192,14 +186,19 @@ namespace
|
||||
}
|
||||
|
||||
gvfg_status_t convert_yuy2_to_frame(const gvfg_frame_t &src,
|
||||
const gvfg_frame_layout_t &srcLayout,
|
||||
gvfg_convert_frame_t &dst)
|
||||
{
|
||||
if (srcLayout.plane_count < 1 || !srcLayout.plane_data[0] || srcLayout.plane_stride[0] < src.width * 2)
|
||||
if (!src.data || src.row_stride_bytes < src.width * 2)
|
||||
return GVFG_EINVAL;
|
||||
uint64_t requiredSize = 0;
|
||||
if (!checked_mul_u64(static_cast<uint64_t>(src.row_stride_bytes),
|
||||
static_cast<uint64_t>(src.height),
|
||||
requiredSize) ||
|
||||
requiredSize > src.data_size)
|
||||
return GVFG_EINVAL;
|
||||
|
||||
const auto *srcBase = static_cast<const uint8_t *>(srcLayout.plane_data[0]);
|
||||
const int srcStride = srcLayout.plane_stride[0];
|
||||
const auto *srcBase = static_cast<const uint8_t *>(src.data);
|
||||
const int srcStride = src.row_stride_bytes;
|
||||
const int bytesPerPixel = convert_format_bytes_per_pixel(dst.desc.pixel_format);
|
||||
if (bytesPerPixel <= 0)
|
||||
return GVFG_ENOTSUP;
|
||||
@@ -251,14 +250,19 @@ namespace
|
||||
}
|
||||
|
||||
gvfg_status_t convert_y210_to_frame(const gvfg_frame_t &src,
|
||||
const gvfg_frame_layout_t &srcLayout,
|
||||
gvfg_convert_frame_t &dst)
|
||||
{
|
||||
if (srcLayout.plane_count < 1 || !srcLayout.plane_data[0] || srcLayout.plane_stride[0] < src.width * 4)
|
||||
if (!src.data || src.row_stride_bytes < src.width * 4)
|
||||
return GVFG_EINVAL;
|
||||
uint64_t requiredSize = 0;
|
||||
if (!checked_mul_u64(static_cast<uint64_t>(src.row_stride_bytes),
|
||||
static_cast<uint64_t>(src.height),
|
||||
requiredSize) ||
|
||||
requiredSize > src.data_size)
|
||||
return GVFG_EINVAL;
|
||||
|
||||
const auto *srcBase = static_cast<const uint8_t *>(srcLayout.plane_data[0]);
|
||||
const int srcStride = srcLayout.plane_stride[0];
|
||||
const auto *srcBase = static_cast<const uint8_t *>(src.data);
|
||||
const int srcStride = src.row_stride_bytes;
|
||||
const int bytesPerPixel = convert_format_bytes_per_pixel(dst.desc.pixel_format);
|
||||
if (bytesPerPixel <= 0)
|
||||
return GVFG_ENOTSUP;
|
||||
@@ -368,17 +372,12 @@ extern "C"
|
||||
if (cfg != GVFG_OK)
|
||||
return cfg;
|
||||
|
||||
gvfg_frame_layout_t srcLayout{};
|
||||
const gvfg_status_t layoutStatus = gvfg_get_frame_layout(src, &srcLayout);
|
||||
if (layoutStatus != GVFG_OK)
|
||||
return layoutStatus;
|
||||
|
||||
switch (src->pixel_format)
|
||||
{
|
||||
case GVFG_PIXFMT_YUY2:
|
||||
return convert_yuy2_to_frame(*src, srcLayout, *dst_frame);
|
||||
return convert_yuy2_to_frame(*src, *dst_frame);
|
||||
case GVFG_PIXFMT_Y210:
|
||||
return convert_y210_to_frame(*src, srcLayout, *dst_frame);
|
||||
return convert_y210_to_frame(*src, *dst_frame);
|
||||
default:
|
||||
return GVFG_ENOTSUP;
|
||||
}
|
||||
@@ -404,18 +403,6 @@ extern "C"
|
||||
return frame->buffer.empty() ? GVFG_ESTATE : GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_convert_get_layout(gvfg_convert_frame frame,
|
||||
gvfg_frame_layout_t *out_layout)
|
||||
{
|
||||
if (!frame || !out_layout)
|
||||
return GVFG_EINVAL;
|
||||
if (frame->buffer.empty() || frame->layout.plane_count <= 0)
|
||||
return GVFG_ESTATE;
|
||||
|
||||
*out_layout = frame->layout;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
const char *gvfg_convert_strerror(gvfg_status_t status)
|
||||
{
|
||||
switch (status)
|
||||
|
||||
@@ -742,6 +742,7 @@ void MainWindow::captureReadLoop()
|
||||
previewFrame.data_size = frame.data_size;
|
||||
previewFrame.width = frame.width;
|
||||
previewFrame.height = frame.height;
|
||||
previewFrame.row_bytes = frame.row_stride_bytes;
|
||||
previewFrame.bit_depth = frame.bit_depth;
|
||||
previewFrame.frame_id = frame.frame_id;
|
||||
|
||||
@@ -749,31 +750,15 @@ void MainWindow::captureReadLoop()
|
||||
{
|
||||
case GVFG_PIXFMT_YUY2:
|
||||
previewFrame.pixel_format = GVFG_PREVIEW_PIXFMT_YUY2;
|
||||
previewFrame.row_bytes = frame.width * 2;
|
||||
break;
|
||||
case GVFG_PIXFMT_Y210:
|
||||
previewFrame.pixel_format = GVFG_PREVIEW_PIXFMT_Y210;
|
||||
previewFrame.row_bytes = frame.width * 4;
|
||||
break;
|
||||
default:
|
||||
previewFrame.pixel_format = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
gvfg_frame_layout_t layout{};
|
||||
if (gvfg_get_frame_layout(&frame, &layout) == GVFG_OK &&
|
||||
layout.plane_count > 0 &&
|
||||
layout.plane_data[0] &&
|
||||
layout.plane_stride[0] > 0 &&
|
||||
layout.plane_size[0] >=
|
||||
static_cast<uint64_t>(layout.plane_stride[0]) *
|
||||
static_cast<uint64_t>(frame.height))
|
||||
{
|
||||
previewFrame.data = layout.plane_data[0];
|
||||
previewFrame.data_size = layout.plane_size[0];
|
||||
previewFrame.row_bytes = layout.plane_stride[0];
|
||||
}
|
||||
|
||||
const gvfg_preview_status_t previewStatus =
|
||||
gvfg_preview_render_frame(previewHandle_, &previewFrame);
|
||||
if (previewStatus != GVFG_PREVIEW_OK)
|
||||
|
||||
@@ -83,7 +83,6 @@ extern "C"
|
||||
enum
|
||||
{
|
||||
GVFG_MAX_DEVICES = 16,
|
||||
GVFG_MAX_PLANES = 1
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@@ -138,19 +137,12 @@ extern "C"
|
||||
uint64_t data_size; /* Total bytes available from data. */
|
||||
int width; /* Frame width in pixels. */
|
||||
int height; /* Frame height in pixels. */
|
||||
int row_stride_bytes; /* Byte distance between the starts of adjacent rows. */
|
||||
int pixel_format; /* gvfg_pixel_format_t value. */
|
||||
int bit_depth; /* Bits per color channel of the native frame. */
|
||||
uint64_t frame_id; /* Monotonic identifier within the current gvfg_start()/stop() run. */
|
||||
} gvfg_frame_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int plane_count; /* Number of valid entries in plane_data/plane_stride/plane_size. */
|
||||
const void *plane_data[GVFG_MAX_PLANES]; /* Plane pointers inside frame.data, valid until gvfg_release_frame(). */
|
||||
int plane_stride[GVFG_MAX_PLANES]; /* Bytes from one row to the next for each plane. */
|
||||
uint64_t plane_size[GVFG_MAX_PLANES]; /* Bytes available in each plane. */
|
||||
} gvfg_frame_layout_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GVFG_EVENT_UNKNOWN = 0,
|
||||
@@ -279,25 +271,6 @@ extern "C"
|
||||
_Out_ gvfg_frame_t *out_frame,
|
||||
_In_ uint32_t timeout_ms);
|
||||
|
||||
/*
|
||||
* Query per-plane layout for a frame returned by gvfg_read_frame().
|
||||
*
|
||||
* Parameters:
|
||||
* - frame: Frame descriptor returned by gvfg_read_frame(). Must not be NULL.
|
||||
* - out_layout: Receives plane pointers, strides, and sizes. Must not be NULL.
|
||||
*
|
||||
* Returns:
|
||||
* - GVFG_OK on success.
|
||||
* - GVFG_EINVAL if frame or out_layout is NULL.
|
||||
* - GVFG_ENOTSUP if the SDK cannot describe the frame layout.
|
||||
*
|
||||
* The returned plane_data pointers are owned by the SDK and remain valid only
|
||||
* until gvfg_release_frame() is called for the source frame.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_get_frame_layout(
|
||||
_In_ const gvfg_frame_t *frame,
|
||||
_Out_ gvfg_frame_layout_t *out_layout);
|
||||
|
||||
/*
|
||||
* Release a frame returned by gvfg_read_frame().
|
||||
*
|
||||
|
||||
@@ -26,21 +26,15 @@ namespace
|
||||
{
|
||||
#if INTPTR_MAX == INT64_MAX
|
||||
static_assert(std::is_standard_layout_v<gvfg_frame_t>);
|
||||
static_assert(sizeof(gvfg_frame_t) == 40, "gvfg_frame_t x64 ABI must remain frozen");
|
||||
static_assert(sizeof(gvfg_frame_t) == 48, "gvfg_frame_t x64 ABI must remain frozen");
|
||||
static_assert(offsetof(gvfg_frame_t, data) == 0);
|
||||
static_assert(offsetof(gvfg_frame_t, data_size) == 8);
|
||||
static_assert(offsetof(gvfg_frame_t, width) == 16);
|
||||
static_assert(offsetof(gvfg_frame_t, height) == 20);
|
||||
static_assert(offsetof(gvfg_frame_t, pixel_format) == 24);
|
||||
static_assert(offsetof(gvfg_frame_t, bit_depth) == 28);
|
||||
static_assert(offsetof(gvfg_frame_t, frame_id) == 32);
|
||||
|
||||
static_assert(std::is_standard_layout_v<gvfg_frame_layout_t>);
|
||||
static_assert(sizeof(gvfg_frame_layout_t) == 32, "gvfg_frame_layout_t x64 ABI must remain frozen");
|
||||
static_assert(offsetof(gvfg_frame_layout_t, plane_count) == 0);
|
||||
static_assert(offsetof(gvfg_frame_layout_t, plane_data) == 8);
|
||||
static_assert(offsetof(gvfg_frame_layout_t, plane_stride) == 16);
|
||||
static_assert(offsetof(gvfg_frame_layout_t, plane_size) == 24);
|
||||
static_assert(offsetof(gvfg_frame_t, row_stride_bytes) == 24);
|
||||
static_assert(offsetof(gvfg_frame_t, pixel_format) == 28);
|
||||
static_assert(offsetof(gvfg_frame_t, bit_depth) == 32);
|
||||
static_assert(offsetof(gvfg_frame_t, frame_id) == 40);
|
||||
#endif
|
||||
|
||||
void copy_cstr(char *dst, size_t dstSize, const char *src)
|
||||
@@ -173,37 +167,24 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
gvfg_status_t populate_frame_layout(const gvfg_frame_t &frame, gvfg_frame_layout_t &layout)
|
||||
gvfg_status_t native_row_stride_bytes(uint32_t width,
|
||||
pcies2mm_pixel_format_t pixelFormat,
|
||||
int &outStride)
|
||||
{
|
||||
layout.plane_count = 0;
|
||||
std::memset(layout.plane_data, 0, sizeof(layout.plane_data));
|
||||
std::memset(layout.plane_stride, 0, sizeof(layout.plane_stride));
|
||||
std::memset(layout.plane_size, 0, sizeof(layout.plane_size));
|
||||
if (!frame.data || frame.data_size == 0 || frame.width <= 0 || frame.height <= 0)
|
||||
return GVFG_EINVAL;
|
||||
|
||||
const uint64_t width = static_cast<uint64_t>(frame.width);
|
||||
const uint64_t height = static_cast<uint64_t>(frame.height);
|
||||
uint64_t bytesPerPixel = 0;
|
||||
if (frame.pixel_format == GVFG_PIXFMT_YUY2)
|
||||
if (pixelFormat == PCIES2MM_PIXFMT_YUY2)
|
||||
bytesPerPixel = 2;
|
||||
else if (frame.pixel_format == GVFG_PIXFMT_Y210)
|
||||
else if (pixelFormat == PCIES2MM_PIXFMT_Y210)
|
||||
bytesPerPixel = 4;
|
||||
else
|
||||
return GVFG_ENOTSUP;
|
||||
|
||||
uint64_t row = 0;
|
||||
uint64_t size = 0;
|
||||
if (!checked_mul_u64(width, bytesPerPixel, row) ||
|
||||
!checked_mul_u64(row, height, size) ||
|
||||
row > static_cast<uint64_t>(INT_MAX) ||
|
||||
size > frame.data_size)
|
||||
if (!checked_mul_u64(static_cast<uint64_t>(width), bytesPerPixel, row) ||
|
||||
row > static_cast<uint64_t>(INT_MAX))
|
||||
return GVFG_EINVAL;
|
||||
|
||||
layout.plane_count = 1;
|
||||
layout.plane_data[0] = frame.data;
|
||||
layout.plane_stride[0] = static_cast<int>(row);
|
||||
layout.plane_size[0] = size;
|
||||
outStride = static_cast<int>(row);
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -469,6 +450,16 @@ struct gvfg_handle_t
|
||||
out.data_size = static_cast<uint64_t>(frame.data_size_bytes);
|
||||
out.width = static_cast<int>(frame.width);
|
||||
out.height = static_cast<int>(frame.height);
|
||||
const gvfg_status_t strideStatus =
|
||||
native_row_stride_bytes(frame.width, frame.pixel_format, out.row_stride_bytes);
|
||||
if (strideStatus != GVFG_OK)
|
||||
{
|
||||
backend->release_frame(frame);
|
||||
std::lock_guard<std::mutex> lock(frameMutex);
|
||||
heldBackendFrame = {};
|
||||
frameHeld = false;
|
||||
return strideStatus;
|
||||
}
|
||||
out.pixel_format = to_gvfg_pixel_format(frame.pixel_format);
|
||||
out.bit_depth = static_cast<int>(frame.bit_depth);
|
||||
out.frame_id = frame.frame_id;
|
||||
@@ -487,10 +478,17 @@ struct gvfg_handle_t
|
||||
if (!frameHeld)
|
||||
return GVFG_ESTATE;
|
||||
|
||||
int expectedStride = 0;
|
||||
if (native_row_stride_bytes(heldBackendFrame.width,
|
||||
heldBackendFrame.pixel_format,
|
||||
expectedStride) != GVFG_OK)
|
||||
return GVFG_ESTATE;
|
||||
|
||||
if (frameToken.data != heldBackendFrame.data ||
|
||||
frameToken.data_size != static_cast<uint64_t>(heldBackendFrame.data_size_bytes) ||
|
||||
frameToken.width != static_cast<int>(heldBackendFrame.width) ||
|
||||
frameToken.height != static_cast<int>(heldBackendFrame.height) ||
|
||||
frameToken.row_stride_bytes != expectedStride ||
|
||||
frameToken.pixel_format != to_gvfg_pixel_format(heldBackendFrame.pixel_format) ||
|
||||
frameToken.bit_depth != static_cast<int>(heldBackendFrame.bit_depth) ||
|
||||
frameToken.frame_id != heldBackendFrame.frame_id)
|
||||
@@ -772,20 +770,6 @@ extern "C"
|
||||
return handle->readFrame(*out_frame, timeout_ms);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_get_frame_layout(const gvfg_frame_t *frame,
|
||||
gvfg_frame_layout_t *out_layout)
|
||||
{
|
||||
if (!frame || !out_layout)
|
||||
return GVFG_EINVAL;
|
||||
gvfg_frame_layout_t layout{};
|
||||
const gvfg_status_t status = populate_frame_layout(*frame, layout);
|
||||
if (status != GVFG_OK)
|
||||
return status;
|
||||
|
||||
*out_layout = layout;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_release_frame(gvfg_handle handle, const gvfg_frame_t *frame)
|
||||
{
|
||||
if (!handle || !frame)
|
||||
|
||||
Reference in New Issue
Block a user