From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/nsmkv/SeekTable.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Src/nsmkv/SeekTable.h (limited to 'Src/nsmkv/SeekTable.h') diff --git a/Src/nsmkv/SeekTable.h b/Src/nsmkv/SeekTable.h new file mode 100644 index 00000000..774ddcf9 --- /dev/null +++ b/Src/nsmkv/SeekTable.h @@ -0,0 +1,54 @@ +#pragma once +#include +#include +#include "mkv_reader.h" + +const uint32_t mkv_metaseek_seekhead = 0x14d9b74; +const uint32_t mkv_metaseek_seek=0xdbb; +const uint32_t mkv_metaseek_seekid = 0x13ab; +const uint32_t mkv_metaseek_seekposition=0x13ac; + +/* this represents a seek table of other nodes in EBML + be careful, CuePoints (CuePoints.h) is for seeking to a certain time in the song +the SeekTable (SeekTable.h) is for fast indexing of the mkv file structure +*/ +namespace nsmkv +{ + class SeekEntry + { + public: + SeekEntry() + { + id=0; + position=0; + } + SeekEntry(uint64_t id, uint64_t position) : id(id), position(position) + { + } + uint64_t id; // ID of the EBML node + uint64_t position; + }; + + class SeekTable + { + public: + void AddEntry(SeekEntry &entry, int flags=0); + void Dump(); + bool GetEntry(uint64_t id, uint64_t *position); + bool EnumEntry(size_t i, uint64_t id, uint64_t *position); + + enum // flags for AddEntry + { + ADDENTRY_SINGLE = 0x1, // if there can only be one + ADDENTRY_FOUND = 0x2, // pass this is you physically found the entry in the file - this takes priority over the SeekHead + }; + private: + bool EnumEntry(size_t i, uint64_t id, SeekEntry **seek_entry); + typedef std::vector SeekEntries; + typedef std::map SeekMap; + SeekMap seekMap; + }; + + // returns bytes read. 0 means EOF + uint64_t ReadSeekHead(nsmkv::MKVReader *reader, uint64_t size, nsmkv::SeekTable &seekTable); +} \ No newline at end of file -- cgit