Bound video recovery correction before media timestamp arithmetic

This commit is contained in:
evgeny committed 2026-10-19 17:45:17 +02:00
1 parent 12e9e4da37
commit 642fc34bcc
1 file changed
+2 -1
+2 -1
View File
@@ -69,7 +69,8 @@ enum call_video_playout_action call_video_playout_poll(struct call_video_playout
// Аудио задаёт базовый темп; долг видео снимается с постоянной 0.5с, максимум 1.6x.
int64_t av = f->pts_us - audio;
uint32_t base = clock->rate_ppm > 1000000 ? clock->rate_ppm : 1000000;
int64_t speed = base + (av < 0 ? -av * 2 : 0);
int64_t correction = av < -300000 ? 600000 : av < 0 ? -av * 2 : 0;
int64_t speed = base + correction;
p->speed_ppm = speed < VIDEO_MAX_SPEED_PPM ? (uint32_t)speed : VIDEO_MAX_SPEED_PPM;
int64_t delta = p->last_pts >= 0 ? f->pts_us - p->last_pts : 0;
int64_t step = delta / p->speed_ppm * 1000000 + delta % p->speed_ppm * 1000000 / p->speed_ppm;