Skip to content

test/cmocka: characterize video_scaler_scale output layouts - #45

Draft
chriscoveries wants to merge 1 commit into
masterfrom
test/video-scaler-characterization
Draft

chriscoveries wants to merge 1 commit into
masterfrom
test/video-scaler-characterization

Conversation

@chriscoveries

@chriscoveries chriscoveries commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

Characterization tests for video_scaler_scale output layout handling, split out of the parked #44 per the owner's verdict. They pin the contract the scaler's scratch-copy path must satisfy; the implementation change itself stays on rust/video-scaler-direct.

For each dst format x geometry the tests scale with FAST_BILINEAR into three layouts — FFmpeg-packed, padded-stride, and 16-byte-misaligned — and compare byte-identical visible output, plus per-plane canary slack and uncopied tail rows (odd-height 420 chroma) untouched.

Coverage: I420, NV12, I444, YUVA, P010, BGRA, Y800 at 128x64 / 322x242 / 160x120; odd geometry I420, NV12, P010, I40A, BGRA at 161x121 / 160x121 / 161x122; 4 repeated calls per case. Registered via tests.d/test_video_scaler.cmake — no shared CMakeLists edit.

Test plan

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>

Copy link
Copy Markdown
Owner Author

Source review of 740a79e1e4ffdafd1df8e9d19bb3c6f5788f4289: this is a clean one-commit/two-test-file split against bacf2abc5d5ef8cd682af0a6ceaaf6e06784ecb2, with no production changes. The test source is byte-identical to #44's characterization file.

CI-observed: run 38122323622 / job 114419437132 records both checkout ref and final git log -1 as this exact head. Linux OFF and ON each passed 69/69 tests, including test_video_scaler. The unchecked CI box in the description can be reconciled with that run; local Debug results remain author-reported here.

Scope caveat for the eventual optimization: test_video_scaler.c:354–361 repeats only the padded layout with unchanged input. That is valid characterization of the current scratch path, but does not establish repeated direct-output behavior or resolve #44's alias/coverage questions. Keep those implementation requirements with #44; no benchmark or local execution was performed in this review.

— dot

chriscoveries pushed a commit that referenced this pull request Oct 13, 2026
* test: characterize video-io.c before port

cmocka tests pinning the current C behavior of
libobs/media-io/video-io.c ahead of the obs-media-io port.

test_video_io links libobs and covers the exported API: open
parameter checks, getters, the cache clamp, connect and delivery,
rejected conversions, a zero conversion size, SRGB collapsing to
709, a real scale (linesize only), a repeated frame, the
frame-rate divisor on connect2, a full cache counting a skip, and
the first raw input clearing the frame counters.

test_video_io_hidden compiles video-io.c into the binary. The six
non-EXPORT functions are hidden, so they cannot be linked out of
libobs. That copy takes precedence and does not exercise a later
Rust swap. It pins the texture-encoder refcount and the shallow
frame-rate-divisor copy.

connect(NULL) crashes in get_root before the NULL check. A NULL
get_skipped_frames or get_total_frames dereferences the handle.
close on a divisor child frees the parent's cache. Those are not
called. The crash without obs_startup is forked and skipped when
obs_startup succeeds.

Refs #45

Local-Gate: v1 tree=e6446569e55c15e7a8b67c4dde7bf9dccfc0ab28 secs=167 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791854349,"gate":"rust/all/fmt","host":"linux-x86_64","key":"59141c2c75455186035b9aaed5de830a13593a503e8c93acb3c1883750cae784","lane":"lint","parents":["487c90c44ffb91e59baa6dd5304688309f8ac2d4"],"secs":61,"stamp":"bb2e1273be913c21939eddf51d36a6f2","tree":"e6446569e55c15e7a8b67c4dde7bf9dccfc0ab28","v":1,"via":"run"}
Ci-Attestation: {"at":1791854349,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"59141c2c75455186035b9aaed5de830a13593a503e8c93acb3c1883750cae784","lane":"lint","parents":["487c90c44ffb91e59baa6dd5304688309f8ac2d4"],"secs":61,"stamp":"6aa834bd91abaf7d1000a104c0d80aea","tree":"e6446569e55c15e7a8b67c4dde7bf9dccfc0ab28","v":1,"via":"run"}
Ci-Attestation: {"at":1791854349,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"bb9356392a2b12790dd03a77e50b858a0d57397c7f05704a3786eaf6db534596","lane":"rust-test","parents":["487c90c44ffb91e59baa6dd5304688309f8ac2d4"],"secs":47,"stamp":"0ed58bf3dc3c76585304dde92651f97b","tree":"e6446569e55c15e7a8b67c4dde7bf9dccfc0ab28","v":1,"via":"run"}
Ci-Attestation: {"at":1791854349,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"d3cdc5c7d09ab91056fbe4b43eedc2b16ddf3172a63403c22204f41e498c1887","lane":"tier2-linux","parents":["487c90c44ffb91e59baa6dd5304688309f8ac2d4"],"secs":59,"stamp":"1f7bf0c8bbcafc528f672dacf31f95a4","tree":"e6446569e55c15e7a8b67c4dde7bf9dccfc0ab28","v":1,"via":"run"}

* rust: Add video-io tests against stubs (RED)

Seventeen Tier 1 tests call the shims. soldr cargo test -p
obs-media-io --test video_io aborts in video_output_open:
not yet implemented. The stub is extern "C", so the panic
cannot unwind.

Refs #45

* rust: Port media-io/video-io.c to obs-media-io

The video thread, cache, and input list live in
obs-media-io::video_output. The shims replace video-io.c
when ENABLE_RUST_LIBOBS is on. video_scaler stays the
FFmpeg C file.

soldr cargo test -p obs-media-io --test video_io --test
video_io_parity passes, 17 and 7. A wrapping_add(1) on
frame_time fails getters_match: 1000000001 vs 1000000000.

Linux cargo test of obs-media-io (arm64 image, rust-lld)
passes the same tests. The GitHub runner is x86_64.

Refs #45

Local-Gate: v1 tree=5a22fb3b58ca2a531a448ac61bd10af3058eaaa7 secs=102 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791857820,"gate":"rust/all/fmt","host":"darwin-arm64","key":"032c6d1e755bc8583714ea3b90a2766e53e83bd789250bfc6bb69e5b7ce175c9","lane":"lint","parents":["3976d46de9fdd5f81fb556afdce290178a86fd96"],"secs":38,"stamp":"c5c9030a73fff1a1fa2595895a9d5e13","tree":"5a22fb3b58ca2a531a448ac61bd10af3058eaaa7","v":1,"via":"run"}
Ci-Attestation: {"at":1791857820,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"032c6d1e755bc8583714ea3b90a2766e53e83bd789250bfc6bb69e5b7ce175c9","lane":"lint","parents":["3976d46de9fdd5f81fb556afdce290178a86fd96"],"secs":38,"stamp":"88221ee8a1712be93a21f922968f2e9c","tree":"5a22fb3b58ca2a531a448ac61bd10af3058eaaa7","v":1,"via":"run"}
Ci-Attestation: {"at":1791857820,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"679dce4c17bc83e5e7ba1ab24be1bde4f8cbfd8203e85bead5b3dca754892dfd","lane":"rust-test","parents":["3976d46de9fdd5f81fb556afdce290178a86fd96"],"secs":22,"stamp":"c22083f8462cd727ea3eaf9baa2fa77e","tree":"5a22fb3b58ca2a531a448ac61bd10af3058eaaa7","v":1,"via":"run"}
Ci-Attestation: {"at":1791857820,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"ac48b099857602c01de0905dee540067c95f3653db63b8bc6fafb3b000fdf217","lane":"tier2-linux","parents":["3976d46de9fdd5f81fb556afdce290178a86fd96"],"secs":42,"stamp":"a67b32085e5f7efb76ece8701c42ef61","tree":"5a22fb3b58ca2a531a448ac61bd10af3058eaaa7","v":1,"via":"run"}

* rust: Drop the input borrow before blog

connect built the scaler inside with_mut. blog runs a log
handler on this thread, and that handler can connect again.
A second with_mut would alias the input list. The guard
stays held across the host call, same as C's input mutex.

Refs #45

Local-Gate: v1 tree=95558b81aa13b77cc6d6ef6fae4e8280c1a40ec9 secs=125 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791858285,"gate":"rust/all/fmt","host":"darwin-arm64","key":"2530b044ec935c0d26bc2f4d8f29011aaf3b4446471c95def9c212428eb210a3","lane":"lint","parents":["14737489d2486c5503baf0a5196e0f9d61d5847b"],"secs":44,"stamp":"11fb0a30ff54c0111723fd156da78301","tree":"95558b81aa13b77cc6d6ef6fae4e8280c1a40ec9","v":1,"via":"run"}
Ci-Attestation: {"at":1791858285,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"2530b044ec935c0d26bc2f4d8f29011aaf3b4446471c95def9c212428eb210a3","lane":"lint","parents":["14737489d2486c5503baf0a5196e0f9d61d5847b"],"secs":44,"stamp":"f2c32cba5ab38e61dc4e531b6841f07f","tree":"95558b81aa13b77cc6d6ef6fae4e8280c1a40ec9","v":1,"via":"run"}
Ci-Attestation: {"at":1791858285,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"0e09ebaf625bd2c1cf43790079bbeb99dbefdb6781ea2684ecbeaac10316e84f","lane":"rust-test","parents":["14737489d2486c5503baf0a5196e0f9d61d5847b"],"secs":34,"stamp":"e33009c1da47fe9d5dd8d41e5d82db0c","tree":"95558b81aa13b77cc6d6ef6fae4e8280c1a40ec9","v":1,"via":"run"}
Ci-Attestation: {"at":1791858285,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"12a383372b1efa4600d00fed68e2e9c07cf11e2581afd6cac49fdd27f66078f0","lane":"tier2-linux","parents":["14737489d2486c5503baf0a5196e0f9d61d5847b"],"secs":47,"stamp":"6b1a53b602bd5f04c61792c9747d1ea3","tree":"95558b81aa13b77cc6d6ef6fae4e8280c1a40ec9","v":1,"via":"run"}

* rust: Format the video-io oracle

clang-format 22.1.3 wants the scaler create signature on
two lines. CI checks changed .c files under rust/. The
local lint lane does not.

Refs #45

Local-Gate: v1 tree=d2db1045a4997d3471298a0eec062117297b56e1 secs=139 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791858979,"gate":"rust/all/fmt","host":"darwin-arm64","key":"5f29de47eb69cabedcd93d87a100d07b1cd812d788942fd0cf97110d51b311d8","lane":"lint","parents":["4a6424b2e2c634b7a9e94d75c84266c083050020"],"secs":46,"stamp":"4b631af1c192120e8661c8fce03b2421","tree":"d2db1045a4997d3471298a0eec062117297b56e1","v":1,"via":"run"}
Ci-Attestation: {"at":1791858979,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"darwin-arm64","key":"5f29de47eb69cabedcd93d87a100d07b1cd812d788942fd0cf97110d51b311d8","lane":"lint","parents":["4a6424b2e2c634b7a9e94d75c84266c083050020"],"secs":46,"stamp":"1cd63f2dbdbd1c10bbc0c2fa72557383","tree":"d2db1045a4997d3471298a0eec062117297b56e1","v":1,"via":"run"}
Ci-Attestation: {"at":1791858979,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"darwin-arm64","key":"ced1802dfb74b4c72d906102e61e78a3bdda7df3439800f5056a95eac6dae7cb","lane":"rust-test","parents":["4a6424b2e2c634b7a9e94d75c84266c083050020"],"secs":47,"stamp":"4f076aafd034bf74512ab3309a5414a9","tree":"d2db1045a4997d3471298a0eec062117297b56e1","v":1,"via":"run"}
Ci-Attestation: {"at":1791858979,"gate":"cpp/linux-x64/tier2","host":"darwin-arm64","key":"50d168f00e0129c61dfa158ebbf0da610074439f1975b96975549d1d46dfdf4a","lane":"tier2-linux","parents":["4a6424b2e2c634b7a9e94d75c84266c083050020"],"secs":46,"stamp":"76d6ad9d6230b445673dc99be8a9fdff","tree":"d2db1045a4997d3471298a0eec062117297b56e1","v":1,"via":"run"}

* rust: Scale frames outside the input borrow

video_scaler_scale logs when sws_scale fails. A log handler
on this thread can connect again. Take the scaler and the
convert buffer out of the input list before that call.

Refs #45

Local-Gate: v1 tree=05d034a9c91e1dbc750f8fa9174df467e607ceeb secs=152 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791861540,"gate":"rust/all/fmt","host":"linux-x86_64","key":"f4557351dd895a801c12ad1cdb9ee67974a6346b21c7bba6f4cbbf424caf8d45","lane":"lint","parents":["caf34863b5c53412e9296a201afa27ed0b7e11be"],"secs":32,"stamp":"34cf9bb63c88427be7fa758824270b56","tree":"05d034a9c91e1dbc750f8fa9174df467e607ceeb","v":1,"via":"run"}
Ci-Attestation: {"at":1791861540,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"f4557351dd895a801c12ad1cdb9ee67974a6346b21c7bba6f4cbbf424caf8d45","lane":"lint","parents":["caf34863b5c53412e9296a201afa27ed0b7e11be"],"secs":32,"stamp":"75fa25fc23a1b7f919190f3fc26be44e","tree":"05d034a9c91e1dbc750f8fa9174df467e607ceeb","v":1,"via":"run"}
Ci-Attestation: {"at":1791861540,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"96815df1a30cde638bbbdd822cc09f9825faf1efc59226270b6ff1d48fbea547","lane":"rust-test","parents":["caf34863b5c53412e9296a201afa27ed0b7e11be"],"secs":58,"stamp":"6e0e129c643a4a426176bf4452e1df8f","tree":"05d034a9c91e1dbc750f8fa9174df467e607ceeb","v":1,"via":"run"}
Ci-Attestation: {"at":1791861540,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ca94ff3ee54ae75306969315358f7a4dbf6e34d7ddc90b9d77f271251b350f8c","lane":"tier2-linux","parents":["caf34863b5c53412e9296a201afa27ed0b7e11be"],"secs":61,"stamp":"cb939d33f857a7e0f495a764c16c4e3b","tree":"05d034a9c91e1dbc750f8fa9174df467e607ceeb","v":1,"via":"run"}
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.

1 participant