mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
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:
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user