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

Side by Side Diff: media/formats/mp4/track_run_iterator.cc

Issue 540503003: Fix TrackRunIterator to generate a parse error when it encounters a reserved dependency value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | media/formats/mp4/track_run_iterator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/mp4/track_run_iterator.h" 5 #include "media/formats/mp4/track_run_iterator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "media/base/buffers.h" 9 #include "media/base/buffers.h"
10 #include "media/formats/mp4/rcheck.h" 10 #include "media/formats/mp4/rcheck.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 TrackRunIterator::TrackRunIterator(const Movie* moov, 83 TrackRunIterator::TrackRunIterator(const Movie* moov,
84 const LogCB& log_cb) 84 const LogCB& log_cb)
85 : moov_(moov), log_cb_(log_cb), sample_offset_(0) { 85 : moov_(moov), log_cb_(log_cb), sample_offset_(0) {
86 CHECK(moov); 86 CHECK(moov);
87 } 87 }
88 88
89 TrackRunIterator::~TrackRunIterator() {} 89 TrackRunIterator::~TrackRunIterator() {}
90 90
91 static void PopulateSampleInfo(const TrackExtends& trex, 91 static bool PopulateSampleInfo(const TrackExtends& trex,
92 const TrackFragmentHeader& tfhd, 92 const TrackFragmentHeader& tfhd,
93 const TrackFragmentRun& trun, 93 const TrackFragmentRun& trun,
94 const int64 edit_list_offset, 94 const int64 edit_list_offset,
95 const uint32 i, 95 const uint32 i,
96 SampleInfo* sample_info, 96 SampleInfo* sample_info,
97 const SampleDependsOn sdtp_sample_depends_on) { 97 const SampleDependsOn sdtp_sample_depends_on,
98 const LogCB& log_cb) {
98 if (i < trun.sample_sizes.size()) { 99 if (i < trun.sample_sizes.size()) {
99 sample_info->size = trun.sample_sizes[i]; 100 sample_info->size = trun.sample_sizes[i];
100 } else if (tfhd.default_sample_size > 0) { 101 } else if (tfhd.default_sample_size > 0) {
101 sample_info->size = tfhd.default_sample_size; 102 sample_info->size = tfhd.default_sample_size;
102 } else { 103 } else {
103 sample_info->size = trex.default_sample_size; 104 sample_info->size = trex.default_sample_size;
104 } 105 }
105 106
106 if (i < trun.sample_durations.size()) { 107 if (i < trun.sample_durations.size()) {
107 sample_info->duration = trun.sample_durations[i]; 108 sample_info->duration = trun.sample_durations[i];
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 case kSampleDependsOnOthers: 151 case kSampleDependsOnOthers:
151 sample_info->is_keyframe = false; 152 sample_info->is_keyframe = false;
152 break; 153 break;
153 154
154 case kSampleDependsOnNoOther: 155 case kSampleDependsOnNoOther:
155 sample_info->is_keyframe = true; 156 sample_info->is_keyframe = true;
156 break; 157 break;
157 158
158 case kSampleDependsOnReserved: 159 case kSampleDependsOnReserved:
159 CHECK(false); 160 MEDIA_LOG(log_cb) << "Reserved value used in sample dependency info.";
161 return false;
160 } 162 }
163 return true;
161 } 164 }
162 165
163 // In well-structured encrypted media, each track run will be immediately 166 // In well-structured encrypted media, each track run will be immediately
164 // preceded by its auxiliary information; this is the only optimal storage 167 // preceded by its auxiliary information; this is the only optimal storage
165 // pattern in terms of minimum number of bytes from a serial stream needed to 168 // pattern in terms of minimum number of bytes from a serial stream needed to
166 // begin playback. It also allows us to optimize caching on memory-constrained 169 // begin playback. It also allows us to optimize caching on memory-constrained
167 // architectures, because we can cache the relatively small auxiliary 170 // architectures, because we can cache the relatively small auxiliary
168 // information for an entire run and then discard data from the input stream, 171 // information for an entire run and then discard data from the input stream,
169 // instead of retaining the entire 'mdat' box. 172 // instead of retaining the entire 'mdat' box.
170 // 173 //
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 tri.aux_info_total_size += tri.aux_info_sizes[k]; 296 tri.aux_info_total_size += tri.aux_info_sizes[k];
294 } 297 }
295 } 298 }
296 } else { 299 } else {
297 tri.aux_info_start_offset = -1; 300 tri.aux_info_start_offset = -1;
298 tri.aux_info_total_size = 0; 301 tri.aux_info_total_size = 0;
299 } 302 }
300 303
301 tri.samples.resize(trun.sample_count); 304 tri.samples.resize(trun.sample_count);
302 for (size_t k = 0; k < trun.sample_count; k++) { 305 for (size_t k = 0; k < trun.sample_count; k++) {
303 PopulateSampleInfo(*trex, traf.header, trun, edit_list_offset, 306 if (!PopulateSampleInfo(*trex, traf.header, trun, edit_list_offset,
304 k, &tri.samples[k], traf.sdtp.sample_depends_on(k)); 307 k, &tri.samples[k],
308 traf.sdtp.sample_depends_on(k),
309 log_cb_)) {
310 return false;
311 }
312
305 run_start_dts += tri.samples[k].duration; 313 run_start_dts += tri.samples[k].duration;
306 314
307 if (!is_sample_to_group_valid) { 315 if (!is_sample_to_group_valid) {
308 // Set group description index to 0 to read encryption information 316 // Set group description index to 0 to read encryption information
309 // from TrackEncryption Box. 317 // from TrackEncryption Box.
310 tri.samples[k].cenc_group_description_index = 0; 318 tri.samples[k].cenc_group_description_index = 0;
311 continue; 319 continue;
312 } 320 }
313 321
314 // ISO-14496-12 Section 8.9.2.3 and 8.9.4 : group description index 322 // ISO-14496-12 Section 8.9.2.3 and 8.9.4 : group description index
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 } 572 }
565 573
566 uint8 TrackRunIterator::GetIvSize(size_t sample_index) const { 574 uint8 TrackRunIterator::GetIvSize(size_t sample_index) const {
567 uint32 index = GetGroupDescriptionIndex(sample_index); 575 uint32 index = GetGroupDescriptionIndex(sample_index);
568 return (index == 0) ? track_encryption().default_iv_size 576 return (index == 0) ? track_encryption().default_iv_size
569 : GetSampleEncryptionInfoEntry(index).iv_size; 577 : GetSampleEncryptionInfoEntry(index).iv_size;
570 } 578 }
571 579
572 } // namespace mp4 580 } // namespace mp4
573 } // namespace media 581 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/formats/mp4/track_run_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698