Skip to content

rust: Port the async frame copy plan and cache decisions in obs-source.c to obs-source #2192

Closed

Description

@rdoupe

Unit

Port the async frame copy plan and cache decisions in libobs/obs-source.c.h to rust/obs-source, as a new module frame_copy. These decisions move:

  • The frame copy. copy_frame_data_line, copy_frame_data_plane and copy_frame_data:
    • which metadata is copied, including the colour range only when the frame is not full range;
    • the rows for each plane of each video_format ((height + 1) / 2 for 4:2:0 chroma);
    • one copy, or row by row with the smaller line size.
  • The texture check. async_texture_changed: whether the size or the convert type changed.
  • The cache.
    • clean_cache: the unused count, and dropping a frame at MAX_UNUSED_FRAME_DURATION.
    • In cache_video: the overflow at MAX_ASYNC_FRAMES (clear and refuse), the reset on a change, and which unused frame to pick first.
  • The full-range rule for non-YUV frames in obs_source_output_video/obs_source_output_video2 and their preload and set-frame variants, plus preload_frame_changed.

These stay in C: every memcpy, frame create and destroy, the cache and frame arrays, async_mutex, the refcount atomics, and get_convert_type (C passes in both types).

Plan (one PR, separate commits)

  1. A behaviour-neutral move into libobs/obs-source-frame-copy.c.h, as hidden functions.
  2. Characterization in test_source_frame_copy_steps. It covers:
    • every video_format, plus values outside the enum;
    • odd heights;
    • equal, smaller and larger line sizes on each plane, and a line size of 0;
    • the cache overflow at MAX_ASYNC_FRAMES - 1, at the limit and at + 1;
    • the unused-count drop at the limit;
    • each full-range case.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-source-frame-copy group. Exported symbols are unchanged.
  4. Tier 3 parity against the original C. It is exhaustive over format × line-size relation and adds a proptest over full-range sizes and line sizes. The step test also runs under ASan, because the plan drives memcpy. Plus a deliberate-break check and port_comparison numbers.

These real-libobs tests must stay green on every lane: test_video_frame, test_async_frame_pacing_steps, the media restart tests, the v4l2 and PipeWire camera tests, and the async rotation and deinterlace tests.

Activity

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2192.

  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