Commit Graph

833 Commits

Author SHA1 Message Date
Kevin Bortis
d8ff7b4a28 refactor: split close.c into reader/writer
Separate writer finalization from resource cleanup in close.c to
enable a future reader-only library target (aaruformatread).

close_write.c contains all write_* helpers and aaruf_finalize_write().
close.c retains aaruf_close() with cleanup only, dispatching writer
finalization via a function pointer set by aaruf_create()/aaruf_open().

Zero behavioral change — same tests pass, same error semantics.
2026-04-02 08:32:10 +02:00
62202a5c29 Merge pull request #32 from RomTholos/fix/verify-v1-lzma-crc
Fix v1 image verification and add aaruf_verify_image tests
2026-04-01 22:41:49 +01:00
b38c92855f Merge pull request #31 from RomTholos/test/flac-error-handling
Add FLAC error handling regression tests
2026-04-01 22:40:31 +01:00
d75bb6f79d Merge pull request #30 from RomTholos/cmake/optional-tool-build
Make tool build optional (requires Argtable3)
2026-04-01 22:40:03 +01:00
bb3560b82c Merge pull request #28 from RomTholos/feat/zstd-all-sections
Extend zstd compression to all sections, add featureIncompatible bit
2026-04-01 22:37:53 +01:00
Kevin Bortis
83433faaf7 Fix v1 image verification and add aaruf_verify_image tests
V1 images stored cmpCrc64 over the full LZMA payload including the
5-byte properties prefix, but verify.c unconditionally skipped the
prefix before computing the CRC. This caused aaruf_verify_image() to
report AARUF_ERROR_INVALID_BLOCK_CRC on every valid v1 image.

The fix makes the LZMA properties skip conditional on v2+ images:
- V1: CRC computed over full cmpLength (properties included), then byte-swapped
- V2+: CRC computed over cmpLength minus 5 (properties excluded), no byte-swap

Applies to DataBlock, DeDuplicationTable (v1), and DeDuplicationTable2.

Verified against fixtures created by Aaru 5.3 (v1) and aaruformattool (v2).

Tests added (14 total, VerifyImageFixture suite):
- Happy path: floptical/mf2hd/cdmode1 for both v1 and v2 (6 tests)
- Invalid context: NULL and garbage (2 tests)
- Corruption detection: data block v1/v2, TracksBlock (3 tests)
- Index corruption: invalid offset, bad signature (2 tests)
- Programmatic round-trip: create + write + close + verify (1 test)
2026-04-01 20:49:25 +02:00
Kevin Bortis
5e00a01e21 Add FLAC error handling regression tests
Regression tests for the error handling improvements in
fix/flac-error-handling (PR #23). The fix changed decode/encode to
return 0 instead of (size_t)-1 on failure, added NULL allocation
checks, and fixed a decoder memory leak on init failure.

Tests added (flacErrors suite):
- decode_garbage_returns_zero: random non-FLAC data
- decode_truncated_flac_returns_zero: valid magic, truncated stream
- decode_empty_input_returns_zero: NULL source buffer
- decode_zero_length_returns_zero: non-NULL but zero-length source
- encode_zero_length_no_crash: NULL source, verifies no crash/leak
- encode_garbage_roundtrip_fails_cleanly: non-PCM encode + decode
- decode_dst_too_small_returns_zero: undersized output buffer

All tests are self-contained (no fixture files needed) and pass
under AddressSanitizer.
2026-04-01 20:24:13 +02:00
Kevin Bortis
6fabbefb30 Extend zstd compression to all sections, add featureIncompatible bit 2026-04-01 19:45:41 +02:00
Kevin Bortis
2b0e3b0a6e Make tool build optional (requires Argtable3) 2026-04-01 19:18:50 +02:00
6fa129282b Merge pull request #25 from RomTholos/fix/mode2-form-detection-read
fix Mode 2 form detection in errored-suffix read path
2026-04-01 16:03:02 +01:00
3cc1830a5f Merge pull request #20 from RomTholos/spec/document-lzma-properties-prefix
spec: clarify LZMA properties prefix in cmpLength and cmpCrc64 scope
2026-04-01 16:02:34 +01:00
Kevin Bortis
b88e71a865 fix Mode 2 form detection in errored-suffix read path 2026-03-31 19:40:47 +02:00
Kevin Bortis
2cbd88a15b spec: clarify LZMA properties prefix in cmpLength and cmpCrc64 scope 2026-03-31 08:59:52 +02:00
3af5f1ec41 Merge pull request #24 from RomTholos/fix/lzma-threading-cleanup
Replace hardcoded LZMA thread count with LZMA_THREADS(ctx)
2026-03-29 22:26:11 +01:00
0e79486a9e [spec] Add annex about Nintendo Wii U Disc Encryption 2026-03-29 19:47:03 +01:00
1172630c84 [spec] Add annex about Nintendo Wii Disc Encryption 2026-03-29 19:37:16 +01:00
88e4b7cf57 [spec] Add annex about GameCube / Wii junk. 2026-03-29 19:30:36 +01:00
ea669e4040 [spec] Add annex about PlayStation 3 encryption. 2026-03-29 19:19:37 +01:00
01e46f9e16 [spec] Add emojis to all headings. 2026-03-29 19:05:06 +01:00
1dcf9fb619 [spec] Add emojis to Annex A. 2026-03-29 19:00:19 +01:00
ee93001607 [spec] Register emoji font. 2026-03-29 18:56:17 +01:00
8adb38096f [spec] Fixed heading in compression. 2026-03-29 18:50:39 +01:00
e168226e9a [spec] Write media types annex. 2026-03-29 18:47:15 +01:00
bf9328f755 [spec] Added historical mistake block identifier. 2026-03-29 18:35:23 +01:00
530dac88a9 [spec] Fixed metadata block description. 2026-03-29 18:33:55 +01:00
9f02e9ab62 [spec] Add Generable sector status. 2026-03-29 18:32:51 +01:00
bf55a0140c Update dependencies to latest version. 2026-03-29 18:31:27 +01:00
43385ad920 [spec] Add missing data types. 2026-03-29 18:31:14 +01:00
85098b0b9e [spec] Fix data type typo. 2026-03-29 18:30:59 +01:00
258d9e33d8 [spec] Fix incorrect data types in specification. 2026-03-29 18:28:54 +01:00
Kevin Bortis
3c00aed352 Replace hardcoded LZMA thread count with LZMA_THREADS(ctx)
The LZMA encoder was called with numThreads=8 at all 19 call sites,
but LZMA only supports 1 or 2 (and _7ZIP_ST forces it to 1 anyway).
Replace with LZMA_THREADS(ctx) macro that clamps ctx->num_threads
to [1, 2], making the code say what it means and honoring the
consumer's threading preference from the threads=N option.
2026-03-29 19:14:38 +02:00
c58bfc167f Merge remote-tracking branch 'origin/devel' into devel 2026-03-29 18:08:31 +01:00
a81a0fe09a Merge pull request #23 from RomTholos/fix/flac-error-handling
fix: FLAC error handling — decode corruption, encode crash, unchecked…
2026-03-29 18:01:20 +01:00
742851934a Merge pull request #22 from RomTholos/spec/clarify-string-encoding
spec: clarify string encoding per block type
2026-03-29 17:59:59 +01:00
d1f7665b3a Merge pull request #21 from RomTholos/spec/document-v1-crc64-byteswap
spec: document CRC64 byte-swap for V1 images
2026-03-29 17:58:24 +01:00
627a1d7edd Merge pull request #19 from RomTholos/spec/document-cst-algorithm
spec: full byte-level algorithm for Claunia Subchannel Transform
2026-03-29 17:56:33 +01:00
24bc41068c Merge pull request #18 from RomTholos/spec/document-blake3-checksum
spec: document BLAKE3 checksum algorithm (ID 5)
2026-03-29 17:54:42 +01:00
69cb91bcad Merge pull request #17 from RomTholos/spec/document-zstd-compression
spec: document Zstandard compression types (IDs 4, 5)
2026-03-29 17:54:06 +01:00
c2e71490df Merge pull request #16 from RomTholos/fix/spec-ddt2-alignment-formula
Fix/spec ddt2 alignment formula
2026-03-29 17:53:23 +01:00
94d2c6e67e Merge pull request #15 from RomTholos/feat/zstd-multithread
Add multi-threaded zstd compression support
2026-03-29 17:52:40 +01:00
Kevin Bortis
26e8d92810 fix: FLAC error handling — decode corruption, encode crash, unchecked returns 2026-03-29 15:47:27 +02:00
Kevin Bortis
4a3ddab743 spec: clarify string encoding per block type 2026-03-29 15:35:04 +02:00
Kevin Bortis
69186ae173 spec: document CRC64 byte-swap for V1 images 2026-03-29 15:32:28 +02:00
Kevin Bortis
94cfa27089 spec: full byte-level algorithm for Claunia Subchannel Transform 2026-03-29 15:24:14 +02:00
Kevin Bortis
4b14de20d8 spec: document BLAKE3 checksum algorithm (ID 5) 2026-03-29 15:16:49 +02:00
Kevin Bortis
b4262d1cf8 spec: document Zstandard compression types (IDs 4, 5) 2026-03-29 15:16:34 +02:00
Kevin Bortis
d9c1c9d607 spec: fix shift formulas in header block spec 2026-03-29 15:06:24 +02:00
Kevin Bortis
120174e4cd Add multi-threaded zstd compression support
Switch zstd encoder from simple API (ZSTD_compress) to advanced API
(ZSTD_CCtx + ZSTD_compress2) with configurable worker threads via
ZSTD_c_nbWorkers. Consumer controls threading through threads=N
option string parameter. Default is 1 (single-threaded, bit-identical
output to previous behavior).

- Enable ZSTD_MULTITHREAD compile definition and link pthreads
- Add num_threads field to options struct and context
- Parse threads=N in option string (clamped >= 1)
- Rewrite aaruf_zstd_encode_buffer() with num_threads parameter
- Update all call sites (write.c, close.c)
2026-03-29 12:56:19 +02:00
Kevin Bortis
b1240dd079 spec: fix block alignment shift formulas in DDT2 spec
The spec used `2 << x` where `1 << x` (= 2^x) was intended.
`2 << x` equals 2^(x+1), which is off by factor 2. The code
unanimously uses `1 << x` across 40+ sites. Corrects the
example result from 0x6A0000 to 0x350000 accordingly.
2026-03-26 18:05:30 +01:00
176a363996 Bump version to 1.0.0-alpha.35 in libaaruformat.nuspec 2026-03-25 16:49:46 +00:00