mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:47:34 +00:00
LibRIFF: Rework to match LibGfx needs
There's now two namespaces, RIFF (little-endian) and IFF (big-endian) which (for the most part) contain the same kinds of structures for handling similar data in both formats. (They also share almost all of their implementation) The main types are ChunkHeader and (Owned)Chunk. While Chunk has no ownership over the data it accesses (and can only be constructed from a byte view), OwnedChunk has ownership over this data and is aimed at reading from streams. OwnedList, implementing the standard RIFF LIST type, is currently only implemented for RIFF due to its only user being WAV, but it may be generalized in the future for use by IFF. Co-authored-by: Timothy Flynn <trflynn89@pm.me>
This commit is contained in:
parent
d125d16287
commit
64598473cc
11 changed files with 366 additions and 145 deletions
35
Userland/Libraries/LibRIFF/RIFF.h
Normal file
35
Userland/Libraries/LibRIFF/RIFF.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, the SerenityOS developers.
|
||||
* Copyright (c) 2023, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibRIFF/ChunkID.h>
|
||||
#include <LibRIFF/Details.h>
|
||||
|
||||
// RIFF chunks (as often used by Microsoft's older formats) use little-endian fields.
|
||||
namespace RIFF {
|
||||
|
||||
static constexpr StringView const riff_magic = "RIFF"sv;
|
||||
static constexpr StringView const list_chunk_id = "LIST"sv;
|
||||
|
||||
using WordType = LittleEndian<u32>;
|
||||
using ChunkHeader = RIFF::Detail::ChunkHeader<WordType>;
|
||||
using FileHeader = RIFF::Detail::FileHeader<ChunkHeader>;
|
||||
using Chunk = RIFF::Detail::Chunk<ChunkHeader>;
|
||||
using OwnedChunk = RIFF::Detail::OwnedChunk<ChunkHeader>;
|
||||
|
||||
// http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Docs/riffmci.pdf page 23 (LIST type)
|
||||
struct OwnedList {
|
||||
static ErrorOr<OwnedList> read_from_stream(Stream& stream);
|
||||
|
||||
ChunkID type;
|
||||
Vector<OwnedChunk> chunks;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue