Repository navigation
test: characterize video-frame.c before media-io port - #117
Merged
Merged
Conversation
cmocka test pinning the current C behavior of libobs/media-io/
video-frame.c and the static inlines in video-frame.h, ahead of the
obs-media-io port (Phase 5, item 'media-io').
- video_frame_init: per-plane linesize and data-pointer offsets for
every video_format across widths {1,3,5,16,47,48,100,640} and
heights {1,3,5,16,480}. VIDEO_FORMAT_NONE is skipped: it allocates
0 bytes via bmalloc, which trips os_breakpoint()/bcrash() - the
characterized crash is asserted in a forked child.
- video_frame_copy: equal linesizes (memcpy path), wider dst and
narrower dst (line-by-line truncation/extension).
- video_frame_free/create/destroy inlines, including NULL tolerance.
Refs #45
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Local-Gate: v1 tree=74741cb20ea0963a8d74f64eb36ef734a7c26e68 secs=349 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791671040,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7a71a5bd655f778761fef7a351357add46260002ede06e4316c89f587555e592","lane":"lint","parents":["135a25105a6b7e09c278a4aa50845a37b22d30bc"],"secs":254,"stamp":"52ff2be802488adc39dd4aeda7eb58ee","tree":"74741cb20ea0963a8d74f64eb36ef734a7c26e68","v":1,"via":"run"}
Ci-Attestation: {"at":1791671040,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7a71a5bd655f778761fef7a351357add46260002ede06e4316c89f587555e592","lane":"lint","parents":["135a25105a6b7e09c278a4aa50845a37b22d30bc"],"secs":254,"stamp":"2e821f0b6f9f4874dfff96e58c85af14","tree":"74741cb20ea0963a8d74f64eb36ef734a7c26e68","v":1,"via":"run"}
Ci-Attestation: {"at":1791671040,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"90d26fda47a2b2ff428d991b28ab166419a1fd21c4ba99667cd09679b392afb5","lane":"rust-test","parents":["135a25105a6b7e09c278a4aa50845a37b22d30bc"],"secs":57,"stamp":"82955257828f066f28e577c1e8d9cb67","tree":"74741cb20ea0963a8d74f64eb36ef734a7c26e68","v":1,"via":"run"}
Ci-Attestation: {"at":1791671040,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"a7352bd2ebe868d178a3a75779f864c953352cc482768be6b743fd08205803a0","lane":"tier2-linux","parents":["135a25105a6b7e09c278a4aa50845a37b22d30bc"],"secs":37,"stamp":"1afc84c0f1c3369ab82ba4b9c4164ee0","tree":"74741cb20ea0963a8d74f64eb36ef734a7c26e68","v":1,"via":"run"}
zackees
force-pushed
the
char/video-frame-test
branch
from
October 10, 2026 22:24
886fe3e to
b1e6c6a
Compare
zackees
marked this pull request as ready for review
October 10, 2026 22:24
Member
|
Rebased onto master (old head 886fe3e, replaced with --force-with-lease). The test/cmocka/CMakeLists.txt conflict is resolved by appending the test_video_frame block to master's file. This is a characterization test, so by policy it pins current C behaviour and passes now: |
This was referenced Oct 10, 2026
5 tasks done
zackees
pushed a commit
to swilk19/obs-studio
that referenced
this pull request
Oct 11, 2026
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]>
zackees
pushed a commit
to swilk19/obs-studio
that referenced
this pull request
Oct 11, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
test/cmocka/test_video_frame.c, a characterization test pinning the current C behavior oflibobs/media-io/video-frame.cand the static inlines invideo-frame.h, ahead of theobs-media-ioport (Phase 5).Coverage
video_frame_init: per-planelinesizeanddatapointer offsets for everyvideo_formatacross widths {1,3,5,16,47,48,100,640} x heights {1,3,5,16,480}.VIDEO_FORMAT_NONEis pinned as a crash: it produces zero total bytes, sobmalloc(0)tripsos_breakpoint()/bcrash()(asserted in a forked child; POSIX).video_frame_copy: equal linesizes (memcpy path), wider destination (line-by-line truncation), narrower destination (extension).video_frame_free/_create/_destroyinlines incl. NULL tolerance.Validation
ENABLE_RUST_LIBOBS=OFFbuild of this repo's master (compiled against installed libobs, Linux).Note on claims
video-frame.c is listed as item 5 of the media-io port order approved on #45 (lane: swilk19, #114). This characterization test is required groundwork regardless of who performs the port.
Refs #45