243 Commits

Author SHA1 Message Date
112f53dc3d More 64-bit file offset fixes. 2026-04-04 16:32:25 +01:00
774ccbc8ae Fix tests compilation in MSVC. 2026-04-04 15:54:38 +01:00
2aac1ce89c refactor: update file I/O to support large files with aaru_off_t type 2026-04-04 15:10:46 +01:00
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
Kevin Bortis
6fabbefb30 Extend zstd compression to all sections, add featureIncompatible bit 2026-04-01 19:45:41 +02: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
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
8a8a89450d lru: use native uint64 keys instead of string conversion
Replace string-keyed uthash lookups with HASH_FIND/HASH_ADD on native
uint64_t keys. This eliminates per-lookup malloc/snprintf/strlen/free
overhead from the block cache hot path (2 lookups per sector read).

Before: malloc(17) + snprintf hex + HASH_FIND_STR + free per lookup
After:  HASH_FIND with 8-byte integer key, zero allocations

Also removes the unused string-key API (find_in_cache/add_to_cache)
and the uint64_to_string helper — all callers use uint64 keys.

Fix off-by-one in eviction: >= caused cache to hold max_items-1
entries instead of max_items. Changed to > so the configured
capacity is honored exactly.
2026-03-19 20:35:42 +01:00
6dbd5f1bb2 Merge pull request #12 from RomTholos/fix/cross-compilation-arm-riscv
Fix cross-compilation for ARM FPU variants and add RISC-V support
2026-03-19 11:58:49 +00:00
Kevin Bortis
bd01e7d8a5 Fix cross-compilation for ARM FPU variants and add RISC-V support 2026-03-19 12:34:00 +01:00
Kevin Bortis
6be36b6bda Add Zstandard compression support
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.
2026-03-19 08:45:07 +01:00
Kevin Bortis
95908b328a Reserve compression IDs 4 and 5 for Zstandard (zstd)
Adds kCompressionZstd = 4 and kCompressionZstdCst = 5 to the
CompressionType enum, following the existing LZMA/LzmaCst pattern.

Ref: https://github.com/aaru-dps/libaaruformat/issues/5
2026-03-18 22:20:26 +01:00
694601cc63 Enhance Wii junk data handling: reconstruct junk in user data area during read and write operations 2026-03-16 22:54:53 +00:00
5b93c56e7b Add support for Nintendo Wii and GameCube junk map and encryption: implement lazy initialization for NgcwJunkEntry and WiiPartitionRegion 2026-03-16 18:34:24 +00:00
53bbb3c7a6 Add new data types for Nintendo Wii and GameCube: introduce WiiPartitionKeyMap and NgcwJunkMap for enhanced region mapping 2026-03-16 18:31:27 +00:00
7ee97105b5 Add new sector status: introduce SectorStatusGenerable to indicate content that can be generated using a known algorithm 2026-03-16 17:28:54 +00:00
913d0508a2 Add recursion guard for Wii U re-encryption: implement flag to prevent recursive calls during sector processing 2026-03-16 13:28:16 +00:00
93357cbf1f Add Wii U encryption support to context structure and cleanup logic 2026-03-16 11:11:40 +00:00
5857e16662 Add Wii U partition-to-key mapping to enums and media tags 2026-03-16 10:51:17 +00:00
73dac131b8 Implement PS3 encryption support with lazy initialization and error handling 2026-03-15 19:12:59 +00:00
d53faf7a38 Rename track type enums for consistency 2026-03-15 18:18:15 +00:00
3d81f50afe Rename data type enum. 2026-03-14 21:45:02 +00:00
a5b8054a14 Rename compression enum. 2026-03-14 20:39:56 +00:00
ce9f6ba610 Rename media tags. 2026-03-14 20:18:35 +00:00
43b226bbfa Rename sector tags. 2026-03-14 19:54:52 +00:00
6fa82b4dfe Add feature compatibility checks for V2+ images and define new error codes 2026-03-14 18:52:51 +00:00
1516e9ff24 Add PS3 related media tags. 2026-03-09 20:11:07 +00:00
30965a0c94 Add Nintendo Wii U disc key to enums and update related functions 2026-03-08 19:59:28 +00:00
4df22c47ef Add Floppy Write-Protect status to media tag and data type enums 2026-01-06 14:00:55 +00:00
Rebecca Wallander
c412030a8b Use block alignment offset instead of absolute offset 2026-01-01 13:37:21 +01:00
Rebecca Wallander
86b6680e3e Add data type to datastream block 2026-01-01 13:37:20 +01:00
Rebecca Wallander
65d34b1e9a Add flux implementation 2026-01-01 13:35:43 +01:00
3dc11ee8b1 Add static LRU hash map implementation with LRU-like eviction.
Not yet used.
2025-12-31 12:03:16 +00:00
b7e0f60673 Guard against writes of too big sectors. 2025-12-30 20:14:18 +00:00
7f0dea2755 Repurpose two unused header fields to store biggest image sector size. 2025-12-30 20:13:39 +00:00
3385caac5d Fix typo in secondary DDTv2 identifier (back-compatible until out of alpha). 2025-12-30 11:12:00 +00:00
344ce95619 Update parse_options function to return table_shift_found flag 2025-12-30 01:41:41 +00:00
43be8e89dd Change sector parameter types from uint16_t to uint32_t for negative and overflow sectors 2025-12-29 16:19:41 +00:00
2ce7e053e0 Add function to free Compact Disc ECC context and update cleanup logic 2025-12-28 17:04:14 +00:00
a93dcfc3d4 Add cache management functions and implement free callback for cached values 2025-12-28 16:57:19 +00:00
76656e25aa Sync media types with Aaru. 2025-12-26 16:00:10 +00:00
955789a160 Increase size of negative and overflow sectors in DDT2 to 32-bit. 2025-12-26 09:39:13 +00:00
050810c91d Update copyright year to 2026. 2025-12-23 08:23:40 +00:00
ced56fad6c Added second layer DVD PFI structure data type. 2025-12-13 11:59:19 +00:00
03c091fdee Add dirty flags so structures only get rewritten on resume if they are changed. 2025-12-12 12:22:39 +00:00
dc221d91ee Fixed missing comma in media types. 2025-12-10 00:30:37 +00:00
bd8c00e758 Synced media types with Aaru. 2025-12-01 12:55:48 +00:00
bbcadedd7e Fix declaration of aaruf_open. 2025-10-21 14:24:56 +01:00
f7da1e27bd Add support for resuming images. 2025-10-21 14:02:47 +01:00
94e44ef304 Do not consider rewinded the first time block 0 is written. 2025-10-20 01:13:14 +01:00