mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:57:46 +00:00
LibGfx: Add initial ISO BMFF parsing and a utility to print file info
Currently, the `isobmff` utility will only print the media file type info from the FileTypeBox (major brand and compatible brands), as well as the names and sizes of top-level boxes.
This commit is contained in:
parent
9caa0bda7d
commit
66c9696687
13 changed files with 510 additions and 0 deletions
37
Tests/LibGfx/TestParseISOBMFF.cpp
Normal file
37
Tests/LibGfx/TestParseISOBMFF.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Gregory Bertilson <zaggy1024@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/MemoryStream.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibGfx/ImageFormats/ISOBMFF/Reader.h>
|
||||
|
||||
TEST_CASE(parse_animated_avif)
|
||||
{
|
||||
auto file = MUST(Core::MappedFile::map("./test-inputs/loop_forever.avif"sv));
|
||||
auto reader = MUST(Gfx::ISOBMFF::Reader::create(MUST(try_make<FixedMemoryStream>(file->bytes()))));
|
||||
auto boxes = MUST(reader.read_entire_file());
|
||||
|
||||
for (auto& box : boxes)
|
||||
box->dump();
|
||||
|
||||
VERIFY(boxes.size() == 4);
|
||||
VERIFY(boxes[0]->box_type() == Gfx::ISOBMFF::BoxType::FileTypeBox);
|
||||
auto& file_type_box = static_cast<Gfx::ISOBMFF::FileTypeBox&>(*boxes[0]);
|
||||
VERIFY(file_type_box.major_brand == Gfx::ISOBMFF::BrandIdentifier::avis);
|
||||
VERIFY(file_type_box.minor_version == 0);
|
||||
Vector<Gfx::ISOBMFF::BrandIdentifier, 7> expected_compatible_brands = {
|
||||
Gfx::ISOBMFF::BrandIdentifier::avif,
|
||||
Gfx::ISOBMFF::BrandIdentifier::avis,
|
||||
Gfx::ISOBMFF::BrandIdentifier::msf1,
|
||||
Gfx::ISOBMFF::BrandIdentifier::iso8,
|
||||
Gfx::ISOBMFF::BrandIdentifier::mif1,
|
||||
Gfx::ISOBMFF::BrandIdentifier::miaf,
|
||||
Gfx::ISOBMFF::BrandIdentifier::MA1A,
|
||||
};
|
||||
VERIFY(file_type_box.compatible_brands == expected_compatible_brands);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue