Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: media/formats/webm/cluster_builder.cc

Issue 1966673002: media: Fix WebM keyframe detection in BlockGroup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add unit tests with keyframe verification Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/webm/cluster_builder.h ('k') | media/formats/webm/webm_cluster_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/webm/cluster_builder.cc
diff --git a/media/formats/webm/cluster_builder.cc b/media/formats/webm/cluster_builder.cc
index 4a96beb5af8fd1dc4c92dd3f3a4b18d2e1f1204c..ba9da26fa3fd2d48a1ee2d14ada22148ed5616a4 100644
--- a/media/formats/webm/cluster_builder.cc
+++ b/media/formats/webm/cluster_builder.cc
@@ -43,6 +43,11 @@ static const uint8_t kBlockGroupHeaderWithoutBlockDuration[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Block(size = 0)
};
+static const uint8_t kBlockGroupReferenceBlock[] = {
+ 0xFB, // ReferenceBlock ID
+ 0x81, 0x00, // ReferenceBlock (size=1, value=0)
+};
+
enum {
kClusterSizeOffset = 4,
kClusterTimecodeOffset = 14,
@@ -102,17 +107,21 @@ void ClusterBuilder::AddBlockGroup(int track_num,
int64_t timecode,
int duration,
int flags,
+ bool is_key_frame,
const uint8_t* data,
int size) {
- AddBlockGroupInternal(track_num, timecode, true, duration, flags, data, size);
+ AddBlockGroupInternal(track_num, timecode, true, duration, flags,
+ is_key_frame, data, size);
}
void ClusterBuilder::AddBlockGroupWithoutBlockDuration(int track_num,
int64_t timecode,
int flags,
+ bool is_key_frame,
const uint8_t* data,
int size) {
- AddBlockGroupInternal(track_num, timecode, false, 0, flags, data, size);
+ AddBlockGroupInternal(track_num, timecode, false, 0, flags, is_key_frame,
+ data, size);
}
void ClusterBuilder::AddBlockGroupInternal(int track_num,
@@ -120,6 +129,7 @@ void ClusterBuilder::AddBlockGroupInternal(int track_num,
bool include_block_duration,
int duration,
int flags,
+ bool is_key_frame,
const uint8_t* data,
int size) {
int block_size = size + 4;
@@ -129,6 +139,9 @@ void ClusterBuilder::AddBlockGroupInternal(int track_num,
} else {
bytes_needed += sizeof(kBlockGroupHeaderWithoutBlockDuration);
}
+ if (!is_key_frame) {
+ bytes_needed += sizeof(kBlockGroupReferenceBlock);
+ }
int block_group_size = bytes_needed - 9;
@@ -158,6 +171,11 @@ void ClusterBuilder::AddBlockGroupInternal(int track_num,
flags &= 0x0f;
WriteBlock(buf, track_num, timecode, flags, data, size);
+ buf += size + 4;
+
+ if (!is_key_frame) {
+ memcpy(buf, kBlockGroupReferenceBlock, sizeof(kBlockGroupReferenceBlock));
+ }
bytes_used_ += bytes_needed;
}
« no previous file with comments | « media/formats/webm/cluster_builder.h ('k') | media/formats/webm/webm_cluster_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698