Add dual-slot font-selectable OSD and privatize playback diagnostics for SDK 3.0.0

- replace the single-overlay API with two independently configured OSD slots per channel, simplify NUL-terminated text/font settings, and add explicit visibility controls that preserve cached glyphs separately from Clear

- enumerate installed Windows font families as an SDK-owned UTF-8 list without callbacks or caller-side free, refresh installed fonts on demand, and use the selected family consistently for measurement and rendering with invalid/missing-font rejection

- retain per-slot YUV and A8 mask caches, blend slot 1 over slot 0 in one GPU dispatch/readback, preserve hidden surfaces, and skip oversized slots independently while capture and the other slot continue

- move detailed playback core statistics to a private Debug-only header/export, remove the public legacy statistics query and compatibility layouts, and retain public preview/delivery statistics

- bump the SDK major version to 3.0.0 for the breaking OSD and playback API changes and document matching header, import-library and runtime deployment requirements

- refresh the capture/playback guides, internal build notes and API reference, document all 51 public Capture/Playback functions, add checked OSD usage examples, and regenerate the branded 23-page PDF

Validation: git diff --cached --check and public API documentation coverage checks passed. The regenerated PDF passed text/content checks and visual review of its rendered pages, including the OSD types, API contracts and examples. Earlier session SDK Release compilation and synthetic YUY2/Y210 blending checks passed; no new build, hardware capture, FPGA upload or long-duration runtime validation was performed during this commit pass.
This commit is contained in:
Mark.lin
2026-10-29 09:02:54 +08:00
parent bfa9397f6b
commit c8b2d0608a
24 changed files with 796 additions and 482 deletions
+64 -20
View File
@@ -1,6 +1,6 @@
# GVFG 客戶 API 使用手冊
本文件說明 SDK 2.1.1 的公開擷取介面 `gvfg_capture.h`。
本文件說明 SDK 3.0.0 的公開擷取介面 `gvfg_capture.h`。
影像/音訊/同步播放另使用 `gvfg_playback.h`,完整流程見
[統一影音播放使用手冊](GVFG_PLAYBACK_API.md)。Capture 與 Playback 是不同 handle 與 DLL。
@@ -122,7 +122,7 @@ Audio 採用相同的 pull 與 ownership 模型:
- 若播放或錄音需要在 release 後繼續使用 PCM,Application 必須先複製。
- Capture 保有自己的交付 buffer;播放副本、queue、同步與輸出由 Playback 管理。
- 使用 Playback 時,submit 已完成複製後即可 release,Demo 不自行實作音訊調速或同步。
- 播放錯誤由 Playback status/last_error 回報,caller 決定停止與重啟。
- 播放錯誤由 Playback API 回傳狀態碼回報,caller 決定停止與重啟。
輸出裝置故障後,應用程式須處理錯誤並決定是否重新啟動播放。
`timeout_ms` 的共同規則:`0` 表示不等待;`GVFG_TIMEOUT_INFINITE` 表示無限等待;
@@ -226,28 +226,69 @@ Zero-copy mode 的 driver lifecycle 由 SDK 管理:open 時 enable,destroy/c
### SDK OSD
OSD 由 `gvfg.dll` 提供。啟用後,
`gvfg_read_channel_frame()` 交付含 OSD 的完整 YUY2/Y210 frame;使用後照常 release。
每個已 open 的 channel 支援兩組獨立 OSD,`osd_index` 為 `0` 或 `1`;
重疊時第 `1` 組蓋在第 `0` 組上。後續 `gvfg_read_channel_frame()` 交付含 OSD 的
YUY2/Y210 frame,使用後照常 release。
- `gvfg_measure_osd_text(text, text_length, font_size_px, &width, &height)`:量測與實際
OSD 相同的單行文字框;不需要 handle,也不會開啟 capture device。
- `gvfg_set_channel_osd(handle, channel, &config)`:啟用或更新已 open channel 的 OSD。
SDK 同步複製文字設定,後續 frame 使用新設定。
- `gvfg_clear_channel_osd(handle, channel)`:停用後續 frame 的 OSD。
- `gvfg_get_osd_fonts(&list)`:重新檢查 Windows 已安裝字型,取得當前可用家族名稱。
不需要 handle、callback 或客戶端 free。`list.count` 是數量,`list.names[i]` 是 UTF-8 名稱。
清單由 SDK 管理,指標有效到下一次呼叫此函式(包含失敗呼叫)或 DLL 卸載為止;
填入 UI 或長期保存時自行複製。呼叫及讀取借用清單須由 caller 序列化。
- `gvfg_measure_osd_text(&config, &width, &height)`:使用設定中的文字、字型與大小量測;
忽略位置與顏色,不需要開啟裝置。
- `gvfg_set_channel_osd(handle, channel, osd_index, &config)`:設定並顯示一組 OSD。
函式返回前同步複製文字與字型名稱;設定失敗保留該組原設定。
- `gvfg_set_channel_osd_visible(handle, channel, osd_index, visible)`:`0` 隱藏、`1` 顯示。
保留設定、YUV 字圖、Mask 與 GPU 資源;單純 Hide/Show 不重新產生字圖。
影像尺寸或格式改變仍可能更新資源。尚未設定或已清除的組別不能直接 Show。
- `gvfg_clear_channel_osd(handle, channel, osd_index)`:停用該組並清除設定與字圖快取;
後續須重新 Set 才能顯示,不影響另一組。
`gvfg_channel_osd_config_t` 可設定文字、`x/y`、`font_size_px` 與 `color_rgb`。
文字為 1–32 個可列印 ASCII 字元(`0x20`–`0x7e`),使用 Arial-preferred normal 字型;
保持單行,不自動換行。字號必須大於 0;SDK 沒有 viewer 的 512 px UI 上限。
顏色為 `0x00RRGGBB`,轉為 BT.709 limited range 後由 GPU 與影片混合。
`gvfg_channel_osd_config_t` 沒有 `struct_size` 或 `text_length`,欄位順序為:
量測的 `width/height` 包含排版空白、glyph overhang 及四邊各 1 px 安全邊,
是保守的完整文字框,不是逐像素緊貼的字形邊界。`x/y` 表示這個框的左上角;
SDK 會依實際 frame 限制在 `0..frame.width - text_width`、
`0..frame.height - text_height`。文字框比 frame 大時,SDK 暫不疊字並繼續擷取;
設定或 frame 尺寸改成可容納後會恢復,不會縮字、截字或換行。
```c
const char *text; /* NUL 結尾,1–32 個可列印 ASCII 字元 */
const char *font_family; /* NUL 結尾的 UTF-8 字型家族名稱,不是檔案路徑 */
uint32_t font_size_px; /* 大於 0 */
uint32_t color_rgb; /* 0x00RRGGBB */
int32_t x;
int32_t y;
```
量測的兩個 output pointer 不可為 NULL;失敗時可寫入的 output 會歸零。
無效文字、長度、字號或 pointer 回傳 `GVFG_EINVAL`;量測失敗回傳 `GVFG_EIO`。
客戶先在 Windows 安裝字型,再重新取得清單,將選到的名稱放入 `font_family`。
只下載但未安裝的字型不會自動列入。字型名稱可為 UTF-8,但 OSD 文字仍只接受
ASCII `0x20`–`0x7e`,不接受中文或換行。清單中的字型不保證含有所有語言的字元。
不存在的字型或無效 UTF-8 名稱回傳 `GVFG_EINVAL`,不靜默改用 Arial。
字型為 normal weight/style/stretch。字級傳給 DirectWrite 的 em 大小,繪製目標固定
96 DPI,因此數值可對應影像像素;不是 Word 的 pt,也不是字形實際墨色高度。
SDK 沒有 viewer 的 512 px UI 上限。顏色轉為 BT.709 limited range,由 GPU 混合。
量測框包含排版空白、glyph overhang 及四邊各 1 px 安全邊,不是 pixel-tight 邊界。
`x/y` 是該框左上角,SDK 依每張影像限制位置,使完整文字框留在影像內。
某組文字框比影像大時,只暫停疊該組;擷取及另一組繼續。設定、尺寸或格式改變後
重新判斷,可容納時恢復,不縮字、截字或換行。
量測失敗時可寫入的尺寸 output 歸零。無效參數、文字、字號、字型或組別回傳
`GVFG_EINVAL`;channel 未 open 或要求顯示未設定的組別回傳 `GVFG_ESTATE`;
其他初始化、量測或資源失敗回傳 `GVFG_EIO`。設定成功不表示已取得的 frame 會被修改。
SDK 不跨 `gvfg_destroy()` 保留設定;viewer 自行保存兩組設定及 visibility,於重新 Start 時還原。
這次是 breaking API 更新:客戶須使用同一版本的 header、import library 與 DLL 重新編譯。
SDK 本身不提供固定角落的預設位置;呼叫端明確傳入 `x/y`。`srcroot` Viewer 的
OSD 1 預設 `(32, 32)`、OSD 2 預設右下角屬於 APP 行為,不是 SDK 自動錨定規則。
### SDK 3.0.0 介面遷移
- OSD 的 `set`/`clear` 新增 `osd_index`;原先的一組設定改為每 channel 兩組。
- `gvfg_channel_osd_config_t` 改用 NUL 結尾字串、移除 `text_length`,新增 `font_family`;
量測函式改收同一份設定,沒有舊版相容入口。
- 公開 Playback 移除 `gvfg_playback_stats_t` 與 `gvfg_playback_get_stats()`。
仍可查詢公開 preview/delivery 統計;詳細核心診斷改為私有的 Debug-only 介面,
不屬於客戶 API,也不提供 Release 匯出或穩定 ABI。
- 字型清單不需要 capture handle。先選擇實際已安裝的字型,再量測/設定 OSD,
並檢查每次 API 回傳值。單一組別的 Set 不提供兩組一起更新的交易保證。
### Audio frame
@@ -265,6 +306,9 @@ SDK 會依實際 frame 限制在 `0..frame.width - text_width`、
### 查詢
- `gvfg_get_version()`:目前載入的 GVFG runtime 版本。
- `gvfg_get_gigabyte_lib_version()`:編譯進該 runtime 的 GigabyteLib 版本;不是 driver
或 FPGA 的執行時版本查詢。兩者回傳靜態字串,不需要 handle 或 free。
- `gvfg_get_channel_signal_status(handle, channel, &status)`:查詢指定 channel 的連線、尺寸、
原生格式與 bit depth。沒有輸入訊號是正常狀態:回傳 `GVFG_OK` 且
`connected == 0`。Channel 尚未 running 時會向 capture backend 更新;running 期間則回傳