Repository navigation
Closed
Labels
readyMeets the definition of Ready; claimable
Description
Unit
Port the frame pacing decisions of video_sleep() in libobs/obs-video.c.h to rust/obs-core, as a new module video_pacing, next to video_output_step (#2165) and video_copy_plan (#2118). The graphics thread calls video_sleep() once per frame (obs_graphics_thread_loop). These decisions move:
- The frame time step. Input: the current frame time, the interval, whether
os_sleepto_ns()reached the next frame time, and the current time. Output:- the new frame time (the next frame time, or the frame time on the interval grid after a late wake-up);
- the frame count (1, or the number of whole intervals since the current frame time, at least 1);
- the lagged frames for
obs_video_stats_add_frames()(count − 1).
- The encoder-group start: whether a ready encoder's group gets its
start_timestamp(all encoders of the group started, and no start timestamp yet), and which time it gets. Note for the characterization: C gives the group the new frame time (*p_timeafter the step), and the frame info gets the old one (cur_time). The characterization pins this as it is.
These stay in C:
os_sleepto_ns()andos_gettime_ns()(C passes their results);obs_video_stats_add_frames();- the ready-encoder-group list, the weak-encoder references and both mutexes;
- the
vframe_infodeque pushes for the raw and GPU mixes, and the mix list with its mutex.
Plan (one PR, separate commits)
- A behaviour-neutral move of the two decisions into
libobs/obs-video-pacing.c.h, as hidden functions on plain values. - Characterization in
test_video_pacing_steps. It covers:- the sleep reached the next frame time (count 1, no lag);
- a late wake-up by less than one interval, by exactly one, and by several intervals (count, lag and the new frame time on the grid);
- a current time earlier than the frame time (the clamp to one interval);
- large time jumps (after suspend/resume) near the limits of the
intcount and of theuint32_tstats arguments; - the encoder-group start for each combination of "all started" and "start timestamp already set", and the old-vs-new time detail above.
- RED, then GREEN: the safe Rust core plus shims, in a
libobs.ported-video-pacinggroup. Exported symbols are unchanged. - Tier 3 parity against the original C: exhaustive over the flags and small interval multiples, plus a proptest over full-range times and intervals. Also a deliberate-break check and
port_comparisonnumbers (this runs once per frame).
These real-libobs tests must stay green on every lane:
test_video_output_step_stepstest_video_copy_plan_stepstest_video_output_formatstest_raw_output_video_resettest_encoding_lag_rescaletest_encoder_group_nulltest_encoder_lifecycle_stepstest_encoder_audio_start_stepstest_media_restart_stale_frame
Production check after the merge: the obs-rust production box (Linux, NDI output, 25 fps) gets a before/after run of the render loop (lagged frames, CPU, wake-ups of the graphics thread).
Metadata
Metadata
Assignees
Labels
readyMeets the definition of Ready; claimable
Type
Projects
- StatusShow more project fieldsDone
Activity
vpacher commentedon Oct 28, 2026
Claiming: #2738
Plan as in the issue: one PR with the behaviour-neutral move, the characterization (
test_video_pacing_steps), RED/GREEN (obs-core::video_pacing, grouplibobs.ported-video-pacing) and Tier 3 parity. I will show a draft PR with the move and the characterization first.libobs: Move the video frame pacing decisions into obs-video-pacing.c
test: Characterize the video frame pacing decisions
obs-core: Add Tier 1 tests for the video pacing port
obs-core: Port the video frame pacing decisions
obs-core: Check the video pacing port against the C
docs: Record the video pacing port
obs-core: Port the video frame pacing decisions (video_sleep) (obs-ru…