Skip to content

ASSET-53: detect stereo packets in later music blocks - #700

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
VictorJulianiR:codex/streamed-opus-channel-count
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
VictorJulianiR:codex/streamed-opus-channel-count

Conversation

@VictorJulianiR

Copy link
Copy Markdown
Contributor

ASSET-53, claimed on #634.

A streamed Opus group can start with mono packets and carry stereo packets in a later block. The exporter previously fixed the output channel count after the first nonempty block. The change keeps looking for stereo until it finds it. Export and manifest generation share that code. The new test covers both block orders and checks the Ogg header, end granule, packet payloads and metadata-only path.

On an authored two-packet fixture, FFmpeg 6.1.1 decoded the parent export as mono with 1,920 frames. With this change, it decoded two distinct channels of 1,800 frames each, matching the declared trim and manifest duration (0.0375 s). The coded packet bytes were identical before and after in all four tested arrangements. The census documented in docs/audio.md found no mixed group in its surveyed banks. FFmpeg decode and controls on the original candidate.

AI-assisted. On the refreshed commit bfa1983, the exporter, manifest and resume suites passed on GitHub-hosted Windows Server 2022 and Ubuntu 24.04. Each runner also combined this change with #608 and ran all three suites on that tree. Synthetic input, CPU only. Both hosted runs.

@kapitche

Copy link
Copy Markdown
Contributor

Tested bfa1983 on Linux (WSL2 Ubuntu), Python 3.12, CPU only: pass

  • pytest tests/test_awc_opus.py: 18 passed, 21 subtests
  • Negative control: with tools/awc_opus.py from main, 1 test fails.
  • Code read: with < 2, a channel first seen as mono (1) can still be upgraded to stereo (2) by a later block, while a stereo result is never downgraded. The per-channel samples //= 2 at the end then sees the right count. Running the TOC check on every block of a mono channel costs little.

@Pierre-Kookis

Copy link
Copy Markdown
Contributor

Checked #700 (ASSET-53) on Windows 11, Python 3.13.14, no game files:

  • python -I tests/test_awc_opus.py: 18 tests OK (main 67204bf: OK as well)
  • Code read of tools/awc_opus.py: around line 193, later blocks can upgrade a mono stream to stereo, and once a stream is stereo it stays stereo. The new tests (from about tests/test_awc_opus.py:381) cover both block orders, the export headers, granule trimming, packet preservation and the metadata-only parse. I found no issues.

I didn't run it on real music banks, so this covers the code and the synthetic tests only.

(AI-assisted review: I ran the tests, and a second model read the code.)

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.

4 participants