Repository navigation
rust: Port media-io video-io.h and frame-rate.h inlines to obs-media-io - #114
Merged
Merged
Conversation
…test Pins the header-inline helpers before the Rust port: format_is_yuv and get_video_format_name for every enum video_format value (including the lower-case "v210" and "R10l"), get_video_colorspace_name (DEFAULT is named as Rec. 709), resolve_video_range and get_video_range_name for every format with each range, and the frame-rate.h conversions and validity check. Values outside the enums are characterized: an unknown format is not YUV and is named "None", an unknown colorspace is "Unknown", an unknown range is returned unchanged by resolve_video_range and named "Partial". Zero frame-rate parts are divided as is (inf, 0 or NaN). The conversions are single double divisions and are compared exactly. Nothing is swapped, so the test passes with ENABLE_RUST_LIBOBS OFF and ON alike. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1, Tier 2 layout and Tier 3 parity tests for the static inline helpers in media-io/video-io.h (format_is_yuv, get_video_format_name, get_video_colorspace_name, resolve_video_range, get_video_range_name) and media-io/frame-rate.h (media_frames_per_second_to_frame_interval, _to_fps, _is_valid), against todo!() cores. The helpers are header-inline, so nothing is swapped or exported and the header-inline exemption applies: Tier 2 is a layout test of every struct the headers define plus the unchanged cmocka test passing OFF and ON. ffi::video_io mirrors struct video_data, struct video_output_info and struct video_scale_info with the enums as c_ints, and ffi::frame_rate mirrors struct media_frames_per_second; the layout test checks size, alignment and every field offset against the oracle, and MAX_AV_PLANES against the length of video_data.data. video_io.rs also gains enum video_trc and enum video_scale_type (VideoTrc, VideoScaleType) with *_to_c / *_from_c like the other media-io enums; the layout test checks their size, alignment and every enumerator's value against the oracle, as for colorspace and range. ffi::video_io also has the helpers for C enum values, for later shims that receive them as c_ints. They convert and call the safe core, and give values outside the enums the C's result: an unknown format is VIDEO_FORMAT_NONE, an unknown colorspace is named "Unknown", and an unknown range is returned unchanged and named "Partial". The oracles are non-inline oracle_* wrappers around the real header functions (oracle/video_io_inlines.c, oracle/frame_rate.c), each with its own binding module. Parity sweeps every enumerator plus values just outside each enum, compares the frame-rate conversions bit for bit at edge values, and adds proptest over arbitrary c_ints and u32s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…io (GREEN) format_is_yuv, get_video_format_name, get_video_colorspace_name, resolve_video_range and get_video_range_name, and the frame-rate.h conversions and validity check, as safe Rust that later media-io ports use when they handle these enums and structs. The C helpers are static inline and stay compiled into every C caller; nothing is swapped or exported, so there is no ENABLE_RUST_LIBOBS guard. No intentional differences. The switches become exhaustive matches, so a new enum value fails to compile instead of falling through to the C's default. The frame-rate conversions are the C's single f64 divisions, zero parts included, and parity is bit-exact. Mutation check: reporting VIDEO_FORMAT_V210 as not YUV, and dropping the denominator test from is_valid, each fail the enumerator sweep and edge-value parity tests. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=9bb9dbcd18d0bb7724447dbf1e397c16a754200e secs=372 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791668831,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f50d22fe6722c6f2be9a65981c1f9aabe7430351bf55abc4aea61bcd7353cf7c","lane":"lint","parents":["300f2d6e21a73d9ad02e401676fed852d528f393"],"secs":127,"stamp":"2752bc6b9899bd8ab204c1ebcd4f546a","tree":"9bb9dbcd18d0bb7724447dbf1e397c16a754200e","v":1,"via":"run"} Ci-Attestation: {"at":1791668831,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f50d22fe6722c6f2be9a65981c1f9aabe7430351bf55abc4aea61bcd7353cf7c","lane":"lint","parents":["300f2d6e21a73d9ad02e401676fed852d528f393"],"secs":127,"stamp":"7a54138ef6489b61881e9c5c25db4796","tree":"9bb9dbcd18d0bb7724447dbf1e397c16a754200e","v":1,"via":"run"} Ci-Attestation: {"at":1791668831,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"901cc0e7d55ba21870d182ddb7658947c37563beb2c1db405a22ed969ebec4e8","lane":"rust-test","parents":["300f2d6e21a73d9ad02e401676fed852d528f393"],"secs":92,"stamp":"2634bd89e5201622b56ebf48a94ddf1e","tree":"9bb9dbcd18d0bb7724447dbf1e397c16a754200e","v":1,"via":"run"} Ci-Attestation: {"at":1791668831,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"77ed72aed16fa50f007e3693bccfcebe557650b4d910a08d172dcfe975191442","lane":"tier2-linux","parents":["300f2d6e21a73d9ad02e401676fed852d528f393"],"secs":152,"stamp":"d0447d0489e766fbf3965cfc0d1c2db0","tree":"9bb9dbcd18d0bb7724447dbf1e397c16a754200e","v":1,"via":"run"}
Member
zackees
force-pushed
the
port/video-io-inlines
branch
from
October 10, 2026 21:47
6126e8b to
533539d
Compare
5 tasks done
This was referenced Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ports the
static inlinehelpers inlibobs/media-io/video-io.h(format_is_yuv,get_video_format_name,get_video_colorspace_name,resolve_video_range,get_video_range_name) andlibobs/media-io/frame-rate.h(media_frames_per_second_to_frame_interval,_to_fps,_is_valid) toobs-media-io, as item 1 of the media-io part 2 order on #45. No intentional differences.Header-inline exemption. The helpers are compiled into every C caller, so nothing is swapped or exported, there is no
ENABLE_RUST_LIBOBSguard and norust-exports.txtentry, and both headers are unmodified. Tier 2 is the unchanged cmocka test passing OFF and ON plus a layout test of every struct the headers define. Tier 1 and Tier 3 run against non-inlineoracle_*wrappers.Structs and enums.
ffi::video_iomirrorsstruct video_data,struct video_output_infoandstruct video_scale_infowith the enums asc_ints, andffi::frame_ratemirrorsstruct media_frames_per_second. The layout test checks size, alignment and every field offset against the oracle (includingvideo_output_info's pointer andsize_t), andMAX_AV_PLANESagainst the length ofvideo_data.data.video_io.rsalso gainsenum video_trcandenum video_scale_type(VideoTrc,VideoScaleType) with*_to_c/*_from_c, and the layout test checks their size, alignment and enumerator values, as #106 did for colorspace and range.Values outside the enums. The safe core takes the Rust enums, with exhaustive
matches in place of the C switches.ffi::video_ioalso has plain (not exported, notno_mangle) helpers that take the C enum values asc_ints, for later shims such asvideo-frame.cthat receive them from C. They convert with*_from_cand give a value outside its enum the C's default result: an unknown format is not YUV and is named"None", an unknown colorspace is"Unknown", and an unknown range is returned unchanged byresolve_video_rangeand named"Partial". If you would rather not carry these until a shim needs them, they can move into the parity test.Oracle.
oracle/video_io_inlines.candoracle/frame_rate.cwrap the header functions, each with its own binding module (src/video_io_inlines.rs,src/frame_rate.rs).frame-rate.hhas no includes of its own, so its wrapper includesutil/c99defs.hfirst.Motivation and Context
Item 1 of the order approved on #45 (#45 (comment)). Later media-io ports use these types and helpers when they handle the enums and structs.
Refs #45
How Has This Been Tested?
Linux x86_64 (WSL2), Rust via soldr.
test/cmocka/test_video_io_inlines.c(C characterization, passes OFF and ON before any Rust), then RED (todo!()core: Tier 1 and parity fail, layout passes), then GREEN.format_is_yuvandget_video_format_namefor everyenum video_formatvalue (including the lower-case"v210"and"R10l"), the colorspace names (DEFAULT is named as Rec. 709),resolve_video_rangeandget_video_range_namefor every format with each range, and values just outside each enum. For frame-rate.h it pins 30/1, 30000/1001, theu32extremes, zero parts (inf, 0 and NaN) and_is_valid. The conversions are singledoubledivisions and are compared exactly.soldr cargo test -p obs-media-io: Tier 1 (1:1 port of the cmocka cases plus edge cases), Tier 2 layout for the four structs and two enums, and Tier 3 parity. Parity sweeps every enumerator plus two values on each side of each enum andINT_MIN/INT_MAX, checks the safe core against the oracle for every enumerator, compares the frame-rate conversions bit for bit (NaN included) over an edge grid with zeros andu32::MAX, and adds proptest over arbitraryc_ints andu32pairs.VIDEO_FORMAT_V210as not YUV fails the enumerator sweep and the safe-core parity test; dropping the denominator test fromis_validfails the frame-rate edge test. Both reverted../lintand./unittest: ok. tier2-linux rantest_video_io_inlineswith ENABLE_RUST_LIBOBS OFF and ON (41/41 each). The libobs exported symbols are identical OFF vs ON (1752). HEAD carries the local-gate stamp.rust-tier2CI jobs cover them.Types of changes
Checklist:
🤖 Generated with Claude Code