summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/WIABlob.cpp
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2020-08-31 14:46:13 +0200
committerJosJuice <josjuice@gmail.com>2020-08-31 14:46:13 +0200
commitbdd28c0edf986244fc7a2845df5537b5bc4bcf7a (patch)
treec402e4af591ddac334becc0d4a81f3a73fb757e4 /Source/Core/DiscIO/WIABlob.cpp
parentf7f0fa2d855c889b093b8ffb4739a1971051b10c (diff)
DiscIO: Expand WIA/RVZ header size heuristic comments
Diffstat (limited to 'Source/Core/DiscIO/WIABlob.cpp')
-rw-r--r--Source/Core/DiscIO/WIABlob.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp
index 3faa4c38c2..30294d2817 100644
--- a/Source/Core/DiscIO/WIABlob.cpp
+++ b/Source/Core/DiscIO/WIABlob.cpp
@@ -1743,19 +1743,24 @@ WIARVZFileReader<RVZ>::Convert(BlobReader* infile, const VolumeDisc* infile_volu
const size_t raw_data_entries_size = raw_data_entries.size() * sizeof(RawDataEntry);
const size_t group_entries_size = group_entries.size() * sizeof(GroupEntry);
- // Conservative estimate for how much space will be taken up by headers.
- // The compression methods None and Purge have very predictable overhead,
- // and the other methods are able to compress group entries well
+ // An estimate for how much space will be taken up by headers.
+ // We will reserve this much space at the beginning of the file, and if the headers don't
+ // fit on that space, we will need to write them at the end of the file instead.
const u64 headers_size_upper_bound = [&] {
+ // 0x100 is added to account for compression overhead (in particular for Purge).
u64 upper_bound = sizeof(WIAHeader1) + sizeof(WIAHeader2) + partition_entries_size +
raw_data_entries_size + 0x100;
- // RVZ's added data in GroupEntry usually compresses well
+ // RVZ's added data in GroupEntry usually compresses well, so we'll assume the compression ratio
+ // for RVZ GroupEntries is 9 / 16 or better. This constant is somehwat arbitrarily chosen, but
+ // no games were found that get a worse compression ratio than that. There are some games that
+ // get a worse ratio than 1 / 2, such as Metroid: Other M (PAL) with the default settings.
if (RVZ && compression_type > WIARVZCompressionType::Purge)
upper_bound += static_cast<u64>(group_entries_size) * 9 / 16;
else
upper_bound += group_entries_size;
+ // This alignment is also somewhat arbitrary.
return Common::AlignUp(upper_bound, VolumeWii::BLOCK_TOTAL_SIZE);
}();