Repository navigation
Closed
Description
#8 closed when feature PR #33 merged, but PR #39 ported only vec2 (new obs-graphics crate).
Remaining:
- Graphics math (policy order):
- vec2 (feat(graphics): port vec2 math to Rust obs-graphics crate (#8) #39)
- vec3 (rust: Port graphics/vec3.c to obs-graphics #75)
- vec4 (rust: Port graphics/vec4.c to obs-graphics #73)
- axisang (rust: Port graphics/axisang.c to obs-graphics #83)
- quat: rust: Port graphics/quat.c to obs-graphics #148
- matrix3: rust: Characterize and port graphics/matrix3.c #149
- matrix4 (SIMD: document any ULP tolerance): rust: Characterize and port graphics/matrix4.c #150
- plane
- bounds
- math-extra
- media-io:
- video-fourcc (rust: Port media-io/video-fourcc.c to a new obs-media-io crate #97)
- video-matrices (rust: Port media-io/video-matrices.c to obs-media-io #106)
- video-io.h / frame-rate.h inline helpers (rust: Port media-io video-io.h and frame-rate.h inlines to obs-media-io #114)
- video-frame characterization test (test: characterize video-frame.c before media-io port #117)
- audio-io characterization test (test: characterize audio-io.c before media-io port #120, draft)
- video-frame port: rust: Port media-io/video-frame.c to obs-media-io #151
- audio-io port
- video-io characterization + port
- format-conversion (deferred: SSE-heavy, little safety gain)
- FFmpeg wrappers (audio-resampler-ffmpeg, video-scaler-ffmpeg, media-remux) stay C.
- AVC/HEVC/AV1 parser ports with cargo-fuzz parity against the C oracle (rust: Port obs-nal.c to a new obs-codec crate #89 obs-nal, rust: Port obs-avc.c to obs-codec #90 AVC, rust: Port obs-hevc.c to obs-codec #98 HEVC, rust: Port obs-av1.c to obs-codec #105 AV1; one-off 1 h fuzz runs, no mismatch). Running the fuzzers on a schedule: quality: Run the cargo-fuzz differential targets on a schedule #144.
- obs-websocket v5 Tier 4 black-box suite, green against the current C++ server (test: obs-websocket v5 Tier 4 black-box suite #104; run by hand; CI against an ON build: ci: Build the full app with ENABLE_RUST_LIBOBS=ON and run Tier 4 against it #140). Rust port of the server: design: obs-websocket v5 server in Rust #147.
- Document the aarch64 last-bit difference: a Rust build of libobs may give
vec2_normresults that differ from C in the last bit on arm64, because of FMA contraction. Decide on a ULP tolerance or on disabling contraction.
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsDone
Activity
b7216309-jpg commentedon Oct 10, 2026
I'd like to take the AVC/HEVC/AV1 parser item. Plan, one PR per C file, each following the testing policy (C characterization first where missing, then RED, then GREEN):
libobs/obs-nal.c:obs_nal_find_startcode, the FFmpeg start-code search that AVC and HEVC share. It scans word by word after an alignment prologue, so parity calls it at every pointer alignment and around the 4-byte start-code adjustment.libobs/obs-avc.c: the 6 exports. Notes:obs_parse_avc_packetprefixes its output with alongrefcount (4 bytes on Windows, 8 elsewhere),obs_parse_avc_headertruncates SPS/PPS sizes touint16_t, and the SPS reader keeps theget_ue_golombcap from fix(libobs): get_ue_golomb UB on a truncated SPS (1 << 32) #17.struct encoder_packetgets a layout test.libobs/obs-hevc.clibobs/obs-av1.c(OBU parsing)Fuzz parity. Each port gets proptest parity against the C oracle on structured inputs (start codes, emulation-prevention bytes, truncated NALs and SPS) and arbitrary bytes. I also plan a
cargo-fuzztarget per parser that runs the Rust and C sides on the same input and asserts equal results. cargo-fuzz needs nightly and libFuzzer, so I'd keep those targets out of the default workspace and the required CI. They would be run on demand, or in a separate job if you want one.Starting with
obs-nal.cnow. Please say if you'd rather split or order this differently.swilk19 commentedon Oct 10, 2026
I'd like to take the media-io item, starting with the two smallest pure-function files. One PR per file, each following the testing policy: a C characterization test first, then a failing (RED) test against stubs, then the port (GREEN).
libobs/media-io/video-fourcc.c:video_format_from_fourcc, in a newobs-media-iocrate (per the testing policy). A cmocka test pins every mapped fourcc, plus unknown codes going toVIDEO_FORMAT_NONE. Parity runs against the C oracle over the fullu32range, and the result enum gets a layout test.libobs/media-io/video-matrices.c:video_format_get_parametersandvideo_format_get_parameters_for_format. Things to note:static bool, so two threads calling at the same time race on the initialization. The Rust side would useOnceLock.bpcis clamped to 8–16.DEFAULT/SRGBmap to 709 and2100_HLGmaps to2100_PQ.range_min/range_maxout-pointers can be NULL.Parity compares every colorspace × range × format (and bpc) combination with the C output, bit for bit.
initialize_matrixcallsvec3_rotate, so I'll start the matrices port once #75 (vec3) lands and build onobs-graphics'Vec3, so it doesn't duplicate that work. fourcc doesn't depend on anything, so I'll start there now.I'm only taking these two files. The rest of media-io (
format-conversion.c,video-frame.c,video-io.c,audio-io.c, the ffmpeg scaler/resampler,media-remux.c) is still open for anyone. Please say if you'd rather split or order this differently.rust: Add the obs-codec crate with an obs-nal shim and tests (RED)
test: obs-websocket v5 Tier 4 black-box suite
swilk19 commentedon Oct 10, 2026
Both files from my first claim are in:
video-fourcc.c(#97) andvideo-matrices.c(#106). Thanks for the rebases and the Windows fix.I'd like to take the rest of media-io's pure, deterministic units next. Same workflow as before: one PR per unit, each with a C characterization test first, then RED, then GREEN.
video-io.hinlines +frame-rate.h: header-inline, so they use the policy's header-inline exemption. That means a layout test for every public struct plusoracle_*wrappers and parity. There's no symbol swap, and the headers are left untouched.audio-io.hinlines + structs: header-inline as well.audio-math.h:mul_to_db/db_to_mul.video-frame.c:video_frame_init,video_frame_copyand related functions, inobs-media-io.format-conversion.c: the pixel-packing conversions, aftervideo-frame.c.I'll keep at most two of these PRs open at a time, since they all touch
obs-media-io'slib.rs,ffi/mod.rsandvideo_io.rs.Not taking yet, and why:
video-io.c,audio-io.c: these are the stateful core: worker threads,os_sem/os_event, recursive mutexes, atomics, and the profiler name store.audio-io's loop is driven by the wall clock. obs-util: port util/task.c to Rust #87 shows a way to handle the threading, by reimplementing the primitives withMutex/Condvarinside the port. But both files also call intoprofiler.c, which is still C, and each needs a deterministic characterization test first. I'd like to finish the pure units before taking these on.video-scaler-ffmpeg.c,audio-resampler-ffmpeg.c,media-remux.c: these are thin FFmpeg wrappers, so I'd leave them in C for now and port them viaffmpeg-sys-nextalongsidevideo-io/audio-io. Pure-Rust replacements aren't bit-exact with FFmpeg, so they would be a separate behaviour change, not a port.Please say if you'd rather split or order this differently, and let me know if you have a preferred approach on any of these.
zackees commentedon Oct 10, 2026
Approved, with one added unit and some notes per item. No one else has claimed any of these: there are no open PRs touching
libobs/media-io/, and the only other claim on this issue (the parsers) is done. Go ahead and start with item 1.Order
video-io.hinlines +frame-rate.h: as proposed.audio-io.h:util/util_uint64.h(util_mul_div64) inobs-util.audio_frames_to_nsandns_to_audio_framesare thin wrappers around it, and it is a util header, so it belongs inobs-util, notobs-media-io. It doesn't touch the obs-media-io files, so it can be open alongside the others without counting toward your two-PR limit.audio-io.hinlines + structs.audio-math.h: keep it separate or fold it into 3, whichever you prefer.video-frame.c.format-conversion.c.video-frame.cdoesn't need item 1, andformat-conversion.cdoesn't includevideo-frame.hor call into it. The order above is just to limit conflicts, so swap them if that's more convenient.Header-inline units (1-4)
Your reading of the exemption is right: a layout test for every public struct, the unchanged C tests passing OFF and ON, no symbol swap, and the header left alone. Tier 1 and Tier 3 still apply, against
oracle_*wrappers. Please still land the cmocka characterization test first. Tier 1 needs a C test to port 1:1, and without one, "unchanged C tests pass OFF/ON" doesn't check anything.video_data,video_output_info,video_scale_info,media_frames_per_second. Also addenum video_trcandenum video_scale_typetovideo_io.rs, with size/align/enumerator checks like rust: Port media-io/video-matrices.c to obs-media-io #106 did for colorspace and range.video_output_infohas a pointer and asize_t, so take the offsets from the oracle rather than hardcoding them.get_video_format_namereturns"v210"and"R10l"(not all upper case), and every out-of-range value goes to the default result (false/"None"/"Unknown"/"Partial"). Parity should cover values outside the enums as well, through*_from_creturningNone.frame-rate.hhas no includes of its own. The oracle wrapper has to includec99defs.hfirst. A zero numerator or denominator gives inf or NaN, and parity compares those bit for bit too.util_mul_div64does different math on different platforms. MSVC x64 uses_umul128/_udiv128, which is exact 128-bit math. Every other platform uses(num / div) * mul + (rem * mul) / divwith u64 wrapping. The results differ oncerem * muloverflows. The Rust code has to match each platform: au128path undercfg(all(target_env = "msvc", target_arch = "x86_64"))andwrapping_*everywhere else. Exclude, and list,div == 0(UB on both paths) and, on MSVC, quotients ≥ 2^64 (_udiv128faults).audio-math.his header-inline too and defines no struct, so its Tier 2 is just the C test passing OFF/ON. It's scalar, so Tier 3 is exact bit equality per the Phase 5 rule, with no ULP tolerance.log10f/powfcome from the platform libm, which is the same libm on both sides of the parity test, so exact bits are achievable. Keep the cmocka test to portable values, though: exact cases like0and-0.0→-inf,1→0,db_to_mul(0)→1,±inf/NaN →0, a negative input → NaN, and a tolerance for everything else, because glibc, UCRT and libSystem differ in the last bit. Keep10.0f32.powf(db / 20.0)as written. If you hit a last-bit mismatch, check whether one compiler rewrotepow(10, x)intoexp10before suspecting anything else.video-frame.c
video-frame.h's inlines (video_frame_free/_create/_destroy) and thestruct video_framelayout test, under the header-inline rule.bmallocandbase_get_alignmentare already Rust, so nothing blocks this.video_frame_get_linesizes/video_frame_get_plane_heightsaren't static, but they have no header declaration and no caller outsidevideo-frame.c, and libobs builds with hidden visibility. Keep them in the safe core with no C symbol. Onlyvideo_frame_initandvideo_frame_copygo inrust-exports.txt.align_uint32(&width, 48), butALIGNmasks with~(alignment - 1), which only works for powers of two. Width 1 aligns to 16 (linesize 48), width 47 aligns to 80 (224), and width 1280 gives 3424 instead of 3456. It never comes out smaller than the width, so nothing overruns. Port it as is. Fixing it would be a separate C change with its own RED test.VIDEO_FORMAT_NONE, an out-of-range format, or width/height 0) ends inbmalloc(0), whichbcrashes. Leave those out of the cmocka test and list them as parity exclusions.width * 4,HALF(UINT32_MAX)= 0, and the u32linesize * heightslength invideo_frame_copy.format-conversion.c
vec3/vec4/matrix4), so this one is exact byte equality. Write a scalar safe core with nocore::arch. Each lane works out to plain integer math: luma and chroma byte extraction, and chroma averaged as(a + b + c + d) >> 2.sse-shim/simde/x86/sse2.honly defines the float__m128ops for non-x86. Includingformat-conversion.cin the oracle will fail on the macOS arm64 Rust job unless you add the__m128iops it uses, lane by lane:_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, and__m128iitself._mm_load_si128is an aligned load. The UYVX functions also step 4 pixels and 2 rows at a time, reading row y+1. Generate 16-byte-aligned input within_linesize % 16 == 0, widths that are multiples of 4, and even row ranges. Inputs outside that read or write past the line in C, so exclude and list them.decompress_*stores native-endianuint32_t, so useto_ne_bytes.Not taking yet
I agree on
video-io.c/audio-io.c. Besidesprofiler.c, they callobs_get_profiler_name_store()inobs.c, plus the scaler and resampler, so they aren't leaf units.On the FFmpeg wrappers, I agree that a pure-Rust replacement would be a behaviour change, not a port. But the wrappers don't need porting for
video-io/audio-ioto be ported: a Rustvideo-iocan callvideo_scaler_*/audio_resampler_*through their existing C API.ffmpeg-sys-nextwould add an FFmpeg build dependency to the Rust workspace and to everyrust-testsjob, for very little gain. Leave the wrappers in C. If you still want them later, write it up under## Decisionshere first.test: characterize video-frame.c before port
test: characterize audio-io.c before port
swilk19 commentedon Oct 11, 2026
The media-io part 2 plan approved above (#45 (comment)) is done. All six units are merged:
video-io.hinlines +frame-rate.h: rust: Port media-io video-io.h and frame-rate.h inlines to obs-media-io #114util/util_uint64.h(util_mul_div64) in obs-util: rust: Port util/util_uint64.h (util_mul_div64) to obs-util #122audio-io.hinlines + structs: rust: Port media-io audio-io.h inlines + structs to obs-media-io #129audio-math.h: rust: Port media-io/audio-math.h to obs-media-io #179video-frame.c(+video-frame.hinlines): rust: Port media-io/video-frame.c to obs-media-io #182, closes rust: Port media-io/video-frame.c to obs-media-io #151format-conversion.c: rust: Port media-io/format-conversion.c to obs-media-io #184, closes rust: Port libobs/media-io/format-conversion.c to obs-media-io #183. The oracle'ssse-shimnow has the__m128iinteger ops. Parity also runs them on x86 against native SSE2, through a second oracle build withOBS_ORACLE_SCALAR_SSE.Still open in media-io, and not claimed by me:
audio-io.candvideo-io.c: the stateful core. As agreed above, these aren't leaf units, because they callprofiler.c,obs_get_profiler_name_store()inobs.c, and the scaler/resampler. test: characterize audio-io.c before media-io port #120 has the audio-io characterization test (draft).Thanks for the reviews, rebases and merges.
From here on, I'll file and claim a separate issue for each unit, as
docs/rust-port/coordination.mddescribes, instead of claiming items here.test: characterize audio-io.c before port
test: characterize audio-io.c before port
nathan-v commentedon Oct 12, 2026
Claiming: libobs/graphics/math-extra.c
test/cmocka/test_math_extra.cpins the current exports. Header-inlineget_percentageandget_percentageistay C. The test does not readwafterpolar_to_cartor a non-zerocart_to_polar(that lane is uninitialized in C).0.0).obs-c-oracle,ENABLE_RUST_LIBOBSdropsgraphics/math-extra.c, export fragmentlibobs/cmake/rust-exports.d/obs-graphics-math_extra.txt. Remove the oracle's unrenamedrand_floathost so the Rust shim provides it forvec3_rand.nathan-v commentedon Oct 13, 2026
Claiming: libobs/media-io/video-io.c (characterization + port)
test/cmocka/test_video_io.cpins open/close, invalid params, getters, connect/disconnect, lock/unlock delivery, the frame-rate divisor, a full cache, texture-encoder refcounts, and the shallowvideo_output_create_with_frame_rate_divisorcopy.test_video_io_inlines.cstays as it is. Odd cases are marked characterized, not endorsed.todo!()stubs inobs-media-io.ENABLE_RUST_LIBOBSdropsmedia-io/video-io.c.video_scaler_*stays the FFmpeg C file.closeon a divisor child stops the root and frees only the child; the C path frees the parent's cache and mutexes too.Please add the claimed label. I cannot.
Refs #45
9 remaining items
rust: Port media-io/video-io.c to obs-media-io
rust: Drop the input borrow before blog
rust: Format the video-io oracle
rust: Scale frames outside the input borrow
rust: Port media-io/video-io.c to obs-media-io (#420)
nathan-v commentedon Oct 14, 2026
Claiming: the Windows half of
libobs/media-io/audio-io.c.Tracked in #728. The Unix port stays as it is. Please add the claimed label on #728; I cannot.
nathan-v commentedon Oct 15, 2026
audio-io port landed in #745 (1b61353). #728 is closed. I can't edit this checklist.
zackees commentedon Oct 25, 2026
Triage (coordinator): tracker. #148-#151 are closed but unchecked here; the open items (plane, bounds, math-extra, video-frame/video-io/audio-io follow-ups) have no issues of their own, so there are no children to attach as sub-issues. Suggest: tick the closed ones and file one issue per remaining item when someone is ready to claim it (as #153 says).
zackees commentedon Oct 30, 2026
Triage on current
master: this tracker is already implemented; its checklist was not updated after the ports landed.Evidence:
soldr cargo test -p obs-graphics --test obs-tests-graphics— 442 passed.soldr cargo test -p obs-media-io --lib— 282 passed.soldr cargo test -p obs-nvenc --test obs-tests-codec— 86 passed, 1 ignored (requires an NVIDIA driver).test/websocket-tier4/; its README documents the completed C++-server run and 147 request-type coverage.-ffp-contract=off(rust/obs-c-oracle/build.rs), so parity has a stable non-fused oracle.No source changes are required. I did not rerun Tier 4 here because it requires a full OBS build plus Xvfb; this triage run verified its checked-in suite and prior completion evidence.