mkvparser: minor SeekHead::Entry clean up.

- Store actual element ID in SeekHead::Entry id field (instead
  of a decoded EBML int, which is completely _wrong_).
- Add a SeekHead::Entry constructor so we get initialized values
  in SeekHead::Entry's when parsing an Entry fails.

Change-Id: I152fae54628cb84918917139dba0cd0b42a44a57
This commit is contained in:
Tom Finegan
2016-08-29 13:52:23 -07:00
parent 24fb44aa1a
commit 826436a42f
3 changed files with 6 additions and 16 deletions

View File

@@ -1476,6 +1476,8 @@ long Segment::Load() {
} }
} }
SeekHead::Entry::Entry() : id(0), pos(0), element_start(0), element_size(0) {}
SeekHead::SeekHead(Segment* pSegment, long long start, long long size_, SeekHead::SeekHead(Segment* pSegment, long long start, long long size_,
long long element_start, long long element_size) long long element_start, long long element_size)
: m_pSegment(pSegment), : m_pSegment(pSegment),
@@ -1767,18 +1769,7 @@ bool SeekHead::ParseEntry(IMkvReader* pReader, long long start, long long size_,
if ((pos + seekIdSize) > stop) if ((pos + seekIdSize) > stop)
return false; return false;
// Note that the SeekId payload really is serialized pEntry->id = ReadID(pReader, pos, len); // payload
// as a "Matroska integer", not as a plain binary value.
// In fact, Matroska requires that ID values in the
// stream exactly match the binary representation as listed
// in the Matroska specification.
//
// This parser is more liberal, and permits IDs to have
// any width. (This could make the representation in the stream
// different from what's in the spec, but it doesn't matter here,
// since we always normalize "Matroska integer" values.)
pEntry->id = ReadUInt(pReader, pos, len); // payload
if (pEntry->id <= 0) if (pEntry->id <= 0)
return false; return false;

View File

@@ -844,6 +844,8 @@ class SeekHead {
long Parse(); long Parse();
struct Entry { struct Entry {
Entry();
// the SeekHead entry payload // the SeekHead entry payload
long long id; long long id;
long long pos; long long pos;

View File

@@ -73,10 +73,7 @@ bool HasCuePoints(const mkvparser::Segment* segment,
std::int64_t offset = 0; std::int64_t offset = 0;
for (int i = 0; i < seek_head->GetCount(); ++i) { for (int i = 0; i < seek_head->GetCount(); ++i) {
const SeekHead::Entry* const entry = seek_head->GetEntry(i); const SeekHead::Entry* const entry = seek_head->GetEntry(i);
// TODO(tomfinegan): Cues ID is really 0x1C53BB6B, aka kMkvCues, but if (entry->id == libwebm::kMkvCues) {
// mkvparser reads IDs as EBML unsigned ints in some cases, yielding magic
// numbers like the following. Investigate fixing this behavior.
if (entry->id == 0xC53BB6B) { // Cues ID as stored in Entry class.
offset = entry->pos; offset = entry->pos;
} }
} }