[pr-tests][audio] darner-formats XMA: unit tests for the bit reader, large values, log2 and sample conversion #329
Loading…
Reference in a new issue
No description provided.
Delete branch "elgibbone/xma-bit-reader"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What it changes
Bits(peek32, its tail path,read,signed,overread) and the helperslarge_value,log2andto_i16had no direct tests; they were only reached through whole-frame decodes.Adds five tests to
crates/darner-formats/src/xma.rs, with no change outside the test module:bit_reads_match_a_bit_by_bit_reader_up_to_and_past_the_end: every width from 0 to 32 bits, from every bit position up to a byte past a 23-byte buffer, against a one-bit-at-a-time reader (the 8-byte path, the tail path and zeros past the end), withconsumedandoverreadchecked on each read.signed_reads_take_the_top_bit_as_the_sign: 6-bit reads as the step size uses them, and a 1-bit read.large_values_read_8_16_24_or_31_bits_after_their_prefix: the four prefixes offf_wma_get_large_val.log2_is_the_floor_and_zero_counts_as_one.samples_round_and_clamp_to_sixteen_bits: scale by 32768, round half away from zero, clamp, NaN to 0.Checked that the tests catch real changes: with the tail path dropping its last byte, the two bit-reader tests fail (the existing XMA tests all still pass);
overreadas>=, a 32767 scale into_i16and 32 bits for the longest large value each fail their test.How it was tested
d340f99(onf3840d7)cargo test -p darner-formats --locked: 92 passed, 0 failed, 7 ignored (88 and 7 on main)cargo clippy -p darner-formats --all-targets --locked -- -D warnings, and with--all-features: cleancargo xwin clippy --target x86_64-pc-windows-msvc: cleancargo xtask policy: 555 files ok;git diff --check: clean--workspace, not on Windows.Checklist
Not run in the game: tests only, no behaviour change.
main.docs/asset-policy.md.Checked for overlap
texture.rs, notxma.rs. #248 is about the XMA worker in darner-hle, not this decoder.Independent Windows build, gate, and code-read review of
d340f9909(full headd340f990957bfc2f5742a7875a15b0fc931c3557, based onmainf3840d73d3504c30218debfbc8795b9225447317). Not run in-game.Environment
x86_64-pc-windows-msvc), MSVC 19.44.35230.Measured results
cargo clippy --workspace --all-targets --locked -- -D warnings): PASS.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS.cargo xtask policy: PASS (asset policy: 555 files ok).cargo test -p darner-formats --locked: PASS (92 passed; 0 failed; 7 ignored; doc tests: 0).Code-read audit
bit_reads_match_a_bit_by_bit_reader_up_to_and_past_the_endchecks widths 0–32 at every position through and beyond a 23-byte buffer against an independent MSB-first reader, and separately checks consumed position and overread state. It exercises bothpeek32's 8-byte path andpeek32_tail(crates/darner-formats/src/xma.rs:233-280,2240-2274).signed_reads_take_the_top_bit_as_the_signpins negative, positive, minimum 6-bit, and 1-bit sign extension.large_values_read_8_16_24_or_31_bits_after_their_prefixcovers all four prefix branches, including the 31-bit maximum and a high-bit payload, and checks consumed lengths (xma.rs:272-278,417-428,2276-2305).log2_is_the_floor_and_zero_counts_as_onecovers zero, powers of two, adjacent values, and the frame trim width;samples_round_and_clamp_to_sixteen_bitschecks signed half-way rounding, saturation, infinities, and NaN againstto_i16(xma.rs:431-433,1366,2307-2337). The diff adds only tests and helpers inside the test module.No blocking issue found; the new tests independently exercise the specified decoder helpers with synthetic data.
Verdict: PASS.
AI-assisted: yes (GitHub Copilot, Auto mode).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.