Repository navigation
fix(media-io): decompress_422 converts one row, in the C and the Rust (#3031) - #3073
Conversation
…uffers (#3031) One packed 4:2:2 row of 4 pixels (in_linesize 8), followed by the next row's first 2 dwords, into one row of 4 32-bit pixels (out_linesize 16). The row must convert alone: no read of the next row, no write past the 16-byte output. - test/cmocka/test_format_conversion.c: test_decompress_422_one_row (new, Tier 2: hybrid libobs and the C reference). - Tier 1 mirror: test_decompress_422_one_row. - Tier 3: decompress_422_one_row runs the native C, the scalar C, the safe core and the shim on the same buffers against the expected bytes. Packed::call is the old Packed::check closure, shared by both. Fails on master in every implementation: min(in_linesize, out_linesize) / 2 converts 4 dwords, so the next row is read and the output gets 16 bytes past its row (the canary differs from byte 16 on). Refs #3031 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cterization cases (#3031) Per the decision on #3031 (#3031 (comment)): fix the C and the Rust together and update the two characterization cases of test/cmocka/test_format_conversion.c to the corrected rows. They were marked "Characterized, not endorsed" and pinned the double row. - test_decompress_422_literals: in_linesize 4, out_linesize 8 converts 1 dword into 2; the second input dword is not read and output dwords 2 and 3 keep the canary. - test_decompress_422_rows_spill is now test_decompress_422_rows_in_bounds: two rows of in_linesize 8 read 4 of the 6 dwords and write 8, the rest of the output keeps the canary. No other assertion in the file changes. The Tier 1 Rust mirror of the two cases changes the same way. Both fail until the GREEN commit. Refs #3031 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#3031) A packed 4:2:2 row has 2 bytes per pixel, so in_linesize bytes are in_linesize / 4 32-bit words. min(in_linesize, out_linesize) / 2 converted twice that: each row read twice its bytes and wrote twice its output, and the last rows of a frame ran past the caller's buffers. Per the decision on #3031, both implementations change by the same line: - libobs/media-io/format-conversion.c.h: / 4. - rust/obs-media-io/src/format_conversion.rs: / 4; the doc no longer describes the spill as kept. The C oracle includes the production file, so Tier 3 stays byte-exact; the parity test sizes its buffers by / 4 now, so every proptest case runs on buffers of exactly the converted rows. The Tier 1 wrap case (decompress_422_row_offset_wraps_like_c) now expects 2 words and the canary after them. rust/README.md drops the "quirks kept" note, the port_comparison bench sizes one frame, and docs/features.md gets the line. Fixes #3031 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=7dad87970600d8ed96ab07db1e6701bae729a2d5 secs=439 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793369524,"gate":"rust/all/fmt","host":"linux-x86_64","key":"906bc270a6079654822d78db12eb3de3a01e403491025a173b5949bea664133f","lane":"lint","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":88,"stamp":"af199ff09d9f55be5ef238470fd30406","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"906bc270a6079654822d78db12eb3de3a01e403491025a173b5949bea664133f","lane":"lint","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":88,"stamp":"aab414dee0b96545a30b7ea665df195f","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"d6670a0afcde730c504f436047736c508321e25bd02d1527e199527b8036a717","lane":"rust-test","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":206,"stamp":"72fe0e3dec8def1decfad55be50c823a","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"09bbab540c315635dabd031bd8d4b9161af0e44733dc8d5bcabbb3b6156f0fee","lane":"cross","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":144,"stamp":"2f3aaa3e45fc7f0fdf7a33ea211ccefe","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"09bbab540c315635dabd031bd8d4b9161af0e44733dc8d5bcabbb3b6156f0fee","lane":"cross","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":144,"stamp":"35e2205223b891f07d5b384d616c37f5","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"09bbab540c315635dabd031bd8d4b9161af0e44733dc8d5bcabbb3b6156f0fee","lane":"cross","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":144,"stamp":"47c8cc3eb50cfeca784053561e94edce","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"09bbab540c315635dabd031bd8d4b9161af0e44733dc8d5bcabbb3b6156f0fee","lane":"cross","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":144,"stamp":"ff7fdd0ce9795cebe236db19f9b79c0f","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"} Ci-Attestation: {"at":1793369524,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"92b6ad32c194344dfde07167da28705e1d78026b69b858e3129877346b3bf406","lane":"tier2-linux","parents":["2de855be9cd50096e3f856004f117986b332e347"],"secs":247,"stamp":"77c5466342e0407bf42a70df1d93f176","tree":"7dad87970600d8ed96ab07db1e6701bae729a2d5","v":1,"via":"run"}
zackees
left a comment
There was a problem hiding this comment.
Coordinator review. The code is correct: / 4 in the C and the Rust, the new one-row cases pass with canaries after the output, parity stays byte-exact across C, C-scalar, shim and safe, and the features line is in.
I turned auto-merge off, and I'm holding this for the maintainer for one reason. It edits an existing C test (test/cmocka/test_format_conversion.c: two assertions in test_decompress_422_literals, and test_decompress_422_rows_spill renamed and changed). AGENTS.md says not to edit existing C tests, and the #3031 decision that allows it was made by the coordinator, not the maintainer. Mitigating: that file is our own characterization test (added 2026-10-10 in 64978ca, not upstream), and the cases it changes were marked "characterized, not endorsed". So I expect a quick yes. Once the maintainer answers on #3031 I'll queue it, or ask for the Rust-only variant.
Fixes #3031
What and why
decompress_422()(exported informat-conversion.h) converted twice each row. A packed 4:2:2 row (UYVY or YUY2) has 2 bytes per pixel, soin_linesizebytes arein_linesize / 432-bit words; the C and the Rust tookmin(in_linesize, out_linesize) / 2. Each row read twice its bytes and wrote twice its output row, and the last rows of a frame ran past the caller's buffers. Nothing in OBS calls it (upstream removed the CPU YUV path, e5b004f); a plugin that calls it with its own frame buffers is affected (low tier under SECURITY.md).Per the decision on #3031 (#3031 (comment)), the C and the Rust change together, by the same line (
/ 2to/ 4):libobs/media-io/format-conversion.c.hrust/obs-media-io/src/format_conversion.rsThe C oracle includes the production file, so Tier 3 stays byte-exact and
rust/README.mdgets no intentional difference; its "quirks kept" note for the spill goes.Commits
RED 8565aac: a new exact-size case, one row in (
in_linesize8, followed by the next row's first 2 dwords) and one row out (out_linesize16), in three tiers:test_decompress_422_one_rowintest/cmocka/test_format_conversion.c(new; hybrid libobs and the C reference);decompress_422_one_row, the native C, the scalar C, the safe core and the shim against the expected bytes.It fails in every implementation on master: each one reads the next row and writes 16 bytes past the output row. The canary differs from byte 16 on, with no out-of-bounds access, because the buffers have 16 bytes of canary slack.
Characterization cases 2de855b: only the two cases the decision names, in their own commit, which cites the decision:
test_decompress_422_literals: 1 dword in, 2 out, the rest canary;test_decompress_422_rows_spillis renamedtest_decompress_422_rows_in_bounds: 2 rows read 4 of 6 dwords and write 8.No other assertion in the file changes. The Tier 1 Rust mirror of the two cases changes the same way.
GREEN f224c6e:
/ 4in both implementations;/ 4, so every proptest case runs on buffers of exactly the converted rows;port_comparisonbench sizes one frame;Tests
format_conversion32/32 on GREEN. RED:decompress_422_one_row(Tier 1 and Tier 3) fails. Tier 3 fails first on the native C.test_format_conversionagainst the hybrid libobs and the C reference) passed, 439 s.port_comparison^format/in Criterion--testmode: every case passes, with frame-sizeddecompress_422buffers.The recorded
port_comparisonbaselines indocs/rust-port/benchmarks/keep theirdecompress_422timings. Those timings measure the old double row on both sides, so the Rust/C ratio stays comparable. The next recording halves both.Upstream obsproject/obs-studio has the same line. Any report there goes to the maintainer (decision point 4).
Checklist
masterdocs/features.md🤖 Generated with Claude Code