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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
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/box_definitions.h" 5 #include "media/formats/mp4/box_definitions.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/video_types.h" 8 #include "media/base/video_types.h"
9 #include "media/base/video_util.h" 9 #include "media/base/video_util.h"
10 #include "media/formats/mp4/avc.h" 10 #include "media/formats/mp4/avc.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {} 95 SampleAuxiliaryInformationOffset::SampleAuxiliaryInformationOffset() {}
96 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {} 96 SampleAuxiliaryInformationOffset::~SampleAuxiliaryInformationOffset() {}
97 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; } 97 FourCC SampleAuxiliaryInformationOffset::BoxType() const { return FOURCC_SAIO; }
98 98
99 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) { 99 bool SampleAuxiliaryInformationOffset::Parse(BoxReader* reader) {
100 RCHECK(reader->ReadFullBoxHeader()); 100 RCHECK(reader->ReadFullBoxHeader());
101 if (reader->flags() & 1) 101 if (reader->flags() & 1)
102 RCHECK(reader->SkipBytes(8)); 102 RCHECK(reader->SkipBytes(8));
103 103
104 uint32 count; 104 uint32_t count;
105 RCHECK(reader->Read4(&count) && 105 RCHECK(reader->Read4(&count) &&
106 reader->HasBytes(count * (reader->version() == 1 ? 8 : 4))); 106 reader->HasBytes(count * (reader->version() == 1 ? 8 : 4)));
107 offsets.resize(count); 107 offsets.resize(count);
108 108
109 for (uint32 i = 0; i < count; i++) { 109 for (uint32_t i = 0; i < count; i++) {
110 if (reader->version() == 1) { 110 if (reader->version() == 1) {
111 RCHECK(reader->Read8(&offsets[i])); 111 RCHECK(reader->Read8(&offsets[i]));
112 } else { 112 } else {
113 RCHECK(reader->Read4Into8(&offsets[i])); 113 RCHECK(reader->Read4Into8(&offsets[i]));
114 } 114 }
115 } 115 }
116 return true; 116 return true;
117 } 117 }
118 118
119 SampleAuxiliaryInformationSize::SampleAuxiliaryInformationSize() 119 SampleAuxiliaryInformationSize::SampleAuxiliaryInformationSize()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return true; 153 return true;
154 } 154 }
155 155
156 TrackEncryption::TrackEncryption() 156 TrackEncryption::TrackEncryption()
157 : is_encrypted(false), default_iv_size(0) { 157 : is_encrypted(false), default_iv_size(0) {
158 } 158 }
159 TrackEncryption::~TrackEncryption() {} 159 TrackEncryption::~TrackEncryption() {}
160 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; } 160 FourCC TrackEncryption::BoxType() const { return FOURCC_TENC; }
161 161
162 bool TrackEncryption::Parse(BoxReader* reader) { 162 bool TrackEncryption::Parse(BoxReader* reader) {
163 uint8 flag; 163 uint8_t flag;
164 RCHECK(reader->ReadFullBoxHeader() && 164 RCHECK(reader->ReadFullBoxHeader() &&
165 reader->SkipBytes(2) && 165 reader->SkipBytes(2) &&
166 reader->Read1(&flag) && 166 reader->Read1(&flag) &&
167 reader->Read1(&default_iv_size) && 167 reader->Read1(&default_iv_size) &&
168 reader->ReadVec(&default_kid, 16)); 168 reader->ReadVec(&default_kid, 16));
169 is_encrypted = (flag != 0); 169 is_encrypted = (flag != 0);
170 if (is_encrypted) { 170 if (is_encrypted) {
171 RCHECK(default_iv_size == 8 || default_iv_size == 16); 171 RCHECK(default_iv_size == 8 || default_iv_size == 16);
172 } else { 172 } else {
173 RCHECK(default_iv_size == 0); 173 RCHECK(default_iv_size == 0);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 height >>= 1; 284 height >>= 1;
285 285
286 return true; 286 return true;
287 } 287 }
288 288
289 SampleDescription::SampleDescription() : type(kInvalid) {} 289 SampleDescription::SampleDescription() : type(kInvalid) {}
290 SampleDescription::~SampleDescription() {} 290 SampleDescription::~SampleDescription() {}
291 FourCC SampleDescription::BoxType() const { return FOURCC_STSD; } 291 FourCC SampleDescription::BoxType() const { return FOURCC_STSD; }
292 292
293 bool SampleDescription::Parse(BoxReader* reader) { 293 bool SampleDescription::Parse(BoxReader* reader) {
294 uint32 count; 294 uint32_t count;
295 RCHECK(reader->SkipBytes(4) && 295 RCHECK(reader->SkipBytes(4) &&
296 reader->Read4(&count)); 296 reader->Read4(&count));
297 video_entries.clear(); 297 video_entries.clear();
298 audio_entries.clear(); 298 audio_entries.clear();
299 299
300 // Note: this value is preset before scanning begins. See comments in the 300 // Note: this value is preset before scanning begins. See comments in the
301 // Parse(Media*) function. 301 // Parse(Media*) function.
302 if (type == kVideo) { 302 if (type == kVideo) {
303 RCHECK(reader->ReadAllChildren(&video_entries)); 303 RCHECK(reader->ReadAllChildren(&video_entries));
304 } else if (type == kAudio) { 304 } else if (type == kAudio) {
(...skipping 20 matching lines...) Expand all
325 sample_group_description.entries.clear(); 325 sample_group_description.entries.clear();
326 } 326 }
327 return true; 327 return true;
328 } 328 }
329 329
330 EditList::EditList() {} 330 EditList::EditList() {}
331 EditList::~EditList() {} 331 EditList::~EditList() {}
332 FourCC EditList::BoxType() const { return FOURCC_ELST; } 332 FourCC EditList::BoxType() const { return FOURCC_ELST; }
333 333
334 bool EditList::Parse(BoxReader* reader) { 334 bool EditList::Parse(BoxReader* reader) {
335 uint32 count; 335 uint32_t count;
336 RCHECK(reader->ReadFullBoxHeader() && reader->Read4(&count)); 336 RCHECK(reader->ReadFullBoxHeader() && reader->Read4(&count));
337 337
338 if (reader->version() == 1) { 338 if (reader->version() == 1) {
339 RCHECK(reader->HasBytes(count * 20)); 339 RCHECK(reader->HasBytes(count * 20));
340 } else { 340 } else {
341 RCHECK(reader->HasBytes(count * 12)); 341 RCHECK(reader->HasBytes(count * 12));
342 } 342 }
343 edits.resize(count); 343 edits.resize(count);
344 344
345 for (std::vector<EditListEntry>::iterator edit = edits.begin(); 345 for (std::vector<EditListEntry>::iterator edit = edits.begin();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 avc_level(0), 390 avc_level(0),
391 length_size(0) {} 391 length_size(0) {}
392 392
393 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {} 393 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {}
394 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; } 394 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; }
395 395
396 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) { 396 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) {
397 return ParseInternal(reader, reader->media_log()); 397 return ParseInternal(reader, reader->media_log());
398 } 398 }
399 399
400 bool AVCDecoderConfigurationRecord::Parse(const uint8* data, int data_size) { 400 bool AVCDecoderConfigurationRecord::Parse(const uint8_t* data, int data_size) {
401 BufferReader reader(data, data_size); 401 BufferReader reader(data, data_size);
402 return ParseInternal(&reader, new MediaLog()); 402 return ParseInternal(&reader, new MediaLog());
403 } 403 }
404 404
405 bool AVCDecoderConfigurationRecord::ParseInternal( 405 bool AVCDecoderConfigurationRecord::ParseInternal(
406 BufferReader* reader, 406 BufferReader* reader,
407 const scoped_refptr<MediaLog>& media_log) { 407 const scoped_refptr<MediaLog>& media_log) {
408 RCHECK(reader->Read1(&version) && version == 1 && 408 RCHECK(reader->Read1(&version) && version == 1 &&
409 reader->Read1(&profile_indication) && 409 reader->Read1(&profile_indication) &&
410 reader->Read1(&profile_compatibility) && 410 reader->Read1(&profile_compatibility) &&
411 reader->Read1(&avc_level)); 411 reader->Read1(&avc_level));
412 412
413 uint8 length_size_minus_one; 413 uint8_t length_size_minus_one;
414 RCHECK(reader->Read1(&length_size_minus_one)); 414 RCHECK(reader->Read1(&length_size_minus_one));
415 length_size = (length_size_minus_one & 0x3) + 1; 415 length_size = (length_size_minus_one & 0x3) + 1;
416 416
417 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid. 417 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid.
418 418
419 uint8 num_sps; 419 uint8_t num_sps;
420 RCHECK(reader->Read1(&num_sps)); 420 RCHECK(reader->Read1(&num_sps));
421 num_sps &= 0x1f; 421 num_sps &= 0x1f;
422 422
423 sps_list.resize(num_sps); 423 sps_list.resize(num_sps);
424 for (int i = 0; i < num_sps; i++) { 424 for (int i = 0; i < num_sps; i++) {
425 uint16 sps_length; 425 uint16_t sps_length;
426 RCHECK(reader->Read2(&sps_length) && 426 RCHECK(reader->Read2(&sps_length) &&
427 reader->ReadVec(&sps_list[i], sps_length)); 427 reader->ReadVec(&sps_list[i], sps_length));
428 RCHECK(sps_list[i].size() > 4); 428 RCHECK(sps_list[i].size() > 4);
429 429
430 if (media_log.get()) { 430 if (media_log.get()) {
431 MEDIA_LOG(INFO, media_log) << "Video codec: avc1." << std::hex 431 MEDIA_LOG(INFO, media_log) << "Video codec: avc1." << std::hex
432 << static_cast<int>(sps_list[i][1]) 432 << static_cast<int>(sps_list[i][1])
433 << static_cast<int>(sps_list[i][2]) 433 << static_cast<int>(sps_list[i][2])
434 << static_cast<int>(sps_list[i][3]); 434 << static_cast<int>(sps_list[i][3]);
435 } 435 }
436 } 436 }
437 437
438 uint8 num_pps; 438 uint8_t num_pps;
439 RCHECK(reader->Read1(&num_pps)); 439 RCHECK(reader->Read1(&num_pps));
440 440
441 pps_list.resize(num_pps); 441 pps_list.resize(num_pps);
442 for (int i = 0; i < num_pps; i++) { 442 for (int i = 0; i < num_pps; i++) {
443 uint16 pps_length; 443 uint16_t pps_length;
444 RCHECK(reader->Read2(&pps_length) && 444 RCHECK(reader->Read2(&pps_length) &&
445 reader->ReadVec(&pps_list[i], pps_length)); 445 reader->ReadVec(&pps_list[i], pps_length));
446 } 446 }
447 447
448 return true; 448 return true;
449 } 449 }
450 450
451 PixelAspectRatioBox::PixelAspectRatioBox() : h_spacing(1), v_spacing(1) {} 451 PixelAspectRatioBox::PixelAspectRatioBox() : h_spacing(1), v_spacing(1) {}
452 PixelAspectRatioBox::~PixelAspectRatioBox() {} 452 PixelAspectRatioBox::~PixelAspectRatioBox() {}
453 FourCC PixelAspectRatioBox::BoxType() const { return FOURCC_PASP; } 453 FourCC PixelAspectRatioBox::BoxType() const { return FOURCC_PASP; }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 ElementaryStreamDescriptor::ElementaryStreamDescriptor() 557 ElementaryStreamDescriptor::ElementaryStreamDescriptor()
558 : object_type(kForbidden) {} 558 : object_type(kForbidden) {}
559 559
560 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {} 560 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {}
561 561
562 FourCC ElementaryStreamDescriptor::BoxType() const { 562 FourCC ElementaryStreamDescriptor::BoxType() const {
563 return FOURCC_ESDS; 563 return FOURCC_ESDS;
564 } 564 }
565 565
566 bool ElementaryStreamDescriptor::Parse(BoxReader* reader) { 566 bool ElementaryStreamDescriptor::Parse(BoxReader* reader) {
567 std::vector<uint8> data; 567 std::vector<uint8_t> data;
568 ESDescriptor es_desc; 568 ESDescriptor es_desc;
569 569
570 RCHECK(reader->ReadFullBoxHeader()); 570 RCHECK(reader->ReadFullBoxHeader());
571 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos())); 571 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos()));
572 RCHECK(es_desc.Parse(data)); 572 RCHECK(es_desc.Parse(data));
573 573
574 object_type = es_desc.object_type(); 574 object_type = es_desc.object_type();
575 575
576 if (object_type != 0x40) { 576 if (object_type != 0x40) {
577 MEDIA_LOG(INFO, reader->media_log()) << "Audio codec: mp4a." << std::hex 577 MEDIA_LOG(INFO, reader->media_log()) << "Audio codec: mp4a." << std::hex
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 824 }
825 825
826 TrackFragmentRun::TrackFragmentRun() 826 TrackFragmentRun::TrackFragmentRun()
827 : sample_count(0), data_offset(0) {} 827 : sample_count(0), data_offset(0) {}
828 TrackFragmentRun::~TrackFragmentRun() {} 828 TrackFragmentRun::~TrackFragmentRun() {}
829 FourCC TrackFragmentRun::BoxType() const { return FOURCC_TRUN; } 829 FourCC TrackFragmentRun::BoxType() const { return FOURCC_TRUN; }
830 830
831 bool TrackFragmentRun::Parse(BoxReader* reader) { 831 bool TrackFragmentRun::Parse(BoxReader* reader) {
832 RCHECK(reader->ReadFullBoxHeader() && 832 RCHECK(reader->ReadFullBoxHeader() &&
833 reader->Read4(&sample_count)); 833 reader->Read4(&sample_count));
834 const uint32 flags = reader->flags(); 834 const uint32_t flags = reader->flags();
835 835
836 bool data_offset_present = (flags & 0x1) != 0; 836 bool data_offset_present = (flags & 0x1) != 0;
837 bool first_sample_flags_present = (flags & 0x4) != 0; 837 bool first_sample_flags_present = (flags & 0x4) != 0;
838 bool sample_duration_present = (flags & 0x100) != 0; 838 bool sample_duration_present = (flags & 0x100) != 0;
839 bool sample_size_present = (flags & 0x200) != 0; 839 bool sample_size_present = (flags & 0x200) != 0;
840 bool sample_flags_present = (flags & 0x400) != 0; 840 bool sample_flags_present = (flags & 0x400) != 0;
841 bool sample_composition_time_offsets_present = (flags & 0x800) != 0; 841 bool sample_composition_time_offsets_present = (flags & 0x800) != 0;
842 842
843 if (data_offset_present) { 843 if (data_offset_present) {
844 RCHECK(reader->Read4(&data_offset)); 844 RCHECK(reader->Read4(&data_offset));
845 } else { 845 } else {
846 data_offset = 0; 846 data_offset = 0;
847 } 847 }
848 848
849 uint32 first_sample_flags = 0; 849 uint32_t first_sample_flags = 0;
850 if (first_sample_flags_present) 850 if (first_sample_flags_present)
851 RCHECK(reader->Read4(&first_sample_flags)); 851 RCHECK(reader->Read4(&first_sample_flags));
852 852
853 int fields = sample_duration_present + sample_size_present + 853 int fields = sample_duration_present + sample_size_present +
854 sample_flags_present + sample_composition_time_offsets_present; 854 sample_flags_present + sample_composition_time_offsets_present;
855 RCHECK(reader->HasBytes(fields * sample_count)); 855 RCHECK(reader->HasBytes(fields * sample_count));
856 856
857 if (sample_duration_present) 857 if (sample_duration_present)
858 sample_durations.resize(sample_count); 858 sample_durations.resize(sample_count);
859 if (sample_size_present) 859 if (sample_size_present)
860 sample_sizes.resize(sample_count); 860 sample_sizes.resize(sample_count);
861 if (sample_flags_present) 861 if (sample_flags_present)
862 sample_flags.resize(sample_count); 862 sample_flags.resize(sample_count);
863 if (sample_composition_time_offsets_present) 863 if (sample_composition_time_offsets_present)
864 sample_composition_time_offsets.resize(sample_count); 864 sample_composition_time_offsets.resize(sample_count);
865 865
866 for (uint32 i = 0; i < sample_count; ++i) { 866 for (uint32_t i = 0; i < sample_count; ++i) {
867 if (sample_duration_present) 867 if (sample_duration_present)
868 RCHECK(reader->Read4(&sample_durations[i])); 868 RCHECK(reader->Read4(&sample_durations[i]));
869 if (sample_size_present) 869 if (sample_size_present)
870 RCHECK(reader->Read4(&sample_sizes[i])); 870 RCHECK(reader->Read4(&sample_sizes[i]));
871 if (sample_flags_present) 871 if (sample_flags_present)
872 RCHECK(reader->Read4(&sample_flags[i])); 872 RCHECK(reader->Read4(&sample_flags[i]));
873 if (sample_composition_time_offsets_present) 873 if (sample_composition_time_offsets_present)
874 RCHECK(reader->Read4s(&sample_composition_time_offsets[i])); 874 RCHECK(reader->Read4s(&sample_composition_time_offsets[i]));
875 } 875 }
876 876
(...skipping 17 matching lines...) Expand all
894 894
895 if (reader->version() == 1) 895 if (reader->version() == 1)
896 RCHECK(reader->Read4(&grouping_type_parameter)); 896 RCHECK(reader->Read4(&grouping_type_parameter));
897 897
898 if (grouping_type != FOURCC_SEIG) { 898 if (grouping_type != FOURCC_SEIG) {
899 DLOG(WARNING) << "SampleToGroup box with grouping_type '" << grouping_type 899 DLOG(WARNING) << "SampleToGroup box with grouping_type '" << grouping_type
900 << "' is not supported."; 900 << "' is not supported.";
901 return true; 901 return true;
902 } 902 }
903 903
904 uint32 count; 904 uint32_t count;
905 RCHECK(reader->Read4(&count)); 905 RCHECK(reader->Read4(&count));
906 entries.resize(count); 906 entries.resize(count);
907 for (uint32 i = 0; i < count; ++i) { 907 for (uint32_t i = 0; i < count; ++i) {
908 RCHECK(reader->Read4(&entries[i].sample_count) && 908 RCHECK(reader->Read4(&entries[i].sample_count) &&
909 reader->Read4(&entries[i].group_description_index)); 909 reader->Read4(&entries[i].group_description_index));
910 } 910 }
911 return true; 911 return true;
912 } 912 }
913 913
914 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry() 914 CencSampleEncryptionInfoEntry::CencSampleEncryptionInfoEntry()
915 : is_encrypted(false), iv_size(0) {} 915 : is_encrypted(false), iv_size(0) {}
916 CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() {} 916 CencSampleEncryptionInfoEntry::~CencSampleEncryptionInfoEntry() {}
917 917
918 SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {} 918 SampleGroupDescription::SampleGroupDescription() : grouping_type(0) {}
919 SampleGroupDescription::~SampleGroupDescription() {} 919 SampleGroupDescription::~SampleGroupDescription() {}
920 FourCC SampleGroupDescription::BoxType() const { return FOURCC_SGPD; } 920 FourCC SampleGroupDescription::BoxType() const { return FOURCC_SGPD; }
921 921
922 bool SampleGroupDescription::Parse(BoxReader* reader) { 922 bool SampleGroupDescription::Parse(BoxReader* reader) {
923 RCHECK(reader->ReadFullBoxHeader() && 923 RCHECK(reader->ReadFullBoxHeader() &&
924 reader->Read4(&grouping_type)); 924 reader->Read4(&grouping_type));
925 925
926 if (grouping_type != FOURCC_SEIG) { 926 if (grouping_type != FOURCC_SEIG) {
927 DLOG(WARNING) << "SampleGroupDescription box with grouping_type '" 927 DLOG(WARNING) << "SampleGroupDescription box with grouping_type '"
928 << grouping_type << "' is not supported."; 928 << grouping_type << "' is not supported.";
929 return true; 929 return true;
930 } 930 }
931 931
932 const uint8 version = reader->version(); 932 const uint8_t version = reader->version();
933 933
934 const size_t kKeyIdSize = 16; 934 const size_t kKeyIdSize = 16;
935 const size_t kEntrySize = sizeof(uint32) + kKeyIdSize; 935 const size_t kEntrySize = sizeof(uint32_t) + kKeyIdSize;
936 uint32 default_length = 0; 936 uint32_t default_length = 0;
937 if (version == 1) { 937 if (version == 1) {
938 RCHECK(reader->Read4(&default_length)); 938 RCHECK(reader->Read4(&default_length));
939 RCHECK(default_length == 0 || default_length >= kEntrySize); 939 RCHECK(default_length == 0 || default_length >= kEntrySize);
940 } 940 }
941 941
942 uint32 count; 942 uint32_t count;
943 RCHECK(reader->Read4(&count)); 943 RCHECK(reader->Read4(&count));
944 entries.resize(count); 944 entries.resize(count);
945 for (uint32 i = 0; i < count; ++i) { 945 for (uint32_t i = 0; i < count; ++i) {
946 if (version == 1) { 946 if (version == 1) {
947 if (default_length == 0) { 947 if (default_length == 0) {
948 uint32 description_length = 0; 948 uint32_t description_length = 0;
949 RCHECK(reader->Read4(&description_length)); 949 RCHECK(reader->Read4(&description_length));
950 RCHECK(description_length >= kEntrySize); 950 RCHECK(description_length >= kEntrySize);
951 } 951 }
952 } 952 }
953 953
954 uint8 flag; 954 uint8_t flag;
955 RCHECK(reader->SkipBytes(2) && // reserved. 955 RCHECK(reader->SkipBytes(2) && // reserved.
956 reader->Read1(&flag) && 956 reader->Read1(&flag) &&
957 reader->Read1(&entries[i].iv_size) && 957 reader->Read1(&entries[i].iv_size) &&
958 reader->ReadVec(&entries[i].key_id, kKeyIdSize)); 958 reader->ReadVec(&entries[i].key_id, kKeyIdSize));
959 959
960 entries[i].is_encrypted = (flag != 0); 960 entries[i].is_encrypted = (flag != 0);
961 if (entries[i].is_encrypted) { 961 if (entries[i].is_encrypted) {
962 RCHECK(entries[i].iv_size == 8 || entries[i].iv_size == 16); 962 RCHECK(entries[i].iv_size == 8 || entries[i].iv_size == 16);
963 } else { 963 } else {
964 RCHECK(entries[i].iv_size == 0); 964 RCHECK(entries[i].iv_size == 0);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 FourCC IndependentAndDisposableSamples::BoxType() const { return FOURCC_SDTP; } 1017 FourCC IndependentAndDisposableSamples::BoxType() const { return FOURCC_SDTP; }
1018 1018
1019 bool IndependentAndDisposableSamples::Parse(BoxReader* reader) { 1019 bool IndependentAndDisposableSamples::Parse(BoxReader* reader) {
1020 RCHECK(reader->ReadFullBoxHeader()); 1020 RCHECK(reader->ReadFullBoxHeader());
1021 RCHECK(reader->version() == 0); 1021 RCHECK(reader->version() == 0);
1022 RCHECK(reader->flags() == 0); 1022 RCHECK(reader->flags() == 0);
1023 1023
1024 int sample_count = reader->size() - reader->pos(); 1024 int sample_count = reader->size() - reader->pos();
1025 sample_depends_on_.resize(sample_count); 1025 sample_depends_on_.resize(sample_count);
1026 for (int i = 0; i < sample_count; ++i) { 1026 for (int i = 0; i < sample_count; ++i) {
1027 uint8 sample_info; 1027 uint8_t sample_info;
1028 RCHECK(reader->Read1(&sample_info)); 1028 RCHECK(reader->Read1(&sample_info));
1029 1029
1030 sample_depends_on_[i] = 1030 sample_depends_on_[i] =
1031 static_cast<SampleDependsOn>((sample_info >> 4) & 0x3); 1031 static_cast<SampleDependsOn>((sample_info >> 4) & 0x3);
1032 1032
1033 RCHECK(sample_depends_on_[i] != kSampleDependsOnReserved); 1033 RCHECK(sample_depends_on_[i] != kSampleDependsOnReserved);
1034 } 1034 }
1035 1035
1036 return true; 1036 return true;
1037 } 1037 }
1038 1038
1039 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 1039 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
1040 size_t i) const { 1040 size_t i) const {
1041 if (i >= sample_depends_on_.size()) 1041 if (i >= sample_depends_on_.size())
1042 return kSampleDependsOnUnknown; 1042 return kSampleDependsOnUnknown;
1043 1043
1044 return sample_depends_on_[i]; 1044 return sample_depends_on_[i];
1045 } 1045 }
1046 1046
1047 } // namespace mp4 1047 } // namespace mp4
1048 } // namespace media 1048 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698