mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Use heuristics to setup table shift.
This commit is contained in:
@@ -219,7 +219,7 @@ typedef struct
|
|||||||
bool deduplicate; ///< Storage dedup flag (DDT always exists). true=share identical sector content, false=store
|
bool deduplicate; ///< Storage dedup flag (DDT always exists). true=share identical sector content, false=store
|
||||||
///< each instance.
|
///< each instance.
|
||||||
uint32_t dictionary; ///< LZMA dictionary size in bytes (>= 4096 recommended). Default: 33554432 (32 MiB).
|
uint32_t dictionary; ///< LZMA dictionary size in bytes (>= 4096 recommended). Default: 33554432 (32 MiB).
|
||||||
uint8_t table_shift; ///< DDT table shift (multi-level fan-out exponent). Default: 9.
|
int8_t table_shift; ///< DDT table shift (multi-level fan-out exponent). Default: heuristically calculated.
|
||||||
uint8_t data_shift; ///< Global data shift: low bits encode sector offset inside a block (2^data_shift span).
|
uint8_t data_shift; ///< Global data shift: low bits encode sector offset inside a block (2^data_shift span).
|
||||||
uint8_t block_alignment; ///< log2 underlying block alignment (2^n bytes). Default: 9 (512 bytes).
|
uint8_t block_alignment; ///< log2 underlying block alignment (2^n bytes). Default: 9 (512 bytes).
|
||||||
bool md5; ///< Generate MD5 checksum (ChecksumAlgorithm::Md5) when finalizing image.
|
bool md5; ///< Generate MD5 checksum (ChecksumAlgorithm::Md5) when finalizing image.
|
||||||
|
|||||||
13
src/create.c
13
src/create.c
@@ -231,10 +231,21 @@ void *aaruf_create(const char *filepath, const uint32_t media_type, const uint32
|
|||||||
ctx->userDataDdtHeader.start = 0;
|
ctx->userDataDdtHeader.start = 0;
|
||||||
ctx->userDataDdtHeader.blockAlignmentShift = parsed_options.block_alignment;
|
ctx->userDataDdtHeader.blockAlignmentShift = parsed_options.block_alignment;
|
||||||
ctx->userDataDdtHeader.dataShift = parsed_options.data_shift;
|
ctx->userDataDdtHeader.dataShift = parsed_options.data_shift;
|
||||||
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
|
|
||||||
ctx->userDataDdtHeader.sizeType = 1;
|
ctx->userDataDdtHeader.sizeType = 1;
|
||||||
ctx->userDataDdtHeader.entries = ctx->userDataDdtHeader.blocks / (1 << ctx->userDataDdtHeader.tableShift);
|
ctx->userDataDdtHeader.entries = ctx->userDataDdtHeader.blocks / (1 << ctx->userDataDdtHeader.tableShift);
|
||||||
|
|
||||||
|
if(parsed_options.table_shift == -1)
|
||||||
|
{
|
||||||
|
uint64_t total_sectors = user_sectors + overflow_sectors + negative_sectors;
|
||||||
|
|
||||||
|
if(total_sectors < 0x8388608ULL)
|
||||||
|
ctx->userDataDdtHeader.tableShift = 0;
|
||||||
|
else
|
||||||
|
ctx->userDataDdtHeader.tableShift = 22;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ctx->userDataDdtHeader.tableShift = parsed_options.table_shift;
|
||||||
|
|
||||||
if(ctx->userDataDdtHeader.blocks % (1 << ctx->userDataDdtHeader.tableShift) != 0) ctx->userDataDdtHeader.entries++;
|
if(ctx->userDataDdtHeader.blocks % (1 << ctx->userDataDdtHeader.tableShift) != 0) ctx->userDataDdtHeader.entries++;
|
||||||
|
|
||||||
TRACE("Initializing primary/single DDT");
|
TRACE("Initializing primary/single DDT");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ aaru_options parse_options(const char *options)
|
|||||||
aaru_options parsed = {.compress = true,
|
aaru_options parsed = {.compress = true,
|
||||||
.deduplicate = true,
|
.deduplicate = true,
|
||||||
.dictionary = 33554432,
|
.dictionary = 33554432,
|
||||||
.table_shift = 9,
|
.table_shift = -1,
|
||||||
.data_shift = 12,
|
.data_shift = 12,
|
||||||
.block_alignment = 9,
|
.block_alignment = 9,
|
||||||
.md5 = false,
|
.md5 = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user