Repository navigation
obs-output: Port the encoder ROI checks and scaling - #1974
Merged
Merged
Conversation
RED for the port of libobs/obs-encoder-roi.c.h to a new module, encoder_roi, of rust/obs-output. The safe core is a stub (todo!()): admit(caps, roi), whether an encoder with caps stores the ROI; scale_factors(), the factors from the video's size to the scaled size; scale_edge() and scale(), the scaled rectangle with saturating edges; and Roi, struct obs_encoder_roi field for field. tests/output/encoder_roi.rs ports the eight cases of test_encoder_roi that reach the checks and the scaling, under the same names, with the same values and expectations: the cap refusal, the 16 x 16 minimum, the priority range, NaN priorities, upside-down rectangles, the scaled walk, no factors without a video size, and the saturation at 2^32. The other four cases (the NULL ROI, roi_increment, the unscaled order and the NULL encoder) test the list, the lock and the guards, which stay C. Edge cases: every capability bit; every rectangle with edges within 40 of 0, 1000 and u32::MAX against the model; the floats next to -1 and 1, subnormals and NaN payloads; the factors' conversion and rounding (2^24 + 1 and u32::MAX are not exact floats); the saturation at NaN, -0, the negatives, the largest float below 2^32 and 2^32; the edge's ties to even; the product rounded in f32 (3 x 1.6666666 is 5, not 4); which factor scales which edge, the priority kept bit for bit, and the layout of Roi. Cases marked characterized, not endorsed, pin what the C does today: u32::MAX saturates even at a factor of 1, edges past 2^24 lose their low bits, and scaling does not keep a rectangle admitted. The tests are a module of the existing core category binary, obs-tests-core; no new test binary. soldr cargo test -p obs-data --test obs-tests-core output::encoder_roi fails 18 of 19 with "not yet implemented"; the layout case passes, since Roi is not a stub. Refs obs-rust#1969
Ports libobs/obs-encoder-roi.c.h to the encoder_roi module of rust/obs-output: which ROIs obs_encoder_add_roi() stores, and how obs_encoder_enum_roi() scales them to the encoder's scaled size. roi_mutex, the list, roi_increment, the walk (last added first), the callback and the obs_encoder_valid() and NULL checks stay C in obs-encoder.c.h, and the encoder plugins read the ROIs as before. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/encoder_roi.rs): admit() runs the C's checks in its order: the cap bit, upside down or empty, NaN, the 16 x 16 minimum (after the upside-down check, so the sizes never wrap), then the priority range. scale_factors() divides the sides as the nearest floats, and gives None without a video size. scale_edge() is one f32 multiply of the edge as a float, then NaN and below 0 are 0, 2^32 and up u32::MAX, and the rest truncated toward 0; Rust's saturating as u32 gives the same values, but the branches are written out to match the C. Nothing is fused or reassociated. The priority is kept bit for bit. The ROIs are untrusted (plugins, scripts, the frontend), so the module denies clippy's indexing, arithmetic, unwrap, expect, panic, todo, unimplemented and unreachable lints. No unsafe. The shims (src/ffi/encoder_roi.rs) have the C signatures and stay hidden. struct obs_encoder_roi is Roi, #[repr(C)]. The scale reads the ROI whole before it writes the scaled one, as the C's compound literal does, so the two may be the same ROI. The factors are written only when there are some, as in C. C side: obs-encoder-roi.c.h moves from libobs.core-output to its own group, libobs.ported-encoder-roi, under LIBOBS_PORTED_SOURCES, with its PCH libobs-ported-encoder-roi.pch.h (math.h, stdint.h, the public obs.h for the struct and OBS_ENCODER_CAP_ROI, and obs-encoder-roi.h; not the core), which the file now includes instead of libobs.pch.h. The three shims are listed in rust-hidden.txt, rust-exports.map (local) and rust-unexports-macos.txt; nm shows them local in the hybrid libobs, and the exported symbols stay 1766 in libobs, the hybrid libobs and libobs-c-reference, identical. ci/test_ported_sources.py checks the group on Linux, Windows and macOS. No _rust variant of test_encoder_roi: it calls only the exported ROI API, never the three hidden functions, so linked after libobs the archive gives it nothing (a probe link takes no member) and it would repeat test_encoder_roi. test_encoder_roi covers the shims through the hybrid libobs. obs-output gains no dependency. Tier 1 output::encoder_roi is 19/19; test_encoder_roi passes 12/12 on the C, hybrid and c-ref libraries. Refs obs-rust#1969
The oracle is obs-encoder-roi.c.h, unmodified, with its three functions renamed, plus the layout of struct obs_encoder_roi and OBS_ENCODER_CAP_ROI as the C sees them. Every output is compared bit for bit: the admit, the factors as f32 bits (left unchanged without a video size: both sides start from the same sentinel), and the scaled ROI field by field with its priority as f32 bits, into a fresh ROI and in place. Runs: the layout; the test_encoder_roi values; every capability bit; every rectangle with edges within 40 of 0, 1000 and u32::MAX; the priority's bit patterns within 256 of -1, 1, +/-0, the smallest normals, the largest floats, the infinities and the NaNs, and every 65521st of all 2^32; sizes at the u32 and 2^24 edges, pair against pair; each edge against special factors and the factors' bit patterns that put the product next to 2^32, 0 and whole numbers; and 8192-case proptests over full-range u32 rectangles, f32 priorities and factors drawn as bit patterns (NaN and +/-inf included) and sizes, rectangles near the 16 x 16 minimum, products near 2^32 or a whole number, and the factors-then-scale chain of obs_encoder_enum_roi(). No float is drawn from a wide Range<f32> (obs-rust#1951). No input is excluded. Breaking the core: the cap check dropped or on bit 5, the upside-down check dropped or one-sided, the NaN check dropped, a minimum of 15 or 17, either size check dropped, -1 or 1 refused, the range dropped or [0, 1], && for || on the video size, the factors divided in f64 or as integers, y from the width, NaN as u32::MAX, below 0 as 1, the upper edge one float below 2^32, u32::MAX - 1 on saturation, the product in f64, the edge kept exact, round or ceil for the truncation, a factor on the wrong edge, an edge from the wrong side and a canonicalized priority each fail Tier 1 and Tier 3. The exact edge first passed Tier 1; edge_scale_edge_rounds_the_edge_first is added for it. The shim writing the factors without a size fails Tier 3 (Tier 1 tests the core). Five survive and are equivalent: < for <= in the upside-down check (an empty side fails the minimum), <= 0 for < 0, the NaN and below-0 check dropped, > for >= at 2^32 and the upper check dropped (Rust's as u32 already gives 0, 0 and u32::MAX there). Reverted. The seeds the mutants failed on are kept in proptest-regressions/encoder_roi_parity.txt. No intentional differences. Refs obs-rust#1969
rust/README.md: the obs-output layout row names
libobs/obs-encoder-roi.c.h, and its row of the ported table gives the
swap, what stays in obs-encoder.c.h, the three functions and their
order of checks, the saturation, the Roi mirror and its layout check,
the in-place scale, the behaviour kept from the characterization, why
there is no _rust variant, and what Tier 3 compares. No intentional
differences. The obs-output Cargo description and crate docs name the
new module. The naming.md row already names the file.
port_comparison: encoder_roi/{admit,scale}/16, shim against oracle, in
benches/port_comparison/encoder_roi.rs: 16 admits, and one set of
factors then 16 scales, as obs_encoder_enum_roi() does. Pinned to one
core, the medians are 32.0 ns (Rust) against 29.1 ns (C) for the
admits and 165.5 ns against 143.0 ns for the scales: about 0.2 and
1.4 ns more per call (not looked into further). They run once per ROI
added, and once per ROI when an encoder rebuilds its ROI map after
roi_increment moved, not per frame.
Fixes obs-rust#1969
This was referenced Oct 23, 2026
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 24, 2026
…obs-rust#2117) * libobs: Move the output video checks into obs-output-video-checks.c Behaviour-neutral extraction before the Rust port. The decisions of get_first_mixer(), obs_output_get_width2() / _height2(), video_valid(), audio_valid(), can_begin_data_capture(), has_scaling(), obs_output_get_video_conversion(), the gates of obs_output_can_begin_data_capture() and the clamp of obs_output_get_congestion() move to libobs/obs-output-video-checks.c.h, as six functions on plain values declared in the new libobs/obs-output-video-checks.h without EXPORT (hidden, as -fvisibility=hidden keeps them): - obs_output_first_mixer(mixer_mask): the lowest set bit below MAX_AUDIO_MIXES, else 0, the loop moved as it was; - obs_output_size_route(encoded, has_encoder, scaled): where one axis of obs_output_get_width2() / _height2() comes from, the encoder, 0, the scaled size or the video's; - obs_output_capture_ready(presence): the flag and presence checks, over struct obs_output_capture_presence (info.flags, a bit per set video and audio encoder, and whether video, audio and service are set), with the encoder loops over the same MAX_OUTPUT_*_ENCODERS; - obs_output_begin_gate(delay_active, active): ready, refuse or check; - obs_output_conversion_plan(sizes): the set conversion with a 0 width or height filled from the raw output's size (the scaled size when set, else the video's, which is what obs_output_get_width() / _height() returned there), the scaled size when has_scaling(), or none; - obs_output_congestion_clamp(value): the 0-1 clamp, a NaN still passing through. obs-output.c.h keeps obs_output_valid(), the log_flag_* warnings, the idx check, the pthread_join() of end_data_capture_thread, the calls to obs_encoder_get_width() / _height() (only on the encoder route, so they run exactly when they ran before), video_output_get_*(), video_output_get_info() for the format, info.get_congestion and every write to video_conversion. obs_output_set_mixer() is unchanged. What changes in what the C reads, not in what it does: - obs_output_can_begin_data_capture() loads active even when delay_active is set (two atomic loads, no side effect); - obs_output_get_width2() / _height2() read video_encoders[idx] (already bounds-checked) on a raw output too; - obs_output_get_video_conversion() reads the video's size up front (video_output_get_*() are NULL-safe reads) instead of through obs_output_get_width() on the set path, and stores the set conversion's width and height back unchanged when they were not 0. Checked in a scratch harness (not committed) that compiles origin/master's functions verbatim against the moved ones on a stand-in output: 20,000,000 random outputs (flags, encoders, video, audio, service, scaled and conversion sizes, mixer masks, the two atomics and f32 congestion bit patterns) give the same results, the same obs_encoder_get_width() / _height() calls and the same video_conversion afterwards. The flags and limits are copied into the header, so it needs no core header; obs-output.c.h checks them against obs-output.h and audio-io.h with _Static_assert. The new file joins libobs.core-output, just before obs-output.c.h, with libobs.pch.h, which includes the new header; source-sets.json lists it. docs/rust-port/naming.md maps it to rust/obs-output. The exported symbol sets are unchanged (1766). git log -L on each moved function shows only upstream history; the fork's fixes in this file (obs-rust#470, obs-rust#539, obs-rust#1109, obs-rust#1572, obs-rust#1599) are in the code that stays in obs-output.c.h. obs-rust#470's NULL video after a view's mix is gone stays covered: video_valid() and the conversion read a NULL video as no video, 0 x 0, as before. Refs obs-rust#2067 * test: Characterize the output video size, conversion and capture checks test_output_video_checks_steps compiles libobs/obs-output-video-checks.c.h (ASan and UBSan) and calls only its six functions through obs-output-video-checks.h, so it runs on every platform without a display. 27 cases: - obs_output_first_mixer(): 0; each single bit of size_t (the mixer for bits 0 to 5, 0 above); several bits (the lowest below MAX_AUDIO_MIXES wins, a bit past the mixers does not hide one below); bits only at or above MAX_AUDIO_MIXES; - obs_output_size_route(): encoded with and without an encoder at the index, whatever the scaled size; raw with a scaled size (1, 2, 720, 1280, 2^31, UINT32_MAX) and without, with and without an encoder; - obs_output_capture_ready(): each flag alone and together (video, audio, encoded, service, raw and encoded AV, a stream), against each presence bit: each of the 10 video and 6 audio encoder bits and the bits past them, the video, the audio and the service; the other flags (MULTI_TRACK, CAN_PAUSE, MULTI_TRACK_VIDEO, unknown) ignored; and every combination of the four flags against every single presence bit (14,976 calls) against a model; - obs_output_begin_gate(): the four combinations of delay_active and active; - obs_output_conversion_plan(): not set against scaled 0, equal and different (one axis is enough; one axis 0 is no scaling; no video reads as 0 x 0); set, kept whatever the scaled and video sizes; set with a 0 width, height or both, filled from the scaled size or else the video's, each axis on its own; - obs_output_congestion_clamp(): -1, 0, 0.5, 1, 2, +-inf and NaN, the floats next to 0 and 1, -0 (kept as -0), FLT_MAX and -FLT_MAX, compared bit for bit. Characterized, not endorsed: - a mixer mask with bits only at or above MAX_AUDIO_MIXES reports mixer 0 (obs_output_set_mixer() with an index of 6 or more; a separate fix); - a set conversion with a 0 axis, no scaled size and no video keeps 0 on that axis and is still returned; - a NaN congestion from the plugin is returned as it is, payload and sign kept. Characterized: an encoder bit at or above MAX_OUTPUT_*_ENCODERS is not an encoder (obs-output.c builds the masks from the arrays, so it never sets one). It is in the native test graph, in the core suite, and links libm off MSVC. The real-libobs tests test_raw_output_video_reset (obs-rust#470), test_scaled_mix_alpha, test_texture_encoder_raw_format, test_output_start_twice (obs-rust#539), test_output_failed_start_encoders, test_output_null_id and test_encoding_lag_rescale cover the callers. Refs obs-rust#2067 * obs-output: Add Tier 1 tests for the output video checks port RED for the port of libobs/obs-output-video-checks.c.h to the video_checks module of rust/obs-output, next to encoder_roi (obs-rust#1974). The safe core is a stub (todo!()): first_mixer(mask) -> usize, size_route(encoded, has_encoder, scaled) -> SizeRoute { Zero, Encoder, Scaled, Video }, capture_ready(&Presence) -> bool, begin_gate(delay_active, active) -> BeginGate { Ready, Refuse, Check }, video_conversion( &ConversionSizes) -> Conversion { None, UseSet, Scaled } and congestion(f32) -> f32, with the flags and limits as constants. tests/output/video_checks.rs ports test_output_video_checks_steps 1:1: its 27 cases under the same names (steps_*), in the same order, with the same values and expectations, the characterized-not-endorsed cases included. Edge cases (edge_*) check the core against models of the original C: every mixer mask of up to two bits with each low 6-bit pattern; every flag word over the low 8 bits, with and without the high bits, against every presence; every 10-bit video and 6-bit audio encoder pattern, with and without the bits past the limits; the size routes over the u32 edges; every conversion over the sizes 0, 1, 2 and u32::MAX, set and not set; the congestion bit patterns within 256 of 0, -0, 1, -1, the infinities and the NaNs, bit for bit; and the constants. soldr cargo test -p obs-data --test obs-tests-core -- output::video_checks:: fails 33 of 34 with "not yet implemented"; edge_constants, which reads only the constants, passes. Refs obs-rust#2067 * obs-output: Port the output video checks Ports libobs/obs-output-video-checks.c.h, the video size, conversion and capture checks of obs-output.c, to the video_checks module of rust/obs-output. obs-output.c.h stays C around it: obs_output_valid(), the log_flag_* warnings, the index check, the pthread_join() of end_data_capture_thread, obs_encoder_get_width() / _height() on the encoder route, video_output_get_*() and video_output_get_info(), info.get_congestion, the atomic loads, the presence masks built from the encoder arrays and every write to video_conversion. obs_output_set_mixer() is unchanged. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/video_checks.rs): - first_mixer(): the first i in 0..MAX_AUDIO_MIXES whose bit is set, else 0; - size_route(): Encoder or Zero for an encoded output, Scaled when the scaled size is not 0, else Video; - capture_ready(): each wanted part (OBS_OUTPUT_VIDEO, _AUDIO, _SERVICE) must be there, video and audio from the encoder bits below MAX_OUTPUT_VIDEO_ENCODERS / _AUDIO_ENCODERS when encoded, from the video and audio otherwise; the checks in the C's order; - begin_gate(): Ready when the delay is active, else Refuse when active, else Check; - video_conversion(): UseSet with each 0 axis filled from the raw output's size (scaled, else the video's); else Scaled when both scaled axes are set and either differs from the video's; else None; - congestion(): below 0 is 0, above 1 is 1, the rest unchanged, so -0 stays -0 and a NaN passes through with its payload. It is f32::clamp(0.0, 1.0), which makes the C's two comparisons in the C's order (clippy's manual_clamp asks for it); the bounds are constants, so it cannot panic. The module denies clippy's arithmetic, indexing, unwrap, expect, panic, todo, unimplemented and unreachable lints, keeps no state and takes no lock. Shims (src/ffi/output_video_checks.rs): the six functions keep the C signatures. struct obs_output_capture_presence, struct obs_output_conversion_sizes and struct obs_output_conversion_choice are mirrored #[repr(C)]; the shims read the input structs by value and return the enum values as u32 (the C's enums) and the choice by value, 0 x 0 with NONE as the C's initializer. No intentional differences. Kept, characterized, not endorsed (test_output_video_checks_steps): a mixer mask with bits only at or above MAX_AUDIO_MIXES reports mixer 0; a set conversion with a 0 axis and no scaled size or video keeps 0; a NaN congestion is returned as it is. C side: the file leaves libobs.core-output for its own group, libobs.ported-output-video-checks (LIBOBS_PORTED_SOURCES), whose PCH is only obs-output-video-checks.h; libobs.pch.h keeps the header for obs-output.c. The functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. libobs-rust already links the crate's ffi. The exported symbol sets are unchanged and equal: 1766 on the C backend, the hybrid and libobs-c-reference; the six functions are local in all three, and the hybrid's come from the Rust archive (no C object of the group in the hybrid libobs). ci/test_ported_sources.py checks the group on every host. test_output_video_checks_steps still compiles the C file into itself, unchanged. It has no _rust variant: linking it against libobs_rust-static was tried and fails with 506 undefined references, because the shims' archive member (obs_output cgu.1) also holds the service lifecycle, the delay and the interleaver, which need libobs's hidden seams and obs-util (GIO, libuuid); test_output_protocol_list_steps is in the same place. The real-libobs tests (test_raw_output_video_reset, test_scaled_mix_alpha, test_texture_encoder_raw_format, test_output_start_twice, test_output_failed_start_encoders, test_output_null_id, test_encoding_lag_rescale) see the swap through the hybrid. Tier 1 output::video_checks passes 34/34. Refs obs-rust#2067 * obs-output: Check the output video checks port against the C Oracle (oracle/output_video_checks.c): the original obs-output-video-checks.c.h, unmodified, with its six functions renamed to oracle_obs_output_*, plus the 17 constants of the header (the flags, the limits and the enum values) and the layout of struct obs_output_capture_presence, struct obs_output_conversion_sizes and struct obs_output_conversion_choice (sizes, alignments and every offset) and the size of the enums. Tier 3 (tests/output/video_checks_parity.rs, 15 tests). Every call runs the shim, the C and the safe core and compares the results exactly: the mixer index, the route and the gate as values, the capture check as a bool, the conversion choice field by field, and the congestion as f32 bits. Runs: - the constants and the layouts against the C; - every mixer mask of up to two bits, each with every low 6-bit pattern or'ed in and replacing its low bits; - every size route over 8 special scaled sizes (0, 1, 2, 720, 1080, 2^31 - 1, 2^31, UINT32_MAX); - the capture check exhaustively: the four checked flags, every 10-bit video and 6-bit audio encoder mask and the video, audio and service bits, 8,388,608 calls; and every low 8-bit flag word, alone, with all high bits and with bit 31, against encoder masks with bits past the limits; - the four begin gates; - every conversion over the sizes 0, 1, 2 and UINT32_MAX on all six, set and not set (8192, each kind reached), plus the steps test's values; - the congestion over the bit patterns within 256 of 0, -0, 1, -1, 0.5, the largest finite floats, the infinities and the NaNs (quiet, signalling, either sign), and every 65521st of all 2^32; - proptests (8192 cases each) over full-range usize mixer masks, u32 flags and encoder masks, u32 sizes biased to 0 and to scaled equal to video on one axis or both, and f32 congestions drawn as bit patterns, plus bit patterns near the edges. No wide Range<f32> is used. The parity module passed 10 runs in a row with fresh seeds. The regression file holds the seeds proptest saved while the mutants below failed; all pass on the port. Each congestion mutant replaces the whole body of congestion(), so the rows hold for the f32::clamp form the port uses (the run was on the C's if / else chain, which clippy then asked to write as clamp). Mutation check (done once, not committed), with Tier 1 (34 tests) and Tier 3 (15) in one run: 45 mutants, 37 in the core and 8 in the shims. 42 fail; the 3 that survive are equivalent. | Mutant | Tier 1 | Tier 3 | |---|---|---| | first_mixer: 7 mixers / 5 mixers | 3 / 3 | 2 / 2 | | first_mixer: none found is MAX_AUDIO_MIXES | 4 | 2 | | first_mixer: highest bit / no mixer limit | 2 / 3 | 2 / 2 | | size_route: Encoder and Zero swapped | 2 | 2 | | size_route: raw always Video / scaled > 1 | 2 / 2 | 2 / 2 | | size_route: a raw output with an encoder asks it | 2 | 2 | | capture: encoded video from the video pointer | 7 | 3 | | capture: 11 video encoders / 5 audio encoders | 5 / 5 | 2 / 3 | | capture: encoder masks without the limit | 6 | 2 | | capture: no service check / service always needed | 3 / 11 | 3 / 3 | | capture: video checked on the audio flag | 8 | 3 | | capture: encoded read from OBS_OUTPUT_SERVICE | 7 | 3 | | capture: raw audio from the video pointer | 4 | 3 | | begin_gate: active first / delay gives Check | 1 / 1 | 1 / 1 | | conversion: fill from the video only / always fill | 2 / 4 | 2 / 2 | | conversion: width filled from the height axis / no fill | 2 / 2 | 2 / 2 | | has_scaling: either axis / both must differ | 2 / 2 | 2 / 2 | | has_scaling: no scaled_height check / ignores the video | 2 / 2 | 2 / 2 | | conversion: the set conversion ignored when scaled | 3 | 2 | | congestion: if value <= 0 (-0 becomes +0) | 2 | 2 | | congestion: NaN as 0 / max().min() | 2 / 3 | 3 / 3 | | congestion: upper bound 0.999 | 3 | 3 | | MAX_AUDIO_MIXES 5 / MAX_OUTPUT_VIDEO_ENCODERS 9 | 3 / 6 | 3 / 4 | | shim: SCALED and VIDEO swapped / READY and REFUSE swapped | 0 | 2 / 1 | | shim: video and audio swapped / set width and height swapped | 0 | 3 / 2 | | shim: NONE carries the scaled size / SET reported as SCALED | 0 | 2 / 2 | | shim: first_mixer of mask & 0x1f | 0 | 2 | | equivalent: the C's if / else if chain with > as >= (1 gives 1 either way) | 0 | 0 | | equivalent: the C's if / else if chain itself, in the core or in the shim (the same comparisons as f32::clamp: NaN and -0 pass) | 0 | 0 | Tier 1 does not reach the shims; Tier 3 kills every shim mutant. Refs obs-rust#2067 * docs: Record the output video checks port The rust/README.md crate table now lists libobs/obs-output-video-checks.c.h among the units rust/obs-output holds, and its port table has a row for it: the six functions and their rules, what stays C in obs-output.c.h (the validity checks, the warnings, the join, the encoder and video size calls, the plugin's congestion, the atomic loads, the presence masks and the writes to video_conversion), the three mirrored structs, the "characterized, not endorsed" behaviours kept, why test_output_video_checks_steps has no _rust variant, the real-libobs tests that see the swap, and what Tier 3 compares. No intentional differences. The crate's description and lib.rs say what it holds. docs/rust-port/naming.md got its entry in the move commit. port_comparison gets its own bench file, benches/port_comparison/output_video_checks.rs: 1024 capture checks over streams, recordings, raw and broken outputs; 1024 conversion plans over 1080p, 720p, 1440p and no video, scaled or not, with set conversions with and without 0 axes; and 1024 rounds of the first mixer, a size route, a begin gate and a congestion clamp (NaN every 97th), each folded into a checksum both sides must match. On x86_64 Linux (GCC, not pinned, a loaded host; median per 1024 calls): capture_ready 2.40 us Rust and 2.76 us C (0.87x), conversion_plan 2.61 us Rust and 5.92 us C (0.44x), mixer_route_gate_congestion 5.78 us Rust and 6.07 us C (0.95x). Each runs at most once per output start or per getter call, so neither side is on a hot path. Fixes obs-rust#2067
6 of 7 tasks
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 24, 2026
* libobs: Move the encoder size and info choices into obs-encoder-size.c Behaviour-neutral extraction before the Rust port. The choices of get_audio_info(), get_video_info(), obs_encoder_set_scaled_size(), obs_encoder_scaling_enabled(), obs_encoder_get_width() / _height() and obs_encoder_get_sample_rate() move to libobs/obs-encoder-size.c.h, as seven functions on plain values declared in the new libobs/obs-encoder-size.h without EXPORT (hidden, as -fvisibility=hidden keeps them): - obs_encoder_size_audio_defaults(info, mix): get_audio_info()'s default fill, an unknown format, a 0 sample rate and unknown speakers each from the mix, over struct obs_encoder_audio_fill (the three fields, the enums as int); - obs_encoder_size_cap_override(caps, w, h, voi_w, voi_h): the video's size for an encoder with OBS_ENCODER_CAP_SCALING, else the size the plugin left; - obs_encoder_size_scaled_gate(type, active, initialized): the three refusals of obs_encoder_set_scaled_size() in their order (not a video encoder, active, initialized), or check; - obs_encoder_size_scaled_match(has_voi, voi_w, voi_h, w, h): disable when the size equals the video's, else set; - obs_encoder_size_scaling(w, h): either scaled axis set; - obs_encoder_size_video_route(type, has_media, scaled): where one axis of obs_encoder_get_width() / _height() comes from: the wrong-type warning, 0 without a video, the scaled size, or the video's; - obs_encoder_size_rate_route(type, has_media, samplerate): the same for obs_encoder_get_sample_rate() (an audio encoder, the stored rate or the mix's). obs-encoder.c.h keeps obs_encoder_valid(), every warning with the encoder's name, video_output_get_info() and audio_output_get_info(), video_output_get_width() / _height() and audio_output_get_sample_rate() (called only on the media route, so they run exactly when they ran before), the load of the active flag and every write to the encoder. The plugin callbacks stay in C in the same order: the default fill, then the plugin's get_audio_info / get_video_info, then the cap override. No lock is taken or dropped. What changes in what the C reads, not in what it does: - obs_encoder_set_scaled_size() loads the active flag and reads initialized before the type is known (an atomic load and a plain read, no side effect); - obs_encoder_get_width() / _height() / _sample_rate() read media and the scaled size or rate before the type check; - get_video_info() reads voi->width / height without the cap (voi is already dereferenced for the format) and stores the size back; - get_audio_info() reads the three mix fields up front. Both callers pass a zeroed info, so the original read all three too; - obs_encoder_scaling_enabled() reads scaled_height when scaled_width is set. Checked in a scratch harness (not committed) that compiles origin/master's functions verbatim against the moved ones on a stand-in encoder, with plugin callbacks that record what they see and change the info: 20,000,000 random calls (types 0, 1 and outside the enum, caps with and without the scaling bit, with and without media, a root size that differs from the video info, scaled sizes and rates biased to 0 and to the video's, the active and initialized flags, a NULL encoder) give the same results, the same warnings, the same media getter calls in the same order, the same plugin inputs, the same info and the same encoder afterwards. Four planted mutants were each caught within 300 calls. The constants are copied into the header, so it needs no core header; obs-encoder.c.h checks them against obs-encoder.h and audio-io.h with _Static_assert. The new file joins libobs.core-output, just before obs-encoder.c.h, with libobs.pch.h, which includes the new header; source-sets.json lists it. docs/rust-port/naming.md maps it to rust/obs-output. The exported symbol sets are unchanged (1766). git log -L on each moved function shows only upstream history. The fork's changes to this file (obs-rust#1109, obs-rust#1964, obs-rust#2111 and the earlier ones) are all in code that stays C. Refs obs-rust#2134 * test: Characterize the encoder size and info choices test_encoder_size_steps compiles libobs/obs-encoder-size.c.h (ASan and UBSan) and calls only its seven functions through obs-encoder-size.h, so it runs on every platform without a display. 28 cases: - obs_encoder_size_audio_defaults(): a zeroed info (what both callers pass) takes every field from the mix; the format, the rate and the speakers each unknown on its own; none unknown; an unknown mix field copied as unknown; every combination of known and unknown fields against a model; values outside the enums (-1, INT_MAX, INT_MIN) counting as known, and the rate at the u32 edges; - obs_encoder_size_cap_override(): without the cap (0 and every other bit) the plugin's size is kept; with it the video's size wins, the plugin's size equal, different or 0; each of the 32 cap bits alone; every pair of eleven edge sizes (0, 1, 2, 720, 1080, 1280, 1920, 2^31 - 1, 2^31, UINT32_MAX - 1, UINT32_MAX) with and without the cap; - obs_encoder_size_scaled_gate(): every refusal. Not a video encoder (audio, 2, 3, -1, INT_MAX, INT_MIN) first, active or initialized or not; an active video encoder, initialized or not; an initialized one; else check; - obs_encoder_size_scaled_match(): equal sizes disable; one axis or both differing, swapped axes and one axis 0 set; no voi sets, the voi's size ignored, 0 x 0 included; every pair of edge sizes, equal, swapped and on one axis; - obs_encoder_size_scaling(): 0 x 0 off, either axis on, the u32 edges; - obs_encoder_size_video_route() and _rate_route(): the wrong type refused before the media is looked at, with and without media and at every edge size; no media reads 0, scaled or not; with media the scaled size (rate) when set, else the video's (mix's); and the width and height end to end, with and without a scaled size, a video or one scaled axis. Characterized, not endorsed: - obs_encoder_set_scaled_size() with one axis 0, or equal to the video's on one axis only, stores it as it is: obs_encoder_scaling_enabled() is then true, and the 0 axis reads the video's; - with OBS_ENCODER_CAP_SCALING, a 0 x 0 video gives 0 x 0, whatever the plugin set; - 0 x 0 asked of a 0 x 0 video goes through the "matches the output" warning. It is in the native test graph, in the core suite (the partition test in rust/obs-build pins no suite size), and links libm off MSVC. No assert_in_range or fail_msg, so it builds with cmocka 1.x and 2.x. The real-libobs tests test_encoder_video_reset (obs-rust#1109), test_encoding_lag_rescale, test_multitrack_encoder_override, test_encoder_fallback and test_encoder_roi (obs-rust#1964) cover the callers. Refs obs-rust#2134 * obs-output: Add Tier 1 tests for the encoder size port RED for the port of libobs/obs-encoder-size.c.h to the encoder_size module of rust/obs-output, next to encoder_roi (obs-rust#1974). The safe core is a stub (todo!()): audio_defaults(AudioFill, AudioFill) -> AudioFill, cap_override(caps, Size, Size) -> Size, scaled_gate(type, active, initialized) -> ScaledGate { NotVideo, Active, Initialized, Check }, scaled_match(Option<Size>, Size) -> ScaledMatch { Disable, Set }, scaling_enabled(Size) -> bool, and video_size_route() / sample_rate_route(type, has_media, stored) -> SizeRoute { WrongType, NoMedia, Stored, Media }, with the types, the cap and the unknown audio values as constants. tests/output/encoder_size.rs ports test_encoder_size_steps 1:1: its 28 cases under the same names (steps_*), in the same order, with the same values and expectations, the characterized-not-endorsed cases included. Edge cases (edge_*) check the core against models of the original C: every pattern of 0 and non-0 audio fields (small, outside the enums, at the edges) against four mixes; every cap word over the low 8 bits, with and without every high bit, and each high bit alone; every type from -8 to 8 and the i32 extremes against both flags; every voi and size over 0, 1, 2^31 and u32::MAX with and without a voi; scaling over the edge sizes; both routes over every type, media and edge size; and the constants. soldr cargo test -p obs-data --test obs-tests-core -- output::encoder_size:: fails 34 of 35 with "not yet implemented"; edge_constants, which reads only the constants, passes. Refs obs-rust#2134 * obs-output: Port the encoder size and info choices Ports libobs/obs-encoder-size.c.h, the encoder size and info choices of obs-encoder.c, to the encoder_size module of rust/obs-output. obs-encoder.c.h stays C around it: obs_encoder_valid(), every warning with the encoder's name, video_output_get_info(), audio_output_get_info(), video_output_get_width() / _height(), audio_output_get_sample_rate(), the plugin's get_audio_info and get_video_info between the default fill and the cap override, the load of the active flag and every write to the encoder and the infos. No lock is involved. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/encoder_size.rs): - audio_defaults(): an unknown format, a 0 rate and unknown speakers each from the mix, any other value kept; - cap_override(): the video's size with OBS_ENCODER_CAP_SCALING, else the plugin's; - scaled_gate(): NotVideo, else Active, else Initialized, else Check, in the C's order; - scaled_match(): Disable when a voi is there and equals the size on both axes, else Set; - scaling_enabled(): either axis not 0; - video_size_route() / sample_rate_route(): WrongType for any type but OBS_ENCODER_VIDEO (OBS_ENCODER_AUDIO), else NoMedia, else Stored when the scaled size (rate) is not 0, else Media. The module denies clippy's arithmetic, indexing, unwrap, expect, panic, todo, unimplemented and unreachable lints, keeps no state and takes no lock. Shims (src/ffi/encoder_size.rs): the seven functions keep the C signatures. struct obs_encoder_audio_fill and struct obs_encoder_size are mirrored #[repr(C)]; the shims read the input fills by value, return the structs by value and the enum values as u32 (the C's enums). The type is a c_int, as the C passes it. No intentional differences. Kept, characterized, not endorsed (test_encoder_size_steps): a scaled size with one axis 0, or equal to the video's on one axis only, is stored as it is; with the cap a 0 x 0 video gives 0 x 0; 0 x 0 asked of a 0 x 0 video takes the "matches the output" path. C side: the file leaves libobs.core-output for its own group, libobs.ported-encoder-size (LIBOBS_PORTED_SOURCES), whose PCH is only obs-encoder-size.h; libobs.pch.h keeps the header for obs-encoder.c. The functions are not EXPORT, so the shims are hidden: rust-hidden.txt, the local: list of rust-exports.map and rust-unexports-macos.txt. libobs-rust already links the crate's ffi. The exported symbol sets are unchanged and equal: 1766 on the C backend, the hybrid and libobs-c-reference; the seven functions are local in all three, and the hybrid's come from the Rust archive (no C object of the group in the hybrid libobs). ci/test_ported_sources.py checks the group on every host. test_encoder_size_steps still compiles the C file into itself, unchanged. It has no _rust variant: linking it against libobs_rust-static was tried and fails with 506 undefined references, because the shims' archive member (obs_output cgu.1) also holds the service lifecycle, the delay and the interleaver, which need libobs's hidden seams and obs-util (GIO, libuuid), as for test_output_video_checks_steps (obs-rust#2117). Its tests.d file says so. soldr cargo test -p obs-data --test obs-tests-core -- output::encoder_size:: passes 35 of 35. Refs obs-rust#2134 * obs-output: Check the encoder size port against the C Oracle (oracle/encoder_size.c): the original obs-encoder-size.c.h, unmodified, with its seven functions renamed to oracle_obs_encoder_size_*, plus the 15 constants of the header (the types, the cap, the unknown audio values and the enum values) and the layout of struct obs_encoder_audio_fill and struct obs_encoder_size (sizes, alignments and every offset) and the size of the two enums. Tier 3 (tests/output/encoder_size_parity.rs, 15 tests). Every call runs the shim, the C and the safe core and compares the results exactly: the audio fill and the size field by field, the gate, match and routes as values, the scaling check as a bool. Runs: - the constants and the layouts against the C; - the audio defaults over every combination of seven formats, five rates and seven speaker values on the info and on the mix (60,025 calls); - the cap override over every cap word of the low 16 bits, alone and with every high bit, and each high bit alone, against three size sets; and every size over six edge values (0, 1, 2, 2^31, UINT32_MAX - 1, UINT32_MAX) on all four, with no cap, the cap and every cap; - the gate exhaustively over both flags and every type from -65,536 to 65,536, the int extremes and every 65,521st int; - the match over every combination of the six edge values on the voi and the size, with and without a voi; - the scaling check over every pair of edge values; - both routes over a seventh of those types and -8 to 8, media or not, and the edge values, each route reached; - proptests (8192 cases each) over full-range int types (biased to -2..3), u32 caps (biased to the scaling bit set and clear), u32 sizes and sample rates (biased to 0 and the top of the range, and the asked size to the voi's on one axis or both). The parity module passed 10 runs in a row with fresh seeds. The regression file holds the seeds proptest saved while the mutants below failed; all pass on the port. Mutation check (done once, not committed), with Tier 1 (35 tests) and Tier 3 (15) in one run: 35 mutants, 24 in the core, 9 in the shims and 2 planted equivalents. All 33 non-equivalent mutants fail. | Mutant | Tier 1 | Tier 3 | |---|---|---| | audio_defaults: format filled when known | 9 | 2 | | audio_defaults: rate never filled | 5 | 2 | | audio_defaults: speakers from the mix format | 5 | 2 | | audio_defaults: rate filled from the mix only when the format is unknown | 3 | 2 | | AUDIO_FORMAT_UNKNOWN 1 | 5 | 3 | | cap_override: OBS_ENCODER_CAP_SCALING 1 << 4 | 3 | 4 | | cap_override: inverted | 5 | 3 | | cap_override: any cap overrides | 3 | 2 | | cap_override: only the width overridden | 4 | 3 | | scaled_gate: initialized before active | 2 | 2 | | scaled_gate: only audio refused | 2 | 2 | | scaled_gate: no initialized check | 2 | 2 | | scaled_gate: active ignored | 2 | 2 | | scaled_match: width only | 3 | 2 | | scaled_match: no voi compares 0 x 0 | 3 | 2 | | scaled_match: inverted | 5 | 2 | | scaling_enabled: both axes needed | 2 | 2 | | scaling_enabled: width only | 2 | 2 | | route: media checked before the type | 3 | 2 | | route: stored when 0 | 4 | 2 | | route: no media check | 4 | 2 | | video route: audio type | 5 | 2 | | video route: any type above 0 is video | 2 | 2 | | rate route: any type up to 0 is audio | 2 | 2 | | shim: STORED and MEDIA swapped | 0 | 2 | | shim: ACTIVE and INITIALIZED swapped | 0 | 2 | | shim: DISABLE and SET swapped | 0 | 2 | | shim: format and speakers swapped | 0 | 2 | | shim: voi width and height swapped | 0 | 3 | | shim: has_voi always true | 0 | 2 | | shim: scaling of the width twice | 0 | 2 | | shim: rate route through the video route | 0 | 2 | | shim: OBS_ENCODER_SIZE_NO_MEDIA 0 | 0 | 3 | | equivalent: scaled_match as the C (has_voi && w == && h ==) | 0 | 0 | | equivalent: route with the stored check first under the media check | 0 | 0 | Tier 1 does not reach the shims; Tier 3 kills every shim mutant. Refs obs-rust#2134 * docs: Record the encoder size port The rust/README.md crate table now lists libobs/obs-encoder-size.c.h among the units rust/obs-output holds, and its port table has a row for it: the seven functions and their rules, what stays C in obs-encoder.c.h (the validity checks, the warnings, the media getters, the plugin callbacks between the default fill and the cap override, the active flag load and the writes to the encoder), the two mirrored structs, the "characterized, not endorsed" behaviours kept, why test_encoder_size_steps has no _rust variant, the real-libobs tests that see the swap, and what Tier 3 compares. No intentional differences. The crate's description and lib.rs say what it holds. docs/rust-port/naming.md got its entry in the move commit. port_comparison gets its own bench file, benches/port_comparison/encoder_size.rs: 1024 audio default fills (a zeroed or partly set info against a 48 kHz or 44.1 kHz mix); 1024 rounds of the cap override, the gate, the match, the scaling check and the video route over 1080p, 720p and 1440p videos scaled to 720p, to their own size or not; and 1024 rate routes, each folded into a checksum both sides must match. On x86_64 Linux (GCC, not pinned, a loaded host; median per 1024 calls): audio_defaults 7.59 us Rust and 10.28 us C (0.74x), video_override_gate_match_route 8.54 us Rust and 8.54 us C (1.00x), rate_route 1.63 us Rust and 1.60 us C (1.02x). Each runs once per encoder start, setting change or getter call, so neither side is on a hot path. These numbers come from a run of this file's benches alone: a full port_comparison run currently stops at the pre-existing bmem/count fixture check, before it reaches them. Fixes obs-rust#2134
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.
Fixes #1969
What and why
This PR ports the encoder region of interest (ROI) helpers in
libobs/obs-encoder-roi.c.h(moved and fixed by #1964) to a newencoder_roimodule ofrust/obs-output:obs_encoder_roi_admit(): whetherobs_encoder_add_roi()stores a ROI. It checks the cap bit, refuses upside-down rectangles and NaN priorities, and checks the 16 × 16 minimum and the priority range.obs_encoder_roi_scale_factors(): the factors from the video's size to the encoder's scaled size, forobs_encoder_enum_roi().obs_encoder_roi_scale(): the scaled rectangle, with saturating edges.What stays C:
roi_mutex, the darray,roi_increment, the reverse walk andenum_procinobs_encoder_enum_roi(), theobs_encoder_valid()guards and the NULL check, and the encoder plugins that read the ROIs. The hybrid libobs drops the C file and links the Rust shims in its place.Safe core (
src/encoder_roi.rs):admit,scale_factors,scale_edgeandscale, plusRoi(struct obs_encoder_roi,#[repr(C)]).admitruns the C's checks in the C's order: the cap bit, upside down or empty, NaN, the minimum, then the range. The sizes are taken only after the upside-down check, so they never wrap.scale_factorsturns each side into the nearestf32and then divides, as the C's(float)casts do. It givesNonewhen the video has no size.scale_edgeis onef32multiply of the edge as a float. Then NaN and anything below 0 give 0, 2^32 and up givesu32::MAX, and the rest is truncated toward 0. Rust's saturatingas u32gives the same values on every input, but the branches are written out to match the C. Nothing is fused or reassociated, and the priority is kept bit for bit.unsafe.Shim (
src/ffi/encoder_roi.rs): the three functions with the C signatures, hidden.No
_rustvariant oftest_encoder_roi. The test calls only the exported ROI API (obs_encoder_add_roi,_clear_roi,_has_roi,_enum_roi,_get_roi_increment).nm -uon its object lists none of the three hidden functions.test_encoder_roi.c.oagainstlibobs.so, thenliblibobs_rust.a, succeeds and takes no archive member (-Wl,-Map), so the variant would only runtest_encoder_roiagain.test_encoder_roialready exercises the shims through the hybrid libobs.C side:
obs-encoder-roi.c.hmoves out oflibobs.core-outputinto its own group,libobs.ported-encoder-roi, listed underLIBOBS_PORTED_SOURCESinsource-sets.json.libobs-ported-encoder-roi.pch.h:math.h,stdint.h, the publicobs.h(for the struct andOBS_ENCODER_CAP_ROI) andobs-encoder-roi.h, but notobs-internal.h. The file now includes that PCH instead oflibobs.pch.h. The function bodies are unchanged.ci/test_ported_sources.pychecks the group on Linux, Windows and macOS.Symbols: the three shims are listed in
rust-hidden.txt, in thelocal:list ofrust-exports.mapand inrust-unexports-macos.txt.nmshows them as local (t) in the hybrid libobs. The exported symbol sets are unchanged: 1766 in all three libraries, identical.Oracle (
oracle/encoder_roi.c): the original file, unmodified, with the three functions renamed tooracle_*. It adds the layout ofstruct obs_encoder_roiand the value ofOBS_ENCODER_CAP_ROIas the C sees them. It compiles under the oracle's strict flag set.Docs:
rust/README.mdrows (crate table and port table), the crate's Cargodescriptionand thelib.rsdocs are updated.docs/rust-port/naming.mdrow already names the file.docs/features.mdline: there is no user-visible change.port_comparison (its own file,
benches/port_comparison/encoder_roi.rs):encoder_roi/{admit,scale}/16, shim against oracle.admitruns 16 admits;scaleruns one set of factors and then 16 scales, asobs_encoder_enum_roi()does. Pinned to one core, the medians are:admit/16scale/16That is about 0.2 ns and 1.4 ns more per call; I have not looked into why. The calls run once per ROI added, and once per ROI when an encoder rebuilds its ROI map after
roi_incrementchanged. They do not run every frame.No intentional differences. Since #1964, every input has defined C behaviour, so the parity test excludes nothing.
Kept from the characterization ("characterized, not endorsed" in Tier 1):
UINT32_MAXsaturates even at a factor of 1, and edges past 2^24 lose their low bits, because the edge becomes a float first.Seen while porting, and not changed here (upstream behaviour):
(roi->bottom - 1) / mb_sizeand(roi->right - 1) / mb_size. When a scaled edge truncates to 0, that wraps toUINT32_MAX, and the ROI then covers from its top or left edge to the end of the frame instead of nothing.RED → GREEN
940ab8d5cobs-output: Add the encoder ROI tests. The core istodo!().soldr cargo test -p obs-data --test obs-tests-core output::encoder_roifails 18 of 19 (1 passed, 18 failed, "not yet implemented").edge_roi_layout:Roiis the real struct, not a stub.59c2a8297, the same commit before the last rebase (that rebase changed only AppImage test files).tests/output/encoder_roi.rs) ports, one for one, the eighttest_encoder_roicases that reach the checks and the scaling, under the same names and with the same values.roi_increment, the unscaled order and the NULL encoder) test the list, the lock and the guards, which stay C, so they have no Tier 1 twin.u32::MAXagainst a model, the floats next to ±1, subnormals and NaN payloads, the factors' rounding, the saturation edges, the edge's ties to even, the product rounded inf32, which factor scales which edge, and the layout.obs-tests-core. No new test binary, so no pinned suite count changes.4253f525bobs-output: Port the encoder ROI checks and scaling.output::encoder_roipasses 19/19, andtest_encoder_roipasses 12/12 on C, hybrid and c-ref.dabf3ef3fobs-output: Check the encoder ROI port against the C(tests/output/encoder_roi_parity.rs, 13 tests).What is compared: every output, bit for bit.
f32bits. When there are no factors, both sides start from the same sentinel, so the test also checks that nothing was written.f32bits, both into a fresh ROI and in place.Runs:
OBS_ENCODER_CAP_ROI;test_encoder_roivalues;u32::MAX;±FLT_MAX, ±inf and the NaNs, plus every 65521st of all 2^32;u32and 2^24 edges, every pair against every pair;u32rectangles,f32priorities and factors drawn as bit patterns (NaN and ±inf included) and sizes, plus rectangles near the 16 × 16 minimum, products near 2^32 or a whole number, and the factors-then-scale chain ofobs_encoder_enum_roi().No float is drawn from a wide
Range<f32>(test: extent_parity proptests can trip proptest's float range assertion (Windows merge group) #1951): the floats come from bit patterns, or from small integer offsets added to them.Tier 1 gains
edge_scale_edge_rounds_the_edge_first(see the mutation check).proptest-regressions/encoder_roi_parity.txtkeeps the seeds the mutants failed on.Mutation check (done once, not committed). Each mutant was applied, both tiers were run, and the change was reverted. 30 of 35 mutants fail Tier 3, and 29 of them also fail Tier 1 (the shim mutant is Tier 3 only, since Tier 1 tests the core):
<=)<= -1(refuses -1)>= 1(refuses 1)&&for||on the video sizef64u32::MAXu32::MAX - 1on saturationf64roundfor truncationceilfor truncationscale_xscale_y+ 0.0, NaN made canonical)<for<=in the upside-down check<= 0for< 0>for>=at 2^32edge_scale_edge_rounds_the_edge_firstwas added for it: 2^24 + 1 is 2^24 as a float, so at × 0.75 the C gives 12582912, where an exact product would round to 12582913.as u32already gives 0 for NaN, 0 for -0 and below, andu32::MAXfrom 2^32 up.OBS_LIBOBS_BACKEND=C, andHYBRIDwithOBS_BUILD_C_REFERENCE=ON. Headless: private Xvfb with-noreset, private D-Bus (dbus-run-session), a fresh HOME, no core dumps (ulimit -c 0), no deepTMPDIR. Thelibobs-c-referencetarget is not inall, so it was built by name before each c-ref run, and its mtime was checked.0c96d4594, on46e001f99. The commits on which each check ran:749e92c66, the same series ond0d55704e.rustfmtfor the lint lane (e7589bce4).46e001f99, which brings only AppImage test files (test(appimage): NixOS lane checks OBS loads NVML from /run/opengl-driver (#1028) #1971, test(appimage): first-start checks OBS loads the host's libnvidia-ml.so.1 (#1970) #1972).e7589bce4.--test-diff,output::encoder_roi(33/33) and the threeci/checks were re-run on0c96d4594.test_encoder_roiOBS_LIBOBS_BACKEND=CHYBRID,OBS_BUILD_C_REFERENCE=ONHYBRID,OBS_BUILD_C_REFERENCE=ONtest_encoder_roicase was skipped on any lane.test_config_hex_float_rounding's comma-locale case (no such locale is installed), andopen_crashes_without_obs_coreintest_audio_ioand intest_video_io.uv run ci/local_gate.py --test-diff origin/master(the CI changed-crates step) passes 2935/2935 with 1 skipped (on0c96d4594).uv run ci/local_gate.py --lane lintand--lane crosspass (one7589bce4).ci/test_build_groups.py,ci/test_ported_sources.pyandci/test_oracle_standins.pypass (on0c96d4594).soldr cargo bench -p obs-c-oracle --bench port_comparison -- encoder_roiruns, and its fixtures agree.Windows/macOS: not built there. The core and the shim have no host conditional, and the new PCH uses only the public
obs.h. The--lane crosschecks pass.Checklist
master(or the description starts with a Stacked: note)docs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): built with scripting ON (PR CI builds no OBS app: rungh workflow run ci.yml --ref <branch>for the full builds) and cross-checked with clang and MSVC (not applicable: no warning or flag change)