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).
This commit is contained in:
Minty-Meeo
2022-02-24 04:51:52 -06:00
parent 75ad057b08
commit deba9ce256
20 changed files with 167 additions and 8 deletions

View File

@ -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;