diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-riff.cpp | 13 | ||||
| -rw-r--r-- | source/core/slang-riff.h | 17 |
2 files changed, 28 insertions, 2 deletions
diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp index 2e633f2e7..1de51d840 100644 --- a/source/core/slang-riff.cpp +++ b/source/core/slang-riff.cpp @@ -548,6 +548,19 @@ void RiffContainer::ListChunk::findContained(FourCC type, List<ListChunk*>& out) } } +void RiffContainer::ListChunk::findContained(FourCC type, List<DataChunk*>& out) +{ + Chunk* chunk = m_containedChunks; + while (chunk) + { + if (chunk->m_fourCC == type && chunk->m_kind == Chunk::Kind::Data) + { + out.add(static_cast<DataChunk*>(chunk)); + } + chunk = chunk->m_next; + } +} + RiffContainer::Data* RiffContainer::ListChunk::findContainedData(FourCC type) const { Chunk* found = findContained(type); diff --git a/source/core/slang-riff.h b/source/core/slang-riff.h index 99d078625..61e6eed1e 100644 --- a/source/core/slang-riff.h +++ b/source/core/slang-riff.h @@ -109,8 +109,8 @@ public: { return SLANG_FAIL; } - // Make sure the alignment is plausible - SLANG_ASSERT((size_t(m_cur) & (SLANG_ALIGN_OF(T) - 1)) == 0); + // TODO: consider whether this type should enforce alignment. + // SLANG_ASSERT((size_t(m_cur) & (SLANG_ALIGN_OF(T) - 1)) == 0); ::memcpy(&out, m_cur, sizeof(T)); m_cur += sizeof(T); return SLANG_OK; @@ -128,6 +128,16 @@ public: { } + SlangResult skip(size_t size) + { + if (m_cur + size > m_end) + { + return SLANG_FAIL; + } + m_cur += size; + return SLANG_OK; + } + protected: const uint8_t* m_start; const uint8_t* m_end; @@ -248,6 +258,9 @@ public: /// Find all contained that match the type void findContained(FourCC type, List<ListChunk*>& out); + /// Find all contained that match the type + void findContained(FourCC type, List<DataChunk*>& out); + /// Find the list (including self) that matches subtype recursively ListChunk* findListRec(FourCC subType); |
