From a725f3fd02476a5517da83bff8dca0c6f024d683 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Fri, 10 Jan 2014 16:27:58 -0800 Subject: [PATCH] Fix mp4 parsing failure if CTTS table is empty. The original code assumes CompositionOffset is always valid and has the same number of samples as other table, which is not true if CTTS table is empty for non-fragmented mp4. Change-Id: If4ecc1159de33202db4ab36df8e32c2a6900daf8 --- media/mp4/track_run_iterator.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/media/mp4/track_run_iterator.cc b/media/mp4/track_run_iterator.cc index 427a652a32..22107d6931 100644 --- a/media/mp4/track_run_iterator.cc +++ b/media/mp4/track_run_iterator.cc @@ -176,17 +176,17 @@ bool TrackRunIterator::Init() { uint32 num_chunks = chunk_offset_vector.size(); // Check that total number of samples match. - DCHECK(num_samples == decoding_time.NumSamples() && - num_samples == composition_offset.NumSamples() && - (num_chunks == 0 || - num_samples == chunk_info.NumSamples(1, num_chunks)) && - num_chunks >= chunk_info.LastFirstChunk()); + DCHECK_EQ(num_samples, decoding_time.NumSamples()); + if (has_composition_offset) + DCHECK_EQ(num_samples, composition_offset.NumSamples()); + if (num_chunks > 0) + DCHECK_EQ(num_samples, chunk_info.NumSamples(1, num_chunks)); + DCHECK_GE(num_chunks, chunk_info.LastFirstChunk()); if (num_samples > 0) { // Verify relevant tables are not empty. - RCHECK(decoding_time.IsValid() && - composition_offset.IsValid() && - chunk_info.IsValid()); + RCHECK(decoding_time.IsValid()); + RCHECK(chunk_info.IsValid()); } uint32 sample_index = 0;