Files
GVFG_Standalone/GVFG_SDK/helpers/gvfg_osd/include/gvfg_osd.h
T
Mark.lin c8b2d0608a 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.
2026-10-29 09:02:54 +08:00

97 lines
2.5 KiB
C

#ifndef GVFG_OSD_H
#define GVFG_OSD_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GVFG_OSD_MAX_TEXT_CHARACTERS 32u
typedef void *gvfg_osd_handle;
typedef enum gvfg_osd_status_t
{
GVFG_OSD_OK = 0,
GVFG_OSD_EINVAL = -1,
GVFG_OSD_ENOMEM = -2,
GVFG_OSD_ERENDER = -3
} gvfg_osd_status_t;
typedef enum gvfg_osd_pixel_format_t
{
GVFG_OSD_PIXFMT_YUY2 = 1,
GVFG_OSD_PIXFMT_Y210 = 2
} gvfg_osd_pixel_format_t;
/*
* Generates an off-line OSD surface using the requested installed system font. Text is
* restricted to printable ASCII and at most GVFG_OSD_MAX_TEXT_CHARACTERS
* characters on one line without wrapping. color_rgb is 0xRRGGBB.
* x/y identify the top-left of the conservative measured text box (including
* glyph overhang and a one-pixel guard). They are clamped to keep that box
* inside the frame. Rendering returns EINVAL if the box cannot fit the frame.
* Output YUV uses BT.709 limited range. The mask is one coverage byte per
* pixel: 0 is transparent and 255 is fully covered.
*/
typedef struct gvfg_osd_config_t
{
uint32_t struct_size;
uint32_t width;
uint32_t height;
uint32_t pixel_format;
const char *text;
const char *font_family; /* UTF-8, NUL-terminated. */
uint32_t text_length;
int32_t x;
int32_t y;
uint32_t font_size_px;
uint32_t color_rgb;
} gvfg_osd_config_t;
/* All buffers are caller-owned and are used only for the duration of render. */
typedef struct gvfg_osd_output_t
{
uint32_t struct_size;
void *yuv_data;
uint64_t yuv_size;
uint32_t yuv_stride;
void *mask_data;
uint64_t mask_size;
uint32_t mask_stride;
} gvfg_osd_output_t;
gvfg_osd_status_t gvfg_osd_create(
gvfg_osd_handle *out_handle);
void gvfg_osd_destroy(
gvfg_osd_handle handle);
/* Conservative whole-text bounds in pixels, not pixel-tight raster bounds. */
gvfg_osd_status_t gvfg_osd_measure(
gvfg_osd_handle handle,
const char *text,
uint32_t text_length,
uint32_t font_size_px,
const char *font_family,
uint32_t *out_width,
uint32_t *out_height);
/* SDK-owned snapshot, invalidated by the next call. Serialize call/read access. */
gvfg_osd_status_t gvfg_osd_get_fonts(uint32_t *out_count, const char *const **out_names);
gvfg_osd_status_t gvfg_osd_render(
gvfg_osd_handle handle,
const gvfg_osd_config_t *config,
const gvfg_osd_output_t *output);
const char *gvfg_osd_strerror(
gvfg_osd_status_t status);
#ifdef __cplusplus
}
#endif
#endif