mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2026-11-12 07:11:03 +00:00
6be36b6bda13dd0c4f70c710673bc33f4e888f03
Implements zstd as an alternative to LZMA for data block and subchannel compression using the allocated compression IDs 4 (kCompressionZstd) and 5 (kCompressionZstdCst). Adds zstd v1.5.7 as a bundled submodule with a static library build including x86_64 assembly fast path for decompression. Write path selects zstd or LZMA based on the zstd option. Subchannel blocks use zstd+CST instead of LZMA+CST when enabled. LZMA properties header is only written for LZMA-based compression types, preventing format corruption in zstd-compressed images. Activated via options string: "zstd=true;zstd_level=19". Default remains LZMA for backwards compatibility. Tested: SHA-256 verified lossless roundtrips across 9 disc systems (Dreamcast, Saturn, Mega CD, PC Engine CD, Neo Geo CD, PS1, PS2 CD, PS2 DVD) and PS1 SBI subchannel preservation with zstd+CST.
libaaruformat
C implementation of Aaru file format.
The target is to be able to compile it with a normal C (C89 compliant) compiler.
There are no external dependencies.
cmake is not a hard dependency, it's merely for the ease of using IDEs (specifically CLion).
Currently supported features:
- AaruFormat V1 images reading (writing will never be implemented)
- AaruFormat V2 images reading and writing
- LZMA compression
- Claunia Subchannel Transform
- Optical disc tracks
- XML metadata retrieval (writing will never be implemented)
- JSON metadata retrieval and writing
- Hashing while writing (MD5, SHA1, SHA256, SpamSum and BLAKE3)
- Deduplication
- Tape file and partitions
- Dump hardware lists
- Currently on sync (as of October 2025) with Aaru's media type list
- CHS geometry retrieval and setting
- Metadata
- Unit testing
- Automatic generation of API documentation
- It is to all effects feature parity with C#
Things still to be implemented that are already in the C# version:
- Automatic media type generation from C# enumeration
- Nuget package for linking with Aaru
Things to be implemented not in the C# version (maybe):
- Compile for Dreamcast (KallistiOS preferibly)
- Compile for PlayStation Portable
- Compile for Wii
- Compile for Wii U
- Compile for PlayStation 2
- Compile for PlayStation 3
- Snapshots
- Parent images
- Data positioning measurements
Building and Testing
Standard Build
mkdir build
cd build
cmake ..
cmake --build .
Running Tests
cd build
ctest --verbose
Building with Address Sanitizer
For debugging memory issues, you can build with Address Sanitizer enabled:
mkdir build-asan
cd build-asan
cmake -DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug ..
cmake --build .
ctest --verbose
For detailed information on using Address Sanitizer to detect memory issues, see docs/ASAN_USAGE.md.
Other Build Options
-DUSE_SLOG=ON- Enable slog logging for debugging-DUSE_ASAN=ON- Enable Address Sanitizer for memory error detection
Languages
C
88.8%
C++
9.8%
CMake
1.1%
Shell
0.2%
PowerShell
0.1%