mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-19 03:55:43 -04:00
[libromdata] ISO: Always use host-endian except for CD-i, in which case, always use big-endian.
Checking for 0 wastes time, since standard ISO-9660 always has both versions filled in, whereas CD-i is big-endian only. The fields were likely kept as-is to make it easier to write tools to handle CD-i format, since it can use existing code on big-endian platforms.
This commit is contained in:
parent
f53eff8bf6
commit
5cfce44312
@ -145,6 +145,26 @@ class ISOPrivate final : public RomDataPrivate
|
|||||||
{
|
{
|
||||||
return static_cast<DiscType>(ISO::checkPVD(pvd.data));
|
return static_cast<DiscType>(ISO::checkPVD(pvd.data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the host-endian version of an LSB/MSB 16-bit value.
|
||||||
|
* @param lm16 LSB/MSB 16-bit value.
|
||||||
|
* @return Host-endian value.
|
||||||
|
*/
|
||||||
|
inline uint16_t host16(const uint16_lsb_msb_t &lm16)
|
||||||
|
{
|
||||||
|
return (likely(discType != DiscType::CDi) ? lm16.he : be16_to_cpu(lm16.be));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the host-endian version of an LSB/MSB 32-bit value.
|
||||||
|
* @param lm32 LSB/MSB 32-bit value.
|
||||||
|
* @return Host-endian value.
|
||||||
|
*/
|
||||||
|
inline uint32_t host32(const uint32_lsb_msb_t &lm32)
|
||||||
|
{
|
||||||
|
return (likely(discType != DiscType::CDi) ? lm32.he : be16_to_cpu(lm32.be));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** ISOPrivate **/
|
/** ISOPrivate **/
|
||||||
@ -271,14 +291,14 @@ void ISOPrivate::addPVDCommon(const T *pvd)
|
|||||||
// Size of volume
|
// Size of volume
|
||||||
fields->addField_string(C_("ISO", "Volume Size"),
|
fields->addField_string(C_("ISO", "Volume Size"),
|
||||||
formatFileSize(
|
formatFileSize(
|
||||||
static_cast<off64_t>(host32ifNZ(&pvd->volume_space_size)) *
|
static_cast<off64_t>(host32(pvd->volume_space_size)) *
|
||||||
static_cast<off64_t>(host16ifNZ(&pvd->logical_block_size))));
|
static_cast<off64_t>(host16(pvd->logical_block_size))));
|
||||||
|
|
||||||
// TODO: Show block size?
|
// TODO: Show block size?
|
||||||
|
|
||||||
// Disc number
|
// Disc number
|
||||||
const uint16_t volume_seq_number = host16ifNZ(&pvd->volume_seq_number);
|
const uint16_t volume_seq_number = host16(pvd->volume_seq_number);
|
||||||
const uint16_t volume_set_size = host16ifNZ(&pvd->volume_set_size);
|
const uint16_t volume_set_size = host16(pvd->volume_set_size);
|
||||||
if (volume_seq_number != 0 && volume_set_size > 1) {
|
if (volume_seq_number != 0 && volume_set_size > 1) {
|
||||||
const char *const disc_number_title = C_("RomData", "Disc #");
|
const char *const disc_number_title = C_("RomData", "Disc #");
|
||||||
fields->addField_string(disc_number_title,
|
fields->addField_string(disc_number_title,
|
||||||
|
@ -81,32 +81,6 @@ typedef union _uint32_lsb_msb_t {
|
|||||||
} uint32_lsb_msb_t;
|
} uint32_lsb_msb_t;
|
||||||
ASSERT_STRUCT(uint32_lsb_msb_t, 8);
|
ASSERT_STRUCT(uint32_lsb_msb_t, 8);
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the host-endian 16-bit value if it's non-zero.
|
|
||||||
* Otherwise, get the swap-endian 16-bit value.
|
|
||||||
*/
|
|
||||||
static inline uint16_t host16ifNZ(const uint16_lsb_msb_t *lm16)
|
|
||||||
{
|
|
||||||
uint16_t val = lm16->he;
|
|
||||||
if (val == 0) {
|
|
||||||
val = __swab16(lm16->se);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the host-endian 32-bit value if it's non-zero.
|
|
||||||
* Otherwise, get the swap-endian 32-bit value.
|
|
||||||
*/
|
|
||||||
static inline uint32_t host32ifNZ(const uint32_lsb_msb_t *lm32)
|
|
||||||
{
|
|
||||||
uint32_t val = lm32->he;
|
|
||||||
if (val == 0) {
|
|
||||||
val = __swab32(lm32->se);
|
|
||||||
}
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ISO-9660 Primary Volume Descriptor date/time struct.
|
* ISO-9660 Primary Volume Descriptor date/time struct.
|
||||||
* Note that the fields are all strings.
|
* Note that the fields are all strings.
|
||||||
|
Loading…
Reference in New Issue
Block a user