Skip to content

bug: libobs: 2x deinterlacing skips the first frame's second field after every start #1965

Closed

Description

@rdoupe

Bug

With 2x deinterlacing (Yadif 2x, Linear 2x, Discard 2x and so on), the first frame a source shows has its second field skipped, or, less often, held too long. The same happens to the first frame after a restart or a full queue.

When that frame is picked with no second frame queued, its half duration is computed against deinterlace_frame_ts, the previous frame's timestamp (libobs/obs-source-deinterlace-pacing.c.h, from #1954). For a source that has never shown a frame, deinterlace_frame_ts is 0. The result is (uint32_t)(ts / 2), which is effectively random. Example: a capture card's frame stamped 1000 s after boot gives 1e12 / 2 mod 2^32 = 1.78 s.

  • Buffered (the default): the second field comes due 1.78 s after the pick. The next frame replaces the first 40 ms later (at 50i), so the first frame's second field is never shown. This happens on nearly every start.
  • Unbuffered: the frame's end lands past TS_JUMP_THRESHOLD, so the next tick moves on as if the clock had jumped, and the second field is skipped the same way. In about 0.8% of starts the truncation leaves 0.5–35.5 ms instead, and the frame is held too long: for example to 59 ms, where a 50i frame ends at 39 ms.
  • After a pause: deinterlace_frame_ts is the last frame shown, so a 10 s pause gives 705 ms, with the same effect.

It costs one field per start, restart or queue overflow, and it doesn't persist. test_deinterlace_2x_field_order leaves the first two frames out of its counts partly for this reason (see #456). Upstream has the same code.

Found while porting the pacing in #1950/#1954. Its characterization tests half_duration_first_frame and first_frame_half_duration_hold pin today's behaviour.

Plan

  1. RED: a steps test, and a real-libobs case in test_deinterlace_2x_field_order (or a sibling test), both showing that the first frame's second field is shown at the right time, buffered and unbuffered.
  2. GREEN: when there is no usable previous timestamp, don't compute the half duration from a gap. That covers a source that has never shown a frame, a timestamp going backwards, and a gap past TS_JUMP_THRESHOLD, which is a pause or a new clock. Use a sane fallback instead: the previous half duration if one is known, otherwise half the canvas frame interval. Make the same change in the Rust port and its parity oracle, so the two stay identical.

Activity

  1. rdoupe commented on Oct 23, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #1965.

  2. added
    claimed
    on Oct 23, 2026
  3. added 3 commits that reference this issue on Oct 23, 2026
    bf32f98
    7bb85f3
    f1c31cd
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