From fc0559c974643203e83179d83a0a9e1f3d9965b2 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 15 Oct 2026 02:13:42 +0200 Subject: [PATCH] Preserve fractional frame budget when downsampling cameras --- tools/chatgui/src/call_video_cadence.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/chatgui/src/call_video_cadence.h b/tools/chatgui/src/call_video_cadence.h index 134eade2..19619277 100644 --- a/tools/chatgui/src/call_video_cadence.h +++ b/tools/chatgui/src/call_video_cadence.h @@ -1,20 +1,21 @@ #pragma once #include -// Бюджет 30 fps с запасом четверти кадра на дрожание PTS, без накопления после паузы. +// Бюджет 30 fps с запасом одного кадра; интервал >=25мс запрещает burst после паузы. class CallVideoCadence { - int64_t lastPts = -1, credit = 1250000; + int64_t lastPts = -1, lastAccepted = -1, credit = 1250000; public: bool accept(int64_t pts) { if (lastPts >= 0) { if (pts <= lastPts) return false; const int64_t elapsed = pts - lastPts; - credit = elapsed >= 41667 ? 1250000 : credit + elapsed * 30; - if (credit > 1250000) credit = 1250000; + credit = elapsed >= 66667 ? 2000000 : credit + elapsed * 30; + if (credit > 2000000) credit = 2000000; } lastPts = pts; - if (credit < 1000000) return false; + if (credit < 1000000 || (lastAccepted >= 0 && pts - lastAccepted < 25000)) return false; credit -= 1000000; + lastAccepted = pts; return true; } };