]> granicus.if.org Git - libvpx/blobdiff - third_party/libwebm/mkvparser/mkvparser.cc
Revert "third_party: Roll libwebm snapshot."
[libvpx] / third_party / libwebm / mkvparser / mkvparser.cc
index d92637b754e66dd030c4c40708456565ba79bf14..21801154d9f5649515320171b14b8d38e7f181c8 100644 (file)
@@ -25,7 +25,6 @@
 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); }
@@ -1476,8 +1475,6 @@ 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_,
                    long long element_start, long long element_size)
     : m_pSegment(pSegment),
@@ -1769,7 +1766,18 @@ bool SeekHead::ParseEntry(IMkvReader* pReader, long long start, long long size_,
   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;
@@ -5180,92 +5188,11 @@ bool Colour::Parse(IMkvReader* reader, long long colour_start,
   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,
@@ -5297,7 +5224,6 @@ long VideoTrack::Parse(Segment* pSegment, const Info& info,
   const long long stop = pos + s.size;
 
   Colour* colour = NULL;
-  Projection* projection = NULL;
 
   while (pos < stop) {
     long long id, size;
@@ -5348,9 +5274,6 @@ long VideoTrack::Parse(Segment* pSegment, const Info& info,
     } 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
@@ -5382,7 +5305,6 @@ long VideoTrack::Parse(Segment* pSegment, const Info& info,
   pTrack->m_stereo_mode = stereo_mode;
   pTrack->m_rate = rate;
   pTrack->m_colour = colour;
-  pTrack->m_projection = projection;
 
   pResult = pTrack;
   return 0;  // success
@@ -5483,8 +5405,6 @@ long VideoTrack::Seek(long long time_ns, const BlockEntry*& pResult) const {
 
 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; }
@@ -6778,10 +6698,8 @@ Cluster::Cluster(Segment* pSegment, long idx, long long element_start
 {}
 
 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;