aboutsummaryrefslogtreecommitdiff
path: root/Src/nsmkv/SeekTable.h
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/nsmkv/SeekTable.h
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/nsmkv/SeekTable.h')
-rw-r--r--Src/nsmkv/SeekTable.h54
1 files changed, 54 insertions, 0 deletions
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 <map>
+#include <vector>
+#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<SeekEntry> SeekEntries;
+ typedef std::map<uint64_t, SeekEntries*> 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