oead supports Yaz0 decompression and fast compression (using syaz0)


Decompression performance is on par with existing Yaz0 decoders.

As of late December 2019, syaz0 is able to compress files much faster than existing Yaz0 encoders. Files that are representative of Breath of the Wild assets were compressed 20x to 30x faster than with existing public tools for an equivalent or better compression ratio, and 70-80x faster (with a slightly worse ratio) in extreme cases.

At the default compression level, file sizes are typically within 1% of Nintendo’s.

For detailed benchmarks, see the results files in the test directory of the syaz0 project.


#include <oead/yaz0.h>

struct Header

Public Functions

OEAD_DEFINE_FIELDS(Header, magic, uncompressed_size, data_alignment, reserved)

Public Members

std::array<char, 4> magic


u32 uncompressed_size

Size of uncompressed data.

u32 data_alignment

[Newer files only] Required buffer alignment

std::array<u8, 4> reserved

Unused (as of December 2019)

std::optional<Header> oead::yaz0::GetHeader(tcb::span<const u8> data)
std::vector<u8> oead::yaz0::Compress(tcb::span<const u8> src, u32 data_alignment = 0, int level = 7)

  • src: Source data

  • data_alignment: Required buffer alignment hint for decompression

  • level: Compression level (6 to 9; 6 is fastest and 9 is slowest)

std::vector<u8> oead::yaz0::Decompress(tcb::span<const u8> src)
void oead::yaz0::Decompress(tcb::span<const u8> src, tcb::span<u8> dst)

For increased flexibility, allocating the destination buffer can be done manually. In that case, the header is assumed to be valid, and the buffer size must be equal to the uncompressed data size.

void oead::yaz0::DecompressUnsafe(tcb::span<const u8> src, tcb::span<u8> dst)

Same, but additionally assumes that the source is well-formed. DO NOT USE THIS FOR UNTRUSTED SOURCES.