cache removed
This commit is contained in:
+5
-20
@@ -111,12 +111,6 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
uint64_t index = mxlGetCurrentIndex(&rate);
|
uint64_t index = mxlGetCurrentIndex(&rate);
|
||||||
log("start index=%llu", index);
|
log("start index=%llu", index);
|
||||||
|
|
||||||
// Cache the last good inset frame so we can composite even when the
|
|
||||||
// hardware input hasn't delivered a frame at the exact current index.
|
|
||||||
std::vector<uint8_t> inset_cache(
|
|
||||||
static_cast<size_t>(inset_stride) * static_cast<size_t>(inset_h), 0);
|
|
||||||
bool have_inset = false;
|
|
||||||
|
|
||||||
uint64_t frame_count = 0, stall_count = 0;
|
uint64_t frame_count = 0, stall_count = 0;
|
||||||
bool fatal = false;
|
bool fatal = false;
|
||||||
|
|
||||||
@@ -128,16 +122,14 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
bg_reader, index, 80'000'000, &bg_grain, &bg_buf);
|
bg_reader, index, 80'000'000, &bg_grain, &bg_buf);
|
||||||
|
|
||||||
if (bg_st == MXL_STATUS_OK && bg_buf) {
|
if (bg_st == MXL_STATUS_OK && bg_buf) {
|
||||||
// Try to read inset at the same index. Short timeout: hardware
|
// Try inset at same index (short timeout — hardware often lands one frame behind).
|
||||||
// inputs often land a frame behind, so we don't wait long —
|
// On any miss, fall back to headIndex: the ring buffer is the cache.
|
||||||
// falling back to the cached frame is acceptable.
|
|
||||||
mxlGrainInfo inset_grain{};
|
mxlGrainInfo inset_grain{};
|
||||||
uint8_t* inset_buf = nullptr;
|
uint8_t* inset_buf = nullptr;
|
||||||
mxlStatus in_st = mxlFlowReaderGetGrain(
|
mxlStatus in_st = mxlFlowReaderGetGrain(
|
||||||
inset_reader, index, 8'000'000, &inset_grain, &inset_buf);
|
inset_reader, index, 8'000'000, &inset_grain, &inset_buf);
|
||||||
|
|
||||||
if (in_st == MXL_ERR_OUT_OF_RANGE_TOO_LATE) {
|
if (in_st != MXL_STATUS_OK) {
|
||||||
// Inset has moved ahead — grab its latest committed frame.
|
|
||||||
mxlFlowRuntimeInfo ri{};
|
mxlFlowRuntimeInfo ri{};
|
||||||
mxlFlowReaderGetRuntimeInfo(inset_reader, &ri);
|
mxlFlowReaderGetRuntimeInfo(inset_reader, &ri);
|
||||||
in_st = mxlFlowReaderGetGrain(
|
in_st = mxlFlowReaderGetGrain(
|
||||||
@@ -145,13 +137,6 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
stall_count++;
|
stall_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_st == MXL_STATUS_OK && inset_buf) {
|
|
||||||
std::memcpy(inset_cache.data(), inset_buf,
|
|
||||||
static_cast<size_t>(inset_stride) * static_cast<size_t>(inset_h));
|
|
||||||
have_inset = true;
|
|
||||||
}
|
|
||||||
// TOO_EARLY (8 ms elapsed, inset not ready): use cached frame — imperceptible.
|
|
||||||
|
|
||||||
mxlGrainInfo out_grain{};
|
mxlGrainInfo out_grain{};
|
||||||
uint8_t* out_buf = nullptr;
|
uint8_t* out_buf = nullptr;
|
||||||
const mxlStatus wst = mxlFlowWriterOpenGrain(
|
const mxlStatus wst = mxlFlowWriterOpenGrain(
|
||||||
@@ -159,9 +144,9 @@ class PiPNode : public dmf::NodeBase {
|
|||||||
if (wst == MXL_STATUS_OK) {
|
if (wst == MXL_STATUS_OK) {
|
||||||
std::memcpy(out_buf, bg_buf,
|
std::memcpy(out_buf, bg_buf,
|
||||||
static_cast<size_t>(bg_stride) * static_cast<size_t>(bg_h));
|
static_cast<size_t>(bg_stride) * static_cast<size_t>(bg_h));
|
||||||
if (have_inset) {
|
if (in_st == MXL_STATUS_OK && inset_buf) {
|
||||||
dmf::v210::scale_and_overlay(
|
dmf::v210::scale_and_overlay(
|
||||||
inset_cache.data(), inset_stride, inset_w, inset_h,
|
inset_buf, inset_stride, inset_w, inset_h,
|
||||||
out_buf, out_stride,
|
out_buf, out_stride,
|
||||||
pip_x, pip_y, clamped_w, clamped_h,
|
pip_x, pip_y, clamped_w, clamped_h,
|
||||||
Y0, Y1, Cb0, Cb1, Cr0, Cr1);
|
Y0, Y1, Cb0, Cb1, Cr0, Cr1);
|
||||||
|
|||||||
Reference in New Issue
Block a user