diff options
| author | Minty-Meeo <45425365+Minty-Meeo@users.noreply.github.com> | 2022-02-24 04:51:52 -0600 |
|---|---|---|
| committer | Minty-Meeo <45425365+Minty-Meeo@users.noreply.github.com> | 2022-03-19 17:13:28 -0500 |
| commit | deba9ce2564485c7fe078d4e73d0d2cba722b1ac (patch) | |
| tree | 4b8042a15afb07fd380f4d894eadfd9f055fff55 /Source/Core/DiscIO | |
| parent | 75ad057b08a85e8bf76153a6fe5b0b696bfc34fe (diff) | |
Added a way to check Block Size, Compression Method, and Compression Level flags to dolphin-tool
New dolphin-tool command: "header"
-b / --block_size
-c / --compression
-l / --compression_level
Informative RVZ/WIA header2 value "compression_level" is now a s32 instead of a u32, because negative compression is a thing.
Speaking of, it is now possible to use negative compression levels in dolphin-tool's convert command (not the GUI, though).
Diffstat (limited to 'Source/Core/DiscIO')
| -rw-r--r-- | Source/Core/DiscIO/Blob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/CISOBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/CompressedBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/DirectoryBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/DriveBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/FileBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/ScrubbedBlob.h | 4 | ||||
| -rw-r--r-- | Source/Core/DiscIO/TGCBlob.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeFileBlobReader.cpp | 5 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeFileBlobReader.h | 1 | ||||
| -rw-r--r-- | Source/Core/DiscIO/WIABlob.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/DiscIO/WIABlob.h | 8 | ||||
| -rw-r--r-- | Source/Core/DiscIO/WbfsBlob.h | 1 |
13 files changed, 31 insertions, 5 deletions
diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h index 0a7cf09664..03a8644de5 100644 --- a/Source/Core/DiscIO/Blob.h +++ b/Source/Core/DiscIO/Blob.h @@ -59,6 +59,7 @@ public: virtual u64 GetBlockSize() const = 0; virtual bool HasFastRandomAccessInBlock() const = 0; virtual std::string GetCompressionMethod() const = 0; + virtual std::optional<int> GetCompressionLevel() const = 0; // NOT thread-safe - can't call this from multiple threads. virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0; diff --git a/Source/Core/DiscIO/CISOBlob.h b/Source/Core/DiscIO/CISOBlob.h index 48acdb0b59..e7dacb3647 100644 --- a/Source/Core/DiscIO/CISOBlob.h +++ b/Source/Core/DiscIO/CISOBlob.h @@ -46,6 +46,7 @@ public: u64 GetBlockSize() const override { return m_block_size; } bool HasFastRandomAccessInBlock() const override { return true; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/CompressedBlob.h b/Source/Core/DiscIO/CompressedBlob.h index c7e81bf2d6..e32cc2569d 100644 --- a/Source/Core/DiscIO/CompressedBlob.h +++ b/Source/Core/DiscIO/CompressedBlob.h @@ -58,6 +58,7 @@ public: u64 GetBlockSize() const override { return m_header.block_size; } bool HasFastRandomAccessInBlock() const override { return false; } std::string GetCompressionMethod() const override { return "Deflate"; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } u64 GetBlockCompressedSize(u64 block_num) const; bool GetBlock(u64 block_num, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/DirectoryBlob.h b/Source/Core/DiscIO/DirectoryBlob.h index 766ead1a7a..3e8c4d9292 100644 --- a/Source/Core/DiscIO/DirectoryBlob.h +++ b/Source/Core/DiscIO/DirectoryBlob.h @@ -280,6 +280,7 @@ public: u64 GetBlockSize() const override { return 0; } bool HasFastRandomAccessInBlock() const override { return true; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } private: struct PartitionWithType diff --git a/Source/Core/DiscIO/DriveBlob.h b/Source/Core/DiscIO/DriveBlob.h index 3710fd0f39..afe3dc8953 100644 --- a/Source/Core/DiscIO/DriveBlob.h +++ b/Source/Core/DiscIO/DriveBlob.h @@ -32,6 +32,7 @@ public: u64 GetBlockSize() const override { return ECC_BLOCK_SIZE; } bool HasFastRandomAccessInBlock() const override { return false; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } private: DriveReader(const std::string& drive); diff --git a/Source/Core/DiscIO/FileBlob.h b/Source/Core/DiscIO/FileBlob.h index eb944e6d06..ea0bd55b89 100644 --- a/Source/Core/DiscIO/FileBlob.h +++ b/Source/Core/DiscIO/FileBlob.h @@ -27,6 +27,7 @@ public: u64 GetBlockSize() const override { return 0; } bool HasFastRandomAccessInBlock() const override { return true; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/ScrubbedBlob.h b/Source/Core/DiscIO/ScrubbedBlob.h index 2b046bec86..6530860afe 100644 --- a/Source/Core/DiscIO/ScrubbedBlob.h +++ b/Source/Core/DiscIO/ScrubbedBlob.h @@ -33,6 +33,10 @@ public: { return m_blob_reader->GetCompressionMethod(); } + std::optional<int> GetCompressionLevel() const override + { + return m_blob_reader->GetCompressionLevel(); + } bool Read(u64 offset, u64 size, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/TGCBlob.h b/Source/Core/DiscIO/TGCBlob.h index caa9bc8f02..b6d393ea7d 100644 --- a/Source/Core/DiscIO/TGCBlob.h +++ b/Source/Core/DiscIO/TGCBlob.h @@ -50,6 +50,7 @@ public: u64 GetBlockSize() const override { return 0; } bool HasFastRandomAccessInBlock() const override { return true; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.cpp b/Source/Core/DiscIO/VolumeFileBlobReader.cpp index 098871b596..f6be7e3a34 100644 --- a/Source/Core/DiscIO/VolumeFileBlobReader.cpp +++ b/Source/Core/DiscIO/VolumeFileBlobReader.cpp @@ -58,6 +58,11 @@ std::string VolumeFileBlobReader::GetCompressionMethod() const return m_volume.GetBlobReader().GetCompressionMethod(); } +std::optional<int> VolumeFileBlobReader::GetCompressionLevel() const +{ + return m_volume.GetBlobReader().GetCompressionLevel(); +} + bool VolumeFileBlobReader::Read(u64 offset, u64 length, u8* out_ptr) { if (offset + length > m_file_info->GetSize()) diff --git a/Source/Core/DiscIO/VolumeFileBlobReader.h b/Source/Core/DiscIO/VolumeFileBlobReader.h index 0489158577..88b0929cbc 100644 --- a/Source/Core/DiscIO/VolumeFileBlobReader.h +++ b/Source/Core/DiscIO/VolumeFileBlobReader.h @@ -30,6 +30,7 @@ public: u64 GetBlockSize() const override; bool HasFastRandomAccessInBlock() const override; std::string GetCompressionMethod() const override; + std::optional<int> GetCompressionLevel() const override; bool Read(u64 offset, u64 length, u8* out_ptr) override; diff --git a/Source/Core/DiscIO/WIABlob.cpp b/Source/Core/DiscIO/WIABlob.cpp index fa83e73043..8ef5a3f6b0 100644 --- a/Source/Core/DiscIO/WIABlob.cpp +++ b/Source/Core/DiscIO/WIABlob.cpp @@ -56,7 +56,7 @@ static void PushBack(std::vector<u8>* vector, const T& x) PushBack(vector, x_ptr, x_ptr + sizeof(T)); } -std::pair<int, int> GetAllowedCompressionLevels(WIARVZCompressionType compression_type) +std::pair<int, int> GetAllowedCompressionLevels(WIARVZCompressionType compression_type, bool gui) { switch (compression_type) { @@ -68,7 +68,10 @@ std::pair<int, int> GetAllowedCompressionLevels(WIARVZCompressionType compressio // The actual minimum level can be gotten by calling ZSTD_minCLevel(). However, returning that // would make the UI rather weird, because it is a negative number with very large magnitude. // Note: Level 0 is a special number which means "default level" (level 3 as of this writing). - return {1, ZSTD_maxCLevel()}; + if (gui) + return {1, ZSTD_maxCLevel()}; + else + return {ZSTD_minCLevel(), ZSTD_maxCLevel()}; default: return {0, -1}; } @@ -1985,7 +1988,8 @@ WIARVZFileReader<RVZ>::Convert(BlobReader* infile, const VolumeDisc* infile_volu header_2.disc_type = Common::swap32(disc_type); header_2.compression_type = Common::swap32(static_cast<u32>(compression_type)); - header_2.compression_level = Common::swap32(static_cast<u32>(compression_level)); + header_2.compression_level = + static_cast<s32>(Common::swap32(static_cast<u32>(compression_level))); header_2.chunk_size = Common::swap32(static_cast<u32>(chunk_size)); header_2.number_of_partition_entries = Common::swap32(static_cast<u32>(partition_entries.size())); diff --git a/Source/Core/DiscIO/WIABlob.h b/Source/Core/DiscIO/WIABlob.h index d13476762b..abfa829397 100644 --- a/Source/Core/DiscIO/WIABlob.h +++ b/Source/Core/DiscIO/WIABlob.h @@ -34,7 +34,7 @@ enum class WIARVZCompressionType : u32 Zstd = 5, }; -std::pair<int, int> GetAllowedCompressionLevels(WIARVZCompressionType compression_type); +std::pair<int, int> GetAllowedCompressionLevels(WIARVZCompressionType compression_type, bool gui); constexpr u32 WIA_MAGIC = 0x01414957; // "WIA\x1" (byteswapped to little endian) constexpr u32 RVZ_MAGIC = 0x015A5652; // "RVZ\x1" (byteswapped to little endian) @@ -56,6 +56,10 @@ public: u64 GetBlockSize() const override { return Common::swap32(m_header_2.chunk_size); } bool HasFastRandomAccessInBlock() const override { return false; } std::string GetCompressionMethod() const override; + std::optional<int> GetCompressionLevel() const override + { + return static_cast<int>(static_cast<s32>(Common::swap32(m_header_2.compression_level))); + } bool Read(u64 offset, u64 size, u8* out_ptr) override; bool SupportsReadWiiDecrypted(u64 offset, u64 size, u64 partition_data_offset) const override; @@ -89,7 +93,7 @@ private: { u32 disc_type; u32 compression_type; - u32 compression_level; // Informative only + s32 compression_level; // Informative only u32 chunk_size; std::array<u8, 0x80> disc_header; diff --git a/Source/Core/DiscIO/WbfsBlob.h b/Source/Core/DiscIO/WbfsBlob.h index 5260003592..30db2a7d4c 100644 --- a/Source/Core/DiscIO/WbfsBlob.h +++ b/Source/Core/DiscIO/WbfsBlob.h @@ -34,6 +34,7 @@ public: u64 GetBlockSize() const override { return m_wbfs_sector_size; } bool HasFastRandomAccessInBlock() const override { return true; } std::string GetCompressionMethod() const override { return {}; } + std::optional<int> GetCompressionLevel() const override { return std::nullopt; } bool Read(u64 offset, u64 nbytes, u8* out_ptr) override; |
