Expand description
A streaming STR player a game can call: play streams one movie from
the disc at double speed, decodes it through the MDEC and shows it, with
its interleaved XA audio going straight from the drive to the SPU.
The pipeline is the hello-fmv console test’s, without the test’s
sector stamps and overlay:
- A polled pump drains every sector the drive has ready into a ring of three frame slots. It runs between every unit of work, including every wait and every two macroblocks of the bitstream decode.
crate::bitstream::decode_frameturns the next frame’s bitstream into one of two run-length buffers while the MDEC decodes the previous frame from the other.- Decoded 16-pixel columns come back over DMA1 into one of two column buffers and go to a free display buffer over DMA2 while DMA1 fills the other.
- The flip is queued to the VBlank handler. There are three display buffers, so the MDEC can start the next frame while the last one waits for its flip.
Pacing follows the drive, not the VBlank: a frame is shown
Config::latency_vblanks after its last sector arrived. The audio
plays as its sectors arrive, so picture and sound keep a fixed offset
for the whole movie whatever the display’s refresh rate, and a 25 fps
PAL movie plays at 25 fps on a 60 Hz display. A frame completed while an
older one still waits for the decoder replaces it (counted in
Outcome::skipped).
Memory comes from the caller (memory_words says how much), so a
game lends a buffer that is idle while the movie plays, such as a level
buffer at boot. The player takes over the CD drive, the MDEC, DMA
channels 0 to 2, root counter 2, the display and the VRAM under
Config::buffers while it runs. No frame of the caller’s may be in
flight on the GPU when it starts, and the SPU must already be
initialised.
Structs§
- Config
- Where and how to show it.
- Movie
- One movie on the disc, as the build measured it.
- Outcome
- What happened, for logs and tests.
Enums§
Constants§
- DEFAULT_
BUFFERS - Display buffers at (0, 0), (0, 256) and (512, 0): room for 320 pixels at 24 bits (480 halfwords) by up to 256 lines each.
- WEDGE_
ERRORS - Consecutive MDEC failures that end a movie as
Stop::Wedged.
Functions§
- find_
root_ file - Find a file in the disc’s root directory by name:
(lba, bytes). Takes the drive over (data mode, double speed) and leaves it stopped. - memory_
words - Words of memory
playneeds formovieatdepth. - play
- Play
movieuntil it ends orpollreturnstrue(checked once per VBlank, e.g. for a skip button).memorymust hold at leastmemory_wordswords and is free again on return. At 15 bits the last frame stays on screen (the display start may be any of the three buffers); at 24 bits every buffer is cleared to black and the caller’s display mode is restored. The drive is stopped and the CD audio volume left at 0.