Repository navigation
obs-source: Port the transition render and audio steps - #2184
Conversation
|
Coordinator: two failures, only one of them from this PR.
|
8fc9854 to
83b9022
Compare
|
Coordinator: this now conflicts with master. #2171 and #2175 landed and added their units to the same |
83b9022 to
00fea3a
Compare
|
Coordinator: green now, thanks. It still conflicts with master after #2175, in |
…ansition-render.c Behaviour-neutral extraction before the Rust port. The render and audio step decisions of the transitions in obs-source-transition.c.h move to libobs/obs-source-transition-render.c.h, declared in the new libobs/obs-source-transition-render.h without EXPORT (hidden): - obs_source_transition_render_video_due() and _video_stop(): the stop step of obs_transition_video_render2() and obs_transition_video_render_direct(). Due at t >= 1 while the video transitions (a NaN t is never due). Then the video ends, and the transition stops unless its audio runs on; the direct render first ends the audio of a transition that is not active (eb35b07). render2 has no inactive rule and passes active as true. - obs_source_transition_render_draw(): render2's draw choice: both children through the callback while the video transitions with the textures locked and a callback set; else source B while the audio transitions; else source A. - obs_source_transition_render_direct_index(): the child the direct render draws: B only for OBS_TRANSITION_SOURCE_B while transitioning. - obs_source_transition_render_audio_stop(): the stop step of obs_transition_audio_render() and transition_stop_audio() (removed): with a timestamp at t >= 1 while the audio transitions; without one only once the video has ended too (7af9c2d). The audio ends, and the transition stops unless its video runs on. - obs_source_transition_render_audio_mix(): mix each child that is there while the audio transitions, else copy source A. - obs_source_transition_render_audio_valid() and _audio_place(): the checks of transition_process_audio(): a child, its audio not pending and not duplicated; a timestamp that is not 0 (3191f5d); the start frame, ns_to_audio_frames(sample_rate, ts - min_ts) written out as its util_mul_div64() so the file needs only util_uint64.h, and the "> AUDIO_OUTPUT_FRAMES" check. - obs_source_transition_render_offset(): the scaled child size of recalculate_transition_matrix() and the offsets it passes to add_alignment(), before the (int) casts: each product rounded to float, then subtracted, as before. Why nine functions and not one step each: every call keeps its place and its condition. obs_source_active() is asked only once the video step is due, so the due test is its own function; obs_source_get_audio_mix() is read between the timestamp check and the start-frame check, so the place says NONE, LATE or MIX and the C returns before or after the read; calc_time() is asked only with a timestamp, so the audio stop step takes whether there is one. The re-read of the children after the audio stop step stays where it was. obs-source-transition.c.h keeps the locks, get_video_time() and calc_time(), copy_transition_state() and the refs, obs_transition_stop(), handle_stop() and the signals, obs_source_active(), the drop of removed children (obs_source_removed() is asked only of a child that is there) and transition_calc_min_ts() with its pending check and obs-rust#130's snapshot read (as obs-rust#2055 left them), the texture trylock, render_child(), the callbacks, the cx/cy check, mix_child() and get_sample_time(), the mixer loop, the memcpy(), the (int) casts, add_alignment() and the matrix calls. transition_process_audio() now reads audio_is_duplicated also when audio_pending is set (two plain field reads of a child it holds a reference to); nothing else is read that was not read before. The target crosses as int; obs-source-transition.c.h checks at compile time that the header's values are OBS_TRANSITION_SOURCE_B and AUDIO_OUTPUT_FRAMES and that enum obs_transition_target is int-sized. Checked against the unchanged functions with a scratch harness (not committed): master's and the moved recalculate_transition_matrix(), obs_transition_video_render2(), obs_transition_video_render_direct(), transition_process_audio() and obs_transition_audio_render() (with their helpers) against stubs that log every lock, trylock, clock read, ref, stop, signal, render, gs_*/matrix call, alignment, timestamp read, mix and memcpy with its arguments (floats as bits), plus the final state. 4,008,640 scenarios, byte-identical logs under GCC -O2 and clang -O0. The new file joins libobs.core-source with libobs.pch.h, which includes the new header. The exported symbol sets are unchanged (1766). Refs obs-rust#2173
test_transition_render_steps, 16 cases, compiles libobs/obs-source-transition-render.c.h (ASan and UBSan) and calls only its nine functions. It pins: - the video stop step's due test at 14 values of t: 0, -0, the smallest subnormal, 0.5, just below 1, 1, just above 1, 2, +-inf, -1, and quiet, negative and signalling NaNs (only t >= 1 is due; a NaN t never ends a transition), with and without the video transitioning; - the stop step for every audio and active flag, and as render2 and the direct render apply it at t just below, at and above 1 and NaN, for every video, audio (and, direct, active) combination: which flags end, the video stop signal and obs_transition_stop(); - render2's draw choice for all 16 flag combinations, including a video transition whose textures are busy or which has no callback (it draws B only while its audio transitions, else A); - the direct render's child for both transitioning states and targets A, B, 2, -1 and the ends of int (only B while transitioning draws B); - the audio stop step with a timestamp at the 14 values of t, without one (only once the video has ended, 7af9c2d; t is not read), and for every pair of children absent, removed, pending, without a timestamp or with one, as obs_transition_audio_render() passes them; - the mix or copy and the validity check for every flag; - the start frame: a timestamp of 0 (nothing more read, pos untouched); the frame edges at 48 kHz and 44.1 kHz around min_ts, 1023, 1024 and 1025 frames, a start at AUDIO_OUTPUT_FRAMES mixing (">", where the scene uses ">="), sample rates of 0, 1 and 1e9; a timestamp below min_ts wrapping to a late frame (885443715538058 with a 64-bit size_t), and a min_ts near UINT64_MAX wrapping back to frame 0; - the offsets for each scale type's scale (32x16 in 64x64 as in test_transition_scale_type, 1280x720, 1000x1000 and 3840x2160 in 1920x1080), the product rounded to float before the subtract (3 times 0x3eaaaaab gives exactly 0; 1053 in 1080 gives -2^-13), transitions of size 0, infinite and NaN scales, and u32-sized sizes. Every pinned float is one rounded multiply and one subtract, the same on every platform the tests run on. Kept, characterized, not endorsed: - a NaN t never ends a transition (render or audio stop step); - a busy texture lock or a missing callback draws the old scene, A, during a video-only transition; - a start frame of exactly AUDIO_OUTPUT_FRAMES mixes 0 frames; - the audio re-read after the stop step does not drop removed children; transition_process_audio() then checks only pending and duplicated; - a timestamp below min_ts wraps and is placed late; a min_ts near UINT64_MAX wraps back to an early frame. It is in the test graph in name order, with libm except on MSVC, and the tests.d fragment says what it pins. Passes 16/16 on the C backend. Refs obs-rust#2173
…s port The transition_render module of rust/obs-source, with its types and todo!() bodies, and its Tier 1 tests (tests/source/transition_render.rs, run by obs-data's obs-tests-core): - steps_*: test/cmocka/test_transition_render_steps.c 1:1, the 16 cases under the same names and in the same order, with the same inputs and expectations, the "characterized, not endorsed" ones included. The stop steps run as the render functions apply them under the lock. - edge_*: the draw choice, the direct index and the mix against their rules over every flag and any i32 target; the start frame at the first ns of every frame up to 1100 and the ns before it at eight sample rates; proptests (20,000 cases each) for the due test and the audio stop step over any f32 bit pattern (half near 1), the video stop step over every flag, the start frame against an exact 128-bit model over any u64 min_ts and difference wherever util_mul_div64() cannot overflow (a rate up to 1e9), its order in ts, and the offsets against an f64 model of one rounded multiply and one rounded subtract over f32 bit patterns and whole-number sizes (never a wide float range, obs-rust#1951). The safe API differs from the C header where Rust says it better: the audio stop step takes Option<f32> (None: no timestamp, the clock is not asked), the place carries its frame (Place::Late(pos), Place::Mix(pos)), the mix is a struct of three bools, and the direct index is a usize. soldr cargo test -p obs-data --test obs-tests-core source::transition_render fails 25 of 25, each with "not yet implemented". Refs obs-rust#2173
Ports libobs/obs-source-transition-render.c.h, the render and audio step decisions of the transitions, to the transition_render module of rust/obs-source. obs-source-transition.c.h stays C: the locks, the clock reads, copy_transition_state() and the refs, obs_transition_stop(), handle_stop() and the signals, obs_source_active(), the removed and pending checks and the timestamp reads, the texture trylock, the renders and callbacks, mix_child() and get_sample_time(), the mixer loop and the memcpy(), the (int) casts, add_alignment() and the matrix calls. The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/transition_render.rs): - video_due(): t >= 1.0 in f32 while the video transitions (NaN never). - video_stop(): StopAudio when not active, else Stop without the audio, else End. - draw(): Callback with the video, the lock and a callback; else B while the audio transitions; else A. - direct_index(): 1 only for TARGET_B while transitioning. - audio_stop(Option<f32>, ...): with a t, t >= 1.0 and the audio; without one, the audio with the video ended; then Stop without the video, else End. - audio_mix() and audio_valid(): the C's flags. - audio_place(): None for a timestamp of 0; else the frame ns_to_audio_frames(rate, ts - min_ts) with the difference wrapping, as Late past AUDIO_FRAMES and Mix up to it. mul_div64() is the C's util_mul_div64(): the wrapping u64 formula, or the exact 128-bit quotient on MSVC x64 (the new platform module's MUL_DIV64_IS_UDIV128, as obs-scene's), written out so the crate still depends on no other crate. The frame is cast to usize as the C casts to size_t (to_size(), the one as-conversion, commented). - offset(): each product rounded to f32, then the subtract (Rust never fuses them). The module denies clippy's arithmetic, indexing, as, unwrap, expect, panic, unimplemented and unreachable lints, keeps no state and takes no lock. Shims (src/ffi/source_transition_render.rs): plain values in and out; the steps as the C's enum values, the mix as its bits, the offset as the repr(C) struct. The place writes the frame through the size_t * only for Late and Mix, as the C does. Intentional difference: a null pos is not written (the C writes through it; libobs passes its own size_t). C side: the file leaves libobs.core-source for its own group, libobs.ported-source-transition-render (LIBOBS_PORTED_SOURCES), whose PCH is only obs-source-transition-render.h and util/util_uint64.h; libobs.pch.h keeps the header for obs-source-transition.c. The nine 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 nine are local in all three, and the hybrid's come from the Rust archive. ci/test_ported_sources.py checks the group on every host. test_transition_render_steps still compiles the C file into itself, unchanged. The new test_transition_render_steps_rust builds the same test source against libobs_rust-static alone (the test includes only the header, so no SIMDe and no libobs include directories), with libm except on MSVC. It passes 16 of 16 on the hybrid tree. Tier 1 source::transition_render passes 25/25. Refs obs-rust#2173
…the C Tier 3 for obs-source::transition_render. The oracle (rust/obs-c-oracle/oracle/source_transition_render.c) compiles the unmodified libobs/obs-source-transition-render.c.h with its nine functions renamed to oracle_*, plus a table of its constants and layouts. The renames also rename struct obs_source_transition_render_offset and enum obs_source_transition_render_audio_place, whose tags share their function's name, so the table names the renamed tags. source::transition_render_parity (13 tests and one ignored) compares the shims with the C, the frame through a size_t * pre-filled with the same guard on both sides (written or not), floats by their bits: - the header's constants, enum values and sizes, the offset struct's size and field offset, int, bool and size_t, and FLT_EVAL_METHOD 0; - every flag combination of the video stop step, the draw choice, the mix and the validity check; the direct index over both states and every target from -70000 to 70000, every 65521st i32 and the ends; the due test and the audio stop step over every flag at 40 special t; the three stop steps as the render functions apply them; - the due test and the audio stop step over every 4099th f32 bit pattern and every pattern within 2^16 of 1.0 (every f32, run once with --release --ignored: all equal); - the place over every combination of 26 special timestamps for ts and min_ts and 14 sample rates up to usize::MAX (where util_mul_div64() wraps), and around the first ns of every frame up to 1100 at eight rates, above and below min_ts; - the offsets over 14 special sizes and scales on each side and both sides at once; - proptests (20,000 cases each) over full-range u64 timestamps (half near min_ts, either side), any usize rate, f32 bit patterns for t, sizes and scales (never a wide Range<f32>, obs-rust#1951) and any i32 target. In the offsets only, where one float operation has two NaN operands, which NaN comes out depends on the operand order the compiler picks (obs-rust#2021); there both sides must give a NaN. Everything else is bit for bit. The intentional difference (a null pos is not written by the shim) is checked on the shim alone. Tier 1 and the parity module pass 38 of 38 (one ignored), 10 runs in a row with fresh seeds. No proptest regression file came up. Refs obs-rust#2173
- rust/README.md: the obs-source crate row names libobs/obs-source-transition-render.c.h, and a new ported-unit row says what moved, what stays C and in which order, how values cross, what is kept and characterized, the intentional difference (a null pos is not written), which tests see the swap and what Tier 3 compares. - rust/obs-source: the crate description and the lib.rs docs list the new module. - rust/obs-c-oracle/benches/port_comparison/source_transition_render.rs, in the sorted mod and modules![...] lists: render (1024 frames of the video steps, the draw choice, the direct index and two offsets) and audio (1024 audio ticks of the stop step, the mix, and two children's checks and start frames). Both sides must give the same checksum; the fixtures allocate nothing, so the module's bmem check (obs-rust#2159) holds. Measured on x86_64 Linux, GCC, load average 6: render 12.46 us Rust, 12.83 us C (0.97x); audio 10.81 us Rust, 11.11 us C (0.97x). docs/rust-port/naming.md needs no row: libobs/obs-source*.c.h already maps to rust/obs-source. Fixes obs-rust#2173
00fea3a to
370b137
Compare
Oracle (oracle/source_frame_copy.c): the original obs-source-frame-copy.c.h, unmodified, with its six functions renamed to oracle_* (the rename also renames the plan struct's tag, consistently), plus the layout of the six structs (size, alignment, every offset), the constants, the step and range values, the long, size_t, int, bool and enum sizes, and every enum video_format value. The structs are mirrored on the Rust side and passed by value, as the C does. Tier 3 (tests/source/frame_copy_parity.rs, 14 tests): every call runs the shim, the oracle and the core, and compares every field: - the layout and the values against the C headers; - exhaustive over format x line-size relation: 38 format values (-3 to 30 and the int ends) against all 625 patterns of the four planes (the source's line size equal, smaller, larger or 0, or the destination's 0), at 16 heights (0 to 5, 1079 to 1081 and the u32 wrap edges), 3 destination line sizes (1920, 7, UINT32_MAX) and both ranges: 2,280,000 plans, with one copies, row copies and no copy reached; - the line sizes real frames have, padded and not, at real sizes; - the cache step over every queue length up to 64 and the usize ends, against keys at the field ends that differ in one field alone or with the size swapped; - the clean step over every count from -1000 to 1000 and the c_long ends; - the range rules over formats -300 to 300 and the int ends, both ranges and every range from -10 to 10 and the int ends; - the preload rule over every combination of shapes around the edges; - proptests (8192 cases each) over full-range u32 heights and line sizes with any format, any queue length and keys, any count, any format and range, and any preload shapes. Intentional difference, unreachable, kept out of the oracle on every platform: an unused entry's ++unused_count at LONG_MAX overflows a long, which is undefined (MSVC can trap overflows, as STATUS_INTEGER_OVERFLOW did in obs-rust#2184's Windows run). The oracle is never called with that input; there the shim and the core both wrap to LONG_MIN and are compared with each other. Counts start at 0 and an entry is erased at 5. Every other input of every function is defined C on every platform: the plan's arithmetic is unsigned (no division but (height + 1) / 2 in uint32_t), and the formats and ranges are only converted and compared. Tier 1 and the parity module passed 10 runs in a row with fresh seeds. The regression files hold the seeds proptest saved while mutants failed; all of them pass on the port. Mutation check (once, not committed; Tier 1 with 30 tests and Tier 3 with 14 in one run, failures per mutant): 40 mutants, 31 in the core and 9 in the shims. 37 fail; the 3 that survive are equivalent. | Mutant | Tier 1 | Tier 3 | |---|---|---| | half saturating / rounds down | 4 / 8 | 2 / 3 | | I420 plane 2 full height / NV12 chroma full height | 5 / 5 | 3 / 3 | | I40A alpha half height / I422 chroma half height | 4 / 4 | 3 / 3 | | P216 copies plane 0 / Y800 copies nothing | 3 / 3 | 3 / 3 | | one copy when dst >= src | 5 | 3 | | row bytes the larger / the source's | 6 / 4 | 3 / 3 | | one copy of a single row | 6 | 3 | | colour range inverted / strides swapped | 4 / 6 | 3 / 3 | | queue limit strict / at 31 | 3 / 2 | 2 / 3 | | texture change ignores the convert type / the width | 3 / 1 | 2 / 1 | | drop at or past the limit / used entries counted | 3 / 3 | 2 / 2 | | count saturating / not incremented on drop | 1 / 3 | 1 / 1 | | V210 not YUV / Y800 YUV | 3 / 3 | 1 / 1 | | default range always partial / *2() "not partial" is full | 2 / 2 | 1 / 2 | | RGB keeps its range / preload ignores the format / no preload is no change | 2 / 2 / 2 | 2 / 2 / 2 | | shim: lines swapped / reset and overflow swapped / plan count capped at 3 | 0 | 3 / 3 / 3 | | shim: in use counted / drop not set / preload always present / range2 arguments swapped | 0 | 2 / 1 / 2 / 1 | | equivalent: one copy's size saturating (a u32 x u32 product fits a 64-bit usize) | 0 | 0 | | equivalent: one copy's size from the source's line size (equal to the destination's) | 0 | 0 | | equivalent: shim swaps width and height in both keys (the comparison is symmetric) | 0 | 0 | Tier 1 does not reach the shims; Tier 3 kills every shim mutant but the equivalent one. "count saturating" differs only at LONG_MAX, where the oracle is not called: Tier 1's edge case and Tier 3's shim-to-core check there kill it. Refs obs-rust#2192
Oracle (oracle/source_frame_copy.c): the original obs-source-frame-copy.c.h, unmodified, with its six functions renamed to oracle_* (the rename also renames the plan struct's tag, consistently), plus the layout of the six structs (size, alignment, every offset), the constants, the step and range values, the long, size_t, int, bool and enum sizes, and every enum video_format value. The structs are mirrored on the Rust side and passed by value, as the C does. Tier 3 (tests/source/frame_copy_parity.rs, 14 tests): every call runs the shim, the oracle and the core, and compares every field: - the layout and the values against the C headers; - exhaustive over format x line-size relation: 38 format values (-3 to 30 and the int ends) against all 625 patterns of the four planes (the source's line size equal, smaller, larger or 0, or the destination's 0), at 16 heights (0 to 5, 1079 to 1081 and the u32 wrap edges), 3 destination line sizes (1920, 7, UINT32_MAX) and both ranges: 2,280,000 plans, with one copies, row copies and no copy reached; - the line sizes real frames have, padded and not, at real sizes; - the cache step over every queue length up to 64 and the usize ends, against keys at the field ends that differ in one field alone or with the size swapped; - the clean step over every count from -1000 to 1000 and the c_long ends; - the range rules over formats -300 to 300 and the int ends, both ranges and every range from -10 to 10 and the int ends; - the preload rule over every combination of shapes around the edges; - proptests (8192 cases each) over full-range u32 heights and line sizes with any format, any queue length and keys, any count, any format and range, and any preload shapes. Intentional difference, unreachable, kept out of the oracle on every platform: an unused entry's ++unused_count at LONG_MAX overflows a long, which is undefined (MSVC can trap overflows, as STATUS_INTEGER_OVERFLOW did in obs-rust#2184's Windows run). The oracle is never called with that input; there the shim and the core both wrap to LONG_MIN and are compared with each other. Counts start at 0 and an entry is erased at 5. Every other input of every function is defined C on every platform: the plan's arithmetic is unsigned (no division but (height + 1) / 2 in uint32_t), and the formats and ranges are only converted and compared. Tier 1 and the parity module passed 10 runs in a row with fresh seeds. The regression files hold the seeds proptest saved while mutants failed; all of them pass on the port. Mutation check (once, not committed; Tier 1 with 30 tests and Tier 3 with 14 in one run, failures per mutant): 40 mutants, 31 in the core and 9 in the shims. 37 fail; the 3 that survive are equivalent. | Mutant | Tier 1 | Tier 3 | |---|---|---| | half saturating / rounds down | 4 / 8 | 2 / 3 | | I420 plane 2 full height / NV12 chroma full height | 5 / 5 | 3 / 3 | | I40A alpha half height / I422 chroma half height | 4 / 4 | 3 / 3 | | P216 copies plane 0 / Y800 copies nothing | 3 / 3 | 3 / 3 | | one copy when dst >= src | 5 | 3 | | row bytes the larger / the source's | 6 / 4 | 3 / 3 | | one copy of a single row | 6 | 3 | | colour range inverted / strides swapped | 4 / 6 | 3 / 3 | | queue limit strict / at 31 | 3 / 2 | 2 / 3 | | texture change ignores the convert type / the width | 3 / 1 | 2 / 1 | | drop at or past the limit / used entries counted | 3 / 3 | 2 / 2 | | count saturating / not incremented on drop | 1 / 3 | 1 / 1 | | V210 not YUV / Y800 YUV | 3 / 3 | 1 / 1 | | default range always partial / *2() "not partial" is full | 2 / 2 | 1 / 2 | | RGB keeps its range / preload ignores the format / no preload is no change | 2 / 2 / 2 | 2 / 2 / 2 | | shim: lines swapped / reset and overflow swapped / plan count capped at 3 | 0 | 3 / 3 / 3 | | shim: in use counted / drop not set / preload always present / range2 arguments swapped | 0 | 2 / 1 / 2 / 1 | | equivalent: one copy's size saturating (a u32 x u32 product fits a 64-bit usize) | 0 | 0 | | equivalent: one copy's size from the source's line size (equal to the destination's) | 0 | 0 | | equivalent: shim swaps width and height in both keys (the comparison is symmetric) | 0 | 0 | Tier 1 does not reach the shims; Tier 3 kills every shim mutant but the equivalent one. "count saturating" differs only at LONG_MAX, where the oracle is not called: Tier 1's edge case and Tier 3's shim-to-core check there kill it. Refs obs-rust#2192
…ust#2215) * libobs: Move the async frame copy plan into obs-source-frame-copy.c Behaviour-neutral extraction before the Rust port. The decisions of the async frame copy and cache in obs-source.c.h move to libobs/obs-source-frame-copy.c.h, declared in the new libobs/obs-source-frame-copy.h without EXPORT (hidden, as -fvisibility=hidden keeps them), as six functions on plain values: - obs_source_frame_copy_plan(format, full_range, height, src, dst): copy_frame_data()'s copies. The colour range is copied only when the frame is not full range; then, per format, each plane's rows ((height + 1) / 2 for 4:2:0 chroma), one copy of linesize x rows in size_t when the two line sizes are equal (copy_frame_data_plane()), else rows of the smaller line size (copy_frame_data_line()). P216, P416 and values outside the enum copy no plane. The switch moved as it was. The line sizes cross as a struct of four uint32_t, by value. - obs_source_frame_copy_cache_step(queued, cache, frame): cache_video()'s queue limit (MAX_ASYNC_FRAMES or more queued: clear and refuse), then async_texture_changed() (the size or the convert type differs: clear and take the size), else keep. - obs_source_frame_copy_cache_clean(used, unused_count): one entry of clean_cache(): an unused entry counts one more call and is dropped at MAX_UNUSED_FRAME_DURATION. unused_count stays long. - obs_source_frame_copy_full_range() and _full_range2(): the range rule of obs_source_output_video(), obs_source_preload_video() and obs_source_set_video_frame() (a frame that is not YUV is full range), and of their *2() variants (resolve_video_range() gives VIDEO_RANGE_FULL). - obs_source_frame_copy_preload_changed(): preload_frame_changed(). obs-source.c.h keeps every memcpy(): copy_frame_data() still copies the metadata and the colour matrix, then gets the plan and runs it, plane i from plane i, each row offset y * line size in uint32_t as before. cache_video() keeps async_mutex, free_async_cache(), the fields it stores, the walk that picks the first unused entry (obs-rust#2009's prev_frame reset included), obs_source_frame_create(), the darrays and the refcount atomics; it passes the two convert types from get_convert_type(). clean_cache() keeps the walk, the destroy and the erase, and stores the count only into an unused entry, as before. MAX_ASYNC_FRAMES and MAX_UNUSED_FRAME_DURATION stay where they are, checked against the header's copies at compile time, as are the plan's 4 planes against MAX_AV_PLANES. What the C now reads that it did not read before. None of these reads changes a result: - copy_frame_data() reads the first four line sizes of both frames for every format; - cache_video() asks get_convert_type() for both convert types before the queue limit (a pure function; before, only a frame under the limit asked); - preload_frame_changed() reads all three fields of both frames when there is a preload frame (before, the || stopped at the first difference); - the *2() variants resolve the range where they store it, not first. Checked against the unchanged functions of origin/master (outside the tree, not committed): a scratch harness compiles master's copy_frame_data_line() through cache_video(), preload_frame_changed() and the six range lines verbatim next to the moved code, with memcpy(), obs_source_frame_create() and _destroy() hooked, against the C backend's libobs: - 2,742,507 copies with fake plane pointers (every format from -3 to 32 and the int ends against all 625 patterns of the four line sizes, equal, smaller, larger, 0 or any, at 11 heights; then random formats, heights up to UINT32_MAX and full-range line sizes) make the same 697,179,469 memcpy() calls (destination, source, size, in order) and leave the same destination fields; - 200,000 copies on real buffers write the same bytes; - 400 sequences of 2000 steps through cache_video() with a model of obs_source_output_video_internal() and the renderer (frames queued, released, the queue stalled to its limit, 1949 frames refused there, and obs_source_output_video(NULL)) leave the same cache entries (frame, used, unused count, fields), queue, cache size, format, range, transfer, last_frame_ts and frame pointers after every step, and make the same memcpy() calls; - 200,000 clean_cache() runs over entries of any used flag and count (26,755 dropped); - every preload pair over sizes and formats around the edges, and the range rule over formats -300 to 300 and the int ends, both ranges and every video_range_type from -5 to 10. Under ASan and UBSan (halt on error, leak detection), a run of 1,142,507 fake copies, 40,000 real ones and 80 sequences reports nothing. 13 of 14 deliberately broken moves fail the harness; the one that survives (storing a used entry's count back) is equivalent. git log -L on each moved function shows only upstream history, plus the fork's obs-rust#2048 (obs-rust#2009), whose prev_frame reset stays in cache_video(). The new file joins libobs.core-source with libobs.pch.h, which includes the new header. The exported symbol sets are unchanged (1766). Refs obs-rust#2192 * test: Characterize the async frame copy plan and cache decisions test_source_frame_copy_steps compiles libobs/obs-source-frame-copy.c.h (ASan and UBSan) and calls only its six functions through their header, with media-io/video-io.h for the enum values. 19 cases: - the constants (4 planes, MAX_ASYNC_FRAMES 30, MAX_UNUSED_FRAME_DURATION 5, the step values), and a table of every enum video_format value in order with the planes the copy makes and each plane's rows (full or (height + 1) / 2); - the copy plan of every format at 12 heights (0 to 5, 9, 719, 720 and 1079 to 1081) with equal line sizes (one copy of line size x rows) and with a padded source (rows of the destination's line size); planes past the count are zero; - no plane for -1, VIDEO_FORMAT_R10L + 1, 1000 and the int ends, nor for P216 and P416 ("Unimplemented"; characterized, not endorsed: no in-tree source outputs them); the colour range is still copied; - odd heights: 4:2:0 chroma rounds up (I420, I010, NV12, P010 and I40A, whose alpha plane is full height), 4:2:2 keeps the full height; - (height + 1) / 2 wraps in uint32_t: UINT32_MAX has 0 chroma rows (characterized, not endorsed), and the one copy's size is the size_t product (0xffffffff x 0xffffffff here); - per plane of every format, the source line size equal, smaller, 1, larger, UINT32_MAX or 0 against the destination's, a destination line size of 0 (rows of 0 bytes), and both 0 (one copy of 0 bytes); each plane decides on its own two line sizes, and a fifth is never read; - the colour range for each range, from format -2 to R10L + 2; - the queue limit at 0, MAX_ASYNC_FRAMES - 1, at it, + 1 and SIZE_MAX, with the keys equal and different: the limit comes first; - async_texture_changed(): the width, the height or the convert type alone resets, swapped sizes reset, equal keys keep (any values); - clean_cache(): an unused entry counts 0 to 4 up by one and is dropped at 5; past 5 it is never dropped (unreachable, as it is erased at 5; characterized, not endorsed), a used entry keeps any count and is not counted, and five calls from 0 drop it on the fifth; - the range rule: YUV keeps its range, any other format and values outside the enum are full range; the *2() rule: VIDEO_RANGE_DEFAULT is partial for YUV and full otherwise, an explicit range is kept (an RGB frame with VIDEO_RANGE_PARTIAL stays limited there, unlike the first rule), a range outside the enum is not full; - preload_frame_changed(): no preload frame is always a change; the width, the height or the format alone is one. The test is in the native test graph in name order, with libm except on MSVC. On the C backend it passes 19 of 19, also on its own with ASan leak detection and halt on error. Refs obs-rust#2192 * obs-source: Add Tier 1 tests for the async frame copy plan port Tests for the port of libobs/obs-source-frame-copy.c.h to the frame_copy module of rust/obs-source, next to conversion_plan. The safe core is a stub (todo!()): - copy_plan(), obs_source_frame_copy_plan() on plain values: the format as the C's int, the range, the height and the four line sizes of each frame, a CopyPlan back (the colour range flag, the count and four PlaneCopy of whole, bytes as usize, rows and the two strides); - its pieces: plane_rows() (the planes of each format and whether each one's rows are the height or half()), half() ((height + 1) / 2 in u32) and plane_copy() (one plane); - cache_step() (cache_video()'s queue limit, then texture_changed(), async_texture_changed() on two Keys of size and convert type) and clean() (one entry of clean_cache(), a CacheAge of in use, counted or dropped, the count a c_long as the C's long); - full_range() and full_range2() (the range rules of obs_source_output_video() and its *2() variant), with is_yuv() and resolve_range() (format_is_yuv() and resolve_video_range()); - preload_changed() (preload_frame_changed(), the preload frame an Option<Shape>). The video_format values are conversion_plan's; MAX_ASYNC_FRAMES, MAX_UNUSED and the video_range_type values are new constants. tests/source/frame_copy.rs ports test_source_frame_copy_steps 1:1: its 19 cases under the same names (steps_*), in the same order, with the same inputs and expectations. Edge cases (edge_*): half() at its ends; plane_copy() for each relation; the plan is its pieces for formats -3 to 30 at heights up to u32::MAX; the queue limit over every length up to 64 and usize::MAX; clean() over counts -10 to 10 and at c_long::MAX (the C's ++ would overflow there; no entry gets past 5, and the port wraps); the range rules against is_yuv() and resolve_range() for formats -3 to 40 and ranges -3 to 5. Proptests (4000 cases each): any format outside the enum copies nothing; each plane against a model in u64 arithmetic (height + 1 reduced modulo 2^32, then halved) for any i32 format and any u32 height and line sizes, biased to the ends; cache_step() for any keys and queue length; clean() for any count; preload_changed() for any shapes. soldr cargo test -p obs-data --test obs-tests-core source::frame_copy fails 28 of 30 with "not yet implemented". The two that pass, steps_constants and steps_table_covers_every_format, read only the constants and the test's own tables. Refs obs-rust#2192 * obs-source: Port the async frame copy plan Ports libobs/obs-source-frame-copy.c.h, the async frame copy plan and cache decisions of obs-source.c, to the frame_copy module of rust/obs-source. obs-source.c.h stays C: every memcpy() (it runs the plan), the metadata copy, obs_source_frame_create() and _destroy(), the async_cache and async_frames darrays and the walk that picks the first unused entry, async_mutex, the refcount atomics and get_convert_type(). The hybrid libobs drops the C file and links the Rust shims in its place. Safe core (src/frame_copy.rs): - plane_rows(): copy_frame_data()'s switch, a match over the format's int giving each plane's rows rule (the height, or half() for 4:2:0 chroma), none for P216, P416 and any value outside the enum. Every format is matched by name, so a new one must be placed. - half() is (height + 1) / 2 with wrapping_add, so UINT32_MAX gives 0 as the C's uint32_t does; plane_copy() is one copy of dst x rows as a usize product (wrapping_mul, the C's size_t) when the line sizes are equal, else rows of the smaller line size; copy_plan() zips the rules with the four line sizes of each frame and sets the colour range flag when the frame is not full range. - cache_step(): the queue limit (MAX_ASYNC_FRAMES) first, then texture_changed() on the two keys. - clean(): an unused entry's ++unused_count in c_long, wrapping, and the drop when it reaches MAX_UNUSED. - full_range() and full_range2(), with is_yuv() and resolve_range() (format_is_yuv() and resolve_video_range(), matched by name). - preload_changed() on an Option<Shape>. The module denies clippy's arithmetic, indexing, as (one allowed cast, u32 to usize), unwrap, expect, panic, todo, unimplemented and unreachable lints, keeps no state and takes no lock. Shims (src/ffi/source_frame_copy.rs): the six functions, with the header's structs mirrored #[repr(C)] and everything passed and returned by value, so no pointer crosses and the shims read and write no memory of the caller. The step crosses as the C's enum value. No intentional difference, except where the C is undefined: ++unused_count overflows a long at LONG_MAX, where the shim wraps; no entry gets past 5. C side: the file leaves libobs.core-source for its own group, libobs.ported-source-frame-copy (LIBOBS_PORTED_SOURCES), whose PCH is <string.h>, media-io/video-io.h (the enums, format_is_yuv() and resolve_video_range()) and the header. libobs.pch.h keeps the header for obs-source.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 is in the hybrid libobs). ci/test_ported_sources.py checks the group on every host. test_source_frame_copy_steps still compiles the C file into itself, unchanged. The new test_source_frame_copy_steps_rust builds the same test source against libobs_rust-static (and libm except on MSVC): the test calls only the six functions and includes their header and media-io/video-io.h, neither of which needs SIMDe, so this variant runs the shims and the structs' layout. It passes 19 of 19. test_video_frame, the media restart tests, the v4l2 and PipeWire camera tests and the deinterlace tests see the swap through the hybrid. Tier 1 source::frame_copy passes 30/30. Refs obs-rust#2192 * obs-source: Check the async frame copy plan port against the C Oracle (oracle/source_frame_copy.c): the original obs-source-frame-copy.c.h, unmodified, with its six functions renamed to oracle_* (the rename also renames the plan struct's tag, consistently), plus the layout of the six structs (size, alignment, every offset), the constants, the step and range values, the long, size_t, int, bool and enum sizes, and every enum video_format value. The structs are mirrored on the Rust side and passed by value, as the C does. Tier 3 (tests/source/frame_copy_parity.rs, 14 tests): every call runs the shim, the oracle and the core, and compares every field: - the layout and the values against the C headers; - exhaustive over format x line-size relation: 38 format values (-3 to 30 and the int ends) against all 625 patterns of the four planes (the source's line size equal, smaller, larger or 0, or the destination's 0), at 16 heights (0 to 5, 1079 to 1081 and the u32 wrap edges), 3 destination line sizes (1920, 7, UINT32_MAX) and both ranges: 2,280,000 plans, with one copies, row copies and no copy reached; - the line sizes real frames have, padded and not, at real sizes; - the cache step over every queue length up to 64 and the usize ends, against keys at the field ends that differ in one field alone or with the size swapped; - the clean step over every count from -1000 to 1000 and the c_long ends; - the range rules over formats -300 to 300 and the int ends, both ranges and every range from -10 to 10 and the int ends; - the preload rule over every combination of shapes around the edges; - proptests (8192 cases each) over full-range u32 heights and line sizes with any format, any queue length and keys, any count, any format and range, and any preload shapes. Intentional difference, unreachable, kept out of the oracle on every platform: an unused entry's ++unused_count at LONG_MAX overflows a long, which is undefined (MSVC can trap overflows, as STATUS_INTEGER_OVERFLOW did in obs-rust#2184's Windows run). The oracle is never called with that input; there the shim and the core both wrap to LONG_MIN and are compared with each other. Counts start at 0 and an entry is erased at 5. Every other input of every function is defined C on every platform: the plan's arithmetic is unsigned (no division but (height + 1) / 2 in uint32_t), and the formats and ranges are only converted and compared. Tier 1 and the parity module passed 10 runs in a row with fresh seeds. The regression files hold the seeds proptest saved while mutants failed; all of them pass on the port. Mutation check (once, not committed; Tier 1 with 30 tests and Tier 3 with 14 in one run, failures per mutant): 40 mutants, 31 in the core and 9 in the shims. 37 fail; the 3 that survive are equivalent. | Mutant | Tier 1 | Tier 3 | |---|---|---| | half saturating / rounds down | 4 / 8 | 2 / 3 | | I420 plane 2 full height / NV12 chroma full height | 5 / 5 | 3 / 3 | | I40A alpha half height / I422 chroma half height | 4 / 4 | 3 / 3 | | P216 copies plane 0 / Y800 copies nothing | 3 / 3 | 3 / 3 | | one copy when dst >= src | 5 | 3 | | row bytes the larger / the source's | 6 / 4 | 3 / 3 | | one copy of a single row | 6 | 3 | | colour range inverted / strides swapped | 4 / 6 | 3 / 3 | | queue limit strict / at 31 | 3 / 2 | 2 / 3 | | texture change ignores the convert type / the width | 3 / 1 | 2 / 1 | | drop at or past the limit / used entries counted | 3 / 3 | 2 / 2 | | count saturating / not incremented on drop | 1 / 3 | 1 / 1 | | V210 not YUV / Y800 YUV | 3 / 3 | 1 / 1 | | default range always partial / *2() "not partial" is full | 2 / 2 | 1 / 2 | | RGB keeps its range / preload ignores the format / no preload is no change | 2 / 2 / 2 | 2 / 2 / 2 | | shim: lines swapped / reset and overflow swapped / plan count capped at 3 | 0 | 3 / 3 / 3 | | shim: in use counted / drop not set / preload always present / range2 arguments swapped | 0 | 2 / 1 / 2 / 1 | | equivalent: one copy's size saturating (a u32 x u32 product fits a 64-bit usize) | 0 | 0 | | equivalent: one copy's size from the source's line size (equal to the destination's) | 0 | 0 | | equivalent: shim swaps width and height in both keys (the comparison is symmetric) | 0 | 0 | Tier 1 does not reach the shims; Tier 3 kills every shim mutant but the equivalent one. "count saturating" differs only at LONG_MAX, where the oracle is not called: Tier 1's edge case and Tier 3's shim-to-core check there kill it. Refs obs-rust#2192 * docs: Record the async frame copy plan port The rust/README.md crate table now lists libobs/obs-source-frame-copy.c.h among the rust/obs-source units, and its port table has a row for it: the six functions and the rules each keeps (with the upstream commits that made them), what stays C (every memcpy(), the metadata copy, frame create and destroy, the darrays and the first-unused walk with obs-rust#2048's prev_frame reset, async_mutex, the refcount atomics and get_convert_type()), everything crossing by value, the wraps it keeps, what is characterized and not endorsed (P216 and P416 copy nothing, UINT32_MAX rows have no chroma rows, a count past 5 is never dropped, the *2() rule keeps an explicit partial range on RGB), the intentional difference (the long overflow at LONG_MAX, unreachable), the _rust variant of the characterization, the real-libobs tests and what Tier 3 compares. The crate's description and lib.rs say what it holds. docs/rust-port/naming.md already maps libobs/obs-source*.c.h to rust/obs-source. port_comparison gets its own bench file, benches/port_comparison/source_frame_copy.rs, in the sorted modules! list: 1024 copy plans (every format and two values outside the enum at 1920 x 1080, 1281 x 721 and 3840 x 2160, equal and padded line sizes) and 1024 frames' cache, clean, range and preload decisions, each folded into a checksum both sides must match. Neither side allocates, so the module's fixture check passes. On x86_64 Linux (GCC, not pinned, load average 45; median per 1024 calls): plan 62.24 us Rust and 39.48 us C (1.58x), cache 39.00 us Rust and 48.34 us C (0.81x), so about 22 ns more a plan and well under 0.1 us a frame. Fixes obs-rust#2192
Fixes #2173
What and why
Ports the render and audio step decisions of
libobs/obs-source-transition.c.h(our #556 area) torust/obs-source, as a new moduletransition_render, next totransition_clock(#2055). These are the decisions ofobs_transition_video_render2(),obs_transition_video_render_direct(),obs_transition_audio_render(),transition_process_audio()and the offsets ofrecalculate_transition_matrix(): when a transition stops, what it draws, which child it mixes or copies, where a child's audio starts in the tick, and where a child of another size sits. They run for every frame a transition renders and every audio tick it mixes. A wrong stop step leaves a transition running (the old scene's audio stays) or ends it early; a wrong start frame shifts or drops a child's audio; a wrong offset misplaces a scene of another size.Six commits:
Move (behaviour-neutral) into
libobs/obs-source-transition-render.c.h, nine functions declared in the newobs-source-transition-render.hwithoutEXPORT(hidden):obs_source_transition_render_video_due()and_video_stop(): the stop step of render2 and the direct render. Due att >= 1while the video transitions; then the video ends, and the transition stops unless its audio runs on. The direct render first ends the audio of a transition that is not active (eb35b07); render2 has no such rule and passesactiveas true;obs_source_transition_render_draw(): render2's draw choice (both children through the callback, B while the audio transitions, else A);obs_source_transition_render_direct_index(): B only forOBS_TRANSITION_SOURCE_Bwhile transitioning;obs_source_transition_render_audio_stop(): the audio render's stop step andtransition_stop_audio()(removed): with a timestamp att >= 1; without one only once the video has ended (7af9c2d);obs_source_transition_render_audio_mix(): mix each child that is there, or copy A;obs_source_transition_render_audio_valid()and_audio_place():transition_process_audio()'s checks (not pending, not duplicated; a timestamp that is not 0, 3191f5d) and the start frame,ns_to_audio_frames(sample_rate, ts - min_ts)written out as itsutil_mul_div64(), late pastAUDIO_OUTPUT_FRAMES;obs_source_transition_render_offset(): the scaled child size and the offsets passed toadd_alignment(), before the(int)casts.obs-source-transition.c.hkeeps the locks,get_video_time()andcalc_time(),copy_transition_state()and the refs,obs_transition_stop(),handle_stop()and the signals,obs_source_active(), the drop of removed children andtransition_calc_min_ts()(its pending check and TSan: audio thread reads source audio_ts / audio_input_buf without audio_buf_mutex #130's snapshot read, as obs-source: Port the transition clock and fit #2055 left them), the texture trylock,render_child(), the callbacks, thecx && cycheck,mix_child()andget_sample_time(), the mixer loop, thememcpy(), the(int)casts,add_alignment()and the matrix calls.obs_source_active()is asked only once the video step is due, so the due test is its own function and_video_stop()takes the answer.obs_source_get_audio_mix()is read between the timestamp check and the start-frame check, so_audio_place()answers NONE, LATE or MIX and the C returns before or after the read.calc_time()is asked only with a timestamp, so_audio_stop()takes whether there is one. The re-read of the children after the audio stop step stays where it was. The plan'smatrix_inputs(tr, source, scale) -> (scaled, offset)became the offsets alone: the C uses the scaled size only for them. The drop of removed children stays C: it is a pointer test andobs_source_removed(), asked only of a child that is there, the same kind of guard on the same read as the pending check obs-source: Port the transition clock and fit #2055 left intransition_calc_min_ts(); moving it would either hoist the call or leave a one-operator function.transition_process_audio()now readsaudio_is_duplicatedalso whenaudio_pendingis set (both fields of a child it holds a reference to). No call is added, dropped or moved.int;obs-source-transition.c.hchecksOBS_TRANSITION_SOURCE_B,AUDIO_OUTPUT_FRAMESand the enum's size at compile time.recalculate_transition_matrix(),obs_transition_video_render2(),obs_transition_video_render_direct(),transition_process_audio(),transition_stop_audio()andobs_transition_audio_render()verbatim, with their helpers (copy_transition_state(),obs_transition_stop(),handle_stop(),transition_calc_min_ts()), and the moved ones, as two translation units over shared stubs. The stubs log every lock and unlock, trylock, clock read (tas bits),transition_valid(), ref and release,obs_source_remove_active_child(), signal,info.transition_stop,obs_source_active(),obs_source_removed(), timestamp read (scripted per read, so the snapshot can change between reads),obs_source_get_audio_mix(),mix_child()(output and input buffer, offset, count, rate, ts, which mix callback),memcpy(), render, colour space, blend,gs_matrix_*andmatrix4_*call (floats as bits),add_alignment()and the callback, with their arguments, then the transition's final flags, children, active flags and matrices. The two logs are byte-identical under GCC -O2 and clang -O0 over 4,008,640 scenarios: render2 exhaustive over the flags, 13 values oft(around 1, ±0, ±inf, NaNs), the trylock result, the callback, three sizes per side and the textures (119,808); the direct render over the flags,t,activeand six targets (4,992); the audio render 40 rounds over every combination of presence, removed, pending, duplicated, the flags andt(or a randomtbit pattern), with random timestamps per read, mixers, channel counts and seven sample rates (2,129,920);transition_process_audio()around each rate's frame edges at 1023, 1024, 1025, 2048 and 2^20 frames, above and below fivemin_ts(including the wrap) plus 300,000 random runs (339,200); andrecalculate_transition_matrix()over 12 special sizes for each of four sides, five scale types and 64 alignments plus 1,000,000 random ones (1,414,720). Planted changes are caught (mismatching runs):t > 1(4,800),>=for the late frame (304), the inactive rule dropped (768), the scales swapped (218,773), the direct index without the transitioning check (204), the no-timestamp stop without its video check (410,045), COPY_A read as MIX_A (351,750). The harness was rerun on the final base.The file stays in
libobs.core-sourcefor this commit. Exports are unchanged (1766).Characterization:
test_transition_render_steps, 16 cases, compiling the moved file (ASan and UBSan). It pins:t(0, −0, the smallest subnormal, 0.5, just below 1, 1, just above 1, 2, ±inf, −1, quiet, negative and signalling NaNs), with and without the video;tjust below, at and above 1 and NaN, for every video, audio and (direct) active flag: the flags afterwards, the video stop signal andobs_transition_stop();int;t, without one, and for every pair of children absent, removed, pending, without a timestamp or with one, as the audio render passes them; the mix and the validity check for every flag;posuntouched); the frame edges at 48 kHz and 44.1 kHz aroundmin_ts(1023, 1024, 1025 frames); rates of 0, 1 and 1e9; theu64wrap both ways;test_transition_scale_type, and 1280x720, 1000x1000 and 3840x2160 in 1920x1080), the product rounded before the subtract, sizes of 0, infinite and NaN scales,u32-sized sizes.add_alignment()stays C (it belongs to the ported scene bounds-place unit andtest_scene_bounds_placecovers it), so the alignment is not an input here;test_transition_scale_typecovers the whole matrix through the real libobs.It is in the test graph in name order, with libm except on MSVC.
test/cmocka/tests.d/test_transition_render_steps.cmakesays what it pins.RED: Tier 1 in the crate, against
todo!().GREEN: the safe core and the
#[no_mangle]shims, in a newlibobs.ported-source-transition-rendergroup with its own PCH (the header andutil/util_uint64.h). The export lists,source-sets.json, the unity lists andci/test_ported_sources.pyare updated, and a_rustvariant of the characterization is added.Tier 3: a C oracle and parity tests, with the mutation check.
Docs: the README rows, the crate's description and
lib.rs, and aport_comparisonbench file.Kept, characterized, not endorsed:
tnever ends a transition (video or audio);AUDIO_OUTPUT_FRAMESis not late, somix_child()mixes 0 frames (the scene's window uses>=; harmless);min_tswraps inuint64_tto a late frame (with a 64-bitsize_t), and amin_tsnearUINT64_MAXwraps back to an early one.The port keeps all of them:
f32compares,wrapping_sub, the C'sutil_mul_div64()formula and the(size_t)cast.bool, the target asint, the steps as the C's enum values, the mix as its bits, the offsets as a two-floatstruct, the start frame through asize_t *. The place enum and the offset struct share their function's name; the oracle's rename macros rename those tags too, and its layout table names the renamed tags.util_mul_div64(). The start frame uses the C's formula as each host compiles it: the wrappinguint64_tformula, or exact 128-bit math on MSVC x64 (MUL_DIV64_IS_UDIV128in a newplatformmodule, asobs-scenehas). For a sample rate up to 1e9 neither overflows and both are exact. Written out in the crate, soobs-sourcestill depends on no other crate.-ffp-contract=fast, before and after this PR. There the C can differ from the hybrid in the last bit of an offset whose product is inexact, which matters only where the(int)cast then lands on the other side of an integer. No test lane runs aarch64 Linux; the oracle is built with-ffp-contract=off.posis not written by the shim; the C writes through it. libobs passes the address of its ownsize_t._rustvariant links the archive alone.test_transition_render_steps_rustbuilds the unchanged test source againstlibobs_rust-static, with libm except on MSVC. The test includes only the header (noobs.h, so no SIMDe and no libobs include directories).libobs-c-reference, identical sets. The nine functions are local (t) in all three; in the hybrid they come from the Rust archive (the C group is compiled only into the C backend andlibobs-c-reference).render(1024 frames: the due test, the video stop step where due, the draw choice, the direct index and two offsets) 12.46 µs Rust, 12.83 µs C (0.97x);audio(1024 audio ticks: the stop step, the mix, two children's checks and start frames) 10.81 µs Rust, 11.11 µs C (0.97x); load average 6. The fixtures allocate nothing, so the module's bmem check (obs-c-oracle: Free what port_comparison's fixtures allocate #2159) holds.docs/features.mdline.Observed, not changed (reported here):
obs_transition_audio_render()drops removed children (ea9e4ca) only before its first timestamp pass. The re-read after the stop step takestransition_sources[]again without that check, so a removed child that still has a timestamp counts in the secondmin_ts, is copied into the state and is passed totransition_process_audio(), which checks onlyaudio_pendingandaudio_is_duplicated(fields, notobs_source_audio_pending(), which since ea9e4ca says pending for a removed source). If that child's timestamp is older than the other's,*ts_outbecomes the removed child's and the other child's audio is placed that much later, or dropped past the tick. The move keeps it exactly, and the characterization pins the re-read's mix and validity rules. Whether it is reachable (a removed source that keeps an older audio timestamp while it is still a transition child) needs a real-libobs test first; a fix changes what the audio render outputs, so it belongs in its own PR.RED → GREEN
b2b52216e.soldr cargo test -p obs-data --test obs-tests-core source::transition_renderfails 25 of 25, each with "not yet implemented" (the 16 portedsteps_*cases and the 9edge_*cases, six of them proptests). Recorded onba4a27995and28fe665f5, the same commit before the rebases.52ca4720e. Tier 1 passes 25/25. The table below ran onbdfc230e8(the same six commits based ona8316f66d); after it the branch was rebased onto6c98110db(frontend files, frontend tests, their cmake fragments andci/platform-ifdef-baseline.jsononly) and two gate fixes were folded in (rustfmt of the oracle bindings, a type alias in the bench), none of which touches libobs or the crate's code. Under a privateXvfb -noreseton a display checked free, withdbus-run-session, a fresh HOME,ulimit -c 0and TMPDIR unset.libobs-c-referencewas built withninja libobs-c-referencebefore the run and is newer than the hybrid library; the c-ref lane putslibobs-c-reference/first onLD_LIBRARY_PATH, checked withldd.test_transition_swaptest_transition_scale_typetest_transition_recursive_destinationtest_item_transition_empty_sourcetest_saved_transitiontest_transition_clock_stepstest_transition_clock_steps_rusttest_transition_render_stepstest_transition_render_steps_rusttest_group_hide_transition_audiotest_transition_audio_rescaletest_visibility_transitiontest_studio_mode_swaptest_fade_to_color_mixtest_stinger_media_durationtest_tbar_positiontest_audio_capture_mix_racegrep -l transition test/cmocka/*.c: the above and 20 more ctest entries)-j8)Every test passed on its first run; no rerun was needed (the #456 and #838 flakes did not come up, and
test_group_hide_transition_audiopassed each time it ran: in the table and in both full runs). The same set also passed on all three builds at the GREEN commit before the rebases (3796e3a82).obs_tests_coredied withSTATUS_INTEGER_OVERFLOW(0xc0000095) whileplace_special_valuesandprop_placewere running. On MSVC x64util_mul_div64()is_umul128()and_udiv128(), whosedivfaults when the quotient does not fit in 64 bits (a divide by zero would be 0xc0000094; the divisor here is 1e9). The parity test passed sample rates up tousize::MAX, so the oracle's C faulted, for example atts = 5 s,min_ts = 0, rateusize::MAX(reproduced on Linux with the samedivq, which raises SIGFPE). On MSVC x64 the test now keeps those inputs from the C and checks only the shim's saturation (LATEatusize::MAX), as theobs-sceneandobs-coreports do. They need a sample rate past 1e9, which libobs never sets, so the difference is unreachable. In the special-value grid that is 1,948 of 9,464 inputs, all with a rate past 1e9; off MSVC x64 nothing changes. Forcing the guard on, on Linux, makesplace_special_valuesfail its saturation check (Linux's shim wraps, as Linux's C does), so the guard covers those inputs. No float-to-int conversion or signed division exists in the C or the shim; the full-f32test is ignored by default and did not run on CI.d35e2189b(source::transition_render_parity, 13 tests and one ignored). Tier 1 and the parity module pass 38 of 38, 10 runs in a row with fresh seeds (on6d9049cdf, the same commit before the rebases, apart from rustfmt of the oracle bindings), and again on the head.due_and_audio_stop_every_f32(everyf32bit pattern, three calls each) ran once with--release --ignored: all equal. No proptest regression file came up; the ones thetodo!()stub and the mutants left were deleted.6d9049cdf): 49 mutants. Failures per mutant, Tier 1 (25 tests) and Tier 3 (13):t > 1/ NaN counts (!(t < 1)) / video ignoredtarget & 1t > 1/ no-timestamp stop without its video check (before 7af9c2d) / no-timestamp never stops>=(the scene's) / saturating difference /min_ts - ts/ rounded, not flooredmul_div64: exactu128on every host / throughf64mul_add) / inf64/ scales swapped / sign flippedhas_min_tsignored / audio END and STOP swappedposnot written / LATE and MIX swapped / offset x and y swapped / direct index arguments swappedf64against 1 − 1e-9 (nof32lies between)else if !audio { A } else { B }u64::try_from(usize)falls back to 0 (it never fails)45 are killed by Tier 3 (35 of them by Tier 1 too); the 4 that survive both are equivalent. Tier 1 does not reach the shims;
test_transition_render_steps_rustand Tier 3 do. The exact-u128mul_div64differs only for sample rates past 1e9, which only Tier 3 tries.Other runs, on the head
83b902204(based on6c98110db) unless noted:uv run ci/local_gate.py --test-diff origin/master: ok (workspace scope, 3528 tests run, 3528 passed, 5 skipped: tests ignored by default, this PR's full-f32sweep among them).--lane lint: ok.--lane cross: ok (it builds libobs for Windows and macOS through the groups, the new PCH andlibobs.pch.hwith its one new include).soldr cargo test -p obs-c-oracle --locked --bench port_comparison: passes (every fixture, this unit's checksums included).ci/test_build_groups.py,ci/test_ported_sources.py,ci/test_oracle_standins.py,ci/test_sorted_shared_lists.py,ci/test_test_graph_sorted.py,ci/test_cmocka_rust_static_guard.py,ci/test_cmocka_windows_diagnostics.py,ci/test_cmocka_includes.pyandci/test_naming.py: OK. gersemi: clean.bdfc230e8's libraries: 1766 on the C backend, the hybrid andlibobs-c-reference, identical sets; the nine functions local in all three.source-sets.json,test-graph.json, the three export lists,ci/test_ported_sources.py, the crate's module lists, the oracle's module list andport_comparison.rswere diffed by hand against origin/master: each is master's list plus this PR's lines. No conflicts; the docs were re-applied by hand on obs-source: Port the deinterlace draw decisions #2153's newlib.rstext. The move harness was rerun against origin/master'sobs-source-transition.c.h(unchanged by those merges): 0 mismatches.35bfe371e(obs-source: Port the source volume snap and apply decisions #2175, the volume port) as head370b1372b: every shared list now holds both the volume and the transition render entries, sorted, and the crate's prose lists name size routing, the transition clock, the transition render and volume; the list checks,source::(451 passed, 5 ignored),port_comparisonand--lane lintpass on it.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)