Skip to content

obs-source: Port the deinterlace frame selection - #2329

Merged
rdoupe merged 6 commits into
obs-rust:masterfrom
rdoupe:port/deinterlace-select
Oct 25, 2026
Merged

rdoupe merged 6 commits into
obs-rust:masterfrom
rdoupe:port/deinterlace-select

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2315

What and why

Ports the deinterlace frame selection of libobs/obs-source-deinterlace.c.h to rust/obs-source, as a new module deinterlace_select next to deinterlace_pacing (#1954) and deinterlace_draw (#2153). Every deinterlaced async source (capture cards, interlaced media) runs these decisions once a tick, under async_mutex. They choose which queued frames the source drops, which it takes as its current and previous frame, and what happens to the textures:

  • first_frame(): a source with no last_frame_ts yet takes its front frame, paired with the next one when two or more are queued;
  • ready_deinterlace_frames():
  • deinterlace_get_closest_frames(): whether the taken frame's flag is read, whether it takes a pair, whether last_frame_ts starts there, and which offset rule applies;
  • deinterlace_update_async_video(): upload the previous frame, swap the textures, or neither.

The plan's API was adjusted. The plan sketched four calls: select(), first(), take() and update(). They became eight functions, because a single select() or take() would hoist reads that the C makes later:

  • async_unbuffered is set by other threads without a lock (obs_source_set_async_unbuffered()). The C reads it before the walk, again for an unbuffered source left with two frames (after the drops, and then deinterlace_offset), and once more after a take for the offset rule. Each of those reads stays where it was.
  • The taken frame's flag is read only with frames left after it, and last_frame_ts only for a buffered source, as before.

The functions: obs_source_deinterlace_select_first(), _walk() (the whole queue walk, on a copy of the timestamps), _unbuffered_pair() (the guard, through the already ported pacing helpers), _take_reads_flag(), _take_pair(), _take_init_last(), _take_offset() and _update().

The walk is now snapshot, decide, apply. ready_deinterlace_frames() copies the queued timestamps first, on the stack, or the heap past MAX_ASYNC_FRAMES (as get_closest_frame() has since the async pacing port). It then erases the dropped frames from the front, each with da_erase() and then remove_async_frame(), in the walk's order. Last it stores last_frame_ts, deinterlace_offset and the front frame's flag. These are the moves the plan's Risks section accepts:

  • a queued frame's timestamp is never written after it is queued, so reading them all first reads the same values;
  • every reader of last_frame_ts and deinterlace_offset holds async_mutex or runs on the graphics thread, so each is stored once, with the walk's final value, instead of once per step.

These stay in C, in their order and under their conditions: async_mutex, the async_frames queue, da_erase(), remove_async_frame() and the cache, every prev_frame write on a frame, the frame pointers, obs->video, the pacing calls, set_async_texture_size(), update_async_textures() and the texture swaps.

Six commits:

  1. Move (behaviour-neutral): the decisions go to libobs/obs-source-deinterlace-select.c.h, declared in the new obs-source-deinterlace-select.h without EXPORT, so they are hidden.

    The move was checked against the original code. A scratch harness (not committed) compiles origin/master's functions verbatim next to this branch's, the moved file and obs-source-deinterlace-pacing.c.h. A script rewrites every field access into a logging accessor on a stand-in source.

    • It records every read and write of the instrumented fields, every da_erase(), remove_async_frame(), lock, refcount, set_async_texture_size(), update_async_textures() and frame release, in order.
    • Each read of async_unbuffered returns a scripted value: the field, one that changes once, or any value per read, as another thread could set it.
    • 160,000,000 random states: 50,000,000 each with GCC and Clang at -O2, 20,000,000 each at -O0, and 10,000,000 each under ASan and UBSan (GCC -O0, Clang -O2).
    • Inputs: queues of 0 to 11 and 28 to 35 frames; regular, jittered, backwards, wrapping and random timestamps; steps and clocks at FRAME_TOLERANCE and MAX_TS_VAR and one either side; any offsets, half durations, current and previous frames and texture states.
    • 16,296,508,900 events are equal, with the final state, after the one normalization the move needs: inside ready_deinterlace_frames(), frame timestamp reads are dropped, last_frame_ts and deinterlace_offset compare by whether and what they last stored, and whether last_frame_ts was read at all must match. The moved walk is also checked to read every timestamp before its first erase, and last_frame_ts and deinterlace_offset at most once each.

    22 deliberately broken moves were tried; 21 fail the harness:

    • the offset read hoisted before the drops, or read without its async_unbuffered read;
    • release before erase;
    • last_frame_ts read when unbuffered;
    • one async_unbuffered read for the whole take;
    • the flag read with nothing left;
    • the flag stored before deinterlace_frame_ts;
    • each decision changed.

    The one that passes is equivalent: take_pair() without its remaining > 0 test, which the guarded flag read already implies.

  2. Characterization: test_deinterlace_select_steps, 20 cases. It compiles the moved file and obs-source-deinterlace-pacing.c.h (ASan and UBSan) and calls only their functions. The callers are copied onto a stand-in source with every erase, release and prev_frame write recorded. It pins:

    It is in the test graph, sorted.

  3. RED: Tier 1 against todo!(). It ports the 20 C cases 1:1 and adds edge tests: the walk against ready_deinterlace_frames() as it was before the move, written out on a queue that is erased frame by frame (exhaustive over queues of 0 to 6 frames on a grid of steps and clocks, and a proptest over any u64 timestamps and state), the walk's bounds, and the small decisions over every input.

  4. GREEN: the safe core and eight #[no_mangle] shims, in a new libobs.ported-source-deinterlace-select group whose PCH is the new header and the pacing header.

    • The commit updates source-sets.json, the unity lists, the three export lists and ci/test_ported_sources.py, each in sorted place.
    • It adds test_deinterlace_select_steps_rust, which links libobs_rust-static alone, as test_deinterlace_pacing_steps_rust does.
  5. Tier 3: a C oracle of the unchanged file (calling the C pacing oracle), the parity tests and a mutation check.

  6. Docs: the README rows, the crate's description, lib.rs and a port_comparison bench file. docs/rust-port/naming.md already maps libobs/obs-source*.c.h to rust/obs-source.

The core denies clippy's arithmetic, indexing, as, unwrap, expect, panic, unimplemented and unreachable lints. It keeps no state and takes no lock.

  • Kept, characterized, not endorsed:
    • a timestamp going backwards is a step of almost 2^64, so it re-anchors the clock;
    • sys_time before last_sys_timestamp moves the clock back;
    • the compares do not wrap, so frames past u64::MAX compare as far behind a clock that has not wrapped;
    • a frame at timestamp 0 leaves last_frame_ts at 0, so the next tick takes the first frame again.
  • Intentional difference: a null timestamps with a count above 0 is an empty queue for the shim; the C reads through it. libobs never passes one. It is listed in the parity test header, the shim docs and rust/README.md.
  • MSVC x64: all arithmetic is u64 and wraps in C; the port uses wrapping_add/wrapping_sub. Nothing divides or reaches util_mul_div64() (the pacing helpers this calls halve by a constant, already ported), so no input can trap and nothing is guarded.

Bench (x86_64 Linux, GCC, release, not pinned to a core, load average about 7; median per 1024 ticks): select_tick Rust 24.8 µs, C 22.0 µs; long_queue (33 frames) Rust 37.5 µs, C 29.4 µs. That is a few ns more per tick for each deinterlaced source.

RED → GREEN

  • RED commit: 5ee69654d (obs-source: Test the deinterlace_select port; e5e439d8b before the rebase onto e389f2fed). soldr cargo test -p obs-data --test obs-tests-core source::deinterlace_select: 1 passed (the enum values), 25 failed, each on a todo!(). On that commit local_gate --lane lint was clean and --test-diff origin/master failed only on those 25 cases.
  • GREEN (7f0067a1d): Tier 1 26/26. Tier 3 (6ad1c7cb1) 7/7: the constant, enum values, struct layouts; the walk exhaustively over queues of 0 to 6 frames × buffered/unbuffered × nine last_frame_ts × 16 steps × clocks (145,152 walks) and every queue of 7 to 40 frames; proptests (20,000 cases each) over full-range u64 timestamp vectors (sorted, unsorted, wrapping, jittered); the pair guard over 14^4 edge combinations; 86,400 ticks of sequences through a model of the deinterlaced async_tick(), C against the shims, every step and the state after every tick.
  • Mutation check: 27 mutants (22 in the core, 5 in the shims). Tier 1 kills all 22 core mutants; Tier 3 kills all 27. No survivors.
  • Tier 2, at the head (d78b0c896, rebased on e389f2fed):
    • exports: 1766 on the C backend, the hybrid and libobs-c-reference, identical; the eight functions are local in all three, and the hybrid's come from the Rust archive (the group's object is built only for libobs-c-reference);
    • the deinterlace, async and media tests (test_deinterlace_select_steps, test_deinterlace_2x_field_order, test_deinterlace_mode_load, test_media_restart_stale_frame, test_media_restart_first_frame, test_deinterlace_pacing_steps, test_async_frame_pacing_steps and 23 more): 30/30 on the C backend, 35/35 on the hybrid and on libobs-c-reference (with the _rust steps variants);
    • full ctest: hybrid 524/524 (3 skipped as usual: test_pulse_default_follow, test_v4l2_vivid_replug, test_v4l2_vivid_stall); C backend 498/499, the one failure test_view, whose obs_startup() could not open the X display under load (XOpenDisplay failed during hotkey initialization); it passes alone on all three.
  • Gates at the head: local_gate --lane lint, --lane cross and --test-diff origin/master (3937 tests passed) pass; Windows clippy (--target x86_64-pc-windows-msvc --all-targets -D warnings) is clean; soldr cargo test -p obs-c-oracle --bench port_comparison passes.
  • Real app: not applicable (no UI, protocol or logging change).

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): not applicable
  • Intentional differences from C listed in the parity test header and rust/README.md (ports)

Behaviour-neutral extraction before the Rust port. The decisions of
first_frame(), ready_deinterlace_frames(),
deinterlace_get_closest_frames() and deinterlace_update_async_video() in
obs-source-deinterlace.c.h move to
libobs/obs-source-deinterlace-select.c.h, as eight functions on plain
values declared in the new libobs/obs-source-deinterlace-select.h
without EXPORT (hidden, as -fvisibility=hidden keeps them):

- obs_source_deinterlace_select_first(): first_frame(), no last_frame_ts
  yet takes the front frame, flagged when two or more are queued;
- obs_source_deinterlace_select_walk(): ready_deinterlace_frames() on
  the queued timestamps. Unbuffered: all but two frames dropped.
  Buffered: the out-of-bounds reset, the FRAME_TOLERANCE stop, the
  pairwise drop, the two-or-fewer exit and its obs-rust#2009 exception, the
  MAX_TS_VAR re-anchor and the final flag. It returns the frames to drop
  from the front, the new last_frame_ts, whether deinterlace_offset
  resets, the front frame's flag and whether a frame is ready;
- obs_source_deinterlace_select_unbuffered_pair(): the "don't skip
  ahead" guard of an unbuffered source left with two frames, through the
  ported obs_source_deinterlace_pacing_wait_for_next() and
  _waiting_frame_ts();
- obs_source_deinterlace_select_take_reads_flag(), _take_pair(),
  _take_init_last() and _take_offset(): what
  deinterlace_get_closest_frames() does with the frame it takes;
- obs_source_deinterlace_select_update(): upload the previous frame,
  swap the textures, or nothing.

The walk becomes snapshot, decide, apply: ready_deinterlace_frames()
copies the queued timestamps first (on the stack, or the heap past
MAX_ASYNC_FRAMES, as get_closest_frame() has since the async pacing
port), then erases the dropped frames from the front, each with
da_erase() and then remove_async_frame(), in the walk's order, then
stores last_frame_ts, deinterlace_offset and the front frame's flag. A
queued frame's timestamp is never written after it is queued, and every
reader of last_frame_ts and deinterlace_offset holds async_mutex or runs
on the graphics thread, so each is stored once, with the walk's final
value, instead of once per step (the reads and stores the plan's Risks
section accepts).

The plan's single take() and select() are split where a read would
otherwise move: async_unbuffered is set without a lock
(obs_source_set_async_unbuffered()), so each of its reads stays where it
was: before the walk, again for an unbuffered source left with two
frames (then deinterlace_offset), after the drops, and once more for the
offset after a take. The taken frame's flag is read only with frames
left, last_frame_ts only for a buffered source, as before. obs->video,
the pacing helpers, set_async_texture_size(), update_async_textures(),
the texture swaps and every prev_frame write on a frame stay in
obs-source-deinterlace.c.h. All arithmetic is uint64_t and wraps as it
did; nothing divides.

The new file joins libobs.core-source with libobs.pch.h, which includes
the new header; source-sets.json lists it. docs/rust-port/naming.md
already maps libobs/obs-source*.c.h to rust/obs-source. The exported
symbol set is unchanged (1766 on the C backend, the hybrid and
libobs-c-reference); the eight functions are local. The deinterlace,
async pacing and media tests (test_deinterlace_2x_field_order,
test_deinterlace_mode_load, test_media_restart_stale_frame,
test_media_restart_first_frame and 26 more) pass on all three.

Checked in a scratch harness (not committed) that compiles
origin/master's functions verbatim and this branch's next to the moved
file and obs-source-deinterlace-pacing.c.h, on a stand-in source whose
every field read and write is logged (a script rewrites each access into
a logging accessor), with every da_erase(), remove_async_frame(), lock,
refcount, set_async_texture_size(), update_async_textures() and frame
release. async_unbuffered returns a scripted value per read (the field,
or one that changes once, or any value per read). 160,000,000 random
states: 50,000,000 each with GCC and Clang at -O2, 20,000,000 each at
-O0, 10,000,000 each under ASan and UBSan (GCC -O0, Clang -O2), with
queues of 0 to 11 and 28 to 35 frames, regular, jittered, backwards,
wrapping and random timestamps, steps and clocks at FRAME_TOLERANCE and
MAX_TS_VAR and one either side, and any offsets, half durations, current
and previous frames and texture states. 16,296,508,900 events are equal,
with the final state, after the one normalization the move needs: inside
ready_deinterlace_frames(), frame timestamp reads are dropped,
last_frame_ts and deinterlace_offset compare by whether and what they
last stored, and whether last_frame_ts was read at all must match. The
moved walk also reads every timestamp before its first erase, and
last_frame_ts and deinterlace_offset at most once each. Twenty-one of
twenty-two deliberately broken moves fail it (the offset read hoisted
before the drops or without its async_unbuffered read, release before
erase, last_frame_ts read when unbuffered, one async_unbuffered read for
the take, the flag read with nothing left, the flag stored before
deinterlace_frame_ts, and each decision changed); the one that passes is
equivalent (take_pair() without its remaining > 0 test, which the
guarded flag read already implies).

Refs obs-rust#2315
test_deinterlace_select_steps compiles
libobs/obs-source-deinterlace-select.c.h, and
obs-source-deinterlace-pacing.c.h which it calls, into itself (ASan and
UBSan) and calls only their hidden functions, through their headers.
ready_deinterlace_frames(), first_frame() and
deinterlace_get_closest_frames() are copied from
obs-source-deinterlace.c onto a stand-in source with every erase,
release and prev_frame write recorded, so the composition is pinned too.
20 cases pin:

- the header's enum values and sizes and MAX_TS_VAR;
- the first frame: no last_frame_ts takes the front frame, flagged with
  two or more queued, for 0 to 4 frames; any last_frame_ts walks;
  characterized, not endorsed: a frame at timestamp 0 leaves
  last_frame_ts at 0;
- the unbuffered walk for queues of 0 to 5, 30 and 33 frames (all but
  two dropped, the front one the clock), whatever the clock and order;
- the buffered walk: an empty queue; the out-of-bounds reset at
  MAX_TS_VAR and one either side, both ways; FRAME_TOLERANCE - 1, at it
  and + 1; the pairwise drop for 5, 6, 30 and 33 frames; the
  two-or-fewer exit for 1 to 5, 30 and 33 frames, with and without a
  taken frame (obs-rust#2009: a dropped frame is no pair); the MAX_TS_VAR
  re-anchor at - 1, at it and + 1, and across a jump with the front
  frame behind the clock;
- characterized, not endorsed: a timestamp going backwards re-anchors
  (the u64 step wraps); sys_time before last_sys_timestamp moves the
  clock back; frames past UINT64_MAX compare as far behind a clock that
  has not wrapped;
- the unbuffered pair guard with and without an offset, at the frame's
  end and either side, and with the next frame before the first
  (characterized, not endorsed: the duration wraps);
- the take decisions and each update case;
- the callers: the first frame with one and two queued, a buffered drop
  and pair ("E0 R0 E1 R1 F2=1 E2 E3"), obs-rust#2009's dropped previous frame,
  an unbuffered queue of 33 (past MAX_ASYNC_FRAMES), an unbuffered
  source waiting and pairing.

The test is in the test graph, sorted. test_deinterlace_2x_field_order,
test_media_restart_stale_frame and test_media_restart_first_frame cover
the callers through the real libobs.

Refs obs-rust#2315
Adds the deinterlace_select module to rust/obs-source with its API and
every function as todo!(): MAX_TS_VAR, FRAME_TOLERANCE (the pacing
module's), the First, State, Walk and Pair results, the OffsetKind and
Update enums (with the C enums' values), first(), walk(),
unbuffered_pair(), the four take_*() decisions and update().

tests/source/deinterlace_select.rs ports test_deinterlace_select_steps
1:1 (steps_*: the same 20 cases, inputs and expectations, with the
stand-in source and the copies of the callers, every erase, release and
prev_frame write recorded) and adds edge cases (edge_*):

- the walk against ready_deinterlace_frames() as it was before the move,
  written out on a queue that is walked with a cursor and erased frame
  by frame: exhaustively over queues of 0 to 6 frames on 14 steps
  (FRAME_TOLERANCE and MAX_TS_VAR and one either side, backwards,
  u64::MAX, 2^63), 8 anchors, a clock at and around each frame, buffered
  and unbuffered, three offsets; and by proptest (20,000 cases) over any
  u64 timestamps, sorted, unsorted, regular from any start (wrapping) or
  jittered with gaps and steps back, and any state;
- the walk's bounds (drops fewer than it was given, an unbuffered queue
  keeps two, a flagged front frame has a pair) for any input;
- the pair guard and first() against their rules, for any input; the
  take and update decisions over every input.

RED: soldr cargo test -p obs-data --test obs-tests-core
source::deinterlace_select: 1 passed (the enum values), 25 failed, each
on a todo!() (obs_source_deinterlace_select_walk, _first,
_unbuffered_pair, _take_reads_flag and _update are the first reached).

Refs obs-rust#2315
Ports libobs/obs-source-deinterlace-select.c.h, the deinterlace frame
selection of first_frame(), ready_deinterlace_frames(),
deinterlace_get_closest_frames() and deinterlace_update_async_video(),
to the deinterlace_select module of rust/obs-source.
obs-source-deinterlace.c.h stays C around it: async_mutex, the timestamp
copy, the async_frames queue, da_erase(), remove_async_frame() and the
cache, every prev_frame write, the frame pointers, each read of the
source's fields where it was (async_unbuffered, set without a lock, once
per read), obs->video, the pacing helpers it already called and the
textures. The hybrid libobs drops the C file and links the Rust shims in
its place.

Safe core (src/deinterlace_select.rs):
- first(): First { first, flag_front } from last_frame_ts and the count;
- walk(&[u64], sys_time, State) -> Walk { drop_front, last_frame_ts,
  offset_reset, pairs, flag_front, ready }: the unbuffered drop to two,
  the out-of-bounds reset, the FRAME_TOLERANCE stop, the pairwise drop
  (a cursor over the slice for the C's erases), the two-or-fewer exit
  and its obs-rust#2009 exception, the MAX_TS_VAR re-anchor; an empty slice
  keeps last_frame_ts and takes nothing;
- unbuffered_pair() -> Pair { prev_frame, frame_ts: Option<u64> },
  through deinterlace_pacing::wait_for_next() and waiting_frame_ts()
  in-crate;
- take_reads_flag(), take_pair(), take_init_last(), take_offset() ->
  OffsetKind and update() -> Update, with the C enums' values. Every sum
  and difference is wrapping_add()/wrapping_sub(), as uint64_t in the C;
  nothing divides, so no MSVC trap is possible. The module denies
  clippy's arithmetic, indexing, as, unwrap, expect, panic,
  unimplemented and unreachable lints, keeps no state and takes no lock.

Shims (src/ffi/source_deinterlace_select.rs): the eight functions keep
the C signatures; the three results are #[repr(C)] mirrors of the C
structs, the enums go back as u32. Only the timestamps cross, by pointer
and count. Intentional difference: a null timestamps with a count above
0 is an empty queue (the C reads through it; libobs never passes one).

C side: the file leaves libobs.core-source for its own group,
libobs.ported-source-deinterlace-select (LIBOBS_PORTED_SOURCES), whose
PCH is obs-source-deinterlace-select.h and
obs-source-deinterlace-pacing.h; libobs.pch.h keeps the header for
obs-source-deinterlace.c. The functions are not EXPORT, so the shims are
hidden: rust-hidden.txt, the local: list of rust-exports.map and
rust-unexports-macos.txt. libobs-rust already links the crate's ffi. The
exported symbol sets are unchanged and equal: 1766 on the C backend, the
hybrid and libobs-c-reference; the eight functions are local in all
three, and the hybrid's come from the Rust archive (the group's object
is built only for libobs-c-reference). ci/test_ported_sources.py checks
the group on every host.

test_deinterlace_select_steps still compiles the C file into itself,
unchanged, and test_deinterlace_select_steps_rust runs the same test
source against libobs_rust-static alone: the obs-source member links on
its own, as for test_deinterlace_pacing_steps_rust.

Tier 1 obs_source::deinterlace_select passes 26/26.

Refs obs-rust#2315
Adds the C oracle of the unchanged
libobs/obs-source-deinterlace-select.c.h (rust/obs-c-oracle,
oracle/source_deinterlace_select.c, its functions renamed to oracle_*,
and the two pacing functions it calls renamed to the C pacing oracle's,
so the oracle is C throughout) and
tests/source/deinterlace_select_parity.rs, which gives every input to
the oracle, the shims and the core and compares the bytes the C lays
out: drop_front and the timestamps as integers, each bool as the byte
the C stores (0 or 1, and equal), the enums as the u32 the C returns.

- the constant, the enum values, the three result structs' sizes and
  offsets and the enum sizes against the C header;
- the walk exhaustively over queues of 0 to 6 frames x buffered and
  unbuffered x nine last_frame_ts (0, at, around and MAX_TS_VAR from the
  front frame, u64::MAX) on 16 steps (FRAME_TOLERANCE and MAX_TS_VAR and
  one either side, backwards, wrapping, 0, 1, 2^63, u64::MAX) from three
  starts, with the clock at and around each frame (145,152 walks, each
  outcome reached over 1,000 times); every queue of 7 to 40 frames on
  the steps;
- proptests (20,000 cases each) over full-range u64 timestamp vectors of
  0 to 40 frames (any, sorted, regular from any start with any step,
  wrapping, jittered with steps back and threshold gaps) and any state;
  and first(), the pair guard and the take and update decisions over any
  input;
- first(), the pair guard (14^4 edge combinations), the take and update
  decisions exhaustively over their edges;
- sequences through a model of the deinterlaced async_tick() as
  obs-source-deinterlace.c.h now calls the functions (the queue, its
  erases and releases, the flags, the 30-frame cache reset and the
  source's fields), one copy driven by the C and one by the shims: 25,
  29.97, 50 and 59.94 fields into 30, 50 and 59.94 fps, buffered and
  unbuffered, clean and with jitter, bursts, stalls, late and missed
  ticks, a canvas clock going back, jumps of MAX_TS_VAR, steps back and
  random timestamps (86,400 ticks; holds, resets, waits, pairs and
  releases each reached over 100 times). The steps and the state after
  every tick must match.

MSVC x64: nothing here divides or reaches util_mul_div64(), so no input
needs a guard. Intentional difference (not compared): a null timestamps
with a count above 0 is an empty queue for the shim.

Mutation check (not committed): 27 mutants, each run against Tier 1 (26
tests) and Tier 3 (7).

| Area | Mutants | Tier 1 kills | Tier 3 kills | Survivors |
|---|---|---|---|---|
| first (one frame flagged, last_frame_ts of 1 as none) | 2 | 2 | 2 | 0 |
| unbuffered walk (keeps three, clock from the last frame) | 2 | 2 | 2 | 0 |
| buffered walk (out of bounds at MAX_TS_VAR or keeping the offset, no sys_offset, tolerance <=, no obs-rust#2009 exception, exit at three or keeping the offset, step of one behind a pair, re-anchor at MAX_TS_VAR or without the front offset, frame_offset not updated, flag from frame, wrapping compare) | 13 | 13 | 13 | 0 |
| pair guard (waits without an offset, frame_ts not moved back) | 2 | 2 | 2 | 0 |
| take and update (flag read with nothing left, init_last inverted, swap before upload) | 3 | 3 | 3 | 0 |
| shims (frame_ts kept when not waiting, set_frame_ts inverted, the two clocks swapped, offset kind inverted, take_pair ignoring remaining) | 5 | 0 | 5 | 0 |

Tier 1 26/26 and Tier 3 7/7 pass.

Refs obs-rust#2315
- rust/README.md: the obs-source crate row lists
  libobs/obs-source-deinterlace-select.c.h, and a new row for it in the
  ported file table: the eight decisions, why the plan is split (each
  read of the unlocked async_unbuffered and of the guarded fields stays
  where it was), what stays C, the characterized and not endorsed cases,
  the intentional difference and the tests;
- rust/obs-source: the crate description and the lib.rs docs name the
  new file and the deinterlace_select module;
- rust/obs-c-oracle: a port_comparison bench file,
  port_comparison/source_deinterlace_select.rs, in the sorted
  modules![...] list: 1024 ticks through first(), the walk, the pair
  guard and the take decisions on both sides (1 to 8 queued frames, and
  33 past MAX_ASYNC_FRAMES), checked equal by a checksum first. Measured
  (x86_64 Linux, GCC, release, not pinned to a core, load average about
  7; median per 1024 ticks): select_tick Rust 24.8 us, C 22.0 us;
  long_queue Rust 37.5 us, C 29.4 us, a few ns more per tick for each
  deinterlaced source. Its fixtures are plain vectors and allocate
  nothing through bmem, so the bench's free check holds.

docs/rust-port/naming.md already maps libobs/obs-source*.c.h to
rust/obs-source, so it needs no new row. The port changes no behaviour a
user can see, so docs/features.md has no line for it.

Fixes obs-rust#2315
@rdoupe
rdoupe force-pushed the port/deinterlace-select branch from e5e439d to d78b0c8 Compare October 25, 2026 03:58
@rdoupe
rdoupe marked this pull request as ready for review October 25, 2026 03:58
@rdoupe
rdoupe requested a review from zackees as a code owner October 25, 2026 03:58
@rdoupe
rdoupe added this pull request to the merge queue Oct 25, 2026
Merged via the queue into obs-rust:master with commit 33f2b4d Oct 25, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port the deinterlace frame selection in obs-source-deinterlace.c to obs-source

1 participant