Skip to content

rust: Port the transition clock and fit in obs-source-transition.c to obs-source #2040

Closed

Description

@rdoupe

Unit

Port the pure clock and fit decisions in libobs/obs-source-transition.c.h (our #556 area) to rust/obs-source, as a new module transition_clock:

  • calc_time: the manual value, before the start, after the end, a zero duration, and the ratio;
  • the manual step in obs_transition_tick: snap when the torque is 0, otherwise step;
  • the size fold of recalculate_transition_size (the larger of the two children);
  • the fit in recalculate_transition_matrix (max-only, aspect and stretch), which gives the scale and the offsets passed to add_alignment;
  • mix_spaces;
  • transition_calc_min_ts (the earliest non-zero child timestamp).

These stay C:

  • the locks and the child size reads;
  • add_alignment (already ported) and the matrix build;
  • get_sample_time, the texrenders and the swap handover;
  • calc_torquef. Rust only returns "snap" or "step", so obs-source gains no crate dependency.

Plan (one PR, separate commits)

  1. Behaviour-neutral move into libobs/obs-source-transition-clock.c.h, as hidden functions.
  2. Characterization: test_transition_clock_steps. It covers:
    • calc_time around the start and end, a zero duration, and huge durations;
    • the manual step with torque 0, with a clamp, and with NaN targets;
    • the fit for each scale type, with a source smaller than, equal to and larger than the transition, a zero transition size and a zero child size;
    • mix_spaces over all 4 × 4 pairs;
    • min_ts with zero, one and two timestamps.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-source-transition-clock group. Exported symbols stay unchanged.
  4. Tier 3 parity against the original C: exhaustive over modes and scale types, plus a proptest over full-range u64 clocks and f32 sizes and targets. Then a deliberate-break check and port_comparison numbers.

calc_time divides in long double in C, whose width differs by platform. Rust divides in f64, which rounds to the same f32 for every clock below 2^53 ns (about 104 days). Bit parity is limited to that range, and the PR says so.

These real-libobs tests must stay green on every lane: test_transition_swap, test_studio_mode_swap, test_transition_recursive_destination, test_fade_to_color_mix, test_transition_audio_rescale and test_stinger_media_duration.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2040.

  2. added
    claimed
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions