namespace mkvparser {
const float MasteringMetadata::kValueNotPresent = FLT_MAX;
const long long Colour::kValueNotPresent = LLONG_MAX;
-const float Projection::kValueNotPresent = FLT_MAX;
#ifdef MSC_COMPAT
inline bool isnan(double val) { return !!_isnan(val); }
}
}
-SeekHead::Entry::Entry() : id(0), pos(0), element_start(0), element_size(0) {}
-
SeekHead::SeekHead(Segment* pSegment, long long start, long long size_,
long long element_start, long long element_size)
: m_pSegment(pSegment),
if ((pos + seekIdSize) > stop)
return false;
- pEntry->id = ReadID(pReader, pos, len); // payload
+ // Note that the SeekId payload really is serialized
+ // 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)
return false;
return true;
}
-bool Projection::Parse(IMkvReader* reader, long long start, long long size,
- Projection** projection) {
- if (!reader || *projection)
- return false;
-
- std::auto_ptr<Projection> projection_ptr(new Projection());
- if (!projection_ptr.get())
- return false;
-
- const long long end = start + size;
- long long read_pos = start;
-
- while (read_pos < end) {
- long long child_id = 0;
- long long child_size = 0;
-
- const long long status =
- ParseElementHeader(reader, read_pos, end, child_id, child_size);
- if (status < 0)
- return false;
-
- if (child_id == libwebm::kMkvProjectionType) {
- long long projection_type = kTypeNotPresent;
- projection_type = UnserializeUInt(reader, read_pos, child_size);
- if (projection_type < 0)
- return false;
-
- projection_ptr->type = static_cast<ProjectionType>(projection_type);
- } else if (child_id == libwebm::kMkvProjectionPrivate) {
- unsigned char* data = SafeArrayAlloc<unsigned char>(1, child_size);
-
- if (data == NULL)
- return false;
-
- const int status =
- reader->Read(read_pos, static_cast<long>(child_size), data);
-
- if (status) {
- delete[] data;
- return status;
- }
-
- projection_ptr->private_data = data;
- projection_ptr->private_data_length = static_cast<size_t>(child_size);
- } else {
- double value = 0;
- const long long value_parse_status =
- UnserializeFloat(reader, read_pos, child_size, value);
- if (value_parse_status < 0) {
- return false;
- }
-
- switch (child_id) {
- case libwebm::kMkvProjectionPoseYaw:
- projection_ptr->pose_yaw = static_cast<float>(value);
- break;
- case libwebm::kMkvProjectionPosePitch:
- projection_ptr->pose_pitch = static_cast<float>(value);
- break;
- case libwebm::kMkvProjectionPoseRoll:
- projection_ptr->pose_roll = static_cast<float>(value);
- break;
- default:
- return false;
- }
- }
-
- read_pos += child_size;
- if (read_pos > end)
- return false;
- }
-
- *projection = projection_ptr.release();
- return true;
-}
-
VideoTrack::VideoTrack(Segment* pSegment, long long element_start,
long long element_size)
- : Track(pSegment, element_start, element_size),
- m_colour(NULL),
- m_projection(NULL) {}
+ : Track(pSegment, element_start, element_size), m_colour(NULL) {}
-VideoTrack::~VideoTrack() {
- delete m_colour;
- delete m_projection;
-}
+VideoTrack::~VideoTrack() { delete m_colour; }
long VideoTrack::Parse(Segment* pSegment, const Info& info,
long long element_start, long long element_size,
const long long stop = pos + s.size;
Colour* colour = NULL;
- Projection* projection = NULL;
while (pos < stop) {
long long id, size;
} else if (id == libwebm::kMkvColour) {
if (!Colour::Parse(pReader, pos, size, &colour))
return E_FILE_FORMAT_INVALID;
- } else if (id == libwebm::kMkvProjection) {
- if (!Projection::Parse(pReader, pos, size, &projection))
- return E_FILE_FORMAT_INVALID;
}
pos += size; // consume payload
pTrack->m_stereo_mode = stereo_mode;
pTrack->m_rate = rate;
pTrack->m_colour = colour;
- pTrack->m_projection = projection;
pResult = pTrack;
return 0; // success
Colour* VideoTrack::GetColour() const { return m_colour; }
-Projection* VideoTrack::GetProjection() const { return m_projection; }
-
long long VideoTrack::GetWidth() const { return m_width; }
long long VideoTrack::GetHeight() const { return m_height; }
{}
Cluster::~Cluster() {
- if (m_entries_count <= 0) {
- delete[] m_entries;
+ if (m_entries_count <= 0)
return;
- }
BlockEntry** i = m_entries;
BlockEntry** const j = m_entries + m_entries_count;