Pip node #6
+10
-13
@@ -106,7 +106,7 @@ class PiPNode : public dmf::NodeBase {
|
||||
std::vector<uint16_t> Cb0(inset_w / 2), Cb1(inset_w / 2);
|
||||
std::vector<uint16_t> Cr0(inset_w / 2), Cr1(inset_w / 2);
|
||||
|
||||
// --- Sync group: ensures both inputs have grain N before compositing ---
|
||||
// --- Sync group: blocks until both inputs have grain N ---
|
||||
mxlFlowSynchronizationGroup sync_group{};
|
||||
mxlCreateFlowSynchronizationGroup(instance(), &sync_group);
|
||||
mxlFlowSynchronizationGroupAddReader(sync_group, bg_reader);
|
||||
@@ -120,8 +120,10 @@ class PiPNode : public dmf::NodeBase {
|
||||
uint64_t frame_count = 0, timeout_count = 0;
|
||||
|
||||
while (dmf::g_running.load(std::memory_order_relaxed)) {
|
||||
mxlStatus st = mxlFlowSynchronizationGroupWaitForDataAt(
|
||||
sync_group, index, 200'000'000);
|
||||
// WaitForDataAt expects TAI nanoseconds, not a grain index.
|
||||
const uint64_t tai_ns = mxlIndexToTimestamp(&rate, index);
|
||||
const mxlStatus st = mxlFlowSynchronizationGroupWaitForDataAt(
|
||||
sync_group, tai_ns, 200'000'000);
|
||||
|
||||
if (st == MXL_STATUS_OK) {
|
||||
mxlGrainInfo bg_grain{}, inset_grain{};
|
||||
@@ -134,25 +136,20 @@ class PiPNode : public dmf::NodeBase {
|
||||
mxlGrainInfo out_grain{};
|
||||
uint8_t* out_buf = nullptr;
|
||||
if (mxlFlowWriterOpenGrain(out_writer, index, &out_grain, &out_buf) == MXL_STATUS_OK) {
|
||||
// Copy full background into output
|
||||
std::memcpy(out_buf, bg_buf,
|
||||
static_cast<size_t>(bg_stride) * static_cast<size_t>(bg_h));
|
||||
|
||||
// Scale inset and composite over background
|
||||
if (inset_buf) {
|
||||
dmf::v210::scale_and_overlay(
|
||||
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);
|
||||
}
|
||||
dmf::v210::scale_and_overlay(
|
||||
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);
|
||||
|
||||
out_grain.flags = (bg_grain.flags | inset_grain.flags) & MXL_GRAIN_FLAG_INVALID;
|
||||
out_grain.validSlices = out_grain.totalSlices;
|
||||
mxlFlowWriterCommitGrain(out_writer, &out_grain);
|
||||
frame_count++;
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
} else if (st == MXL_ERR_TIMEOUT) {
|
||||
|
||||
Reference in New Issue
Block a user