Skip to content

Commit 9f67516

Browse files
youennfphiln
authored andcommitted
Update libwebm up to M115
https://bugs.webkit.org/show_bug.cgi?id=257265 rdar://109779378 Reviewed by Eric Carlson. Resync libwebm from upstream. Make sure to put all WebKit specific changes in #if defined(WEBRTC_WEBKIT_BUILD). * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/CMakeLists.txt: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_header_parser.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_header_parser.h: (vp9_parser::Vp9HeaderParser::display_width const): (vp9_parser::Vp9HeaderParser::display_height const): * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_level_stats.h: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer/mkvmuxer.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer_sample.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvparser/mkvparser.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_info.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/include/webm/callback.h: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/src/callback.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/src/master_parser.cc: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/src/master_parser.h: * Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/src/webm_parser.cc: * Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp: * Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h: Canonical link: https://commits.webkit.org/264506@main
1 parent 1684c74 commit 9f67516

16 files changed

Lines changed: 103 additions & 48 deletions

File tree

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ option(ENABLE_IWYU "Enables include-what-you-use support." OFF)
2525
option(ENABLE_WERROR "Enable warnings as errors." OFF)
2626
option(ENABLE_WEBM_PARSER "Enables new parser API." OFF)
2727

28-
if(WIN32)
28+
if(WIN32 OR CYGWIN OR MSYS)
29+
# Allow use of rand_r() / fdopen() and other POSIX functions.
2930
require_cxx_flag_nomsvc("-std=gnu++11")
3031
else()
3132
require_cxx_flag_nomsvc("-std=c++11")

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_header_parser.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,16 @@ void Vp9HeaderParser::ParseColorSpace() {
169169
void Vp9HeaderParser::ParseFrameResolution() {
170170
width_ = VpxReadLiteral(16) + 1;
171171
height_ = VpxReadLiteral(16) + 1;
172+
if (ReadBit()) {
173+
display_width_ = VpxReadLiteral(16) + 1;
174+
display_height_ = VpxReadLiteral(16) + 1;
175+
} else {
176+
display_width_ = width_;
177+
display_height_ = height_;
178+
}
172179
}
173180

174181
void Vp9HeaderParser::ParseFrameParallelMode() {
175-
if (ReadBit()) {
176-
VpxReadLiteral(16); // display width
177-
VpxReadLiteral(16); // display height
178-
}
179182
if (!error_resilient_mode_) {
180183
ReadBit(); // Consume refresh frame context
181184
frame_parallel_mode_ = ReadBit();

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_header_parser.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ class Vp9HeaderParser {
6464
int color_space() const { return color_space_; }
6565
int width() const { return width_; }
6666
int height() const { return height_; }
67+
int display_width() const { return display_width_; }
68+
int display_height() const { return display_height_; }
6769
int refresh_frame_flags() const { return refresh_frame_flags_; }
6870
int row_tiles() const { return row_tiles_; }
6971
int column_tiles() const { return column_tiles_; }
7072
int frame_parallel_mode() const { return frame_parallel_mode_; }
7173

72-
// WebKit Additions:
74+
#if defined(WEBRTC_WEBKIT_BUILD)
7375
int color_range() const { return color_range_; }
7476
int subsampling_x() const { return subsampling_x_; }
7577
int subsampling_y() const { return subsampling_y_; }
78+
#endif
7679

7780
private:
7881
// Set the compressed VP9 frame.
@@ -120,6 +123,8 @@ class Vp9HeaderParser {
120123
int refresh_frame_flags_;
121124
int width_;
122125
int height_;
126+
int display_width_;
127+
int display_height_;
123128
int row_tiles_;
124129
int column_tiles_;
125130
int frame_parallel_mode_;

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/common/vp9_level_stats.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ enum Vp9Level {
4040
};
4141

4242
struct Vp9LevelRow {
43+
Vp9LevelRow() = default;
44+
~Vp9LevelRow() = default;
45+
Vp9LevelRow(Vp9LevelRow&& other) = default;
46+
Vp9LevelRow(const Vp9LevelRow& other) = default;
4347
Vp9LevelRow& operator=(Vp9LevelRow&& other) = delete;
4448
Vp9LevelRow& operator=(const Vp9LevelRow& other) = delete;
4549

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer/mkvmuxer.cc

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,7 +2622,8 @@ bool Cluster::Finalize(bool set_last_frame_duration, uint64_t duration) {
26222622

26232623
uint64_t Cluster::Size() const {
26242624
const uint64_t element_size =
2625-
EbmlMasterElementSize(libwebm::kMkvCluster, 0xFFFFFFFFFFFFFFFFULL) +
2625+
EbmlMasterElementSize(static_cast<uint64_t>(libwebm::kMkvCluster),
2626+
uint64_t{0xFFFFFFFFFFFFFFFFU}) +
26262627
payload_size_;
26272628
return element_size;
26282629
}
@@ -3084,6 +3085,7 @@ Segment::Segment()
30843085
accurate_cluster_duration_(false),
30853086
fixed_size_cluster_timecode_(false),
30863087
estimate_file_duration_(false),
3088+
ebml_header_size_(0),
30873089
payload_pos_(0),
30883090
size_position_(0),
30893091
doc_type_version_(kDefaultDocTypeVersion),
@@ -4105,12 +4107,16 @@ int Segment::WriteFramesAll() {
41054107
// places where |doc_type_version_| needs to be updated.
41064108
if (frame->discard_padding() != 0)
41074109
doc_type_version_ = 4;
4108-
if (!cluster->AddFrame(frame))
4109-
return -1;
4110+
if (!cluster->AddFrame(frame)) {
4111+
delete frame;
4112+
continue;
4113+
}
41104114

41114115
if (new_cuepoint_ && cues_track_ == frame->track_number()) {
4112-
if (!AddCuePoint(frame->timestamp(), cues_track_))
4113-
return -1;
4116+
if (!AddCuePoint(frame->timestamp(), cues_track_)) {
4117+
delete frame;
4118+
continue;
4119+
}
41144120
}
41154121

41164122
if (frame->timestamp() > last_timestamp_) {
@@ -4153,12 +4159,16 @@ bool Segment::WriteFramesLessThan(uint64_t timestamp) {
41534159
const Frame* const frame_prev = frames_[i - 1];
41544160
if (frame_prev->discard_padding() != 0)
41554161
doc_type_version_ = 4;
4156-
if (!cluster->AddFrame(frame_prev))
4157-
return false;
4162+
if (!cluster->AddFrame(frame_prev)) {
4163+
delete frame_prev;
4164+
continue;
4165+
}
41584166

41594167
if (new_cuepoint_ && cues_track_ == frame_prev->track_number()) {
4160-
if (!AddCuePoint(frame_prev->timestamp(), cues_track_))
4161-
return false;
4168+
if (!AddCuePoint(frame_prev->timestamp(), cues_track_)) {
4169+
delete frame_prev;
4170+
continue;
4171+
}
41624172
}
41634173

41644174
++shift_left;

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ uint64 WriteVoidElement(IMkvWriter* writer, uint64 size) {
606606

607607
void GetVersion(int32* major, int32* minor, int32* build, int32* revision) {
608608
*major = 0;
609-
*minor = 2;
610-
*build = 1;
609+
*minor = 3;
610+
*build = 0;
611611
*revision = 0;
612612
}
613613

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvmuxer_sample.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void Usage() {
6666
printf(" 1: Equirectangular\n");
6767
printf(" 2: Cube map\n");
6868
printf(" 3: Mesh\n");
69-
printf(" -projection_file <string> Override projection private data");
69+
printf(" -projection_file <string> Override projection private data\n");
7070
printf(" with contents of this file\n");
7171
printf(" -projection_pose_yaw <float> Projection pose yaw\n");
7272
printf(" -projection_pose_pitch <float> Projection pose pitch\n");

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/mkvparser/mkvparser.cc

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ Type* SafeArrayAlloc(unsigned long long num_elements,
5454

5555
void GetVersion(int& major, int& minor, int& build, int& revision) {
5656
major = 1;
57-
minor = 0;
57+
minor = 1;
5858
build = 0;
59-
revision = 30;
59+
revision = 0;
6060
}
6161

6262
long long ReadUInt(IMkvReader* pReader, long long pos, long& len) {
@@ -1502,8 +1502,8 @@ long SeekHead::Parse() {
15021502

15031503
// first count the seek head entries
15041504

1505-
int entry_count = 0;
1506-
int void_element_count = 0;
1505+
long long entry_count = 0;
1506+
long long void_element_count = 0;
15071507

15081508
while (pos < stop) {
15091509
long long id, size;
@@ -1513,10 +1513,15 @@ long SeekHead::Parse() {
15131513
if (status < 0) // error
15141514
return status;
15151515

1516-
if (id == libwebm::kMkvSeek)
1516+
if (id == libwebm::kMkvSeek) {
15171517
++entry_count;
1518-
else if (id == libwebm::kMkvVoid)
1518+
if (entry_count > INT_MAX)
1519+
return E_PARSE_FAILED;
1520+
} else if (id == libwebm::kMkvVoid) {
15191521
++void_element_count;
1522+
if (void_element_count > INT_MAX)
1523+
return E_PARSE_FAILED;
1524+
}
15201525

15211526
pos += size; // consume payload
15221527

@@ -1582,13 +1587,13 @@ long SeekHead::Parse() {
15821587

15831588
ptrdiff_t count_ = ptrdiff_t(pEntry - m_entries);
15841589
assert(count_ >= 0);
1585-
assert(count_ <= entry_count);
1590+
assert(static_cast<long long>(count_) <= entry_count);
15861591

15871592
m_entry_count = static_cast<int>(count_);
15881593

15891594
count_ = ptrdiff_t(pVoidElement - m_void_elements);
15901595
assert(count_ >= 0);
1591-
assert(count_ <= void_element_count);
1596+
assert(static_cast<long long>(count_) <= void_element_count);
15921597

15931598
m_void_element_count = static_cast<int>(count_);
15941599

@@ -2299,7 +2304,7 @@ bool CuePoint::Load(IMkvReader* pReader) {
22992304
long long pos = pos_;
23002305

23012306
// First count number of track positions
2302-
2307+
unsigned long long track_positions_count = 0;
23032308
while (pos < stop) {
23042309
long len;
23052310

@@ -2323,12 +2328,17 @@ bool CuePoint::Load(IMkvReader* pReader) {
23232328
if (id == libwebm::kMkvCueTime)
23242329
m_timecode = UnserializeUInt(pReader, pos, size);
23252330

2326-
else if (id == libwebm::kMkvCueTrackPositions)
2327-
++m_track_positions_count;
2331+
else if (id == libwebm::kMkvCueTrackPositions) {
2332+
++track_positions_count;
2333+
if (track_positions_count > UINT_MAX)
2334+
return E_PARSE_FAILED;
2335+
}
23282336

23292337
pos += size; // consume payload
23302338
}
23312339

2340+
m_track_positions_count = static_cast<size_t>(track_positions_count);
2341+
23322342
if (m_timecode < 0 || m_track_positions_count <= 0) {
23332343
return false;
23342344
}
@@ -4194,20 +4204,26 @@ long ContentEncoding::ParseContentEncodingEntry(long long start, long long size,
41944204
const long long stop = start + size;
41954205

41964206
// Count ContentCompression and ContentEncryption elements.
4197-
int compression_count = 0;
4198-
int encryption_count = 0;
4207+
long long compression_count = 0;
4208+
long long encryption_count = 0;
41994209

42004210
while (pos < stop) {
42014211
long long id, size;
42024212
const long status = ParseElementHeader(pReader, pos, stop, id, size);
42034213
if (status < 0) // error
42044214
return status;
42054215

4206-
if (id == libwebm::kMkvContentCompression)
4216+
if (id == libwebm::kMkvContentCompression) {
42074217
++compression_count;
4218+
if (compression_count > INT_MAX)
4219+
return E_PARSE_FAILED;
4220+
}
42084221

4209-
if (id == libwebm::kMkvContentEncryption)
4222+
if (id == libwebm::kMkvContentEncryption) {
42104223
++encryption_count;
4224+
if (encryption_count > INT_MAX)
4225+
return E_PARSE_FAILED;
4226+
}
42114227

42124228
pos += size; // consume payload
42134229
if (pos > stop)
@@ -4918,16 +4934,19 @@ long Track::ParseContentEncodingsEntry(long long start, long long size) {
49184934
const long long stop = start + size;
49194935

49204936
// Count ContentEncoding elements.
4921-
int count = 0;
4937+
long long count = 0;
49224938
while (pos < stop) {
49234939
long long id, size;
49244940
const long status = ParseElementHeader(pReader, pos, stop, id, size);
49254941
if (status < 0) // error
49264942
return status;
49274943

49284944
// pos now designates start of element
4929-
if (id == libwebm::kMkvContentEncoding)
4945+
if (id == libwebm::kMkvContentEncoding) {
49304946
++count;
4947+
if (count > INT_MAX)
4948+
return E_PARSE_FAILED;
4949+
}
49314950

49324951
pos += size; // consume payload
49334952
if (pos > stop)
@@ -5653,7 +5672,7 @@ long Tracks::Parse() {
56535672
const long long stop = m_start + m_size;
56545673
IMkvReader* const pReader = m_pSegment->m_pReader;
56555674

5656-
int count = 0;
5675+
long long count = 0;
56575676
long long pos = m_start;
56585677

56595678
while (pos < stop) {
@@ -5667,8 +5686,11 @@ long Tracks::Parse() {
56675686
if (size == 0) // weird
56685687
continue;
56695688

5670-
if (id == libwebm::kMkvTrackEntry)
5689+
if (id == libwebm::kMkvTrackEntry) {
56715690
++count;
5691+
if (count > INT_MAX)
5692+
return E_PARSE_FAILED;
5693+
}
56725694

56735695
pos += size; // consume payload
56745696
if (pos > stop)

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_info.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,15 @@ void PrintVP9Info(const uint8_t* data, int size, FILE* o, int64_t time_ns,
761761
version, altref_frame, error_resilient_mode, row_tiles,
762762
column_tiles, frame_parallel_mode);
763763

764-
if (key && size > 4) {
765-
fprintf(o, " cs:%d", parser->color_space());
764+
if (key) {
765+
if (size > 4) {
766+
fprintf(o, " cs:%d", parser->color_space());
767+
}
768+
if (parser->display_width() != parser->width() ||
769+
parser->display_height() != parser->height()) {
770+
fprintf(o, " dw:%d dh:%d", parser->display_width(),
771+
parser->display_height());
772+
}
766773
}
767774

768775
if (count > 0) {

Source/ThirdParty/libwebrtc/Source/third_party/libwebm/webm_parser/include/webm/callback.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ class Callback {
335335
*/
336336
virtual Status OnSegmentEnd(const ElementMetadata& metadata);
337337

338+
#if defined(WEBRTC_WEBKIT_BUILD)
338339
virtual Status OnElementEnd(const ElementMetadata& metadata);
340+
#endif
339341

340342
protected:
341343
/**

0 commit comments

Comments
 (0)