提交 51dd204c 编写于 作者: J jp9000

libobs: Save clamped video time

The "clamped" video time is the system time per video frame that is
closest to the current system time, but always divisible by the frame
interval.  For example, if the last frame system timestamp was 1600 and
the new frame is 2500, but the frame interval is 800, then the
"clamped" video time is 2400.

This clamped value is useful to get the relative system time without any
jitter.
上级 7f7901b9
......@@ -217,6 +217,7 @@ struct obs_core_video {
gs_stagesurf_t *mapped_surface;
int cur_texture;
uint64_t video_time;
video_t *video;
pthread_t video_thread;
bool thread_initialized;
......
......@@ -562,17 +562,18 @@ static inline void output_frame(uint64_t *cur_time, uint64_t interval)
void *obs_video_thread(void *param)
{
uint64_t last_time = 0;
uint64_t cur_time = os_gettime_ns();
uint64_t interval = video_output_get_frame_time(obs->video.video);
obs->video.video_time = os_gettime_ns();
os_set_thread_name("libobs: graphics thread");
while (!video_output_stopped(obs->video.video)) {
last_time = tick_sources(cur_time, last_time);
last_time = tick_sources(obs->video.video_time, last_time);
render_displays();
output_frame(&cur_time, interval);
output_frame(&obs->video.video_time, interval);
}
UNUSED_PARAMETER(param);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册