Index: media/mp4/track_run_iterator.cc |
diff --git a/media/mp4/track_run_iterator.cc b/media/mp4/track_run_iterator.cc |
index 59bc22967e48fc0f802481b046b49c7279661a6b..79bd5745203e6a41d342408b5c6f290b3d98b221 100644 |
--- a/media/mp4/track_run_iterator.cc |
+++ b/media/mp4/track_run_iterator.cc |
@@ -71,6 +71,7 @@ TrackRunIterator::~TrackRunIterator() {} |
static void PopulateSampleInfo(const TrackExtends& trex, |
const TrackFragmentHeader& tfhd, |
const TrackFragmentRun& trun, |
+ const int64 edit_list_offset, |
const uint32 i, |
SampleInfo* sample_info) { |
if (i < trun.sample_sizes.size()) { |
@@ -94,6 +95,7 @@ static void PopulateSampleInfo(const TrackExtends& trex, |
} else { |
sample_info->cts_offset = 0; |
} |
+ sample_info->cts_offset += edit_list_offset; |
uint32 flags; |
if (i < trun.sample_flags.size()) { |
@@ -164,6 +166,15 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { |
RCHECK(desc_idx > 0); // Descriptions are one-indexed in the file |
desc_idx -= 1; |
+ // Process edit list to remove CTS offset introduced in the presence of |
+ // B-frames. Other uses of edit lists are not supported, as they are |
+ // both uncommon and better served by higher-level protocols. |
acolwell GONE FROM CHROMIUM
2012/08/07 20:12:13
nit: It looks like there should be a
if (stuff w
strobe_
2012/08/07 22:54:39
Done.
|
+ int64 edit_list_offset = 0; |
+ const std::vector<EditListEntry>& edits = trak->edit.list.edits; |
+ if (!edits.empty() && edits[0].media_time > 0) { |
+ edit_list_offset = -edits[0].media_time; |
+ } |
+ |
int64 run_start_dts = traf.decode_time.decode_time; |
int sample_count_sum = 0; |
@@ -226,7 +237,8 @@ bool TrackRunIterator::Init(const MovieFragment& moof) { |
tri.samples.resize(trun.sample_count); |
for (size_t k = 0; k < trun.sample_count; k++) { |
- PopulateSampleInfo(*trex, traf.header, trun, k, &tri.samples[k]); |
+ PopulateSampleInfo(*trex, traf.header, trun, edit_list_offset, |
+ k, &tri.samples[k]); |
run_start_dts += tri.samples[k].duration; |
} |
runs_.push_back(tri); |