Consolidate playback APIs and add standalone OSD bitmap rendering
- move public PCM, image and presentation types into gvfg_playback.h and remove the separate backend headers from source and installation - keep WASAPI and D3D backends private while preserving the existing public type names, fields and static backend integration - move detailed preview delivery counters into a private header and expose their playback query only through the Debug diagnostics API - retain public preview information and basic presentation statistics, mark EQUEUE_FULL as reserved, and document capacity limits as advanced settings with recommended defaults - refresh customer guides, API reference and error handling for the single-header interface, presentation counter limits and EAUDIO handle-recreation policy - add SDK-owned standalone premultiplied BGRA text rendering with transparent backgrounds, measured dimensions, thread-local snapshot lifetime and validated output bounds Validation: git diff --cached --check passed. Release gvfg_playback and Customer Sample builds, standalone C/C++ header checks, Debug playback syntax checks and Release export inspection passed earlier in this session. Final follow-up changes affect comments and documentation only. No runtime or hardware playback validation was performed. The existing Release gvfg target was also checked and was up to date. OSD rendering changes were source-reviewed; no new bitmap or hardware test was run in this commit pass. Capture debug exports are unchanged.
This commit is contained in:
@@ -11,6 +11,7 @@ EXPORTS
|
||||
gvfg_get_osd_fonts
|
||||
gvfg_set_channel_osd_visible
|
||||
gvfg_measure_osd_text
|
||||
gvfg_render_osd_bgra
|
||||
gvfg_set_channel_osd
|
||||
gvfg_clear_channel_osd
|
||||
gvfg_set_channel_audio_enabled
|
||||
|
||||
@@ -224,6 +224,15 @@ extern "C"
|
||||
const char *const *names; /* SDK-owned UTF-8 family names; do not modify/free. */
|
||||
} gvfg_osd_font_list_t;
|
||||
|
||||
typedef struct gvfg_osd_bitmap_t
|
||||
{
|
||||
const uint8_t *data; /* SDK-owned; do not modify/free. See gvfg_render_osd_bgra(). */
|
||||
uint64_t data_size; /* stride * height bytes. */
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride; /* Byte distance between rows; width * 4. */
|
||||
} gvfg_osd_bitmap_t;
|
||||
|
||||
#define GVFG_OSD_SLOT_COUNT 2u
|
||||
#define GVFG_OSD_MAX_TEXT_CHARACTERS 32u
|
||||
|
||||
@@ -388,6 +397,21 @@ extern "C"
|
||||
GVFG_PARAM_OUT uint32_t *out_width,
|
||||
GVFG_PARAM_OUT uint32_t *out_height);
|
||||
|
||||
/* Render one standalone text bitmap; no device, channel or Start needed.
|
||||
* Same text/font/size limits as measure; ignores x/y. Auto-sized conservative
|
||||
* text box, top-down, left-to-right B,G,R,A bytes with PREMULTIPLIED alpha.
|
||||
* Transparent background; anti-aliased edges retain partial alpha.
|
||||
* Snapshot expires at the next call to this function on the SAME thread
|
||||
* (including failure), thread exit, or DLL unload. Copy before rendering a
|
||||
* second OSD or handing data to another thread/asynchronous FPGA transfer.
|
||||
* Other OSD APIs do not invalidate it. out_bitmap is empty on failure.
|
||||
* Invalid/missing font/input or unsupported dimensions: GVFG_EINVAL;
|
||||
* allocation/render failure: GVFG_EIO. No caller-side free is needed.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_render_osd_bgra(
|
||||
GVFG_PARAM_IN const gvfg_channel_osd_config_t *config,
|
||||
GVFG_PARAM_OUT gvfg_osd_bitmap_t *out_bitmap);
|
||||
|
||||
/* Set and show slot 0 or 1 on an opened channel. Strings are copied before
|
||||
* return; slot 1 is blended over slot 0. Applies to subsequent YUY2/Y210
|
||||
* frames using BT.709 limited range. X/Y are clamped to fit the text box.
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <deque>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@@ -1214,6 +1215,59 @@ extern "C"
|
||||
catch (...) { return GVFG_EIO; }
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_render_osd_bgra(const gvfg_channel_osd_config_t *config,
|
||||
gvfg_osd_bitmap_t *out_bitmap)
|
||||
{
|
||||
thread_local std::vector<uint8_t> pixels;
|
||||
pixels.clear();
|
||||
if (out_bitmap) *out_bitmap = {};
|
||||
if (!config || !config->text || !out_bitmap)
|
||||
return GVFG_EINVAL;
|
||||
const size_t length = strnlen_s(config->text, GVFG_OSD_MAX_TEXT_CHARACTERS + 1u);
|
||||
if (length == 0 || length > GVFG_OSD_MAX_TEXT_CHARACTERS)
|
||||
return GVFG_EINVAL;
|
||||
try
|
||||
{
|
||||
gvfg_osd_handle rawHandle = nullptr;
|
||||
if (gvfg_osd_create(&rawHandle) != GVFG_OSD_OK)
|
||||
return GVFG_EIO;
|
||||
const std::unique_ptr<void, decltype(&gvfg_osd_destroy)> helper(rawHandle, &gvfg_osd_destroy);
|
||||
uint32_t width = 0, height = 0;
|
||||
auto status = gvfg_osd_measure(helper.get(), config->text,
|
||||
static_cast<uint32_t>(length), config->font_size_px, config->font_family,
|
||||
&width, &height);
|
||||
if (status != GVFG_OSD_OK)
|
||||
return status == GVFG_OSD_EINVAL ? GVFG_EINVAL : GVFG_EIO;
|
||||
const uint64_t stride = static_cast<uint64_t>(width) * 4u;
|
||||
// WIC GetDataPointer reports its byte count as UINT.
|
||||
if (width > INT_MAX || height > INT_MAX || stride > UINT_MAX ||
|
||||
stride * height > UINT_MAX ||
|
||||
stride * height > (std::numeric_limits<size_t>::max)())
|
||||
return GVFG_EINVAL;
|
||||
pixels.resize(static_cast<size_t>(stride * height));
|
||||
gvfg_osd_config_t render{};
|
||||
render.struct_size = sizeof(render);
|
||||
render.width = width;
|
||||
render.height = height;
|
||||
render.text = config->text;
|
||||
render.font_family = config->font_family;
|
||||
render.text_length = static_cast<uint32_t>(length);
|
||||
render.font_size_px = config->font_size_px;
|
||||
render.color_rgb = config->color_rgb;
|
||||
status = gvfg_osd_render_bgra(helper.get(), &render, pixels.data(), pixels.size(),
|
||||
static_cast<uint32_t>(stride));
|
||||
if (status != GVFG_OSD_OK)
|
||||
return status == GVFG_OSD_EINVAL ? GVFG_EINVAL : GVFG_EIO;
|
||||
out_bitmap->data = pixels.data();
|
||||
out_bitmap->data_size = pixels.size();
|
||||
out_bitmap->width = width;
|
||||
out_bitmap->height = height;
|
||||
out_bitmap->stride = static_cast<uint32_t>(stride);
|
||||
return GVFG_OK;
|
||||
}
|
||||
catch (...) { return GVFG_EIO; }
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_osd(gvfg_handle handle, int channel_index,
|
||||
uint32_t osd_index, const gvfg_channel_osd_config_t *config)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user