From a3d0a338c594e154463d8e9d5a2af8d67a35e574 Mon Sep 17 00:00:00 2001 From: JohannesItten Date: Thu, 9 Jul 2026 23:26:08 +0300 Subject: [PATCH] cache removed --- nodes/pip/main.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/nodes/pip/main.cpp b/nodes/pip/main.cpp index cf9e500..577c6a2 100644 --- a/nodes/pip/main.cpp +++ b/nodes/pip/main.cpp @@ -111,12 +111,6 @@ class PiPNode : public dmf::NodeBase { uint64_t index = mxlGetCurrentIndex(&rate); 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 inset_cache( - static_cast(inset_stride) * static_cast(inset_h), 0); - bool have_inset = false; - uint64_t frame_count = 0, stall_count = 0; bool fatal = false; @@ -128,16 +122,14 @@ class PiPNode : public dmf::NodeBase { bg_reader, index, 80'000'000, &bg_grain, &bg_buf); if (bg_st == MXL_STATUS_OK && bg_buf) { - // Try to read inset at the same index. Short timeout: hardware - // inputs often land a frame behind, so we don't wait long — - // falling back to the cached frame is acceptable. + // Try inset at same index (short timeout — hardware often lands one frame behind). + // On any miss, fall back to headIndex: the ring buffer is the cache. mxlGrainInfo inset_grain{}; uint8_t* inset_buf = nullptr; mxlStatus in_st = mxlFlowReaderGetGrain( inset_reader, index, 8'000'000, &inset_grain, &inset_buf); - if (in_st == MXL_ERR_OUT_OF_RANGE_TOO_LATE) { - // Inset has moved ahead — grab its latest committed frame. + if (in_st != MXL_STATUS_OK) { mxlFlowRuntimeInfo ri{}; mxlFlowReaderGetRuntimeInfo(inset_reader, &ri); in_st = mxlFlowReaderGetGrain( @@ -145,13 +137,6 @@ class PiPNode : public dmf::NodeBase { stall_count++; } - if (in_st == MXL_STATUS_OK && inset_buf) { - std::memcpy(inset_cache.data(), inset_buf, - static_cast(inset_stride) * static_cast(inset_h)); - have_inset = true; - } - // TOO_EARLY (8 ms elapsed, inset not ready): use cached frame — imperceptible. - mxlGrainInfo out_grain{}; uint8_t* out_buf = nullptr; const mxlStatus wst = mxlFlowWriterOpenGrain( @@ -159,10 +144,10 @@ class PiPNode : public dmf::NodeBase { if (wst == MXL_STATUS_OK) { std::memcpy(out_buf, bg_buf, static_cast(bg_stride) * static_cast(bg_h)); - if (have_inset) { + if (in_st == MXL_STATUS_OK && inset_buf) { dmf::v210::scale_and_overlay( - inset_cache.data(), inset_stride, inset_w, inset_h, - out_buf, out_stride, + inset_buf, inset_stride, inset_w, inset_h, + out_buf, out_stride, pip_x, pip_y, clamped_w, clamped_h, Y0, Y1, Cb0, Cb1, Cr0, Cr1); }