Expand description
FMV playback building blocks for PS1 guests.
A movie is a .STR file: 2048-byte sectors, each carrying a 32-byte
chunk header and 2016 bytes of one frame’s compressed bitstream (the
“BS” format). Playing one is a pipeline:
- CD sectors stream in (the caller owns the drive; see the
hello-fmvexample) andstream::FrameAssemblerstitches a frame’s chunks back together. bitstream::decode_frameruns the variable-length decode on the CPU, turning the bitstream into the MDEC’s run-length halfwords.mdec::Mdec, the driver that owns the MDEC’s DMA channels, feeds those to the MDEC over DMA0 and pulls decoded 16-pixel-wide columns back over DMA1 for upload to VRAM.
Everything but mdec is plain logic, built and tested on the host; the
driver only touches a register when one of its methods runs.
A game that only wants to play a movie calls player::play (guest only),
which runs all three stages overlapped and shows the result; the
hello-fmv example is the simpler, sector-checking test player.
Bitstream versions 1 and 2 (the same coding) are decoded; v3 differs in the DC
coding and is rejected with bitstream::DecodeError::Version.
The encoder is psxavenc (zlib license), run as a host build tool:
psxavenc -t strv -v v2 -s 320x240 -r 15 -x 2 in.mp4 out.str.
Modules§
- bitstream
- BS (“bitstream”) frame decode: variable-length codes to MDEC run-length halfwords.
- idct
- The MDEC’s IDCT matrix, generated from the DCT basis.
- iso
- Minimal ISO9660 lookup: find a file in the disc’s root directory.
- mdec
- MDEC driver: table upload, decode command, DMA0 in, DMA1 out.
- player
- A streaming STR player a game can call:
playstreams 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. - rle
- Run-length data: what
crate::bitstream::decode_frameproduces and the MDEC decodes, and the lengths the MDEC can be handed. - stream
- STR video sectors: the 32-byte chunk header and frame reassembly.