diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.cpp index efa6a0903e4..ad9413527c3 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Boxes.cpp @@ -12,7 +12,7 @@ ErrorOr read_box_header(Stream& stream) { BoxHeader header; u64 total_size = TRY(stream.read_value>()); - header.type = TRY(stream.read_value()); + header.type = TRY(stream.read_value>()); u64 data_size_read = sizeof(u32) + sizeof(BoxType); @@ -68,7 +68,7 @@ void UnknownBox::dump(String const& prepend) const ErrorOr FileTypeBox::read_from_stream(BoxStream& stream) { // unsigned int(32) major_brand; - major_brand = TRY(stream.read_value()); + major_brand = TRY(stream.read_value>()); // unsigned int(32) minor_version; minor_version = TRY(stream.read_value>()); @@ -77,7 +77,7 @@ ErrorOr FileTypeBox::read_from_stream(BoxStream& stream) return Error::from_string_literal("FileTypeBox compatible_brands contains a partial brand"); for (auto minor_brand_count = stream.remaining() / sizeof(BrandIdentifier); minor_brand_count > 0; minor_brand_count--) - TRY(compatible_brands.try_append(TRY(stream.read_value()))); + TRY(compatible_brands.try_append(TRY(stream.read_value>()))); return {}; } diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Enums.h b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Enums.h index 4716dc30c52..02073340314 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Enums.h +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Enums.h @@ -23,7 +23,7 @@ namespace Gfx::ISOBMFF { enum class BoxType : u32 { None = 0, -#define ENUMERATE_ONE(box_name, box_4cc) box_name = RIFF::ChunkID(#box_4cc).as_big_endian_number(), +#define ENUMERATE_ONE(box_name, box_4cc) box_name = RIFF::ChunkID(#box_4cc).as_number(), ENUMERATE_ALL() @@ -54,7 +54,7 @@ static bool is_valid_box_type(BoxType type) enum class BrandIdentifier : u32 { None = 0, -#define ENUMERATE_ONE(brand_4cc) brand_4cc = RIFF::ChunkID(#brand_4cc).as_big_endian_number(), +#define ENUMERATE_ONE(brand_4cc) brand_4cc = RIFF::ChunkID(#brand_4cc).as_number(), ENUMERATE_ALL() @@ -70,7 +70,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Gfx::ISOBMFF::BoxType const& box_type) { StringView format_string = Gfx::ISOBMFF::is_valid_box_type(box_type) ? "({})"sv : "Unknown Box ({})"sv; - return Formatter::format(builder, format_string, RIFF::ChunkID::from_big_endian_number(to_underlying(box_type))); + return Formatter::format(builder, format_string, RIFF::ChunkID::from_number(to_underlying(box_type))); } }; @@ -78,6 +78,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Gfx::ISOBMFF::BrandIdentifier const& brand_identifier) { - return Formatter::format(builder, "{}"sv, RIFF::ChunkID::from_big_endian_number(to_underlying(brand_identifier))); + return Formatter::format(builder, "{}"sv, RIFF::ChunkID::from_number(to_underlying(brand_identifier))); } }; diff --git a/Userland/Libraries/LibRIFF/ChunkID.h b/Userland/Libraries/LibRIFF/ChunkID.h index a47e2860bf7..54401841c1a 100644 --- a/Userland/Libraries/LibRIFF/ChunkID.h +++ b/Userland/Libraries/LibRIFF/ChunkID.h @@ -32,14 +32,22 @@ struct ChunkID { constexpr ChunkID(ChunkID const&) = default; constexpr ChunkID(ChunkID&&) = default; constexpr ChunkID& operator=(ChunkID const&) = default; - static constexpr ChunkID from_big_endian_number(u32 number) { return bit_cast>(AK::convert_between_host_and_big_endian(number)); } + static constexpr ChunkID from_number(u32 number) + { + return Array { { + static_cast((number >> 24) & 0xff), + static_cast((number >> 16) & 0xff), + static_cast((number >> 8) & 0xff), + static_cast(number & 0xff), + } }; + } static ErrorOr read_from_stream(Stream& stream); StringView as_ascii_string() const; - constexpr u32 as_big_endian_number() const + constexpr u32 as_number() const { - return AK::convert_between_host_and_big_endian((id_data[0] << 24) | (id_data[1] << 16) | (id_data[2] << 8) | id_data[3]); + return (id_data[0] << 24) | (id_data[1] << 16) | (id_data[2] << 8) | id_data[3]; } bool operator==(ChunkID const&) const = default;