summaryrefslogtreecommitdiff
path: root/third_party/libwebm/mkvparser
diff options
context:
space:
mode:
authorFrank Galligan <fgalligan@google.com>2016-10-17 12:41:39 -0700
committerFrank Galligan <fgalligan@google.com>2016-10-17 12:45:05 -0700
commit808a560be6a71dd0d27f29c26f9fefb5e809d373 (patch)
tree0cccb37802013e6ac2b8447acccd4695c3762924 /third_party/libwebm/mkvparser
parent9e8efa5b189a5abf78b1bcbc8076893728129d1e (diff)
downloadlibvpx-808a560be6a71dd0d27f29c26f9fefb5e809d373.tar
libvpx-808a560be6a71dd0d27f29c26f9fefb5e809d373.tar.gz
libvpx-808a560be6a71dd0d27f29c26f9fefb5e809d373.tar.bz2
libvpx-808a560be6a71dd0d27f29c26f9fefb5e809d373.zip
third_party: Roll libwebm snapshot.
fc5f88d Fix temp files being left on system. c04a134 Add support for overriding PixelWidth and PixelHeight. c0160e0 Add support to explicitly set segment duration. 02bc809 Add support to estimate file duration. c97e3e7 Add support to output sub-sample encryption information. 26f4344 MakeUID: quiet unused param warning in Android builds d6af52a Change check to fix compile error. 1720020 webm_parser: Add Mesh value for ProjectionType 78f2c5a webm_parser: Use ./ prefix for includes da62f65 webm_parser: Remove webm/ prefix from public includes e15e8f2 webm_parser: Update README build instructions 5023f2b mkvmuxer: Fix Colour::Valid() cf16204 mkvmuxer_tests: Actually test cue points in the cue point test. 93e9fb3 Validate Colour element values. 8036925 mkvparser_tests: Add Projection element test. f52d38c mkvparser_tests: Add Colour element test. 826436a mkvparser: minor SeekHead::Entry clean up. 24fb44a mkvmuxer_tests: Add Projection element test. 1e0a8ea mkvmuxer_tests: Add Colour element test. 0278616 mkvmuxer: Colour accessors/mutators. 2346f8f Add mkvparser wrapper functions. 54d6b6b webm_info: Add Projection element support. 65fee06 mkvmuxer_sample: Add support for Projection element. 9a3f2b5 mkvparser_sample: Add support for Projection element. 41e814a mkvparser: Add Projection element support. 483a0ff mkvmuxer: Add Projection element support. 676a713 Add support for the Projection element 725f362 mkvmuxer: Fix memory leak when Colour is set multiple times. fa182de mkvparser_sample: Add output of audio track codec private size. 8f521f2 mkvparser_tests: Add invalid BlockGroup test. 39137d7 Remove docs saying binary elements default to 0 c147504 Fix legacy Makefile. 80685d3 Do not skip over unknown elements at the root level 58711e8 mkvparser_sample: Fix version info string. 837746f mkvparser_tests: Add invalid block test. 207cd80 Disambiguate sample sources and targets. a112d71 mkvparser_tests: Refactor invalid file loading code. 5dea33e Disambiguate test source and target names. 125049e parser_tests: Add another truncated chapter string test. 1de8d4c parser_tests: Add truncated chapter string test. ff8c2b6 parser_tests: Move cue validation to test_util. 4b0690f parser_tests: Add invalid lacing test. 9828e39 mkvmuxer: Set default doc type version to 4. 5495a59 webm_parser: Reference more files in CMakeLists.txt. 0c0ecd0 vpxpes_parser: Add start code emulation prevention support. 639a4bc webm2pes: Remove debug printfs(). 9a51102 webm2pes: fflush() in the correct conversion function. dc7f155 webm2pes: Track total bytes written. d518128 webm_parser: Enable usage of werror. e1fe762 webm2pes: Add test for mux/demux of large input. 1b24a79 vpxpes_parser: Read and store PTS when present. 6cf0a0f vpxpes_parser: Store frame payloads. 25d2602 webm_parser: Convert style to match the rest of libwebm 24be76d webm2pes: Replace VpxFrame with VideoFrame. b451c3b Add a basic video frame storage class. 05c90eb libwebm_util: Clarify error text in superframe parser. e6415af webm2pes: Make WritePesPacket() a public method. 8f840dd webm2pes: Move frame read out of PES packet write method. 448af97 webm2pes: Restore frame fragmentation support. f8bb714 cmake: Integrate new parsing API and tests. cb8ce0b Add a new incremental parsing API 900d322 vpxpes_parser/webm2pes: BCMV and PTS fixes. 4b73545 webm2pes: Add start code emulation prevention. 82903f3 Add column tiles and frame parallel to webm_info 5d91edf style_clean_up: Remove unnecessary parentheses a95aa4b vp9_level_stats: correct total_uncompressed_bits_ calculation f46566f mkvreader: Fix shorten-64-to-32 warning in 32 bit builds. 76630ca mkvwriter: Fix shorten-64-to-32 warning in 32 bit builds. a8ffbd4 webm2pes: Fix format specifier warnings. faf89d4 Add MaxLumaSampleRate grace percent to stats. d31e6c9 Fix profile 2 in vp9_header_parser. bd3ab3a Add flag to estimate last frame's duration to stats. c182ed9 Fix lint issue in hdr_util.h cc62ecd Add test for Cluster memory leak 196708a Change MaxLumaSampleRate to be based on frame resolution. cbd676b mkvmuxer: Fix leak when a Cluster isn't finalized 47f2843 Add parsing support for new features in CodecPrivate. 9a235e0 mkvmuxer: Set doctype to matroska when muxing non-WebM codecs. e3c9576 Add VP9 level output to webm_info. bbaaf2d Add class to gather VP9 level stats. 5cf549f cmake: Log compiler flag at check time. 8bb68c2 Add file to parse data from VP9 frames. df3412f Add support for setting VP9 profile and level to sample_muxer. 296429a Add support to parse VP9 profile. 87832d4 mkvmuxer: Fix Segment::Finalize in kLive mode 6df3e56 mkvmuxerutil.hpp: Add using directives for overloaded size utils. ec47928 mkvmuxerutil: Revert to using mkvmuxertypes. 4e3d037 Add support to output Colour elements to webm_info. a1dc4f2 Fix parsing of VP9 level. 039df94 Add TEST_TMPDIR environment variable d3656fd muxer_tests: ignore iwyu re gtest-message.h e76dd5e Fix file name in mkvmuxertypes shim. 1be5889 Add temporary include shims at old file locations. Change-Id: I6a1026814560be80d604a5ecb9b66406a1186dd9
Diffstat (limited to 'third_party/libwebm/mkvparser')
-rw-r--r--third_party/libwebm/mkvparser/mkvparser.cc112
-rw-r--r--third_party/libwebm/mkvparser/mkvparser.h33
-rw-r--r--third_party/libwebm/mkvparser/mkvreader.cc4
3 files changed, 132 insertions, 17 deletions
diff --git a/third_party/libwebm/mkvparser/mkvparser.cc b/third_party/libwebm/mkvparser/mkvparser.cc
index 21801154d..d92637b75 100644
--- a/third_party/libwebm/mkvparser/mkvparser.cc
+++ b/third_party/libwebm/mkvparser/mkvparser.cc
@@ -25,6 +25,7 @@
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); }
@@ -1475,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_,
long long element_start, long long element_size)
: m_pSegment(pSegment),
@@ -1766,18 +1769,7 @@ bool SeekHead::ParseEntry(IMkvReader* pReader, long long start, long long size_,
if ((pos + seekIdSize) > stop)
return false;
- // 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
+ pEntry->id = ReadID(pReader, pos, len); // payload
if (pEntry->id <= 0)
return false;
@@ -5188,11 +5180,92 @@ 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) {}
+ : Track(pSegment, element_start, element_size),
+ m_colour(NULL),
+ m_projection(NULL) {}
-VideoTrack::~VideoTrack() { delete m_colour; }
+VideoTrack::~VideoTrack() {
+ delete m_colour;
+ delete m_projection;
+}
long VideoTrack::Parse(Segment* pSegment, const Info& info,
long long element_start, long long element_size,
@@ -5224,6 +5297,7 @@ 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;
@@ -5274,6 +5348,9 @@ 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
@@ -5305,6 +5382,7 @@ 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
@@ -5405,6 +5483,8 @@ 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; }
@@ -6698,8 +6778,10 @@ Cluster::Cluster(Segment* pSegment, long idx, long long element_start
{}
Cluster::~Cluster() {
- if (m_entries_count <= 0)
+ if (m_entries_count <= 0) {
+ delete[] m_entries;
return;
+ }
BlockEntry** i = m_entries;
BlockEntry** const j = m_entries + m_entries_count;
diff --git a/third_party/libwebm/mkvparser/mkvparser.h b/third_party/libwebm/mkvparser/mkvparser.h
index 42e6e88ab..26c2b7e5e 100644
--- a/third_party/libwebm/mkvparser/mkvparser.h
+++ b/third_party/libwebm/mkvparser/mkvparser.h
@@ -473,6 +473,34 @@ struct Colour {
MasteringMetadata* mastering_metadata;
};
+struct Projection {
+ enum ProjectionType {
+ kTypeNotPresent = -1,
+ kRectangular = 0,
+ kEquirectangular = 1,
+ kCubeMap = 2,
+ kMesh = 3,
+ };
+ static const float kValueNotPresent;
+ Projection()
+ : type(kTypeNotPresent),
+ private_data(NULL),
+ private_data_length(0),
+ pose_yaw(kValueNotPresent),
+ pose_pitch(kValueNotPresent),
+ pose_roll(kValueNotPresent) {}
+ ~Projection() { delete[] private_data; }
+ static bool Parse(IMkvReader* reader, long long element_start,
+ long long element_size, Projection** projection);
+
+ ProjectionType type;
+ unsigned char* private_data;
+ size_t private_data_length;
+ float pose_yaw;
+ float pose_pitch;
+ float pose_roll;
+};
+
class VideoTrack : public Track {
VideoTrack(const VideoTrack&);
VideoTrack& operator=(const VideoTrack&);
@@ -497,6 +525,8 @@ class VideoTrack : public Track {
Colour* GetColour() const;
+ Projection* GetProjection() const;
+
private:
long long m_width;
long long m_height;
@@ -508,6 +538,7 @@ class VideoTrack : public Track {
double m_rate;
Colour* m_colour;
+ Projection* m_projection;
};
class AudioTrack : public Track {
@@ -813,6 +844,8 @@ class SeekHead {
long Parse();
struct Entry {
+ Entry();
+
// the SeekHead entry payload
long long id;
long long pos;
diff --git a/third_party/libwebm/mkvparser/mkvreader.cc b/third_party/libwebm/mkvparser/mkvreader.cc
index 9f90d8c4f..b8fd00c26 100644
--- a/third_party/libwebm/mkvparser/mkvreader.cc
+++ b/third_party/libwebm/mkvparser/mkvreader.cc
@@ -117,7 +117,7 @@ int MkvReader::Read(long long offset, long len, unsigned char* buffer) {
if (status)
return -1; // error
#else
- fseek(m_file, offset, SEEK_SET);
+ fseeko(m_file, static_cast<off_t>(offset), SEEK_SET);
#endif
const size_t size = fread(buffer, 1, len, m_file);
@@ -128,4 +128,4 @@ int MkvReader::Read(long long offset, long len, unsigned char* buffer) {
return 0; // success
}
-} // namespace mkvparser \ No newline at end of file
+} // namespace mkvparser