Release SDK 1.1.0 with bounded OSD placement and delivery diagnostics
- expose stateless OSD text measurement and use matching single-line glyph bounds, overhang, and guard pixels to clamp placement within each frame without wrapping or truncating oversized text - reuse the held SDK-owned capture buffer for non-zero-copy OSD, preserve its stride and size, and overwrite only the GPU-processed rectangle while retaining the backend hold until application release - add internal timed and profiled frame reads with acquisition timing after the frame event wait, per-stage OSD wall times, and unchanged public frame timestamps and existing timing layouts - isolate driver-buffer writes behind a default-OFF experimental build option, validate committed writable pages before ROI writes, retain independent-output fallback, and expose per-frame rejection details without changing vendor release rules - bump the SDK version from 1.0.2 to 1.1.0 and document minor-version feature releases, patch-version bug fixes, placement behavior, ownership, diagnostics, and experimental DMA limitations Validation: git diff --cached --check passed before commit. No SDK rebuild or Customer Demo regression suite was run in this commit pass. User-provided capture logs exercised delivery diagnostics and showed PAGE_READONLY fallback; successful driver-buffer writes and DMA ownership safety remain unverified.
This commit is contained in:
@@ -46,6 +46,9 @@ target_compile_definitions(gvfg PRIVATE
|
||||
target_compile_definitions(gvfg PRIVATE
|
||||
GVFG_INTERNAL_DIAGNOSTICS=$<IF:$<CONFIG:Debug>,1,0>
|
||||
)
|
||||
if (GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE)
|
||||
target_compile_definitions(gvfg PRIVATE GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE=1)
|
||||
endif()
|
||||
|
||||
target_link_libraries(gvfg PRIVATE
|
||||
gvfg_osd_core
|
||||
|
||||
@@ -8,6 +8,7 @@ EXPORTS
|
||||
gvfg_set_channel_zero_copy_enabled
|
||||
gvfg_get_channel_zero_copy_enabled
|
||||
gvfg_set_channel_video_format
|
||||
gvfg_measure_osd_text
|
||||
gvfg_set_channel_osd
|
||||
gvfg_clear_channel_osd
|
||||
gvfg_set_channel_audio_enabled
|
||||
@@ -33,6 +34,10 @@ EXPORTS
|
||||
gvfg_strerror
|
||||
gvfg_get_channel_last_sdk_error_detail
|
||||
gvfg_debug_get_channel_backend_stats
|
||||
gvfg_debug_read_channel_frame_timed
|
||||
gvfg_debug_read_channel_frame_profiled
|
||||
gvfg_debug_get_channel_osd_experiment_flags
|
||||
gvfg_debug_get_channel_osd_page_check
|
||||
gvfg_debug_get_device_capabilities
|
||||
gvfg_debug_read_register
|
||||
gvfg_debug_write_register
|
||||
|
||||
@@ -216,8 +216,8 @@ extern "C"
|
||||
{
|
||||
const char *text; /* Printable English ASCII text (0x20-0x7e). */
|
||||
uint32_t text_length; /* 1 through GVFG_OSD_MAX_TEXT_CHARACTERS. */
|
||||
int32_t x; /* Left position in output-frame pixels. */
|
||||
int32_t y; /* Top position in output-frame pixels. */
|
||||
int32_t x; /* Measured text-box left in frame pixels; clamped to fit. */
|
||||
int32_t y; /* Measured text-box top in frame pixels; clamped to fit. */
|
||||
uint32_t font_size_px; /* Font size in pixels; must be non-zero. */
|
||||
uint32_t color_rgb; /* 0x00RRGGBB. */
|
||||
} gvfg_channel_osd_config_t;
|
||||
@@ -368,10 +368,30 @@ extern "C"
|
||||
GVFG_PARAM_IN int channel_index,
|
||||
GVFG_PARAM_IN gvfg_pixel_format_t format);
|
||||
|
||||
/*
|
||||
* Measure printable ASCII text as a single non-wrapping line, using the
|
||||
* same font/layout as SDK OSD. No capture handle or open device is needed.
|
||||
* Returns a conservative whole-text box in pixels, including glyph
|
||||
* overhang and a one-pixel guard per edge; these are not pixel-tight bounds.
|
||||
* Both outputs must be non-NULL and are zeroed on failure.
|
||||
* Returns GVFG_EINVAL for invalid input or unrepresentable dimensions,
|
||||
* and GVFG_EIO on measurement failure.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_measure_osd_text(
|
||||
GVFG_PARAM_IN const char *text,
|
||||
GVFG_PARAM_IN uint32_t text_length,
|
||||
GVFG_PARAM_IN uint32_t font_size_px,
|
||||
GVFG_PARAM_OUT uint32_t *out_width,
|
||||
GVFG_PARAM_OUT uint32_t *out_height);
|
||||
|
||||
/*
|
||||
* Enable or update SDK-side OSD for an opened channel. The configuration
|
||||
* is copied synchronously and applies to subsequent YUY2 or Y210 frames.
|
||||
* Text is rendered as BT.709 limited-range video and blended by the GPU.
|
||||
* The single-line measured text box is positioned at x/y, clamped inside
|
||||
* each frame. If the whole box is larger than the frame, OSD is temporarily
|
||||
* skipped while capture continues. It resumes when settings or frame size
|
||||
* change so that the text fits; text is not wrapped, shrunk, or truncated.
|
||||
*/
|
||||
GVFG_API gvfg_status_t gvfg_set_channel_osd(
|
||||
GVFG_PARAM_IN gvfg_handle handle,
|
||||
|
||||
@@ -49,6 +49,116 @@ typedef struct
|
||||
int has_audio;
|
||||
} gvfg_debug_device_capabilities_t;
|
||||
|
||||
/* CPU wall times around the synchronous OSD delivery path, in milliseconds.
|
||||
* SUBMIT is command submission, not GPU execution time. READBACK_WAIT includes
|
||||
* waiting for earlier GPU work; FRAME_COPY can overlap that GPU work.
|
||||
* PROCESS_TOTAL includes the other process stages, but not BACKEND_RELEASE.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GVFG_DEBUG_OSD_LOCK_WAIT,
|
||||
GVFG_DEBUG_OSD_SURFACE,
|
||||
GVFG_DEBUG_OSD_PREPARE,
|
||||
GVFG_DEBUG_OSD_UPLOAD,
|
||||
GVFG_DEBUG_OSD_SUBMIT,
|
||||
GVFG_DEBUG_OSD_FRAME_COPY,
|
||||
GVFG_DEBUG_OSD_READBACK_WAIT,
|
||||
GVFG_DEBUG_OSD_ROI_COPY,
|
||||
GVFG_DEBUG_OSD_BACKEND_RELEASE,
|
||||
GVFG_DEBUG_OSD_PROCESS_TOTAL,
|
||||
GVFG_DEBUG_OSD_STAGE_COUNT
|
||||
} gvfg_debug_osd_stage_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint64_t frame_id;
|
||||
int osd_applied;
|
||||
int surface_rebuilt;
|
||||
uint32_t roi_width;
|
||||
uint32_t roi_height;
|
||||
double stage_ms[GVFG_DEBUG_OSD_STAGE_COUNT];
|
||||
} gvfg_debug_osd_frame_timing_t;
|
||||
|
||||
/* Internal diagnostic variant of read_channel_frame, with identical frame
|
||||
* ownership/release semantics. Timing is collected only through this entry
|
||||
* point; normal customer reads do not perform these extra clock queries.
|
||||
* On success timing.frame_id matches out_frame->frame_id. No GPU queries,
|
||||
* extra Flush, or additional synchronization are introduced.
|
||||
*/
|
||||
GVFG_DEBUG_API gvfg_status_t gvfg_debug_read_channel_frame_timed(
|
||||
GVFG_PARAM_IN gvfg_handle handle,
|
||||
GVFG_PARAM_IN int channel_index,
|
||||
GVFG_PARAM_OUT gvfg_frame_t *out_frame,
|
||||
GVFG_PARAM_OUT gvfg_debug_osd_frame_timing_t *out_timing,
|
||||
GVFG_PARAM_IN uint32_t timeout_ms);
|
||||
|
||||
/* Acquisition starts after a video-frame event is ready, before retrieving
|
||||
* or copying its data. Excludes waiting for the next frame. The public frame
|
||||
* timestamp remains unchanged (data acquired, before OSD).
|
||||
* A separate type/entry point preserves the older timed-read ABI.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
gvfg_debug_osd_frame_timing_t osd;
|
||||
uint64_t acquisition_begin_ns;
|
||||
} gvfg_debug_frame_read_timing_t;
|
||||
|
||||
enum
|
||||
{
|
||||
GVFG_DEBUG_OSD_EXPERIMENT_ENABLED = 1u,
|
||||
GVFG_DEBUG_OSD_EXPERIMENT_USED = 2u,
|
||||
GVFG_DEBUG_OSD_EXPERIMENT_REJECTED = 4u
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GVFG_DEBUG_OSD_PAGE_OK = 0,
|
||||
GVFG_DEBUG_OSD_PAGE_NO_POINTER,
|
||||
GVFG_DEBUG_OSD_PAGE_INVALID_RANGE,
|
||||
GVFG_DEBUG_OSD_PAGE_QUERY_FAILED,
|
||||
GVFG_DEBUG_OSD_PAGE_NOT_COMMITTED,
|
||||
GVFG_DEBUG_OSD_PAGE_GUARD_OR_NOACCESS,
|
||||
GVFG_DEBUG_OSD_PAGE_NOT_READWRITE,
|
||||
GVFG_DEBUG_OSD_PAGE_INVALID_REGION
|
||||
} gvfg_debug_osd_page_reason_t;
|
||||
|
||||
/* Separate diagnostic type: existing timing/flags ABI remains unchanged.
|
||||
* Native Windows values; win32_error is meaningful only for QUERY_FAILED.
|
||||
* Does not expose addresses or imply DMA safety. */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t reason;
|
||||
uint32_t protect;
|
||||
uint32_t state;
|
||||
uint32_t type;
|
||||
uint32_t win32_error;
|
||||
uint32_t query_bytes;
|
||||
} gvfg_debug_osd_page_check_t;
|
||||
|
||||
/* Query before releasing the matching successfully delivered frame. */
|
||||
GVFG_DEBUG_API gvfg_status_t gvfg_debug_get_channel_osd_page_check(
|
||||
GVFG_PARAM_IN gvfg_handle handle,
|
||||
GVFG_PARAM_IN int channel_index,
|
||||
GVFG_PARAM_IN uint64_t frame_id,
|
||||
GVFG_PARAM_OUT gvfg_debug_osd_page_check_t *out_check);
|
||||
|
||||
/* frame_id=0 queries build configuration only. Otherwise the frame must still
|
||||
* be held and its ID must match. Never implies a DMA ownership guarantee.
|
||||
* Separate query preserves all existing timing struct layouts/read ABIs.
|
||||
*/
|
||||
GVFG_DEBUG_API gvfg_status_t gvfg_debug_get_channel_osd_experiment_flags(
|
||||
GVFG_PARAM_IN gvfg_handle handle,
|
||||
GVFG_PARAM_IN int channel_index,
|
||||
GVFG_PARAM_IN uint64_t frame_id,
|
||||
GVFG_PARAM_OUT uint32_t *out_flags);
|
||||
|
||||
GVFG_DEBUG_API gvfg_status_t gvfg_debug_read_channel_frame_profiled(
|
||||
GVFG_PARAM_IN gvfg_handle handle,
|
||||
GVFG_PARAM_IN int channel_index,
|
||||
GVFG_PARAM_OUT gvfg_frame_t *out_frame,
|
||||
GVFG_PARAM_OUT gvfg_debug_frame_read_timing_t *out_timing,
|
||||
GVFG_PARAM_IN uint32_t timeout_ms);
|
||||
|
||||
/*
|
||||
* Query driver-neutral internal backend counters.
|
||||
*
|
||||
|
||||
@@ -458,6 +458,8 @@ namespace gvfg::internal
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
frame_held_ = false;
|
||||
held_zero_copy_data_ = nullptr;
|
||||
held_zero_copy_bytes_ = 0;
|
||||
}
|
||||
running_ = true;
|
||||
start_event_monitoring();
|
||||
@@ -477,6 +479,8 @@ namespace gvfg::internal
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
frame_held_ = false;
|
||||
held_zero_copy_data_ = nullptr;
|
||||
held_zero_copy_bytes_ = 0;
|
||||
}
|
||||
recovery_cv_.notify_all();
|
||||
stop_event_monitoring();
|
||||
@@ -499,9 +503,12 @@ namespace gvfg::internal
|
||||
return result;
|
||||
}
|
||||
|
||||
gvfg_status_t GigabyteCaptureSession::wait_frame(uint32_t timeoutMs, gvfg_frame_t &out)
|
||||
gvfg_status_t GigabyteCaptureSession::wait_frame(uint32_t timeoutMs, gvfg_frame_t &out,
|
||||
uint64_t *acquisitionBeginNs)
|
||||
{
|
||||
out = {};
|
||||
if (acquisitionBeginNs)
|
||||
*acquisitionBeginNs = 0;
|
||||
if (!running_ || !context_)
|
||||
return reject(GVFG_ESTATE, "Capture frame read rejected: stream is not running");
|
||||
{
|
||||
@@ -525,6 +532,10 @@ namespace gvfg::internal
|
||||
return wait_for_recovery(timeoutMs);
|
||||
if (wait != WAIT_OBJECT_0 + 2 && wait != WAIT_OBJECT_0 + 3)
|
||||
return reject(GVFG_EIO, "Capture video event wait failed");
|
||||
// The frame event is ready. Start before buffer preparation, vendor
|
||||
// retrieval/copy and their locks, but after waiting for a new frame.
|
||||
if (acquisitionBeginNs)
|
||||
*acquisitionBeginNs = monotonic_ns();
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
if (wait == WAIT_OBJECT_0 + 2)
|
||||
@@ -547,6 +558,7 @@ namespace gvfg::internal
|
||||
bytes = video_info_.cbBufSize;
|
||||
}
|
||||
const void *data = nullptr;
|
||||
void *zeroCopyData = nullptr;
|
||||
gvfg_status_t status = GVFG_OK;
|
||||
if (zero_copy_enabled_)
|
||||
{
|
||||
@@ -560,6 +572,7 @@ namespace gvfg::internal
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
record_get_frame_timing(std::chrono::duration<double, std::micro>(end - begin).count());
|
||||
data = buffer;
|
||||
zeroCopyData = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -593,9 +606,34 @@ namespace gvfg::internal
|
||||
out.bit_depth = signal.bit_depth;
|
||||
++video_frames_from_lib_;
|
||||
frame_held_ = true;
|
||||
held_zero_copy_data_ = zeroCopyData;
|
||||
held_zero_copy_bytes_ = zeroCopyData ? bytes : 0;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
uint8_t *GigabyteCaptureSession::writable_copy_frame_data(const gvfg_frame_t &frame)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
if (zero_copy_enabled_ || !frame_held_ || copy_buffer_.empty() ||
|
||||
frame.data != copy_buffer_.data() || frame.data_size != copy_buffer_.size())
|
||||
return nullptr;
|
||||
return copy_buffer_.data();
|
||||
}
|
||||
|
||||
uint8_t *GigabyteCaptureSession::experimental_zero_copy_frame_data(const gvfg_frame_t &frame)
|
||||
{
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
if (!zero_copy_enabled_ || !frame_held_ || !held_zero_copy_data_ ||
|
||||
frame.data != held_zero_copy_data_ || frame.data_size != held_zero_copy_bytes_)
|
||||
return nullptr;
|
||||
return static_cast<uint8_t *>(held_zero_copy_data_);
|
||||
#else
|
||||
(void)frame;
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
gvfg_status_t GigabyteCaptureSession::release_frame()
|
||||
{
|
||||
{
|
||||
@@ -604,6 +642,8 @@ namespace gvfg::internal
|
||||
return reject(GVFG_ESTATE, "Capture frame release rejected: no frame is held");
|
||||
// Current GigabyteLib zero-copy contract requires no per-frame release call.
|
||||
frame_held_ = false;
|
||||
held_zero_copy_data_ = nullptr;
|
||||
held_zero_copy_bytes_ = 0;
|
||||
}
|
||||
recovery_cv_.notify_all();
|
||||
return GVFG_OK;
|
||||
|
||||
@@ -55,7 +55,13 @@ namespace gvfg::internal
|
||||
gvfg_status_t configure_stream();
|
||||
gvfg_status_t start_stream();
|
||||
gvfg_status_t stop_stream();
|
||||
gvfg_status_t wait_frame(uint32_t timeoutMs, gvfg_frame_t &out);
|
||||
gvfg_status_t wait_frame(uint32_t timeoutMs, gvfg_frame_t &out,
|
||||
uint64_t *acquisitionBeginNs = nullptr);
|
||||
// Internal writable access only to the currently held SDK-owned copy.
|
||||
// Driver zero-copy buffers are never returned. Valid until release.
|
||||
uint8_t *writable_copy_frame_data(const gvfg_frame_t &frame);
|
||||
// Opt-in test candidate only, not a driver write/hold guarantee.
|
||||
uint8_t *experimental_zero_copy_frame_data(const gvfg_frame_t &frame);
|
||||
gvfg_status_t wait_audio(uint32_t timeoutMs, void *destination,
|
||||
uint32_t destinationCapacity, uint32_t &outBytes);
|
||||
gvfg_status_t release_frame();
|
||||
@@ -112,6 +118,8 @@ namespace gvfg::internal
|
||||
std::mutex capture_mutex_;
|
||||
std::vector<uint8_t> copy_buffer_;
|
||||
bool frame_held_ = false;
|
||||
void *held_zero_copy_data_ = nullptr;
|
||||
uint64_t held_zero_copy_bytes_ = 0;
|
||||
uint64_t video_frames_from_lib_ = 0;
|
||||
uint64_t audio_frames_from_lib_ = 0;
|
||||
uint64_t video_dma_event_wakes_ = 0;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
@@ -20,6 +21,56 @@ namespace gvfg::internal
|
||||
{
|
||||
namespace
|
||||
{
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
// Permission snapshot only: this does NOT establish exclusive DMA ownership.
|
||||
bool writableExperimentalRange(const gvfg_frame_t &source, uint64_t offset, uint64_t span,
|
||||
gvfg_debug_osd_page_check_t *result)
|
||||
{
|
||||
gvfg_debug_osd_page_check_t check{};
|
||||
const auto reject = [&](gvfg_debug_osd_page_reason_t reason) {
|
||||
check.reason = static_cast<uint32_t>(reason);
|
||||
if (result)
|
||||
*result = check;
|
||||
return false;
|
||||
};
|
||||
const uintptr_t base = reinterpret_cast<uintptr_t>(source.data);
|
||||
const uintptr_t limit = (std::numeric_limits<uintptr_t>::max)();
|
||||
if (!span || offset > source.data_size || span > source.data_size - offset ||
|
||||
offset > limit - base || span > limit - (base + offset))
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_INVALID_RANGE);
|
||||
uintptr_t cursor = base + static_cast<uintptr_t>(offset);
|
||||
const uintptr_t end = cursor + static_cast<uintptr_t>(span);
|
||||
while (cursor < end)
|
||||
{
|
||||
MEMORY_BASIC_INFORMATION info{};
|
||||
const SIZE_T queried = VirtualQuery(reinterpret_cast<const void *>(cursor), &info, sizeof(info));
|
||||
// Capture the error immediately, and only on a failed native call.
|
||||
check.win32_error = queried == 0 ? GetLastError() : 0;
|
||||
check.query_bytes = static_cast<uint32_t>(queried);
|
||||
check.protect = info.Protect;
|
||||
check.state = info.State;
|
||||
check.type = info.Type;
|
||||
if (queried != sizeof(info))
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_QUERY_FAILED);
|
||||
if (info.State != MEM_COMMIT)
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_NOT_COMMITTED);
|
||||
if (info.Protect & (PAGE_GUARD | PAGE_NOACCESS))
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_GUARD_OR_NOACCESS);
|
||||
if ((info.Protect & 0xffu) != PAGE_READWRITE)
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_NOT_READWRITE);
|
||||
const uintptr_t regionBase = reinterpret_cast<uintptr_t>(info.BaseAddress);
|
||||
if (info.RegionSize > limit - regionBase)
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_INVALID_REGION);
|
||||
const uintptr_t next = regionBase + info.RegionSize;
|
||||
if (next <= cursor)
|
||||
return reject(GVFG_DEBUG_OSD_PAGE_INVALID_REGION);
|
||||
cursor = next;
|
||||
}
|
||||
if (result)
|
||||
*result = {};
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
constexpr char kOsdBlendShader[] = R"(
|
||||
Texture2D<uint4> sourceTexture : register(t0);
|
||||
Texture2D<uint4> osdTexture : register(t1);
|
||||
@@ -318,12 +369,34 @@ struct GpuOsdProcessor::Impl
|
||||
surfaceDirty = true;
|
||||
const uint32_t yuvStride = frameWidth * (pixelFormat == GVFG_PIXFMT_YUY2 ? 2u : 4u);
|
||||
const uint32_t maskStride = frameWidth;
|
||||
gvfg_osd_handle rawHandle = nullptr;
|
||||
if (gvfg_osd_create(&rawHandle) != GVFG_OSD_OK)
|
||||
return false;
|
||||
std::unique_ptr<void, decltype(&gvfg_osd_destroy)> handle(rawHandle, &gvfg_osd_destroy);
|
||||
uint32_t textWidth = 0;
|
||||
uint32_t textHeight = 0;
|
||||
const gvfg_osd_status_t measureStatus = gvfg_osd_measure(
|
||||
handle.get(), text.c_str(), static_cast<uint32_t>(text.size()),
|
||||
fontSize, &textWidth, &textHeight);
|
||||
// Stored input already passed configure() validation. EINVAL here
|
||||
// means the measured box cannot be represented by uint32_t either.
|
||||
if (measureStatus != GVFG_OSD_OK && measureStatus != GVFG_OSD_EINVAL)
|
||||
return false;
|
||||
if (measureStatus == GVFG_OSD_EINVAL ||
|
||||
textWidth > frameWidth || textHeight > frameHeight)
|
||||
{
|
||||
// Retain the configuration and retry only after settings or the
|
||||
// input dimensions/format change. Capture must continue normally.
|
||||
region = {};
|
||||
surfaceWidth = frameWidth;
|
||||
surfaceHeight = frameHeight;
|
||||
surfaceFormat = pixelFormat;
|
||||
surfaceDirty = false;
|
||||
return true;
|
||||
}
|
||||
yuvSurface.resize(static_cast<size_t>(yuvStride) * frameHeight);
|
||||
maskSurface.resize(static_cast<size_t>(maskStride) * frameHeight);
|
||||
|
||||
gvfg_osd_handle handle = nullptr;
|
||||
if (gvfg_osd_create(&handle) != GVFG_OSD_OK)
|
||||
return false;
|
||||
gvfg_osd_config_t config{};
|
||||
config.struct_size = sizeof(config);
|
||||
config.width = frameWidth;
|
||||
@@ -346,8 +419,8 @@ struct GpuOsdProcessor::Impl
|
||||
output.mask_data = maskSurface.data();
|
||||
output.mask_size = maskSurface.size();
|
||||
output.mask_stride = maskStride;
|
||||
const gvfg_osd_status_t status = gvfg_osd_render(handle, &config, &output);
|
||||
gvfg_osd_destroy(handle);
|
||||
const gvfg_osd_status_t status = gvfg_osd_render(handle.get(), &config, &output);
|
||||
handle.reset();
|
||||
if (status != GVFG_OSD_OK)
|
||||
return false;
|
||||
|
||||
@@ -402,9 +475,35 @@ struct GpuOsdProcessor::Impl
|
||||
gvfg_status_t process(const gvfg_frame_t &source,
|
||||
std::vector<uint8_t> &destination,
|
||||
int &destinationStride,
|
||||
bool &applied)
|
||||
bool &applied,
|
||||
gvfg_debug_osd_frame_timing_t *timing,
|
||||
uint8_t *writableSource,
|
||||
bool experimentalZeroCopy,
|
||||
bool *inPlaceApplied,
|
||||
uint32_t *experimentFlags,
|
||||
gvfg_debug_osd_page_check_t *pageCheck)
|
||||
{
|
||||
if (pageCheck)
|
||||
*pageCheck = {};
|
||||
if (inPlaceApplied)
|
||||
*inPlaceApplied = false;
|
||||
#ifndef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
if (experimentalZeroCopy)
|
||||
return GVFG_EINVAL;
|
||||
(void)experimentFlags;
|
||||
#endif
|
||||
using Clock = std::chrono::steady_clock;
|
||||
auto stageStart = timing ? Clock::now() : Clock::time_point{};
|
||||
const auto finishStage = [timing, &stageStart](gvfg_debug_osd_stage_t stage) {
|
||||
if (timing)
|
||||
{
|
||||
const auto end = Clock::now();
|
||||
timing->stage_ms[stage] = std::chrono::duration<double, std::milli>(end - stageStart).count();
|
||||
stageStart = end;
|
||||
}
|
||||
};
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
finishStage(GVFG_DEBUG_OSD_LOCK_WAIT);
|
||||
applied = false;
|
||||
if (!active)
|
||||
return GVFG_OK;
|
||||
@@ -424,13 +523,19 @@ struct GpuOsdProcessor::Impl
|
||||
rowBytes64;
|
||||
if (source.data_size < requiredSource)
|
||||
return GVFG_EINVAL;
|
||||
if (writableSource && static_cast<const void *>(writableSource) != source.data)
|
||||
return GVFG_EINVAL;
|
||||
|
||||
if ((surfaceDirty || surfaceWidth != static_cast<uint32_t>(source.width) ||
|
||||
surfaceHeight != static_cast<uint32_t>(source.height) ||
|
||||
surfaceFormat != source.pixel_format) &&
|
||||
const bool rebuild = surfaceDirty || surfaceWidth != static_cast<uint32_t>(source.width) ||
|
||||
surfaceHeight != static_cast<uint32_t>(source.height) ||
|
||||
surfaceFormat != source.pixel_format;
|
||||
if (timing)
|
||||
timing->surface_rebuilt = rebuild ? 1 : 0;
|
||||
if (rebuild &&
|
||||
!rebuildSurface(static_cast<uint32_t>(source.width),
|
||||
static_cast<uint32_t>(source.height), source.pixel_format))
|
||||
return GVFG_EIO;
|
||||
finishStage(GVFG_DEBUG_OSD_SURFACE);
|
||||
// Invisible text needs no processed buffer or GPU work.
|
||||
if (region.empty())
|
||||
return GVFG_OK;
|
||||
@@ -438,9 +543,34 @@ struct GpuOsdProcessor::Impl
|
||||
const uint32_t rowBytes = static_cast<uint32_t>(rowBytes64);
|
||||
const uint32_t bytesPerPixel = source.pixel_format == GVFG_PIXFMT_YUY2 ? 2u : 4u;
|
||||
const uint32_t regionRowBytes = region.width * bytesPerPixel;
|
||||
const size_t sourceOffset = static_cast<size_t>(region.top) * source.row_stride_bytes +
|
||||
static_cast<size_t>(region.left) * bytesPerPixel;
|
||||
destination.resize(static_cast<size_t>(rowBytes) * static_cast<size_t>(source.height));
|
||||
const uint64_t sourceOffset64 = static_cast<uint64_t>(region.top) * source.row_stride_bytes +
|
||||
static_cast<uint64_t>(region.left) * bytesPerPixel;
|
||||
if (sourceOffset64 > (std::numeric_limits<size_t>::max)())
|
||||
return GVFG_EINVAL;
|
||||
const size_t sourceOffset = static_cast<size_t>(sourceOffset64);
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
const uint64_t writeSpan = static_cast<uint64_t>(region.height - 1u) *
|
||||
source.row_stride_bytes + regionRowBytes;
|
||||
if (experimentalZeroCopy &&
|
||||
(!writableSource || !writableExperimentalRange(source, sourceOffset, writeSpan, pageCheck)))
|
||||
{
|
||||
if (!writableSource && pageCheck)
|
||||
pageCheck->reason = GVFG_DEBUG_OSD_PAGE_NO_POINTER;
|
||||
writableSource = nullptr;
|
||||
if (experimentFlags)
|
||||
*experimentFlags |= GVFG_DEBUG_OSD_EXPERIMENT_REJECTED;
|
||||
}
|
||||
#endif
|
||||
if (!writableSource)
|
||||
destination.resize(static_cast<size_t>(rowBytes) * static_cast<size_t>(source.height));
|
||||
uint8_t *outputData = writableSource ? writableSource : destination.data();
|
||||
const uint32_t outputStride = writableSource ? static_cast<uint32_t>(source.row_stride_bytes) : rowBytes;
|
||||
if (timing)
|
||||
{
|
||||
timing->roi_width = region.width;
|
||||
timing->roi_height = region.height;
|
||||
}
|
||||
finishStage(GVFG_DEBUG_OSD_PREPARE);
|
||||
D3D11_MAPPED_SUBRESOURCE mapped{};
|
||||
if (FAILED(context->Map(sourceTexture.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped)))
|
||||
return GVFG_EIO;
|
||||
@@ -450,6 +580,7 @@ struct GpuOsdProcessor::Impl
|
||||
context->Unmap(sourceTexture.Get(), 0);
|
||||
if (!copiedSource)
|
||||
return GVFG_EIO;
|
||||
finishStage(GVFG_DEBUG_OSD_UPLOAD);
|
||||
|
||||
ID3D11ShaderResourceView *srvs[] = {sourceSrv.Get(), osdSrv.Get(), maskSrv.Get()};
|
||||
ID3D11UnorderedAccessView *uavs[] = {outputUav.Get()};
|
||||
@@ -469,28 +600,52 @@ struct GpuOsdProcessor::Impl
|
||||
context->CSSetShader(nullptr, nullptr, 0);
|
||||
|
||||
context->CopyResource(readbackTexture.Get(), outputTexture.Get());
|
||||
// CPU only preserves the native frame; all blending remains on the GPU.
|
||||
// Copy before Map READ so it can overlap queued GPU work.
|
||||
copyFrameRows(source, destination.data(), rowBytes);
|
||||
finishStage(GVFG_DEBUG_OSD_SUBMIT);
|
||||
// Driver zero-copy input requires an independent frame by default.
|
||||
// SDK-owned copy input already contains the untouched full frame, so
|
||||
// only its ROI is overwritten after GPU readback; no full copy/resize.
|
||||
if (!writableSource)
|
||||
{
|
||||
copyFrameRows(source, outputData, rowBytes);
|
||||
finishStage(GVFG_DEBUG_OSD_FRAME_COPY);
|
||||
}
|
||||
if (FAILED(context->Map(readbackTexture.Get(), 0, D3D11_MAP_READ, 0, &mapped)))
|
||||
return GVFG_EIO;
|
||||
finishStage(GVFG_DEBUG_OSD_READBACK_WAIT);
|
||||
if (mapped.RowPitch < regionRowBytes)
|
||||
{
|
||||
context->Unmap(readbackTexture.Get(), 0);
|
||||
return GVFG_EIO;
|
||||
}
|
||||
const size_t destinationOffset = static_cast<size_t>(region.top) * rowBytes +
|
||||
const size_t destinationOffset = static_cast<size_t>(region.top) * outputStride +
|
||||
static_cast<size_t>(region.left) * bytesPerPixel;
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
// Recheck immediately before writing. Permissions can still change after
|
||||
// this check; neither this nor the SDK hold prevents concurrent DMA.
|
||||
if (experimentalZeroCopy && writableSource &&
|
||||
!writableExperimentalRange(source, sourceOffset, writeSpan, pageCheck))
|
||||
{
|
||||
context->Unmap(readbackTexture.Get(), 0);
|
||||
return GVFG_EIO;
|
||||
}
|
||||
#endif
|
||||
for (uint32_t row = 0; row < region.height; ++row)
|
||||
{
|
||||
std::memcpy(destination.data() + destinationOffset + static_cast<size_t>(row) * rowBytes,
|
||||
std::memcpy(outputData + destinationOffset + static_cast<size_t>(row) * outputStride,
|
||||
static_cast<const uint8_t *>(mapped.pData) +
|
||||
static_cast<size_t>(row) * mapped.RowPitch,
|
||||
regionRowBytes);
|
||||
}
|
||||
context->Unmap(readbackTexture.Get(), 0);
|
||||
destinationStride = static_cast<int>(rowBytes);
|
||||
finishStage(GVFG_DEBUG_OSD_ROI_COPY);
|
||||
destinationStride = static_cast<int>(outputStride);
|
||||
applied = true;
|
||||
if (inPlaceApplied)
|
||||
*inPlaceApplied = writableSource != nullptr;
|
||||
if (experimentalZeroCopy && writableSource && experimentFlags)
|
||||
*experimentFlags |= GVFG_DEBUG_OSD_EXPERIMENT_USED;
|
||||
if (timing)
|
||||
timing->osd_applied = 1;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -530,14 +685,39 @@ GpuOsdProcessor::GpuOsdProcessor() : impl_(std::make_unique<Impl>()) {}
|
||||
GpuOsdProcessor::~GpuOsdProcessor() = default;
|
||||
gvfg_status_t GpuOsdProcessor::configure(const gvfg_channel_osd_config_t &config)
|
||||
{
|
||||
return impl_->configure(config);
|
||||
try
|
||||
{
|
||||
return impl_->configure(config);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return GVFG_EIO;
|
||||
}
|
||||
}
|
||||
void GpuOsdProcessor::clear() { impl_->clear(); }
|
||||
gvfg_status_t GpuOsdProcessor::process(const gvfg_frame_t &source,
|
||||
std::vector<uint8_t> &destination,
|
||||
int &destinationStride,
|
||||
bool &applied)
|
||||
bool &applied,
|
||||
gvfg_debug_osd_frame_timing_t *timing,
|
||||
uint8_t *writableSource,
|
||||
bool experimentalZeroCopy,
|
||||
bool *inPlaceApplied,
|
||||
uint32_t *experimentFlags,
|
||||
gvfg_debug_osd_page_check_t *pageCheck)
|
||||
{
|
||||
return impl_->process(source, destination, destinationStride, applied);
|
||||
try
|
||||
{
|
||||
return impl_->process(source, destination, destinationStride, applied, timing, writableSource,
|
||||
experimentalZeroCopy, inPlaceApplied, experimentFlags, pageCheck);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
applied = false;
|
||||
if (inPlaceApplied)
|
||||
*inPlaceApplied = false;
|
||||
destinationStride = 0;
|
||||
return GVFG_EIO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "gvfg_capture.h"
|
||||
#include "gvfg_debug.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -16,10 +17,21 @@ public:
|
||||
|
||||
gvfg_status_t configure(const gvfg_channel_osd_config_t &config);
|
||||
void clear();
|
||||
// writableSource must equal source.data. Only the backend can grant this
|
||||
// writable SDK-owned storage, held until the caller releases the frame.
|
||||
// The default-OFF experimental override admits driver storage only after
|
||||
// page checks; this is not a driver/DMA ownership guarantee.
|
||||
// nullptr preserves the separate-output path used for driver zero-copy.
|
||||
gvfg_status_t process(const gvfg_frame_t &source,
|
||||
std::vector<uint8_t> &destination,
|
||||
int &destinationStride,
|
||||
bool &applied);
|
||||
bool &applied,
|
||||
gvfg_debug_osd_frame_timing_t *timing = nullptr,
|
||||
uint8_t *writableSource = nullptr,
|
||||
bool experimentalZeroCopy = false,
|
||||
bool *inPlaceApplied = nullptr,
|
||||
uint32_t *experimentFlags = nullptr,
|
||||
gvfg_debug_osd_page_check_t *pageCheck = nullptr);
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "gvfg_debug.h"
|
||||
#include "gigabyte_capture_session.h"
|
||||
#include "gpu/gvfg_gpu_osd.h"
|
||||
#include "gvfg_osd.h"
|
||||
#include "gvfgframework.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -367,9 +368,15 @@ struct gvfg_channel_session_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t readFrame(gvfg_frame_t &out, uint32_t timeoutMs)
|
||||
gvfg_status_t readFrame(gvfg_frame_t &out, uint32_t timeoutMs,
|
||||
gvfg_debug_osd_frame_timing_t *timing = nullptr,
|
||||
uint64_t *acquisitionBeginNs = nullptr)
|
||||
{
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
if (timing)
|
||||
*timing = {};
|
||||
if (acquisitionBeginNs)
|
||||
*acquisitionBeginNs = 0;
|
||||
if (!session)
|
||||
return reject(GVFG_ESTATE, "gvfg_read_channel_frame rejected: channel is not open");
|
||||
if (!running)
|
||||
@@ -389,7 +396,7 @@ struct gvfg_channel_session_t
|
||||
return reject(GVFG_ESTATE, stateError);
|
||||
|
||||
gvfg_frame_t frame{};
|
||||
const gvfg_status_t st = session->wait_frame(timeoutMs, frame);
|
||||
const gvfg_status_t st = session->wait_frame(timeoutMs, frame, acquisitionBeginNs);
|
||||
if (st != GVFG_OK)
|
||||
{
|
||||
{
|
||||
@@ -422,8 +429,28 @@ struct gvfg_channel_session_t
|
||||
|
||||
bool osdApplied = false;
|
||||
int processedStride = 0;
|
||||
// This capability comes from the backend, never from const_cast of a
|
||||
// public frame pointer. Driver storage is excluded by default; only
|
||||
// the explicit unsafe build option below can admit it for experiments.
|
||||
uint8_t *writableSource = session->writable_copy_frame_data(frame);
|
||||
bool experimentalZeroCopy = false;
|
||||
bool inPlaceApplied = false;
|
||||
uint32_t experimentFlags = 0;
|
||||
gvfg_debug_osd_page_check_t pageCheck{};
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
experimentFlags = GVFG_DEBUG_OSD_EXPERIMENT_ENABLED;
|
||||
if (!writableSource)
|
||||
{
|
||||
writableSource = session->experimental_zero_copy_frame_data(frame);
|
||||
experimentalZeroCopy = writableSource != nullptr;
|
||||
}
|
||||
#endif
|
||||
const uint64_t processBeginNs = timing ? now_ns() : 0;
|
||||
const gvfg_status_t osdStatus =
|
||||
osdProcessor.process(frame, processedVideoBuffer, processedStride, osdApplied);
|
||||
osdProcessor.process(frame, processedVideoBuffer, processedStride, osdApplied, timing,
|
||||
writableSource, experimentalZeroCopy, &inPlaceApplied, &experimentFlags, &pageCheck);
|
||||
if (timing)
|
||||
timing->stage_ms[GVFG_DEBUG_OSD_PROCESS_TOTAL] = static_cast<double>(now_ns() - processBeginNs) / 1e6;
|
||||
if (osdStatus != GVFG_OK)
|
||||
{
|
||||
session->release_frame();
|
||||
@@ -433,9 +460,14 @@ struct gvfg_channel_session_t
|
||||
}
|
||||
|
||||
bool backendFrameHeld = true;
|
||||
if (osdApplied)
|
||||
// An in-place copy-mode frame must keep the backend hold until the
|
||||
// user's release; otherwise recovery/next capture may reuse its data.
|
||||
if (osdApplied && !inPlaceApplied)
|
||||
{
|
||||
const uint64_t releaseBeginNs = timing ? now_ns() : 0;
|
||||
const gvfg_status_t releaseStatus = session->release_frame();
|
||||
if (timing)
|
||||
timing->stage_ms[GVFG_DEBUG_OSD_BACKEND_RELEASE] = static_cast<double>(now_ns() - releaseBeginNs) / 1e6;
|
||||
if (releaseStatus != GVFG_OK)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(frameMutex);
|
||||
@@ -460,6 +492,8 @@ struct gvfg_channel_session_t
|
||||
{
|
||||
frame.frame_id = ++videoFrameId;
|
||||
heldSessionFrame = frame;
|
||||
heldOsdExperimentFlags = experimentFlags;
|
||||
heldOsdPageCheck = pageCheck;
|
||||
heldFrameNeedsBackendRelease = backendFrameHeld;
|
||||
readInProgress = false;
|
||||
frameHeld = true;
|
||||
@@ -483,11 +517,38 @@ struct gvfg_channel_session_t
|
||||
out.bit_depth = static_cast<int>(frame.bit_depth);
|
||||
out.frame_id = frame.frame_id;
|
||||
out.timestamp_ns = frame.timestamp_ns;
|
||||
if (timing)
|
||||
timing->frame_id = out.frame_id;
|
||||
noteDeliveredFrame(out.width, out.height, out.bit_depth, out.pixel_format);
|
||||
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t osdExperimentFlags(uint64_t frameId, uint32_t &flags)
|
||||
{
|
||||
flags = 0;
|
||||
#ifdef GVFG_EXPERIMENTAL_ZERO_COPY_OSD_INPLACE
|
||||
flags = GVFG_DEBUG_OSD_EXPERIMENT_ENABLED;
|
||||
#endif
|
||||
if (frameId == 0)
|
||||
return GVFG_OK;
|
||||
std::lock_guard<std::mutex> lock(frameMutex);
|
||||
if (!frameHeld || heldSessionFrame.frame_id != frameId)
|
||||
return GVFG_ESTATE;
|
||||
flags = heldOsdExperimentFlags;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t osdPageCheck(uint64_t frameId, gvfg_debug_osd_page_check_t &check)
|
||||
{
|
||||
check = {};
|
||||
std::lock_guard<std::mutex> lock(frameMutex);
|
||||
if (!frameId || !frameHeld || heldSessionFrame.frame_id != frameId)
|
||||
return GVFG_ESTATE;
|
||||
check = heldOsdPageCheck;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t releaseFrame(const gvfg_frame_t &frameToken)
|
||||
{
|
||||
if (!session)
|
||||
@@ -628,7 +689,9 @@ struct gvfg_channel_session_t
|
||||
const gvfg_status_t status = osdProcessor.configure(config);
|
||||
return status == GVFG_OK
|
||||
? GVFG_OK
|
||||
: reject(status, "gvfg_set_channel_osd rejected: configuration is invalid");
|
||||
: reject(status, status == GVFG_EINVAL
|
||||
? "gvfg_set_channel_osd rejected: configuration is invalid"
|
||||
: "gvfg_set_channel_osd failed to store configuration");
|
||||
}
|
||||
|
||||
gvfg_status_t clearOsd()
|
||||
@@ -820,6 +883,8 @@ struct gvfg_channel_session_t
|
||||
std::atomic<bool> running{false};
|
||||
std::mutex frameMutex;
|
||||
bool readInProgress = false;
|
||||
uint32_t heldOsdExperimentFlags = 0;
|
||||
gvfg_debug_osd_page_check_t heldOsdPageCheck{};
|
||||
bool frameHeld = false;
|
||||
bool heldFrameNeedsBackendRelease = false;
|
||||
uint64_t videoFrameId = 0;
|
||||
@@ -1108,6 +1173,45 @@ extern "C"
|
||||
return handle->setChannelVideoFormat(channel_index, format);
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_measure_osd_text(const char *text, uint32_t text_length,
|
||||
uint32_t font_size_px,
|
||||
uint32_t *out_width, uint32_t *out_height)
|
||||
{
|
||||
if (out_width)
|
||||
*out_width = 0;
|
||||
if (out_height)
|
||||
*out_height = 0;
|
||||
if (!text || text_length == 0 || text_length > GVFG_OSD_MAX_TEXT_CHARACTERS ||
|
||||
font_size_px == 0 || !out_width || !out_height)
|
||||
return GVFG_EINVAL;
|
||||
for (uint32_t i = 0; i < text_length; ++i)
|
||||
{
|
||||
const unsigned char c = static_cast<unsigned char>(text[i]);
|
||||
if (c < 0x20 || c > 0x7e)
|
||||
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);
|
||||
const gvfg_osd_status_t status = gvfg_osd_measure(
|
||||
helper.get(), text, text_length, font_size_px, out_width, out_height);
|
||||
if (status == GVFG_OSD_OK)
|
||||
return GVFG_OK;
|
||||
return status == GVFG_OSD_EINVAL ? GVFG_EINVAL : GVFG_EIO;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
*out_width = 0;
|
||||
*out_height = 0;
|
||||
return GVFG_EIO;
|
||||
}
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_set_channel_osd(gvfg_handle handle,
|
||||
int channel_index,
|
||||
const gvfg_channel_osd_config_t *config)
|
||||
@@ -1180,6 +1284,65 @@ extern "C"
|
||||
"gvfg_read_channel_frame rejected: channel is not open");
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_read_channel_frame_timed(gvfg_handle handle,
|
||||
int channel_index,
|
||||
gvfg_frame_t *out_frame,
|
||||
gvfg_debug_osd_frame_timing_t *out_timing,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
if (out_timing)
|
||||
*out_timing = {};
|
||||
if (!handle || !out_frame || !out_timing)
|
||||
return GVFG_EINVAL;
|
||||
gvfg_channel_session_t *channel = handle->findChannel(channel_index);
|
||||
return channel ? channel->readFrame(*out_frame, timeout_ms, out_timing)
|
||||
: handle->rejectChannel(channel_index, GVFG_ESTATE,
|
||||
"gvfg_debug_read_channel_frame_timed rejected: channel is not open");
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_read_channel_frame_profiled(gvfg_handle handle,
|
||||
int channel_index,
|
||||
gvfg_frame_t *out_frame,
|
||||
gvfg_debug_frame_read_timing_t *out_timing,
|
||||
uint32_t timeout_ms)
|
||||
{
|
||||
if (out_timing)
|
||||
*out_timing = {};
|
||||
if (!handle || !out_frame || !out_timing)
|
||||
return GVFG_EINVAL;
|
||||
gvfg_channel_session_t *channel = handle->findChannel(channel_index);
|
||||
return channel ? channel->readFrame(*out_frame, timeout_ms, &out_timing->osd,
|
||||
&out_timing->acquisition_begin_ns)
|
||||
: handle->rejectChannel(channel_index, GVFG_ESTATE,
|
||||
"gvfg_debug_read_channel_frame_profiled rejected: channel is not open");
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_get_channel_osd_experiment_flags(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint64_t frame_id,
|
||||
uint32_t *out_flags)
|
||||
{
|
||||
if (out_flags)
|
||||
*out_flags = 0;
|
||||
if (!handle || !out_flags)
|
||||
return GVFG_EINVAL;
|
||||
gvfg_channel_session_t *channel = handle->findChannel(channel_index);
|
||||
return channel ? channel->osdExperimentFlags(frame_id, *out_flags) : GVFG_ESTATE;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_debug_get_channel_osd_page_check(gvfg_handle handle,
|
||||
int channel_index,
|
||||
uint64_t frame_id,
|
||||
gvfg_debug_osd_page_check_t *out_check)
|
||||
{
|
||||
if (out_check)
|
||||
*out_check = {};
|
||||
if (!handle || !out_check)
|
||||
return GVFG_EINVAL;
|
||||
gvfg_channel_session_t *channel = handle->findChannel(channel_index);
|
||||
return channel ? channel->osdPageCheck(frame_id, *out_check) : GVFG_ESTATE;
|
||||
}
|
||||
|
||||
gvfg_status_t gvfg_release_channel_frame(gvfg_handle handle,
|
||||
int channel_index,
|
||||
const gvfg_frame_t *frame)
|
||||
|
||||
Reference in New Issue
Block a user