Skip to content

libmpeg (sdkDemux): a demux call after a refused sound packet costs EE time - #158

Merged
boubou666 merged 1 commit into
masterfrom
mpeg-refused-demux-cost
Nov 27, 2026
Merged

boubou666 merged 1 commit into
masterfrom
mpeg-refused-demux-cost

Conversation

@boubou666

Copy link
Copy Markdown
Contributor

With sdkDemux, a sound packet that the game's PCM callback refuses (its ring full) ends the demux call, and the next call offers it again, as the SDK does. On the console the player's turn between two calls takes time (the demux itself, the IPU's decoding). Here it took none, so a player spinning until its sound thread made room ran the callback about 9,000 times a field.

Effect in Shinobido: each movie field took 23 ms of host time (dispatches, stops and the stacked handlers). Movies played at about 60% speed in the window and 80% headless, with the sound starved.

Fix: the demux call after a refusal now costs 0.2 ms of EE time (l.callCycles, so a pinned time still wins). Nothing changes for a stream whose callbacks never refuse.

Measured on Shinobido's intro (NINJA.PSS):

  • handlers: 102 a field instead of 9,300;
  • host time: 1.4 ms a field instead of 23;
  • 25 pictures a second in the window;
  • the pictures' EE timing is unchanged (30 every 60 vblanks);
  • the movie's recorded sound has no gap.

🤖 Generated with Claude Code

….2 ms of EE time

With sdkDemux, a sound packet the game's callback refuses (its ring full) ends the
demux call, and the next call offers it again, as the SDK does. On the console the
player's turn between two calls takes time (the demux, the IPU); here none, so a
player spinning until its sound thread made room ran the callback about 9,000 times a
field. Shinobido's movies took 23 ms of host time a field and played at 60% speed in
the window (and headless 80%), their sound starved.

The call after a refusal now costs 0.2 ms (l.callCycles: a pinned time still wins).
Shinobido's intro: 102 handlers a field instead of 9,300, 1.4 ms of host time instead
of 23, 25 pictures a second in the window; the pictures' EE timing unchanged (30
every 60 vblanks) and the movie's sound without a gap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@boubou666
boubou666 merged commit 922bbe2 into master Nov 27, 2026
4 checks passed
@boubou666
boubou666 deleted the mpeg-refused-demux-cost branch November 27, 2026 00:30
boubou666 pushed a commit to TheBozos/Shinobido_WOTN_Recomp that referenced this pull request Nov 27, 2026
…the movie spin

Movies played at about 60% speed in the window: the player re-offered a refused sound
packet about 9,000 times a field, each through the PCM callback's handler. A demux call
after a refusal now costs EE time; the intro takes 1.4 ms of host time a field instead
of 23 and shows 25 pictures a second.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants