Skip to content

rust: Port the 2x deinterlace frame pacing in obs-source-deinterlace.c to obs-source #1950

Closed

Description

@rdoupe

Unit

This ports the 2x deinterlace frame pacing decisions in libobs/obs-source-deinterlace.c.h to rust/obs-source, as a new module deinterlace_pacing next to audio_timing (#1936). These decisions move, all from deinterlace_get_closest_frames:

  • the unbuffered hold check: keep the current frame while its end is ahead, unless time jumped by TS_JUMP_THRESHOLD;
  • the half-duration step;
  • the buffered offset;
  • the unbuffered re-anchor rule (keep the offset unless the frame comes early, or comes late by a field or a tick).

The unbuffered "don't skip ahead" guard in ready_deinterlace_frames moves too.

These stay C:

  • the async_frames queue and the buffered walk;
  • first_frame;
  • deinterlace_process_last_frame;
  • textures and rendering.

C passes in obs->video.video_time and video_frame_interval_ns, and stores the results.

Plan (one PR, separate commits)

  1. A behaviour-neutral move into libobs/obs-source-deinterlace-pacing.c.h, as hidden pure functions.

  2. Characterization, test_deinterlace_pacing_steps. It pins:

    • each branch of the re-anchor;
    • the hold check at TS_JUMP_THRESHOLD ± 1;
    • a half-duration over 2^32 ns, which truncates in the uint32_t cast;
    • a timestamp going backwards (u64 wrap);
    • the first frame's half-duration, which today is computed against deinterlace_frame_ts == 0.

    The last three are pinned as characterized, not endorsed.

  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-source-deinterlace-pacing group. Exported symbols are unchanged.

  4. Tier 3 parity against the original C: a proptest over full-range u64 inputs, and sequences that model 25/29.97/50/59.94 field rates into 30/60 fps canvases. Plus a deliberate-break check and port_comparison numbers.

test_deinterlace_2x_field_order (real libobs, both field orders, 50i into 60) must stay green on every lane.

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