Skip to content

rust: Port libobs/media-io/format-conversion.c to obs-media-io #183

Closed

Description

@swilk19

Unit

libobs/media-io/format-conversion.c → obs-media-io

Phase and position

Phase 5, media-io item 6 in the approved order on #45. Requirements are from the maintainer's approval: #45 (comment) (see its format-conversion.c section). Independent of item 5, video-frame.c, #151; the maintainer noted the two can be swapped.

Dependencies and existing tests

No unit dependencies: the six functions are pure buffer transforms and format-conversion.c doesn't include or call video-frame.h. No cmocka characterization test exists, so test/cmocka/test_format_conversion.c lands first, passing with ENABLE_RUST_LIBOBS OFF and ON. Nothing in the tree calls these functions; they are exported API only, so that test is the only Tier 2 coverage.

Notes

  • Exports: compress_uyvx_to_i420, compress_uyvx_to_nv12, convert_uyvx_to_i444, decompress_420, decompress_nv12, decompress_422.
  • The SIMD is SSE2 integer only, so parity is exact byte equality (no ULP allowance). The Rust core is scalar with no core::arch: luma/chroma byte extraction, chroma averaged as (a + b + c + d) >> 2.
  • The oracle's sse-shim/simde/x86/sse2.h only has the float __m128 ops for non-x86. It needs the __m128i ops this file uses (_mm_set1_epi32/epi16, _mm_and_si128, _mm_srli_si128, _mm_packs_epi32, _mm_packus_epi16, _mm_add_epi64, _mm_shuffle_epi32, _mm_shufflelo_epi16, _mm_srai_epi16, _mm_load_si128), lane by lane, for the macOS arm64 job.
  • Parity inputs: 16-byte-aligned buffers with in_linesize % 16 == 0, widths that are multiples of 4, even row ranges. Inputs outside that read or write past the line in C, so they are excluded and listed.
  • Output buffers are canary-filled and compared in full, so stray writes show up. decompress_* stores native-endian uint32_t, so expectations use to_ne_bytes.

Activity

  1. swilk19 commented on Oct 11, 2026

    @swilk19
    ContributorAuthor

    Claiming: libobs/media-io/format-conversion.c (item 6 on #45). One PR, port/format-conversion:

    1. Characterization: test/cmocka/test_format_conversion.c, passing OFF and ON.
    2. RED: Tier 1 tests in obs-media-io porting it 1:1 against a todo!() core, plus the __m128i ops in the oracle's sse2 shim and oracle_* parity scaffolding.
    3. GREEN: a scalar safe core plus FFI for the six exports in a new rust-exports.d fragment, with Tier 3 byte-exact parity using canary-filled buffers.

    I expect to open the PR within 48 hours. I don't have permission to add labels, so this issue is missing claimed, port and enhancement.

  2. added a commit that references this issue on Oct 11, 2026
    9e51716
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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions