Skip to content

media-io: scale directly into output planes when their layout allows - #44

Draft
chriscoveries wants to merge 63 commits into
masterfrom
rust/video-scaler-direct
Draft

chriscoveries wants to merge 63 commits into
masterfrom
rust/video-scaler-direct

Conversation

@chriscoveries

@chriscoveries chriscoveries commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Refs #19.

Summary

video_scaler_scale() runs sws_scale() into an av_image_alloc() scratch image and then memcpy's every plane into the caller's buffers. When the caller's planes already have the layout sws writes — every used plane present, base_get_alignment()-aligned, at FFmpeg's packed linesize (av_image_fill_linesizes) — the scaler now passes them to sws_scale() directly — skipping one full-frame memcpy per call. Anything else takes the unchanged scratch + per-row-copy fallback.

This change is deliberately correctness-only: no performance numbers are claimed (shared-box timings can't support them).

Guard rationale:

  • Stride equality, not >=: so sws can never write past a plane's extent; padded-stride callers fall back.
  • Odd heights excluded for vertically-subsampled dst formats: sws writes ceil(h >> log2_chroma_h) chroma rows while the copy contract (and a foreign caller's floor-sized planes) covers floor(h/2). video_frame_init allocates ceil, but the guard can't verify a caller's extent, so it stays conservative.
  • Alignment: output plane pointers must be base_get_alignment() (32)-aligned, matching what bmalloc/av_image_alloc provide.

Threading / sws_receive_slice migration is deliberately out of scope per the issue.

Tests

New test/cmocka/test_video_scaler.c (registered via tests.d/test_video_scaler.cmake, not by editing shared CMakeLists). For each dst format x geometry it compares the packed layout, a padded-stride layout, and a 16-byte-misaligned layout for byte-identical visible output, plus per-plane canary slack and uncopied tail rows (odd-height 420 chroma) untouched. The same tests pass on the unmodified code — they characterize the contract both paths must satisfy; the change is behavior-preserving by design, so there is no RED commit (the only observable difference is the skipped copy; direct-path engagement was verified under a debugger).

Coverage: I420, NV12, I444, YUVA, P010, BGRA, Y800 at 128x64 / 322x242 / 160x120; odd geometry I420, NV12, P010, I40A, BGRA at 161x121 / 160x121 / 161x122; misaligned and padded-stride layouts; 4 repeated calls per case.

Validation

  • ./lint clean.
  • macOS Tier 2: OFF 57/57, ON 57/57; test_video_scaler|test_video_frame x100 in both modes, zero flakes; libobs export list identical OFF vs ON (1863 symbols).
  • CI: Self-hosted CI green on the code; the commit above re-runs on the message-amended SHA.

Not done

  • sws_scale remains single-threaded via the legacy call; the FFmpeg 8 slice-threaded path (sws_scale_frame + sws_receive_slice) is a separate change.
  • Odd-height subsampled formats could take the direct path in principle (the real caller allocates ceil rows), but that changes observable output (the last chroma row is currently dropped); left out intentionally.

zackees and others added 30 commits October 10, 2026 17:48
Local-Gate: v1 tree=12181cd5c0c6a7e8760df475d2ed59d402965a3e secs=422 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791680648,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7c749e9aca4da4806c2200f2129ff08f55d3849dec1cb4462a12e862f35560a3","lane":"lint","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":157,"stamp":"6dba9556acdb54e34a4a0feefc8717b5","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7c749e9aca4da4806c2200f2129ff08f55d3849dec1cb4462a12e862f35560a3","lane":"lint","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":157,"stamp":"a84b07d1dab7c308420ad277cdcd2784","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9f87de8caad7a109e98a513cebbc6a4e2c2912591653222741fb64245d3a8d2a","lane":"rust-test","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":96,"stamp":"fa4c91516e133bfb159952d0748cd87b","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Ci-Attestation: {"at":1791680648,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"5830cfad62c7b86d246e7ce107b2da26837de63e50f2dec08f244fa8acb865c9","lane":"tier2-linux","parents":["ab5fbfda14e6b50c9f8907d967bed01ad0671956"],"secs":168,"stamp":"d092b5074bcc09793bd2d91a82f49571","tree":"12181cd5c0c6a7e8760df475d2ed59d402965a3e","v":1,"via":"run"}
Pins mul_to_db and db_to_mul from media-io/audio-math.h before the
Rust port. log10f and powf come from the platform libm, and glibc,
the UCRT and libSystem can differ in the last bit, so only results
every libm gets exactly are compared exactly: 0 and -0 -> -inf,
1 -> 0 and +inf -> +inf for mul_to_db; 0 -> 1, non-finite input -> 0
(+inf included), and finite input past float range -> inf or 0 for
db_to_mul. A negative multiplier or NaN gives NaN. Everything else,
including the float extremes, is compared with a relative tolerance
of about 8 ULPs. Characterized, not endorsed.

The header calls log10f/powf, so the test links libm outside MSVC,
like the graphics math tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1 and Tier 3 tests for mul_to_db and db_to_mul against todo!()
cores in obs_media_io::audio_math. audio-math.h is header-inline and
defines no struct, so there is no shim, no layout test and no symbol
swap; Tier 2 is the unchanged characterization test passing OFF/ON.

The oracle wraps the header in non-inline oracle_mul_to_db and
oracle_db_to_mul (oracle/audio_math.c, bindings in src/audio_math.rs).

Tier 1 ports test_audio_math.c case for case, with its exact cases and
relative tolerance, and adds the sign of the exact zero results, NaNs
of either sign and any payload giving 0 from db_to_mul, and the largest
in-range dB values.

The C is scalar, so per the Phase 5 rule parity is exact bit equality
(any NaN equals any NaN), with no ULP tolerance: both sides call the
same platform log10f/powf. It covers special values (zeros,
infinities, NaNs, subnormals, the float extremes, the cmocka values,
each with both signs), every 4096th bit pattern, and proptest over
arbitrary bits and the audio range (multipliers 0..4, -200..40 dB).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaderboard: industrial style, merged-PR ranking, completeness checks
mul_to_db and db_to_mul get Rust equivalents in
obs_media_io::audio_math, for Rust ports of the audio code that
converts between faders and gain. The header is static inline, so
nothing is swapped or exported. No intentional differences.

The cores are the header's expressions: -inf for a zero multiplier,
else 20 * log10(mul); 10^(db / 20) via powf for finite dB, else 0.
f32::log10 and f32::powf lower to the platform log10f/powf, the same
calls the C makes, so parity is bit-exact on each platform, also in
release builds (no pow(10, x) -> exp10 rewrite on either side).

Mutation check: computing powf as exp(x * ln 10) or log10 as
ln(x) / ln 10 fails every parity test; keeping +inf dB (checking
!is_nan instead of is_finite) fails the special-value and bit-pattern
sweeps. Making the zero check sign-sensitive passes, as expected:
log10f(-0) is -inf as well, so that mutant is equivalent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=3900f919177dac1fb933c78a8e8e1d7b400e92ae secs=164 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791680975,"gate":"rust/all/fmt","host":"linux-x86_64","key":"5987b139be6f71709ce8b1e5468e0beaadfcd29d1efcd0fa45a0c90dfb1b3310","lane":"lint","parents":["6d23f0ccfa214ad6144f0b4da6b7187c329dbf33"],"secs":54,"stamp":"856dffc539a0d984d0c682c8eb4289f8","tree":"3900f919177dac1fb933c78a8e8e1d7b400e92ae","v":1,"via":"run"}
Ci-Attestation: {"at":1791680975,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"5987b139be6f71709ce8b1e5468e0beaadfcd29d1efcd0fa45a0c90dfb1b3310","lane":"lint","parents":["6d23f0ccfa214ad6144f0b4da6b7187c329dbf33"],"secs":54,"stamp":"102162225499cd7dd23d4d6b3bcd3b61","tree":"3900f919177dac1fb933c78a8e8e1d7b400e92ae","v":1,"via":"run"}
Ci-Attestation: {"at":1791680975,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"72aa51d98402d5ac64565e50f9ada5e540cc12f73963586798e351cd46ba9145","lane":"rust-test","parents":["6d23f0ccfa214ad6144f0b4da6b7187c329dbf33"],"secs":46,"stamp":"e90f0df1f369bed465076d970be04f55","tree":"3900f919177dac1fb933c78a8e8e1d7b400e92ae","v":1,"via":"run"}
Ci-Attestation: {"at":1791680975,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"0e9dd62c5b41dfeb23ffdb9f275282bb2ffe294e7c4cf05331c0db242a684c87","lane":"tier2-linux","parents":["6d23f0ccfa214ad6144f0b4da6b7187c329dbf33"],"secs":63,"stamp":"c9c4908a0161afcf39f97745686f17eb","tree":"3900f919177dac1fb933c78a8e8e1d7b400e92ae","v":1,"via":"run"}
rust: port graphics/matrix3.c to obs-graphics
rust: Port media-io/audio-math.h to obs-media-io
Tier 1, Tier 2 layout and Tier 3 parity tests for video_frame_init,
video_frame_copy and the video-frame.h inlines, against a todo!() core.
test/cmocka/test_video_frame.c (obs-rust#117) is the existing C test, so there
is no characterization commit. Tier 1 ports it 1:1, including its
expected_linesizes / expected_heights model, and adds edge cases: the
V210 ALIGN-by-48 quirk (1 -> 16, 47 and 48 -> 80, 1280 stays 1280), u32
wraps (width * 4, HALF(UINT32_MAX) = 0, the u32 linesize * rows copy
length), and a plane after a skipped one landing on plane 0.

Only video_frame_init and video_frame_copy get C symbols, listed in
rust-exports.d/obs-media-io-video_frame.txt.
video_frame_get_linesizes and video_frame_get_plane_heights have no
header declaration and no caller outside video-frame.c, so they are
safe-core functions only. ffi::video_frame mirrors struct video_frame.
It also has plain-Rust video_frame_free / _create / _destroy for later
ports that handle a struct video_frame. The C inlines stay compiled into
their callers (header-inline rule). A format outside enum video_format
takes the C switches' default, VIDEO_FORMAT_NONE.

video_frame_init still reaches bmalloc(0), which crashes, for
VIDEO_FORMAT_NONE, an unknown format and a zero width or height, as
test_video_frame.c's frame_init_none expects. The safe VideoFrame::new
panics there.

The oracle (oracle/video_frame.c) renames the four non-static functions
and wraps the inlines in oracle_* functions. Its bmalloc and bfree are
libobs's, which under cargo test is the Rust bmem port. Parity sweeps
every enumerator and out-of-range values over widths and heights at each
rounding step and u32 wrap for the linesizes and heights. It compares
frame shapes (linesizes, and plane offsets from data[0]) from init and
create, and checks free and destroy. Copies run into separate
canary-filled destinations, with equal, wider, narrower and zero
linesizes, and every byte is compared. Proptest adds arbitrary formats
and sizes. The exclusions are the C crashes and UB: bmalloc(0), layouts
too large to allocate, and copies past a plane or between overlapping
planes.

RED: 19 of the 20 Tier 1 tests fail on todo!(). The parity binary aborts
at its first todo!() inside an extern "C" shim. The layout test passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
video_frame_init and video_frame_copy, plus the safe core
(obs_media_io::video_frame) that later media-io ports use: the linesize
and plane-height tables, FrameLayout (where init puts each plane in its
one bmalloc block), copy_extent / copy_plane, and an owned VideoFrame.
video-frame.c joins the ENABLE_RUST_LIBOBS guard. No intentional
differences.

The C switches become exhaustive matches, and the shims map a format
outside the enum to VIDEO_FORMAT_NONE, which is what the C's default
does. The u32 linesize math wraps as in C (width * 4, HALF(UINT32_MAX),
and V210's ALIGN by 48 with a power-of-two mask), and so does the u32
linesize * rows length of an equal-linesize copy. Plane sizes and
offsets are usize, as the C's size_t. FrameLayout records the C's
offsets[i - 1] rule, so a plane after a skipped one starts at offset 0.
video_frame_init calls the real bmalloc with the layout's size, so a
zero-size frame still crashes in bmalloc(0), as test_video_frame.c's
frame_init_none requires.

Mutation check: dropping HALF's rounding, moving each plane one byte
past the previous one, copying one byte more per row into a wider dst,
and rounding V210 to a true multiple of 48 each fail Tier 1 and parity.
Making the equal-linesize copy length usize fails Tier 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=9f2175734fa63710b346cbb1fb7c9f8dea29343d secs=248 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791683468,"gate":"rust/all/fmt","host":"linux-x86_64","key":"e8a0f7af274ad886cbd562c503aab0d219ce962aac5a29651d46b98d19f32ee1","lane":"lint","parents":["07c2c68433edecd5f8b64d9db5c9ccf866304df0"],"secs":115,"stamp":"d52ce43fa01631865319bb175950a38a","tree":"9f2175734fa63710b346cbb1fb7c9f8dea29343d","v":1,"via":"run"}
Ci-Attestation: {"at":1791683468,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"e8a0f7af274ad886cbd562c503aab0d219ce962aac5a29651d46b98d19f32ee1","lane":"lint","parents":["07c2c68433edecd5f8b64d9db5c9ccf866304df0"],"secs":115,"stamp":"822a86d6e9d209a47d1f48905a2b76ac","tree":"9f2175734fa63710b346cbb1fb7c9f8dea29343d","v":1,"via":"run"}
Ci-Attestation: {"at":1791683468,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"fdfc27a308eb2752ec54bce9502273a44ef009ea151ec5a71f9209412b1f99f3","lane":"rust-test","parents":["07c2c68433edecd5f8b64d9db5c9ccf866304df0"],"secs":55,"stamp":"991aaa2f7b5ff40bfc59fdd7c8c03d27","tree":"9f2175734fa63710b346cbb1fb7c9f8dea29343d","v":1,"via":"run"}
Ci-Attestation: {"at":1791683468,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4f0a44c71280f272d6a5d52a74c6417ffb7febaf08408be7379c3942e5d4fb06","lane":"tier2-linux","parents":["07c2c68433edecd5f8b64d9db5c9ccf866304df0"],"secs":77,"stamp":"9ab70169229d9c18172ece7f0a604322","tree":"9f2175734fa63710b346cbb1fb7c9f8dea29343d","v":1,"via":"run"}
Twitch's Go Live config sets B-frames, lookahead, preset, and tuning.
Apply local overrides after that config is loaded. An explicit NVENC
lookahead off stays off.
The preset, tune, B-frame, and lookahead table, the Go Live opts filter,
and the NVENC lookahead and UHQ decisions are cmocka tests linked to plain
C files. Those files return empty results, so
test_nvenc_preset_and_tune_table stops on a null preset key and
test_explicit_off_beats_preset_lookahead stops because
nvenc_lookahead_force_off(true, false) is false.

Refs #19
mtv_translate_encoder_override maps one UI choice onto NVENC, legacy
NVENC, Quick Sync, AMF, x264, SVT-AV1, and AOM. Encoders outside that
table keep the service value. obs-nvenc uses nvenc_lookahead_enabled,
nvenc_lookahead_force_off, and nvenc_bframes_for_uhq when it programs
the session.

The cmocka tests added in the previous commit pass: seven multitrack
cases and two NVENC cases, including a tune with no equivalent and UHQ
forcing at least 4 B-frames.

Refs #19

Local-Gate: v1 tree=d8043dcdfb165a854609413e95d47c1b9787925c secs=177 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791684336,"gate":"rust/all/fmt","host":"linux-x86_64","key":"72bd0d455d8c5d446e418f551d500b30782f29eb9dd6abb408583a0043fa3859","lane":"lint","parents":["25bfb8ae60ba4d12a6277ce7b4554432e82c9c48"],"secs":93,"stamp":"1e4cd47a13478d94ca8daf16c111cd83","tree":"d8043dcdfb165a854609413e95d47c1b9787925c","v":1,"via":"run"}
Ci-Attestation: {"at":1791684336,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"72bd0d455d8c5d446e418f551d500b30782f29eb9dd6abb408583a0043fa3859","lane":"lint","parents":["25bfb8ae60ba4d12a6277ce7b4554432e82c9c48"],"secs":93,"stamp":"f69ce2e3c4863fc51e9db00e36c6bf77","tree":"d8043dcdfb165a854609413e95d47c1b9787925c","v":1,"via":"run"}
Ci-Attestation: {"at":1791684336,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"33485dc3078001d9470d1d04eb699382a8abf25acf82763fdcd69a66c05f56a7","lane":"rust-test","parents":["25bfb8ae60ba4d12a6277ce7b4554432e82c9c48"],"secs":36,"stamp":"61b1343643a3bb1cc519c698c43e1cca","tree":"d8043dcdfb165a854609413e95d47c1b9787925c","v":1,"via":"run"}
Ci-Attestation: {"at":1791684336,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f392b4bde3d95281e58453f6b1a042cf05525eec56e03480a70cb24e05ed9767","lane":"tier2-linux","parents":["25bfb8ae60ba4d12a6277ce7b4554432e82c9c48"],"secs":48,"stamp":"05957d5d9606842543c4727f91a5e672","tree":"d8043dcdfb165a854609413e95d47c1b9787925c","v":1,"via":"run"}
rust: Port media-io/video-frame.c to obs-media-io
…rrides

frontend: Add Enhanced Broadcasting encoder overrides
Settings, Stream can ask the service which encodes the current settings
would get, without starting a broadcast. The table is read-only and
shows the service values. Custom RTMP previews the pasted config
override. A preview download skips the continue-anyway status prompts.

Split from the encoder-override change. Refs #19
mtv_ladder_fill is the Qt-free formatting of a Go Live config into
preview rows. The stub leaves that output empty, so
test_rungs_keep_order_resolution_and_codec stops because the row count
is 0 instead of 2. The other cases cover fps, bitrate, codec, missing
or invalid fields, and an empty config.

Refs #19
mtv_ladder_fill keeps rung order and formats resolution, fps, bitrate,
and the encoder id. Missing settings become "-". An empty config has no
rows and no bitrate total. Settings calls it for a downloaded Go Live
config and for a pasted Custom RTMP override.

The cmocka tests added in the previous commit pass: four cases.

Refs #19

Local-Gate: v1 tree=e1687730a67aed5761bad316ff9c57d07d0702c4 secs=194 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791685605,"gate":"rust/all/fmt","host":"linux-x86_64","key":"3f265d96d00bc45a3e6f6e41eeff26cd55672fbab83ee0d98cb27387cca87e57","lane":"lint","parents":["41b39ab546e1531202bdac8683153c44f862f282"],"secs":77,"stamp":"135f51b71929c48f545d5300831e8a08","tree":"e1687730a67aed5761bad316ff9c57d07d0702c4","v":1,"via":"run"}
Ci-Attestation: {"at":1791685605,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"3f265d96d00bc45a3e6f6e41eeff26cd55672fbab83ee0d98cb27387cca87e57","lane":"lint","parents":["41b39ab546e1531202bdac8683153c44f862f282"],"secs":77,"stamp":"07376efff4dffbd03963df2384fa7219","tree":"e1687730a67aed5761bad316ff9c57d07d0702c4","v":1,"via":"run"}
Ci-Attestation: {"at":1791685605,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"4f41bd2dddf7214d26dfba0fc449b9eb47edf90f66c8f6b84541f3cbcb93872b","lane":"rust-test","parents":["41b39ab546e1531202bdac8683153c44f862f282"],"secs":36,"stamp":"8dfff2d8be8f7efcda3492650b768c04","tree":"e1687730a67aed5761bad316ff9c57d07d0702c4","v":1,"via":"run"}
Ci-Attestation: {"at":1791685605,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"6f61f462a9d23b83e86933abdd610033cf2cc6d691ec0a5f48e6107c8ba191f4","lane":"tier2-linux","parents":["41b39ab546e1531202bdac8683153c44f862f282"],"secs":81,"stamp":"7cd001c150f8c620008ec6573d30a122","tree":"e1687730a67aed5761bad316ff9c57d07d0702c4","v":1,"via":"run"}
Pins the current behaviour of the six functions media-io/format-conversion.c
exports. Nothing in the tree calls them, so this is their only C coverage
and the Tier 2 check for the port (obs-rust#183).

Every buffer starts filled with a canary byte and each test compares the
whole buffer, so writes outside the expected area fail too. Inputs follow
the functions' contracts: 16-byte-aligned UYVX rows with in_linesize a
multiple of 16 and widths a multiple of 4, and uint16_t/uint32_t-aligned
linesizes for decompress_*.

Characterized, not endorsed:
- compress_uyvx_to_i420 addresses the V plane with out_linesize[1];
  convert_uyvx_to_i444 addresses all three planes with out_linesize[0].
- decompress_420 and decompress_nv12 round start_y and end_y down to row
  pairs, so start_y 1, end_y 3 writes rows 0 and 1.
- decompress_420 takes its width from in_linesize[0] alone.
- decompress_422 reads min(in_linesize, out_linesize) / 2 dwords per row,
  twice the row, and writes twice as many dwords, so each row spills into
  the next.

Refs obs-rust#183

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tier 1 and Tier 3 parity tests for the six functions
media-io/format-conversion.c exports, against a todo!() core.

The safe core takes its planes as Source/Sink traits addressed by byte
offset. Byte slices implement both and panic where the C would read or
write out of bounds; the shims implement them over the caller's raw
pointers, so they convert nothing and the core sees the C's offsets.
Each shim reads only the output/input and linesize entries the C reads.

The oracle builds format-conversion.c twice. oracle_* uses native SSE2
on x86. oracle_scalar_* defines OBS_ORACLE_SCALAR_SSE, so even on x86
it uses the plain-C __m128i intrinsics this commit adds to the oracle's
sse-shim (_mm_load_si128, _mm_set1_epi32/epi16, _mm_and_si128,
_mm_srli_si128, _mm_packs_epi32, _mm_packus_epi16, _mm_add_epi64,
_mm_shuffle_epi32, _mm_shufflelo_epi16, _mm_srai_epi16), which non-x86
builds use for both. Parity compares all four implementations byte for
byte, so the x86 jobs check the stand-ins before the arm64 job relies on
them.

Parity buffers are 16-byte aligned, sized to exactly the bytes a call
touches plus canary slack, and compared whole. The test file lists the
excluded inputs: misaligned loads and stores, loops that wrap past
u32::MAX, and overlapping planes.

RED: soldr cargo test -p obs-media-io --test format_conversion fails 22
of 22, --test format_conversion_parity fails 8 of 8 (not yet
implemented).

Refs obs-rust#183

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in lint

1.99.0 is beyond what soldr 0.9.31/0.9.32 support natively, and rustup
could not provision it for corrosion in the Tier 2 Docker lane. The image
now installs the toolchain pinned in rust-toolchain.toml.

Local-Gate: v1 tree=c08ca0c99fa20a754f3352d28600eeef519e6ff8 secs=236 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791686317,"gate":"rust/all/fmt","host":"linux-x86_64","key":"86022adca560d44d21df745744ce9189bcb9fae900bf324af052c860ce520450","lane":"lint","parents":["246ba33d1bca7fd1ca659da4a2f0edce5be41d0d"],"secs":34,"stamp":"e83ecdc16fa494a88a6e0d2e987c866c","tree":"c08ca0c99fa20a754f3352d28600eeef519e6ff8","v":1,"via":"run"}
Ci-Attestation: {"at":1791686317,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"86022adca560d44d21df745744ce9189bcb9fae900bf324af052c860ce520450","lane":"lint","parents":["246ba33d1bca7fd1ca659da4a2f0edce5be41d0d"],"secs":34,"stamp":"3b3d9c4b7a139c26272aa836ab97d30a","tree":"c08ca0c99fa20a754f3352d28600eeef519e6ff8","v":1,"via":"run"}
Ci-Attestation: {"at":1791686317,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"629b81291eead5aadaf73671aed45197646910f04ebd01cdfa11fafa8fceca86","lane":"rust-test","parents":["246ba33d1bca7fd1ca659da4a2f0edce5be41d0d"],"secs":37,"stamp":"88f6d5f21f80cb2ead870f9bee9ea5c5","tree":"c08ca0c99fa20a754f3352d28600eeef519e6ff8","v":1,"via":"run"}
Ci-Attestation: {"at":1791686317,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a6ec7051b16edc241deb69ff6cb5acf0024a77d8dd394c9708758da82f5925e6","lane":"tier2-linux","parents":["246ba33d1bca7fd1ca659da4a2f0edce5be41d0d"],"secs":164,"stamp":"78c8f933da3ac5e116903a542bf6f6d7","tree":"c08ca0c99fa20a754f3352d28600eeef519e6ff8","v":1,"via":"run"}
compress_uyvx_to_i420, compress_uyvx_to_nv12, convert_uyvx_to_i444,
decompress_420, decompress_nv12 and decompress_422 move to Rust. With
ENABLE_RUST_LIBOBS=ON libobs builds without media-io/format-conversion.c
and exports the Rust shims under the same names. No intentional
differences.

The C's SSE2 is integer only, and every lane reduces to byte extraction
or a (a + b + c + d) >> 2 chroma average, so the core is scalar with no
core::arch and parity is byte-exact. Offsets use the C's u32 arithmetic,
wrapping included, and each loop keeps the C's order of reads and writes,
which decides the result where output rows overlap. uint16_t/uint32_t
values are stored native-endian as in the C, including the I420 chroma
the C packs into one uint32_t and splits into two uint16_t stores.

Mutation checks: halving the chroma divisor, swapping decompress_420's
row write order, changing decompress_422's luma duplication and the I420
chroma packing each fail parity. Breaking _mm_packus_epi16,
_mm_shuffle_epi32, _mm_srai_epi16 or _mm_shufflelo_epi16 in the oracle's
plain-C sse-shim fails parity as "CScalar differs from C" on x86.

Local gate: rust-test and tier2-linux pass (test_format_conversion passes
OFF and ON; exported symbols identical, 1752). obs-media-io tests also
pass for x86_64-pc-windows-msvc via cargo-xwin.

Fixes obs-rust#183

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=e2a36762c7a5157c323e2754690ab6ba7213dcfa secs=150 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791686476,"gate":"rust/all/fmt","host":"linux-x86_64","key":"05801aa46783e55e6e04153c3347c6417abd35835e74561121b5cb9604ea5039","lane":"lint","parents":["07e455b799ee5447efaa23ccab9600dc6da880bf"],"secs":31,"stamp":"44a6d04f5eeaa235b4dd078dbaf7578c","tree":"e2a36762c7a5157c323e2754690ab6ba7213dcfa","v":1,"via":"run"}
Ci-Attestation: {"at":1791686476,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"05801aa46783e55e6e04153c3347c6417abd35835e74561121b5cb9604ea5039","lane":"lint","parents":["07e455b799ee5447efaa23ccab9600dc6da880bf"],"secs":31,"stamp":"771bc902bc2e221cfb589516aa23773f","tree":"e2a36762c7a5157c323e2754690ab6ba7213dcfa","v":1,"via":"run"}
Ci-Attestation: {"at":1791686476,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d3822cf976ffc59edf870d9b5a02c2b1d2bc85be9b739e0035b8b38881bde94f","lane":"rust-test","parents":["07e455b799ee5447efaa23ccab9600dc6da880bf"],"secs":38,"stamp":"17639da348f0ad7ca81887a113cfa0c4","tree":"e2a36762c7a5157c323e2754690ab6ba7213dcfa","v":1,"via":"run"}
Ci-Attestation: {"at":1791686476,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"33a162da37eb409489461f876489e604e62c9e2da8e8281e6d484002c7c5e56a","lane":"tier2-linux","parents":["07e455b799ee5447efaa23ccab9600dc6da880bf"],"secs":81,"stamp":"cbc3595ea12a68316fc9465a0037c43a","tree":"e2a36762c7a5157c323e2754690ab6ba7213dcfa","v":1,"via":"run"}
frontend: Preview the Enhanced Broadcasting encoding ladder
rust: Port media-io/format-conversion.c to obs-media-io
rust: Pin the toolchain to the soldr-supported 1.98.1 and enforce it in lint
./lint runs the ci/ tests, which writes __pycache__ next to them. Nothing
ignored it, so obs-rust#185 merged five ci/__pycache__/*.pyc files and obs-rust#178 two
tools/leaderboard/__pycache__/*.pyc files. test_repo_hygiene fails while
any .pyc is tracked or bytecode is not ignored.

Also adds test_tier2_run.test_image_installs_pinned_toolchain, which
guards obs-rust#185's fix: run.sh must build the image with RUST_TOOLCHAIN set
to the rust-toolchain.toml channel. It fails against run.sh before obs-rust#185.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Untracks the seven .pyc files and ignores __pycache__/ and *.py[cod].
test_repo_hygiene passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After obs-rust#185 the image installs only the pinned 1.98.1. A /build volume
configured before that still has Corrosion's cached stable rustc and
cargo paths, so tier2-linux fails at configure:

  Could not find toolchain 'stable-x86_64-unknown-linux-gnu'

StaleBuildTest describes reset_stale_build in
rust/tools/linux-validate/stale-build.sh, which does not exist yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
rdoupe and others added 25 commits October 10, 2026 21:21
A Media Source playing an RTSP camera never reconnects once the camera
goes silent (loses power, drops off the network) without closing the
connection (upstream obsproject/obs-studio#12958, reported by
canadianlocomotivelogistics; also #11537 by dzek69). The media thread
blocks in av_read_frame() forever, so stop_cb never runs and
obs-ffmpeg-source never schedules its reconnect.

init_avformat() bounds network reads with the RTSP option "stimeout",
which FFmpeg removed in 5.0 (renamed "timeout"). avformat_open_input()
leaves the unknown key unused, so neither RTSP over TCP nor over UDP
has any read timeout.

Move that option into mp_media_set_network_timeouts() in
media-playback/network-timeout.c, unchanged, and test it:

- every option it sets for an rtsp:// input exists in the linked
  FFmpeg's RTSP demuxer (fails: 'stimeout'),
- it sets the RTSP socket I/O "timeout" (fails),
- a "timeout" from the source's FFmpeg Options is kept (passes),
- end to end: a camera on 127.0.0.1 that answers OPTIONS, DESCRIBE,
  SETUP and PLAY and then sends nothing must make the media stop
  within 20 s (fails after the 20 s deadline).

3 of the 4 tests fail. Setting "timeout" (e.g. 5 s, without
overwriting the user's value) turns them green in about 10 s.
Refs obs-rust#189.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
An RTSP camera that went silent without closing the connection left
the Media Source frozen for good: the media thread blocked in
av_read_frame(), so it never stopped and the source never reconnected
(upstream obsproject/obs-studio#12958, #11537).

The read timeout was set with "stimeout", which FFmpeg 5.0 renamed to
"timeout" in its RTSP demuxer; every FFmpeg OBS supports ignores the
old name. Set "timeout" to 5 s for rtsp:// and rtsps:// inputs instead.
A silent camera now makes the read fail after about 10 s (FFmpeg
retries once), the media stops, and obs-ffmpeg-source reconnects after
its reconnect delay. A "timeout" from the source's FFmpeg Options is
kept. Other protocols give "timeout" other meanings, so they are left
alone, as they effectively were before.

All 4 tests in test_media_network_timeout now pass; the end-to-end
silent camera case stops in about 10 s.

Fixes obs-rust#189.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=a3d760ce52f8fe6958748ab671f6b1e9c151f1a5 secs=116 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791692616,"gate":"rust/all/fmt","host":"linux-x86_64","key":"85215dd48055485ab498497a9a0463d56d127805d386abc4674fd5cc4a8b85d0","lane":"lint","parents":["14cee7d88dddd81608918690e003c6c3060397bd"],"secs":44,"stamp":"0a4a8086c71080ebcac96292a1d70a8b","tree":"a3d760ce52f8fe6958748ab671f6b1e9c151f1a5","v":1,"via":"run"}
Ci-Attestation: {"at":1791692616,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"85215dd48055485ab498497a9a0463d56d127805d386abc4674fd5cc4a8b85d0","lane":"lint","parents":["14cee7d88dddd81608918690e003c6c3060397bd"],"secs":44,"stamp":"c52f9463672755a97487057e38ed89ea","tree":"a3d760ce52f8fe6958748ab671f6b1e9c151f1a5","v":1,"via":"run"}
Ci-Attestation: {"at":1791692616,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"abe3c09d530d0d8ec9d83c41fb2085639839a3e015ce23eacb2f0bbfc713ad71","lane":"rust-test","parents":["14cee7d88dddd81608918690e003c6c3060397bd"],"secs":25,"stamp":"3219ce5232243e84e33ace997442953a","tree":"a3d760ce52f8fe6958748ab671f6b1e9c151f1a5","v":1,"via":"run"}
Ci-Attestation: {"at":1791692616,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"7355211988cea6819a7c55b21478b0c45db50c513b33def98f2a8cc688928ab9","lane":"tier2-linux","parents":["14cee7d88dddd81608918690e003c6c3060397bd"],"secs":47,"stamp":"e449e485df7af3943fb30428f8b01811","tree":"a3d760ce52f8fe6958748ab671f6b1e9c151f1a5","v":1,"via":"run"}
cmocka test pinning the current C behavior of libobs/media-io/
audio-io.c ahead of the obs-media-io port (Phase 5). audio-io.c is the
smallest media-io unit not already claimed by an open port order.

- open(): AUDIO_OUTPUT_INVALIDPARAM for unset format/name/rate/speakers
  (no thread spawned, *audio untouched); getters mirror audio_output_info
  (interleaved float stereo: 1 plane / 2 ch / 8-byte block; planar
  16-bit 5.1: 6 planes / 6 ch / 2-byte block).
- connect(): NULL/zero conversion fields fall back to the output info;
  duplicate (callback, param) on one mix is refused while the same
  callback with a different param registers a second input; out-of-range
  mix index and NULL audio return false.
- active(): tracks registered mix inputs through connect/disconnect.
- Thread model: open() spawns the input thread immediately and the
  callback fires on the audio clock.
- Characterized crashes (not endorsed): the unguarded NULL getters and,
  with no obs core running, audio_output_open itself die by signal
  (the spawned thread dereferences obs->name_store on entry) - each
  pinned in a forked child with cmocka's signal handlers reset.

The behavioral pins need a running obs core (obs_startup), which needs
a display on Linux; they skip in the headless gate and run under
xvfb-run.

Refs #45

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=f3d2e26bde1bcfec8370af8c615fa43998fc9ae9 secs=350 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791672334,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"68289f5197c34c3b485811e11aef0a06","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f06beafdad8c0e6401d54ec504cdbb4c6ff8cc9c99298d7770b1042156188009","lane":"lint","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":199,"stamp":"ea4878636b524b67d0b5a5c00246cd9b","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9b440df8274dd21e1d86abf9f72adc95f209321fa7b3613730625747620dda42","lane":"rust-test","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":78,"stamp":"9a81bd835884cc8f59413b7b65a44cac","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Ci-Attestation: {"at":1791672334,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"b6e993eabe33d303d6a813f6a7b6c6c5edf09ddebf517c252f712b9d95b33f63","lane":"tier2-linux","parents":["b3cc16f7cbb177da70d2d0997a15d111f7dee3ec"],"secs":71,"stamp":"8e4d35b0e6cf8b077f8de1178e0f2bfa","tree":"f3d2e26bde1bcfec8370af8c615fa43998fc9ae9","v":1,"via":"run"}
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=18904b28bd85ff6ff08ce80f10dae94dda139a76 secs=38 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791675132,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"db7e536db53a4bb710d35628331746f3","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ba65b923f501ad750e65692f42aaa0a23a3021236d6ae0efd3f1c94918d7cee1","lane":"lint","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":5,"stamp":"62b64d1aa0d162a22ecf50075452742a","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8ab76ba0fdab0ca2f07ef85c35d69bdce29faac588a2f8d7b312b2cd664d174e","lane":"rust-test","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":21,"stamp":"eb5d4333df52d26eb3ebf743f506d30b","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
Ci-Attestation: {"at":1791675132,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ee43101ce8b5a6c42ef660cf7f6f55c3532aaadab25c2ee4811df6d285c824a2","lane":"tier2-linux","parents":["325a49d29d0d9051e6b473e980fad71b822c6f87"],"secs":12,"stamp":"2fa187fac20ed6705d15911748c303f8","tree":"18904b28bd85ff6ff08ce80f10dae94dda139a76","v":1,"via":"run"}
The input callback signals g_input_event from the audio thread, so
destroying it before audio_output_close() could race a late signal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XFvTpgDN6Zh3USjgworNmT
Local-Gate: v1 tree=c4b764f6d8aa71c39e58671c953d64aa1fb41caf secs=62 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791692794,"gate":"rust/all/fmt","host":"linux-x86_64","key":"b7026c063f951c53a9d4ed45ca3c8974bd7c92ddf4320444a488f40238a5f9a1","lane":"lint","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":14,"stamp":"bbf8ac2c04ea813a254211e50b9cb57d","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"}
Ci-Attestation: {"at":1791692794,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"b7026c063f951c53a9d4ed45ca3c8974bd7c92ddf4320444a488f40238a5f9a1","lane":"lint","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":14,"stamp":"8683db975511caac7301b6107c277f76","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"}
Ci-Attestation: {"at":1791692794,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"515c1a621978d2e8cd35efcb9530a01d3b26eca9e5615b6dc02b99cd8b09a7e3","lane":"rust-test","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":31,"stamp":"45108c7b930820a3ecd87f5b62ba17ce","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"}
Ci-Attestation: {"at":1791692794,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"8869ee39dcde8b028bca3040629b682d2541aae6981a1527e58b33cf13566102","lane":"tier2-linux","parents":["fad9f73502e5917c3bf91b2ea96ad8acb093ef1d"],"secs":17,"stamp":"06c66dacab9b3abfac084c0a51d7b313","tree":"c4b764f6d8aa71c39e58671c953d64aa1fb41caf","v":1,"via":"run"}
The Windows Tier 2 build failed to link test_media_network_timeout:
fail_msg() expands to cm_print_error(), which the Windows cmocka library
does not export (LNK2019). Print the message with fprintf() and call
fail(), as test_base, test_video_fourcc and test_video_matrices do.

Also drop the email address from the new files' copyright lines.

Refs obs-rust#189.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Microphones captured with the PulseAudio input on pipewire-pulse drop
out for ~75 ms at a time, logged as "Audio timestamp ... exceeded
TS_SMOOTHING_THRESHOLD, diff=7xxxxxxx ns" (obsproject/obs-studio#12835),
and two PulseAudio sources on one device sound choppy
(obsproject/obs-studio#10808).

pulse-input stamps every packet with its arrival time minus its own
length, but record streams arrive in bursts: pipewire-pulse hands over
all 25 ms fragments of a graph cycle at once when the quantum is longer,
a capture thread held up by load reads the fragments that queued up
back to back, and the second stream on OBS's one connection gets its
packets up to 150 ms at a time. A burst then shares one timestamp, and
once it spans libobs' 70 ms smoothing window a packet is placed ~75 ms
in the past (overwriting audio) and the next ~75 ms in the future
(silence).

Measured against a private, hardware-free PipeWire 1.6.8 with libobs'
smoothing replayed on the timestamps: 239 of 580 packets break at
quantum 8192 and 12 at 4096 (none at 1024 or 2048); at quantum 1024 a
100 ms capture-thread stall every 3 s breaks 8 times in 15 s; the
second of two streams on one context breaks about seven times a
second. Every packet is read alone, so the readable size cannot date
it.

Move the timestamp into linux-pulseaudio/pulse-timing.c, without
mainloop or stream calls, and test it with these burst patterns, a
recorded 3 s arrival trace of the second stream, real loss, device
clock drift and reset, judged by libobs' smoothing rule after
pulse-input's 500 ms startup skip. The function keeps today's formula,
so 4 of the 9 tests fail: burst_delivery_stays_contiguous,
server_cycle_bursts_are_seamless, capture_thread_stall_is_seamless and
recorded_second_stream_is_not_choppy. The others pin what a fix must
keep: no packet stamped after it was read, and real gaps and clock
drift still follow the system clock.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Stamping each packet with its arrival time gives all packets of a burst
one timestamp, and libobs then cuts ~75 ms holes and overlaps into the
audio (obsproject/obs-studio#12835, obsproject/obs-studio#10808).

The packets of a record stream follow on from each other in samples,
however the server batches them, so count each packet on from where the
previous one ended. Fall back to the clock only where counting cannot be
right:

- a packet would end after it was read: the device clock runs fast, or
  the timeline started on a packet that was already late;
- a packet is more than 1 s late against the timeline: audio was really
  lost.

A packet may also wait a while after its end on the timeline. Once a
second, move the timeline on by the least wait any packet of that second
had, so a slow device clock does not leave it ever further behind; that
step is far below libobs' 70 ms smoothing window. All state lives in
struct pulse_timing, one per stream.

This turns the 4 failing tests of test_pulse_timing green
(burst_delivery_stays_contiguous, server_cycle_bursts_are_seamless,
capture_thread_stall_is_seamless and
recorded_second_stream_is_not_choppy), and the 5 that pin real loss,
clock drift and reset keep passing.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=183262e0eb9b29ece23fd9105a4897ac2b02d2e7 secs=132 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791693212,"gate":"rust/all/fmt","host":"linux-x86_64","key":"cc5fee07f9f73a33dd0f25e00f3ab95bc51f29fec1b191516323743447b5d351","lane":"lint","parents":["1ac0561184bba031d2b1e50ea2cac17de2f8aad3"],"secs":52,"stamp":"e1630a0c74cb641ead843bffbcc4d14b","tree":"183262e0eb9b29ece23fd9105a4897ac2b02d2e7","v":1,"via":"run"}
Ci-Attestation: {"at":1791693212,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"cc5fee07f9f73a33dd0f25e00f3ab95bc51f29fec1b191516323743447b5d351","lane":"lint","parents":["1ac0561184bba031d2b1e50ea2cac17de2f8aad3"],"secs":52,"stamp":"b6b8fa9a730313c91641d0873934b6e5","tree":"183262e0eb9b29ece23fd9105a4897ac2b02d2e7","v":1,"via":"run"}
Ci-Attestation: {"at":1791693212,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"60c18784e70319e99bbbed48eb7d3628c8e634138d09038abf4f0dddf78fed94","lane":"rust-test","parents":["1ac0561184bba031d2b1e50ea2cac17de2f8aad3"],"secs":41,"stamp":"06f9d7668248fbf76a01cc3e64181f4f","tree":"183262e0eb9b29ece23fd9105a4897ac2b02d2e7","v":1,"via":"run"}
Ci-Attestation: {"at":1791693212,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"757c9f7973cc50b71e9c3d580f6c9cae01f6f4f13bfd6c9dd1d0e951f0e532ec","lane":"tier2-linux","parents":["1ac0561184bba031d2b1e50ea2cac17de2f8aad3"],"secs":39,"stamp":"7914df4ea4fac362989cb4fd3fb003b1","tree":"183262e0eb9b29ece23fd9105a4897ac2b02d2e7","v":1,"via":"run"}
media-playback: Time out silent RTSP sources
test: characterize audio-io.c before media-io port
…tamps

linux-pulseaudio: Count packet timestamps in samples
A FreeType 2 text source caches every glyph it has drawn in one
2048x2048 atlas and only empties it when the font or antialiasing
changes. A source reading a file that keeps changing therefore fills
the atlas, and from then on every new letter is skipped with only an
"Out of space trying to render glyphs" warning in the log (upstream
obsproject/obs-studio#11819, reported by iarspider). At the default
256 px size the standard ASCII set alone uses most of the atlas.

Move the atlas packing out of cache_glyphs() into glyph-atlas.c, free
of FreeType and graphics calls, and test it with fixed-size glyphs.
The function keeps today's behaviour (stop at the first glyph that does
not fit, never evict), so 2 of the 5 tests fail:

- new_text_after_full_atlas_is_drawn
- texts_keep_rotating_without_losing_letters

Refs obs-rust#195.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The FFmpeg VAAPI encoders fail to start when the profile names a device
that is not usable on this machine (obsproject/obs-studio#13773):

  Failed to create VAAPI device context: Invalid argument

vaapi_update() hands the saved vaapi_device straight to
av_hwdevice_ctx_create() and gives up when that fails. A profile keeps
the path the user picked, so it goes stale when the profile is used on
another machine, a second GPU is removed, or a driver change renumbers
the render nodes. The default device (the first render node that encodes
the codec) only applies while the setting is unset.

Reproduced with libobs on a Radeon 680M (radeonsi), encoding a color
source with ffmpeg_vaapi, ffmpeg_vaapi_tex and hevc_ffmpeg_vaapi: a
missing render node, a by-path node of another PCI slot and a primary
node the user cannot open all fail with EINVAL, /dev/null with "Generic
error in an external library", and an empty setting with EIO or EINVAL
(FFmpeg treats "" as an X11 display or device name, not as "pick one").
The output never starts. With the setting unset or set to the real
render node, 60 frames are encoded.

Move the choice into obs-ffmpeg/vaapi-device-select.c, without libva or
FFmpeg calls, and have vaapi_update() ask it with the codec's default
device as the candidate and the existing codec support probe. The
function keeps today's behaviour, so 5 of the 7 tests fail:
missing_render_node_falls_back, other_machines_by_path_device_falls_back,
unusable_existing_node_falls_back, unusable_candidates_are_skipped and
empty_device_uses_working_node. The others pin what a fix must keep: a
working configured device is used, and with nothing usable the
configured device fails as before.

Refs obs-rust#197.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
When a glyph of the current text does not fit in the source's atlas,
empty the atlas once and cache the current text again, so glyphs of
earlier texts make room for it instead of new letters being skipped
until the font changes (upstream obsproject/obs-studio#11819, reported
by iarspider). An atlas that was already empty when the text arrived is
not cleared again: a text with more glyphs than fit at its size still
stops with the "Out of space" warning rather than looping.

new_text_after_full_atlas_is_drawn and
texts_keep_rotating_without_losing_letters now pass; 5 of 5 tests pass.

Fixes obs-rust#195.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=5ec92a6bd2fce8c1720c3efcd0b61e134dc8d170 secs=106 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791695031,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7a2b3cf7ebcdb5a8fbf224947731272211ca277dcd3072c193dcecf48875a9b0","lane":"lint","parents":["d94bdbd0f89e12315ecfdf7e140959c73eb5113e"],"secs":15,"stamp":"4791d58b61f8de2acd86c29caec45236","tree":"5ec92a6bd2fce8c1720c3efcd0b61e134dc8d170","v":1,"via":"run"}
Ci-Attestation: {"at":1791695031,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7a2b3cf7ebcdb5a8fbf224947731272211ca277dcd3072c193dcecf48875a9b0","lane":"lint","parents":["d94bdbd0f89e12315ecfdf7e140959c73eb5113e"],"secs":15,"stamp":"79cfd47fd161716d09fc1a738f9465ed","tree":"5ec92a6bd2fce8c1720c3efcd0b61e134dc8d170","v":1,"via":"run"}
Ci-Attestation: {"at":1791695031,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"8a24c8171e0fd3cce5f1a5116ef1b2d46335f2a140a61756c426464d6221ee24","lane":"rust-test","parents":["d94bdbd0f89e12315ecfdf7e140959c73eb5113e"],"secs":30,"stamp":"a4073f3b80f5d3fb156010b3fb975846","tree":"5ec92a6bd2fce8c1720c3efcd0b61e134dc8d170","v":1,"via":"run"}
Ci-Attestation: {"at":1791695031,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"787348aaa3944da2e0a259d8b86a3f6671e73ead1bcfc15f57cc4bcef22fca4a","lane":"tier2-linux","parents":["d94bdbd0f89e12315ecfdf7e140959c73eb5113e"],"secs":60,"stamp":"6278b9d9aaca814d5377b2b629def250","tree":"5ec92a6bd2fce8c1720c3efcd0b61e134dc8d170","v":1,"via":"run"}
When the saved vaapi_device cannot be opened or does not encode the
codec, use the codec's default device (the first render node that does)
and log the substitution, instead of failing to start the output
(obsproject/obs-studio#13773). A working configured device is still
used as is, and with no usable device the encoder fails as before.

Probing the configured device adds one libva initialisation when an
encoder starts. On a Radeon 680M, ffmpeg_vaapi, ffmpeg_vaapi_tex and
hevc_ffmpeg_vaapi now encode 60 frames with a missing render node, a
by-path node of another PCI slot, an inaccessible primary node,
/dev/null and an empty setting, logging for example:

  Device '/dev/dri/renderD129' is not usable, falling back to
  '/dev/dri/renderD128'

All 7 tests in test_vaapi_device_select pass.

Fixes obs-rust#197.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=f9c2895c659ef07a2d0e884b847b0bd5340c3b30 secs=87 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791695586,"gate":"rust/all/fmt","host":"linux-x86_64","key":"806535844ffbda5b5f280e32cea09799744c41f1fbf81adbd735c4e5e19160d9","lane":"lint","parents":["b7c41b83967cfe2332a77323f861b8cbb07f2390"],"secs":11,"stamp":"25558eff9c6aafd17dae8ce6da1b8064","tree":"f9c2895c659ef07a2d0e884b847b0bd5340c3b30","v":1,"via":"run"}
Ci-Attestation: {"at":1791695586,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"806535844ffbda5b5f280e32cea09799744c41f1fbf81adbd735c4e5e19160d9","lane":"lint","parents":["b7c41b83967cfe2332a77323f861b8cbb07f2390"],"secs":11,"stamp":"26b5b3e96b3212ac48ad1b602b701934","tree":"f9c2895c659ef07a2d0e884b847b0bd5340c3b30","v":1,"via":"run"}
Ci-Attestation: {"at":1791695586,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"72830ba33d742856f6918c78e9321f4603021f4c8d98f36f88879a5056a058dd","lane":"rust-test","parents":["b7c41b83967cfe2332a77323f861b8cbb07f2390"],"secs":33,"stamp":"1c2b52afd24b9cc1cf757a94bddee152","tree":"f9c2895c659ef07a2d0e884b847b0bd5340c3b30","v":1,"via":"run"}
Ci-Attestation: {"at":1791695586,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"1c56a809a5aa0814cf3eb694602c79a69d078b494866d2f4106503f716e561bf","lane":"tier2-linux","parents":["b7c41b83967cfe2332a77323f861b8cbb07f2390"],"secs":43,"stamp":"c145636435182f1416135f07c8bdae3d","tree":"f9c2895c659ef07a2d0e884b847b0bd5340c3b30","v":1,"via":"run"}
text-freetype2: Evict old glyphs when the atlas is full
obs-ffmpeg: Fall back to a working VAAPI device
…786)

With the filename format "%CCYY-%MM-%DD %hh:%mm:%ss", Advanced output
mode writes recordings whose names keep the ':' while saved replay
buffers have it replaced (reported upstream by pricklythorn).
AdvancedOutput::StartRecording passes the raw FilenameFormatting
setting to GetRecordingFilename and to the split-file "format",
whereas the replay buffer, Simple mode recordings, screenshots and the
stream dump all go through GetFormatString, which replaces the
characters Windows filesystems reject.

output_filename_format is the Qt-free form of GetFormatString that
every file output can share. The stub returns the format unchanged,
as the Advanced recording path does today, so 5 of 6 cases fail:
test_recording_format_replaces_colons,
test_replay_buffer_format_replaces_colons,
test_recording_matches_replay_buffer,
test_every_reserved_character_is_replaced and
test_subdirectories_in_format_are_kept.
test_plain_formats_are_unchanged passes.

Refs obs-rust#199.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With the filename format "%CCYY-%MM-%DD %hh:%mm:%ss", Advanced mode
recordings and their split files kept the ':' in their names, while
replay buffers, Simple mode recordings and screenshots had it replaced.
Such files cannot be written to NTFS or exFAT drives or copied to
Windows. Reported upstream by pricklythorn.

AdvancedOutput::StartRecording now runs FilenameFormatting through
GetFormatString like every other file output, for both the first file
and the split-file format. GetFormatString wraps the Qt-free
output_filename_format, which replaces * ? " | : > < with '_' and '\'
with '/'. Only the format changes; the recording directory is never
touched, and subdirectories in the format are kept.

test_recording_format_replaces_colons,
test_replay_buffer_format_replaces_colons,
test_recording_matches_replay_buffer,
test_every_reserved_character_is_replaced and
test_subdirectories_in_format_are_kept now pass (6/6).

Fixes obs-rust#199.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=08724963159cdb2db00f9106c07dba15482a87ec secs=77 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791696801,"gate":"rust/all/fmt","host":"linux-x86_64","key":"292e234cedff0cea4b95cfac7aa0c24e8ae4ca5f6c2bf61da3d7f372499bf607","lane":"lint","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":11,"stamp":"446fc02f499915554183864c0c951b0d","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"292e234cedff0cea4b95cfac7aa0c24e8ae4ca5f6c2bf61da3d7f372499bf607","lane":"lint","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":11,"stamp":"1ac26b469b145e89d34de8389f52ac56","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"90fdd482a5db00d3ed788a4b3bb023a40268364e1dddc39c864abb334f73af4b","lane":"rust-test","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":24,"stamp":"9a2c750c1df915f8ec67bf7884b22b94","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"882ab4885f23cdf6b47a7eb460314ae6747179d6648a6c1dc6b80379776615ff","lane":"tier2-linux","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":43,"stamp":"46a7afd1fffc58fd6dd7c0b12d865bbe","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Picking a discrete framerate for a v4l2 source sets the device to its
fastest rate instead (obsproject/obs-studio#13388, reported by acscd),
and every camera control change such as zoom or focus restarts the
stream (#13896, reported by shanefagan).

Both come from the framerate list storing the packed 64-bit
(numerator, denominator) interval through an int: only the denominator
survives, which unpacks as 0/30 s per frame, and the stored setting
never matches the packed interval the device reports back.

Move the list entry and the framerate restart decision into
v4l2-framerate.c unchanged so cmocka can test them without a device.
The list value tests fail until the truncation is fixed.

Refs obs-rust#201.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The framerate list stored each discrete frame interval through an int,
truncating the packed 64-bit (numerator, denominator) tuple to its
denominator. Store it as int64_t so the setting holds the interval the
user picked: the device runs at the selected rate, and the setting
matches what the device reports back, so unrelated settings changes no
longer restart the capture.

Turns picked_framerate_requests_that_interval and
control_change_does_not_restart_stream green.

This is obsproject/obs-studio#13808 by acscd.

Fixes obs-rust#201.

Co-Authored-By: acscd <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=9cbfe21ec8400538dc0dfda09175307778fd7f7a secs=84 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791697391,"gate":"rust/all/fmt","host":"linux-x86_64","key":"bdf42dd17bbd8b13266ec682931f98ba52be392534539a6aacb0a77dfa2bef37","lane":"lint","parents":["e58c8d7d9025167b4ad39231563a3668c5e0ebd2"],"secs":11,"stamp":"dbbfa686223fe5d779d544b7fbed1637","tree":"9cbfe21ec8400538dc0dfda09175307778fd7f7a","v":1,"via":"run"}
Ci-Attestation: {"at":1791697391,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"bdf42dd17bbd8b13266ec682931f98ba52be392534539a6aacb0a77dfa2bef37","lane":"lint","parents":["e58c8d7d9025167b4ad39231563a3668c5e0ebd2"],"secs":11,"stamp":"709d1e537fa6e37f7b9d8aec69b0ca31","tree":"9cbfe21ec8400538dc0dfda09175307778fd7f7a","v":1,"via":"run"}
Ci-Attestation: {"at":1791697391,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"a03713842106d45d59cad7bbc78f21de3055cb1eab37a12daa26cfa98dffc177","lane":"rust-test","parents":["e58c8d7d9025167b4ad39231563a3668c5e0ebd2"],"secs":26,"stamp":"73d8080acdbd1c4dd04b7a20f9d539a2","tree":"9cbfe21ec8400538dc0dfda09175307778fd7f7a","v":1,"via":"run"}
Ci-Attestation: {"at":1791697391,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"f73dc3b35b472d69f8709ce6ba79e05e806891d05ed819201c3f891e41df9651","lane":"tier2-linux","parents":["e58c8d7d9025167b4ad39231563a3668c5e0ebd2"],"secs":47,"stamp":"3e1036a16bd58062521bfdb3f8a15f32","tree":"9cbfe21ec8400538dc0dfda09175307778fd7f7a","v":1,"via":"run"}
…e-sanitise

frontend: Sanitise Advanced mode recording filenames
…uncation

linux-v4l2: Keep packed framerate in list values
Pin observable behavior ahead of a guarded direct-output rework: for
each tested format and geometry, a packed (video_frame-layout)
destination, a padded-stride destination, and a 16-byte-misaligned
destination must produce identical visible bytes, leave canary slack
intact, and leave uncopied tail rows (e.g. the ceil-allocated final
chroma row on odd-height 420 formats) untouched.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
video_scaler_scale() runs sws_scale() into a scratch image allocated by
av_image_alloc() and then copies every plane into the caller's buffers.
When the caller's planes are already in the layout sws would write --
every used plane present, base_get_alignment()-aligned, at FFmpeg's
packed linesize -- pass them to sws_scale() directly and skip the copy.

The guard is deliberately conservative:

- Strides must equal av_image_fill_linesizes() output, not merely be
  large enough, so sws can never write past a plane's extent.
- Odd heights on vertically subsampled formats fall back: sws writes
  ceil(h/2) chroma rows while the copy contract (and a foreign caller's
  floor-sized planes) only covers floor(h/2).
- Any missing plane, under-aligned pointer, or non-packed stride falls
  back to the unchanged scratch + per-row copy path.

Observable output is unchanged; test/cmocka/test_video_scaler.c pins
packed/padded/misaligned layouts byte-identical with canary slack and
uncopied tail rows untouched, on both the old and new code paths.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@chriscoveries
chriscoveries force-pushed the rust/video-scaler-direct branch from 740842a to 704957f Compare October 11, 2026 07:04

chriscoveries commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner Author

Source review of 704957ffb08aa9afe65073b25b1fd109733ffca8; no local execution or benchmark.

Please settle the aliasing contract before accepting the direct path. video-scaler-ffmpeg.c:247–274 checks destination layout but never input/output overlap. The public declaration:38–39 states no non-overlap precondition. Previously the entire input was consumed into scratch before copying to output.

A concrete source-derived case is BGRA→BGRA, 16×2, 64-byte source/destination strides, a 32-aligned 160-byte allocation, and output[0] = input[0] + 32. The new guard accepts it. FFmpeg 8 selects packedCopyWrapper for identical packed formats, whose equal-stride path uses memcpy. That creates overlapping memcpy ranges; the old scratch path keeps both copies disjoint. This is an unexecuted synthetic compatibility risk. The known video-io consumer:98–111 uses separate conversion frames; I have not found a production aliasing caller or completed a whole-tree caller audit. Please retain scratch fallback for overlapping source/destination spans with an overlap regression, or establish an existing no-alias contract explicitly.

Two smaller acceptance notes:

  • The four-repeat fixture:354–361 uses only LAYOUT_PADDED, hence only fallback. Add repeated packed/direct calls and alternating packed/padded calls with changed inputs; check every plane against a fresh scratch-path reference.
  • Scratch allocation:193 remains unconditional, so this change removes eligible copies but does not remove the scratch image's resident allocation. When benchmarking resumes, count real direct-path hits and measure the per-consumer conversion path; no runtime or RAM win is established here.

CI-observed separately: run 38120138238 / job 114412986141 checked out this exact SHA (ref plus final git log), and both Linux OFF/ON runs passed 65/65, including test_video_scaler. It does not test the new alias fixture; the macOS numbers remain author-reported in this review.

Scope clarification (refreshed 07:42 UTC): fork master is now bacf2abc5d5ef8cd682af0a6ceaaf6e06784ecb2. Comparing that current master with this head shows two topic commits/three files ahead and 18 commits behind, with merge base c2d617e8f020efbd4d6cfae281881ac3e36a1c08. The PR metadata still reports the older 8325758 base and 63 commits/130 files; that inherited ancestry is not the scaler patch's scope. Revalidate integration against current master before merge review.

— dot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants