Data Compression

From N64brew Wiki
Jump to navigation Jump to search

Compressing your assets will let you fit more data on a cartridge. But which data should you compress, and how? What are the tradeoffs?

TODO: Link to decoding libraries / compression tools.

Data Compression

Any data can be compressed with a general-purpose data compression algorithm, such as Deflate. However, this is generally not as effective for media, like images, audio, or video.


  • Raw
  • JPEG
  • HVQ


TODO: Calculate bit rates at different sample rates. Find samples for comparison or create a test ROM.

The microcode and audio libraries that come with LibUltra support PCM and VADPCM. TODO: What about LibDragon?

  • PCM: Baseline for comparison: 16 bits per sample. This is raw, uncompressed audio.
  • VADPCM: Used in many retail Nintendo 64 games. Always 4.5 bits per sample, encoded in blocks of 16 samples.
  • MP3: "Known to be possible." Used in some retail Nintendo 64 games, such as Conker's Bad Fur Day.
  • Music can also be stored in MOD or MIDI format, but this is not a type of compression.
Encoding Sample Rate Bit rate (kbit/s) Length per megabyte (s/MiB) Capacity of 64 MiB cartridge (h:mm:ss)
16-bit PCM 44.1 kHz 706 kbit/s 11.9 s/MiB 12:41
32 kHz 512 kbit/s 16.4 s/MiB 17:29
22.05 kHz 353 kbit/s 23.8 s/MiB 25:22
16 kHz 256 kbit/s 32.7 s/MiB 34:57
VADPCM 44.1 kHz 198 kbit/s 42.3 s/MiB 45:05
32 kHz 144 kbit/s 58.3 s/MiB 1:02:08
22.05 kHz 99.2 kbit/s 84.5 s/MiB 1:30:11
16 kHz 72.0 kbit/s 117 s/MiB 2:04:17

Note that 1 MiB is 1024*1024 bytes, and 1 kbit is 1,000 bits.


TODO: How easy is it to use these codecs? Are there code samples?

  • HVQM: "Known to be possible." Used by some retail Nintendo 64 games.
  • H.264: "Known to be possible." Giovanni Bajo is working on a port of Dragon's Lair, using H.264 for the video.