Add frame layout API and split conversion helper
- Add gvfg_get_frame_layout() and gvfg_frame_layout_t for per-plane frame metadata without extending gvfg_frame_t - Update gvfg_preview to consume gvfg_get_frame_layout() before falling back to width-derived stride - Add optional gvfg_convert helper DLL for explicit snapshot/export conversion outside the core capture API - Support YUY2/Y210 conversion to BGRA8, RGB48, and RGBA64 helper frames - Add SAL annotations to public capture, preview, convert, and debug headers - Update Traditional Chinese API/package documentation for core, preview, and convert helper split
This commit is contained in:
+223
-56
@@ -1,13 +1,13 @@
|
||||
# GVFG Customer API
|
||||
# GVFG 客戶端 API
|
||||
|
||||
This document describes the customer-facing GVFG capture API in
|
||||
`sdk/gvfg/include/gvfg_capture.h`.
|
||||
本文說明客戶端使用的 GVFG capture API,主要 public header 是
|
||||
`sdk/gvfg/include/gvfg_capture.h`。
|
||||
|
||||
The customer SDK is capture-only. It does not expose SDK-managed preview,
|
||||
driver registers, DMA internals, or FPGA debug controls. Preview rendering is
|
||||
handled by internal applications or tools on top of frames returned by the SDK.
|
||||
Customer SDK 的 core API 只負責 capture。它不 expose SDK-managed preview、
|
||||
driver registers、DMA internals 或 FPGA debug controls。Preview rendering、
|
||||
snapshot conversion 這類功能放在 helper DLL,使用者需要時再另外 link。
|
||||
|
||||
## Basic Flow
|
||||
## 基本流程
|
||||
|
||||
```text
|
||||
gvfg_enumerate_devices
|
||||
@@ -23,12 +23,12 @@ gvfg_enumerate_devices
|
||||
-> gvfg_destroy
|
||||
```
|
||||
|
||||
## Threading
|
||||
## 執行緒模型
|
||||
|
||||
The frame API is pull-based. The SDK does not start a customer frame thread or
|
||||
preview thread from the public API layer.
|
||||
Frame API 是 pull-based。Public API layer 不會替 customer 啟動 frame thread
|
||||
或 preview thread。
|
||||
|
||||
Applications decide where to call `gvfg_read_frame()`:
|
||||
Application 自己決定在哪裡呼叫 `gvfg_read_frame()`:
|
||||
|
||||
```text
|
||||
UI app:
|
||||
@@ -40,25 +40,25 @@ console/service app:
|
||||
call gvfg_read_frame() directly from its processing loop
|
||||
```
|
||||
|
||||
The backend may still use internal driver I/O workers while capture is running.
|
||||
Those are implementation details behind `gvfg.dll`.
|
||||
Backend 在 capture running 時可以有自己的 internal driver I/O workers,但那是
|
||||
`gvfg.dll` 背後的 implementation detail。
|
||||
|
||||
## Frame Ownership
|
||||
## Frame 所有權
|
||||
|
||||
`gvfg_read_frame()` returns one SDK-owned frame buffer.
|
||||
`gvfg_read_frame()` 會回傳一個 SDK-owned frame buffer。
|
||||
|
||||
Rules:
|
||||
規則:
|
||||
|
||||
- `frame.data` is valid until `gvfg_release_frame()` is called.
|
||||
- A handle may hold only one frame at a time.
|
||||
- If the application needs the data after release, it must copy the frame.
|
||||
- `gvfg_stop()` invalidates any unreleased frame.
|
||||
- `frame.data` 在呼叫 `gvfg_release_frame()` 前有效。
|
||||
- 同一個 handle 一次最多只能 hold 一個 frame。
|
||||
- Application 如果需要在 release 後繼續使用資料,必須自己 copy frame。
|
||||
- `gvfg_stop()` 會讓尚未 release 的 frame 失效。
|
||||
|
||||
## Public Types
|
||||
## 公開型別
|
||||
|
||||
### `gvfg_handle`
|
||||
|
||||
Opaque session handle.
|
||||
Opaque session handle。
|
||||
|
||||
```c
|
||||
typedef struct gvfg_handle_t *gvfg_handle;
|
||||
@@ -66,7 +66,7 @@ typedef struct gvfg_handle_t *gvfg_handle;
|
||||
|
||||
### `gvfg_status_t`
|
||||
|
||||
Common return status.
|
||||
共用 return status。
|
||||
|
||||
```c
|
||||
typedef enum
|
||||
@@ -83,11 +83,11 @@ typedef enum
|
||||
|
||||
### `gvfg_device_info_t`
|
||||
|
||||
Device entry returned by `gvfg_enumerate_devices()`.
|
||||
`gvfg_enumerate_devices()` 回傳的 device entry。
|
||||
|
||||
### `gvfg_signal_status_t`
|
||||
|
||||
Customer-readable input signal status:
|
||||
Customer-readable input signal status:
|
||||
|
||||
- width / height
|
||||
- video format text
|
||||
@@ -95,13 +95,12 @@ Customer-readable input signal status:
|
||||
- bit depth
|
||||
- SDI / HDMI lock status
|
||||
|
||||
Raw FPGA values, register-like values, and validity masks are internal debug
|
||||
data and are available only through `gvfg_debug.h` in the internal debug
|
||||
package.
|
||||
Raw FPGA values、register-like values、validity masks 都是 internal debug data,
|
||||
只應透過 internal debug package 裡的 `gvfg_debug.h` 提供。
|
||||
|
||||
### `gvfg_frame_t`
|
||||
|
||||
Frame returned by `gvfg_read_frame()`.
|
||||
`gvfg_read_frame()` 回傳的 frame descriptor。
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
@@ -116,21 +115,110 @@ typedef struct
|
||||
} gvfg_frame_t;
|
||||
```
|
||||
|
||||
### `gvfg_frame_layout_t`
|
||||
|
||||
由 `gvfg_get_frame_layout()` 回傳的 optional per-plane layout。
|
||||
|
||||
```c
|
||||
typedef struct
|
||||
{
|
||||
uint32_t struct_size;
|
||||
uint32_t layout_flags;
|
||||
int row_bytes;
|
||||
int plane_count;
|
||||
const void *plane_data[GVFG_MAX_PLANES];
|
||||
int plane_stride[GVFG_MAX_PLANES];
|
||||
uint64_t plane_size[GVFG_MAX_PLANES];
|
||||
uint64_t plane_offset[GVFG_MAX_PLANES];
|
||||
uint64_t reserved[8];
|
||||
} 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。
|
||||
|
||||
`gvfg_frame_t::data` 和 `data_size` 仍然描述整個 native buffer。`plane_offset[]`
|
||||
是從 `data` 開始算的 byte offset,未來 driver 如果回報 padded 或 non-default
|
||||
DMA layout,也可以在不改 `gvfg_frame_t` 的情況下支援。
|
||||
|
||||
`layout_flags` 是 `gvfg_frame_layout_flags_t` bitmask。目前 backend 會設
|
||||
`GVFG_FRAME_LAYOUT_CONTIGUOUS` 和 `GVFG_FRAME_LAYOUT_SDK_DERIVED`,表示 planes
|
||||
位在同一個 native DMA buffer 裡,而且 pitch 是 SDK 依照 known native format
|
||||
推導出來的。Application 必須忽略 `reserved[]`。
|
||||
|
||||
目前 tightly packed layout:
|
||||
|
||||
- `YUY2` / `UYVY`:one plane,`plane_stride[0] = width * 2`。
|
||||
- `Y210`:one plane,`plane_stride[0] = width * 4`。
|
||||
- `RGB24`:one plane,`plane_stride[0] = width * 3`。
|
||||
- `YUV444`:one plane,8-bit 時 `width * 3`,>8-bit 時 `width * 6`。
|
||||
- `NV12`:two planes,Y 後接 interleaved UV,
|
||||
`plane_stride[0] = plane_stride[1] = width`。
|
||||
- `P010`:two planes,Y 後接 interleaved UV,
|
||||
`plane_stride[0] = plane_stride[1] = width * 2`。
|
||||
|
||||
### `gvfg_convert_frame`
|
||||
|
||||
Optional `gvfg_convert.dll` 使用的 helper-owned destination frame。
|
||||
|
||||
```c
|
||||
typedef struct gvfg_convert_frame_t *gvfg_convert_frame;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t struct_size;
|
||||
int width;
|
||||
int height;
|
||||
int pixel_format;
|
||||
int row_bytes;
|
||||
uint32_t flags;
|
||||
uint32_t reserved0;
|
||||
uint64_t data_size;
|
||||
uint64_t reserved[8];
|
||||
} gvfg_convert_frame_desc_t;
|
||||
```
|
||||
|
||||
這個設計接近 Blackmagic-style conversion:application 先建立 destination
|
||||
frame,再明確把 source frame convert 進去。Core capture API 仍然回傳
|
||||
hardware/native buffer,不會在 `gvfg_read_frame()` 裡偷偷轉格式。
|
||||
|
||||
Snapshot 用途可以把 `width`、`height`、`row_bytes` 設成 0,讓 helper 依照
|
||||
captured source frame 自動決定大小。
|
||||
|
||||
第一版 destination formats:
|
||||
|
||||
- `GVFG_CONVERT_FMT_BGRA8`:8-bit BGRA,alpha 255。
|
||||
- `GVFG_CONVERT_FMT_RGB48`:16-bit RGB container,適合 10-bit-friendly snapshot。
|
||||
- `GVFG_CONVERT_FMT_RGBA64`:16-bit RGBA container,alpha 65535。
|
||||
|
||||
第一版 conversions:
|
||||
|
||||
- `YUY2 -> BGRA8 / RGB48 / RGBA64`
|
||||
- `Y210 -> BGRA8 / RGB48 / RGBA64`
|
||||
|
||||
Conversion 使用 BT.709 limited-range YUV to RGB,和 preview path 對齊。其他
|
||||
source 或 destination format 會回傳 `GVFG_ENOTSUP`。
|
||||
|
||||
### `gvfg_event_t`
|
||||
|
||||
Capture event returned by `gvfg_poll_event()`.
|
||||
`gvfg_poll_event()` 回傳的 capture event。
|
||||
|
||||
Customer events are driver-neutral:
|
||||
Customer event 保持 driver-neutral:
|
||||
|
||||
- `GVFG_EVENT_PLUG_IN`
|
||||
- `GVFG_EVENT_PLUG_OUT`
|
||||
- `GVFG_EVENT_CAPTURE_PAUSED`
|
||||
- `GVFG_EVENT_CAPTURE_RESUMED`
|
||||
|
||||
Frame interrupts, IRQ bit numbers, and IRQ masks are internal details and are
|
||||
not exposed through `gvfg_capture.h`.
|
||||
Frame interrupts、IRQ bit numbers、IRQ masks 都是 internal details,不應出現在
|
||||
`gvfg_capture.h`。
|
||||
|
||||
## Main APIs
|
||||
## 主要 API
|
||||
|
||||
Public header 內的 function prototype 會使用 Windows SAL annotation,例如
|
||||
`_In_`、`_Out_`、`_Inout_` 來標示參數方向。以下文件中的 prototype 為了閱讀性會省略
|
||||
SAL;實際呼叫 API 時,application 不需要也不能額外傳入這些 annotation。
|
||||
|
||||
### `gvfg_enumerate_devices`
|
||||
|
||||
@@ -138,7 +226,7 @@ not exposed through `gvfg_capture.h`.
|
||||
int gvfg_enumerate_devices(gvfg_device_info_t *out_devices, int max_devices);
|
||||
```
|
||||
|
||||
Enumerates GVFG capture devices. Pass `NULL, 0` to query the device count.
|
||||
列舉 GVFG capture devices。傳 `NULL, 0` 可以只查詢 device count。
|
||||
|
||||
### `gvfg_create` / `gvfg_destroy`
|
||||
|
||||
@@ -147,8 +235,7 @@ gvfg_status_t gvfg_create(gvfg_handle *out_handle);
|
||||
gvfg_status_t gvfg_destroy(gvfg_handle handle);
|
||||
```
|
||||
|
||||
Creates or destroys a session handle. Destroying a running handle stops capture
|
||||
first.
|
||||
建立或銷毀 session handle。銷毀 running handle 時會先 stop capture。
|
||||
|
||||
### `gvfg_open`
|
||||
|
||||
@@ -156,7 +243,7 @@ first.
|
||||
gvfg_status_t gvfg_open(gvfg_handle handle, int device_index);
|
||||
```
|
||||
|
||||
Opens a device by index from `gvfg_enumerate_devices()`.
|
||||
用 `gvfg_enumerate_devices()` 得到的 device index 開啟 device。
|
||||
|
||||
### `gvfg_start` / `gvfg_stop`
|
||||
|
||||
@@ -165,8 +252,7 @@ gvfg_status_t gvfg_start(gvfg_handle handle);
|
||||
gvfg_status_t gvfg_stop(gvfg_handle handle);
|
||||
```
|
||||
|
||||
Starts or stops capture. After `gvfg_start()`, call `gvfg_read_frame()` to
|
||||
receive frames.
|
||||
開始或停止 capture。`gvfg_start()` 成功後,用 `gvfg_read_frame()` 取 frame。
|
||||
|
||||
### `gvfg_read_frame`
|
||||
|
||||
@@ -176,13 +262,95 @@ gvfg_status_t gvfg_read_frame(gvfg_handle handle,
|
||||
uint32_t timeout_ms);
|
||||
```
|
||||
|
||||
Reads one frame. Use `timeout_ms == 0` to wait indefinitely.
|
||||
讀取一個 frame。`timeout_ms == 0` 表示 indefinite wait。
|
||||
|
||||
Returns:
|
||||
回傳值:
|
||||
|
||||
- `GVFG_OK` when a frame is available.
|
||||
- `GVFG_ETIMEOUT` when no frame arrives before the timeout.
|
||||
- `GVFG_ESTATE` when capture is not running or a previous frame is still held.
|
||||
- `GVFG_OK`:取得 frame。
|
||||
- `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。
|
||||
|
||||
呼叫前先初始化 `out_layout->struct_size`:
|
||||
|
||||
```c
|
||||
gvfg_frame_layout_t layout = {};
|
||||
layout.struct_size = sizeof(layout);
|
||||
gvfg_get_frame_layout(&frame, &layout);
|
||||
```
|
||||
|
||||
回傳的 `plane_data[]` pointers 只在 `gvfg_release_frame()` 前有效。
|
||||
|
||||
### `gvfg_convert_create_frame` / `gvfg_convert_destroy_frame`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_convert_create_frame(const gvfg_convert_frame_desc_t *desc,
|
||||
gvfg_convert_frame *out_frame);
|
||||
gvfg_status_t gvfg_convert_destroy_frame(gvfg_convert_frame frame);
|
||||
```
|
||||
|
||||
建立或銷毀 helper-owned destination frame。Caller 主要設定
|
||||
`desc.pixel_format`;`width`、`height`、`row_bytes` 可以是 0,讓
|
||||
`gvfg_convert_frame_from_capture()` 依照 source frame 自動 configure。
|
||||
|
||||
### `gvfg_convert_frame_from_capture`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_convert_frame_from_capture(const gvfg_frame_t *src,
|
||||
gvfg_convert_frame dst_frame);
|
||||
```
|
||||
|
||||
把 captured native frame 轉進 helper-owned destination frame。這不會改變
|
||||
capture output format。
|
||||
|
||||
Snapshot buffer flow 範例:
|
||||
|
||||
```c
|
||||
#include <gvfg_capture.h>
|
||||
#include <gvfg_convert.h>
|
||||
|
||||
gvfg_frame_t frame = {};
|
||||
if (gvfg_read_frame(h, &frame, 1000) == GVFG_OK) {
|
||||
gvfg_convert_frame_desc_t desc = {};
|
||||
desc.struct_size = sizeof(desc);
|
||||
desc.pixel_format = GVFG_CONVERT_FMT_RGB48;
|
||||
|
||||
gvfg_convert_frame image = NULL;
|
||||
if (gvfg_convert_create_frame(&desc, &image) == GVFG_OK &&
|
||||
gvfg_convert_frame_from_capture(&frame, image) == 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_destroy_frame(image);
|
||||
gvfg_release_frame(h, &frame);
|
||||
}
|
||||
```
|
||||
|
||||
### `gvfg_convert_get_frame_desc` / `gvfg_convert_get_buffer` / `gvfg_convert_get_layout`
|
||||
|
||||
```c
|
||||
gvfg_status_t gvfg_convert_get_frame_desc(gvfg_convert_frame frame,
|
||||
gvfg_convert_frame_desc_t *out_desc);
|
||||
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。
|
||||
|
||||
### `gvfg_release_frame`
|
||||
|
||||
@@ -191,7 +359,7 @@ gvfg_status_t gvfg_release_frame(gvfg_handle handle,
|
||||
const gvfg_frame_t *frame);
|
||||
```
|
||||
|
||||
Releases the frame returned by `gvfg_read_frame()`.
|
||||
Release `gvfg_read_frame()` 回傳的 frame。
|
||||
|
||||
### `gvfg_poll_event`
|
||||
|
||||
@@ -201,7 +369,7 @@ gvfg_status_t gvfg_poll_event(gvfg_handle handle,
|
||||
uint32_t timeout_ms);
|
||||
```
|
||||
|
||||
Polls one event. Use `timeout_ms == 0` for a non-blocking poll.
|
||||
Poll 一個 event。`timeout_ms == 0` 表示 non-blocking poll。
|
||||
|
||||
### `gvfg_get_signal_status`
|
||||
|
||||
@@ -210,7 +378,7 @@ gvfg_status_t gvfg_get_signal_status(gvfg_handle handle,
|
||||
gvfg_signal_status_t *out_status);
|
||||
```
|
||||
|
||||
Queries current input signal metadata.
|
||||
查詢目前 input signal metadata。
|
||||
|
||||
### `gvfg_get_runtime_info`
|
||||
|
||||
@@ -219,14 +387,13 @@ gvfg_status_t gvfg_get_runtime_info(gvfg_handle handle,
|
||||
gvfg_runtime_info_t *out_info);
|
||||
```
|
||||
|
||||
Queries current signal status, last read frame format, FPS, and delivered frame
|
||||
count.
|
||||
查詢目前 signal status、last read frame format、FPS、delivered frame count。
|
||||
|
||||
## Preview Boundary
|
||||
## Preview 邊界
|
||||
|
||||
Preview is not part of the core capture SDK API.
|
||||
Preview 不是 core capture SDK API 的一部分。
|
||||
|
||||
Applications have two choices after `gvfg_read_frame()` returns a frame:
|
||||
Application 在 `gvfg_read_frame()` 回傳 frame 後有幾種選擇:
|
||||
|
||||
```text
|
||||
gvfg_read_frame
|
||||
@@ -235,6 +402,6 @@ gvfg_read_frame
|
||||
-> gvfg_release_frame
|
||||
```
|
||||
|
||||
Customer demo source may include `gvfg_preview.h` and link `gvfg_preview.dll`
|
||||
when it needs a simple display path. The preview helper source remains private;
|
||||
customer code only sees the helper API and binary.
|
||||
Customer demo source 需要簡單 display path 時,可以 include `gvfg_preview.h`
|
||||
並 link `gvfg_preview.dll`。Preview helper source 保持 private;customer code
|
||||
只看到 helper API 和 binary。
|
||||
|
||||
+70
-42
@@ -1,11 +1,11 @@
|
||||
# GVFG Internal Notes
|
||||
|
||||
This document is the internal engineering map for the standalone GVFG SDK.
|
||||
Customer-facing API details live in `docs/GVFG_CUSTOMER_API.md`.
|
||||
這份文件是 standalone GVFG SDK 的內部工程地圖。客戶端 API 細節請看
|
||||
`docs/GVFG_CUSTOMER_API.md`。
|
||||
|
||||
## Current Direction
|
||||
## 目前方向
|
||||
|
||||
GVFG is split into three clear pieces:
|
||||
GVFG 目前切成幾個清楚的模組:
|
||||
|
||||
```text
|
||||
sdk/gvfg/
|
||||
@@ -16,15 +16,19 @@ helpers/gvfg_preview/
|
||||
gvfg_preview.dll
|
||||
optional display helper; renders gvfg_frame_t after gvfg_read_frame()
|
||||
|
||||
helpers/gvfg_convert/
|
||||
gvfg_convert.dll
|
||||
optional snapshot/export helper; converts native capture frames on request
|
||||
|
||||
samples/gvfg_qt_preview/
|
||||
internal debug Qt tool
|
||||
uses gvfg.dll + gvfg_preview.dll + gvfg_debug.h
|
||||
```
|
||||
|
||||
The core SDK must stay driver-neutral from the customer's point of view.
|
||||
XDMA, IRQ, DMA counters, raw FPGA values, and backend details are internal.
|
||||
從 customer 角度看,core SDK 必須維持 driver-neutral。XDMA、IRQ、DMA counters、
|
||||
raw FPGA values、backend details 都是 internal。
|
||||
|
||||
## Architecture
|
||||
## 架構
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
@@ -38,6 +42,11 @@ flowchart TD
|
||||
PreviewPipe["private D3D preview pipeline"]
|
||||
end
|
||||
|
||||
subgraph Convert["Optional Convert Helper: gvfg_convert.dll"]
|
||||
ConvertApi["helpers/gvfg_convert/include/gvfg_convert.h"]
|
||||
ConvertPipe["private CPU/GPU conversion path"]
|
||||
end
|
||||
|
||||
subgraph SDK["Core SDK: gvfg.dll"]
|
||||
CaptureApi["sdk/gvfg/include/gvfg_capture.h"]
|
||||
DebugApi["sdk/gvfg/include/gvfg_debug.h\ninternal only"]
|
||||
@@ -52,10 +61,13 @@ flowchart TD
|
||||
|
||||
CustomerApp --> CaptureApi
|
||||
CustomerApp -. optional display .-> PreviewApi
|
||||
CustomerApp -. optional snapshot .-> ConvertApi
|
||||
QtApp --> CaptureApi
|
||||
QtApp --> DebugApi
|
||||
QtApp --> PreviewApi
|
||||
PreviewApi --> PreviewPipe
|
||||
ConvertApi --> ConvertPipe
|
||||
ConvertApi --> CaptureApi
|
||||
CaptureApi --> Facade
|
||||
DebugApi --> Facade
|
||||
Facade --> Xdma
|
||||
@@ -63,9 +75,9 @@ flowchart TD
|
||||
Workers --> Ring
|
||||
```
|
||||
|
||||
## Capture Flow
|
||||
## Capture 流程
|
||||
|
||||
The capture API follows an FFmpeg-style pull model:
|
||||
Capture API 採 FFmpeg-style pull model:
|
||||
|
||||
```text
|
||||
gvfg_enumerate_devices
|
||||
@@ -81,19 +93,27 @@ gvfg_enumerate_devices
|
||||
-> gvfg_destroy
|
||||
```
|
||||
|
||||
`gvfg.dll` does not own the application's public read thread. UI apps should
|
||||
create their own worker thread and call `gvfg_read_frame()` there.
|
||||
`gvfg.dll` 不擁有 application 的 public read thread。UI app 應該自己建立 worker
|
||||
thread,並在那個 thread 呼叫 `gvfg_read_frame()`。
|
||||
|
||||
## Frame Ownership
|
||||
## Frame 所有權
|
||||
|
||||
- `gvfg_read_frame()` returns one SDK-owned frame buffer.
|
||||
- `frame.data` remains valid until `gvfg_release_frame()` is called.
|
||||
- A handle may hold only one frame at a time.
|
||||
- If the application needs data after release, it must copy the frame.
|
||||
- `gvfg_preview_render_frame()` is synchronous and should be called before
|
||||
`gvfg_release_frame()`.
|
||||
- `gvfg_read_frame()` 回傳一個 SDK-owned frame buffer。
|
||||
- `frame.data` 在 `gvfg_release_frame()` 前有效。
|
||||
- `gvfg_frame_t` 要保持 ABI-stable;不要為了 layout 直接 append fields。
|
||||
- `gvfg_get_frame_layout()` 回傳 SDK-filled layout metadata:`plane_data`、
|
||||
`plane_stride`、`plane_size`、`plane_offset`。目前 XDMA backend 先用
|
||||
width/height/format 推導 tightly packed layout;未來 driver 如果能回報真實
|
||||
pitch 或 plane offsets,應該更新 layout query path,而不是改既有 frame struct。
|
||||
- `gvfg_preview.dll` 應優先吃 `gvfg_get_frame_layout()`;layout query 不可用時才
|
||||
fallback 到 width-derived stride。
|
||||
- `gvfg_convert.dll` 負責 explicit snapshot/export conversion。不要把 color
|
||||
conversion、image export、GPU conversion policy 搬進 `gvfg.dll`。
|
||||
- 同一個 handle 一次最多 hold 一個 frame。
|
||||
- Application 如果 release 後還要用 data,必須自己 copy frame。
|
||||
- `gvfg_preview_render_frame()` 是 synchronous,應該在 `gvfg_release_frame()` 前呼叫。
|
||||
|
||||
Typical two-way use:
|
||||
Typical two-way use:
|
||||
|
||||
```text
|
||||
gvfg_read_frame
|
||||
@@ -102,9 +122,9 @@ gvfg_read_frame
|
||||
-> gvfg_release_frame
|
||||
```
|
||||
|
||||
## Event Boundary
|
||||
## Event 邊界
|
||||
|
||||
Customer events stay driver-neutral:
|
||||
Customer event 保持 driver-neutral:
|
||||
|
||||
```text
|
||||
GVFG_EVENT_PLUG_IN
|
||||
@@ -113,20 +133,21 @@ GVFG_EVENT_CAPTURE_PAUSED
|
||||
GVFG_EVENT_CAPTURE_RESUMED
|
||||
```
|
||||
|
||||
Video IRQ handling is internal to `sdk/gvfg/src/backend/xdma`. IRQ bit numbers,
|
||||
IRQ masks, DMA counters, and raw FPGA register-like values should not appear in
|
||||
`gvfg_capture.h`.
|
||||
Video IRQ handling 是 `sdk/gvfg/src/backend/xdma` 內部細節。IRQ bit numbers、
|
||||
IRQ masks、DMA counters、raw FPGA register-like values 不應出現在
|
||||
`gvfg_capture.h`。
|
||||
|
||||
## API Surfaces
|
||||
|
||||
Customer/demo visible:
|
||||
Customer/demo 可見:
|
||||
|
||||
```text
|
||||
include/gvfg_capture.h
|
||||
include/gvfg_preview.h when display helper is used
|
||||
include/gvfg_convert.h when snapshot/export conversion is used
|
||||
```
|
||||
|
||||
Internal debug only:
|
||||
Internal debug only:
|
||||
|
||||
```text
|
||||
include/gvfg_debug.h
|
||||
@@ -139,29 +160,32 @@ PDB symbols
|
||||
internal diagnostic tools
|
||||
```
|
||||
|
||||
## Package Split
|
||||
## Package 切分
|
||||
|
||||
### Demo / Customer Package
|
||||
|
||||
Include:
|
||||
Include:
|
||||
|
||||
```text
|
||||
include/gvfg_capture.h
|
||||
include/gvfg_preview.h when the demo shows video
|
||||
include/gvfg_convert.h when the demo exports snapshots
|
||||
lib/gvfg.lib
|
||||
lib/gvfg_preview.lib when the demo shows video
|
||||
lib/gvfg_convert.lib when the demo exports snapshots
|
||||
bin/gvfg.dll
|
||||
bin/gvfg_preview.dll when the demo shows video
|
||||
bin/gvfg_convert.dll when the demo exports snapshots
|
||||
samples/customer-facing source
|
||||
docs/GVFG_CUSTOMER_API.md
|
||||
```
|
||||
|
||||
Do not include:
|
||||
Do not include:
|
||||
|
||||
```text
|
||||
include/gvfg_debug.h
|
||||
SDK source
|
||||
preview helper source
|
||||
helper source
|
||||
XDMA backend headers
|
||||
PDB symbols
|
||||
register / DMA / IRQ debug docs
|
||||
@@ -170,16 +194,19 @@ internal diagnostic tools
|
||||
|
||||
### Internal Debug Package
|
||||
|
||||
Include:
|
||||
Include:
|
||||
|
||||
```text
|
||||
include/gvfg_capture.h
|
||||
include/gvfg_debug.h
|
||||
include/gvfg_preview.h
|
||||
include/gvfg_convert.h
|
||||
lib/gvfg.lib
|
||||
lib/gvfg_preview.lib
|
||||
lib/gvfg_convert.lib
|
||||
bin/gvfg.dll
|
||||
bin/gvfg_preview.dll
|
||||
bin/gvfg_convert.dll
|
||||
bin/gvfg_qt_preview.exe
|
||||
PDB symbols
|
||||
internal debug notes
|
||||
@@ -187,41 +214,42 @@ internal debug notes
|
||||
|
||||
### Full Release Package
|
||||
|
||||
The full application release can use `gvfg.dll` and `gvfg_preview.dll`, plus
|
||||
licensing and closed-source application integration. Do not use the full release
|
||||
package as the daily driver/FPGA bring-up vehicle.
|
||||
Full application release 可以使用 `gvfg.dll`、`gvfg_preview.dll` 和
|
||||
`gvfg_convert.dll`,再加上 licensing 與 closed-source application integration。
|
||||
不要把 full release package 當成 daily driver/FPGA bring-up vehicle。
|
||||
|
||||
## Build
|
||||
|
||||
Top-level CMake builds the core SDK, preview helper, and optional sample:
|
||||
Top-level CMake 會 build core SDK、helpers 和 optional sample:
|
||||
|
||||
```text
|
||||
BUILD_GVFG_SAMPLES=ON
|
||||
GVFG_XDMA_DEBUG_LOG=OFF
|
||||
```
|
||||
|
||||
Outputs:
|
||||
輸出產物:
|
||||
|
||||
```text
|
||||
bin/gvfg.dll
|
||||
bin/gvfg_preview.dll
|
||||
bin/gvfg_convert.dll
|
||||
lib/gvfg.lib
|
||||
lib/gvfg_preview.lib
|
||||
lib/gvfg_convert.lib
|
||||
bin/gvfg_qt_preview.exe
|
||||
```
|
||||
|
||||
`GVFG_XDMA_DEBUG_LOG=ON` enables verbose XDMA flow logging in the internal
|
||||
backend.
|
||||
`GVFG_XDMA_DEBUG_LOG=ON` 會打開 internal backend 的 verbose XDMA flow logging。
|
||||
|
||||
## Draw.io Files
|
||||
|
||||
Keep draw.io files for visual discussions:
|
||||
保留 draw.io files 方便討論圖:
|
||||
|
||||
```text
|
||||
docs/GVFG_ARCHITECTURE_OVERVIEW.drawio
|
||||
docs/GVFG_DMA_RING_DATA_FLOW.drawio
|
||||
```
|
||||
|
||||
When code changes only affect API order, package boundaries, or module
|
||||
ownership, update this Markdown file. Update draw.io only when the deeper data
|
||||
flow or frame ownership diagram changes.
|
||||
如果 code change 只影響 API order、package boundary 或 module ownership,更新這份
|
||||
Markdown 即可。只有 deeper data flow 或 frame ownership diagram 改變時,才需要更新
|
||||
draw.io。
|
||||
|
||||
Reference in New Issue
Block a user