Opus: the MFT decoder takes only an output type with its channel count #624

Closed
github-bot wants to merge 2 commits from gh-pr/624/head into gh-pr/624/base
Owner

@⁠milas6669 on GitHub · 2026-11-24 02:37 UTC · original
milas6669:opus-mft-output-guards → main · +56 −9 · 1 files · 2 commits · closed without merging

Stacked on #622; only the top commit belongs here.

configure_output took the first PCM16/Float32 output type and overwrote the channel count, which can read out of bounds in the multistream interleave if the MFT lists another count first. It now chooses among the types with the decoder's own count (choose_output_type). drain_output gives up after 4 MF_E_TRANSFORM_STREAM_CHANGE answers instead of looping forever.

Part of #327 (item 3).

What is in it

  • opus.rs: choose_output_type, MAX_STREAM_CHANGES, the two call sites; test output_type_choice_needs_the_decoders_channel_count

Tested

  • RTX 3070, Windows 11 Pro 10.0.26200, MSVC 19.44, Rust 1.100.0, debug build
  • cargo test --workspace -- --test-threads=4: 647 passed, 0 failed, 21 ignored
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)

Regression run

  • not run: no title on this machine to run scripts/smoke.ps1 against

Not tested

  • AMD, a retail title, scripts/smoke.ps1 main vs PR head
  • the retry cap (no mock MFT), a real multichannel stream through the Windows Opus decoder

AI use

  • Claude Code, Claude Sonnet 5.5: wrote the code, the tests and this description. Reviewed and opened by the person submitting.
**@⁠milas6669** on GitHub · 2026-11-24 02:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/624) `milas6669:opus-mft-output-guards` → `main` · +56 −9 · 1 files · 2 commits · closed without merging Stacked on #622; only the top commit belongs here. `configure_output` took the first PCM16/Float32 output type and overwrote the channel count, which can read out of bounds in the multistream interleave if the MFT lists another count first. It now chooses among the types with the decoder's own count (`choose_output_type`). `drain_output` gives up after 4 `MF_E_TRANSFORM_STREAM_CHANGE` answers instead of looping forever. Part of #327 (item 3). **What is in it** - `opus.rs`: `choose_output_type`, `MAX_STREAM_CHANGES`, the two call sites; test `output_type_choice_needs_the_decoders_channel_count` **Tested** - RTX 3070, Windows 11 Pro 10.0.26200, MSVC 19.44, Rust 1.100.0, debug build - `cargo test --workspace -- --test-threads=4`: 647 passed, 0 failed, 21 ignored - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64) **Regression run** - not run: no title on this machine to run `scripts/smoke.ps1` against **Not tested** - AMD, a retail title, `scripts/smoke.ps1` main vs PR head - the retry cap (no mock MFT), a real multichannel stream through the Windows Opus decoder **AI use** - Claude Code, Claude Sonnet 5.5: wrote the code, the tests and this description. Reviewed and opened by the person submitting.
RFC 7845 section 5.1.1.2 gives 7 channels as 5 streams with 2 coupled pairs.
The table said 4 streams and 3 coupled, so a 6.1 Opus voice was split into the
wrong streams. Adds a test that checks the mappings of 3 to 8 channels.

Part of #327
configure_output took the first PCM16 or Float32 type and overwrote the channel
count, which could make the multistream interleave read out of bounds when the
MFT listed another channel count first. It now chooses among the types with the
decoder's own count. drain_output also gives up after 4 stream changes instead
of retrying forever.

The type choice has a unit test; the retry cap has none (no mock MFT).

Stacked on the 6.1 mapping branch. Part of #327
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:40 +00:00
github-bot closed this pull request 2026-11-26 04:27:40 +00:00
Author
Owner

@⁠milas6669 on GitHub · 2026-11-24 03:22 UTC · original

Closing: #503 already covers the MFT output-type guard and was opened earlier. Please review it instead.

**@⁠milas6669** on GitHub · 2026-11-24 03:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/624#issuecomment-7121029954) Closing: #503 already covers the MFT output-type guard and was opened earlier. Please review it instead.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.