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

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

Issue 276503002: Log codec IDs for MediaSource content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
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/formats/mp4/es_descriptor.h" 8 #include "media/formats/mp4/es_descriptor.h"
9 #include "media/formats/mp4/rcheck.h" 9 #include "media/formats/mp4/rcheck.h"
10 10
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 : version(0), 342 : version(0),
343 profile_indication(0), 343 profile_indication(0),
344 profile_compatibility(0), 344 profile_compatibility(0),
345 avc_level(0), 345 avc_level(0),
346 length_size(0) {} 346 length_size(0) {}
347 347
348 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {} 348 AVCDecoderConfigurationRecord::~AVCDecoderConfigurationRecord() {}
349 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; } 349 FourCC AVCDecoderConfigurationRecord::BoxType() const { return FOURCC_AVCC; }
350 350
351 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) { 351 bool AVCDecoderConfigurationRecord::Parse(BoxReader* reader) {
352 return ParseInternal(reader); 352 return ParseInternal(reader, reader->log_cb());
353 } 353 }
354 354
355 bool AVCDecoderConfigurationRecord::Parse(const uint8* data, int data_size) { 355 bool AVCDecoderConfigurationRecord::Parse(const uint8* data, int data_size) {
356 BufferReader reader(data, data_size); 356 BufferReader reader(data, data_size);
357 return ParseInternal(&reader); 357 return ParseInternal(&reader, LogCB());
358 } 358 }
359 359
360 bool AVCDecoderConfigurationRecord::ParseInternal(BufferReader* reader) { 360 bool AVCDecoderConfigurationRecord::ParseInternal(BufferReader* reader,
361 const LogCB& log_cb) {
361 RCHECK(reader->Read1(&version) && version == 1 && 362 RCHECK(reader->Read1(&version) && version == 1 &&
362 reader->Read1(&profile_indication) && 363 reader->Read1(&profile_indication) &&
363 reader->Read1(&profile_compatibility) && 364 reader->Read1(&profile_compatibility) &&
364 reader->Read1(&avc_level)); 365 reader->Read1(&avc_level));
365 366
366 uint8 length_size_minus_one; 367 uint8 length_size_minus_one;
367 RCHECK(reader->Read1(&length_size_minus_one) && 368 RCHECK(reader->Read1(&length_size_minus_one) &&
368 (length_size_minus_one & 0xfc) == 0xfc); 369 (length_size_minus_one & 0xfc) == 0xfc);
369 length_size = (length_size_minus_one & 0x3) + 1; 370 length_size = (length_size_minus_one & 0x3) + 1;
370 371
371 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid. 372 RCHECK(length_size != 3); // Only values of 1, 2, and 4 are valid.
372 373
373 uint8 num_sps; 374 uint8 num_sps;
374 RCHECK(reader->Read1(&num_sps) && (num_sps & 0xe0) == 0xe0); 375 RCHECK(reader->Read1(&num_sps) && (num_sps & 0xe0) == 0xe0);
375 num_sps &= 0x1f; 376 num_sps &= 0x1f;
376 377
377 sps_list.resize(num_sps); 378 sps_list.resize(num_sps);
378 for (int i = 0; i < num_sps; i++) { 379 for (int i = 0; i < num_sps; i++) {
379 uint16 sps_length; 380 uint16 sps_length;
380 RCHECK(reader->Read2(&sps_length) && 381 RCHECK(reader->Read2(&sps_length) &&
381 reader->ReadVec(&sps_list[i], sps_length)); 382 reader->ReadVec(&sps_list[i], sps_length));
383 RCHECK(sps_list[i].size() > 4);
384
385 if (!log_cb.is_null()) {
386 MEDIA_LOG(log_cb) << "Video codec: avc1." << std::hex
387 << static_cast<int>(sps_list[i][1])
388 << static_cast<int>(sps_list[i][2])
389 << static_cast<int>(sps_list[i][3]);
390 }
382 } 391 }
383 392
384 uint8 num_pps; 393 uint8 num_pps;
385 RCHECK(reader->Read1(&num_pps)); 394 RCHECK(reader->Read1(&num_pps));
386 395
387 pps_list.resize(num_pps); 396 pps_list.resize(num_pps);
388 for (int i = 0; i < num_pps; i++) { 397 for (int i = 0; i < num_pps; i++) {
389 uint16 pps_length; 398 uint16 pps_length;
390 RCHECK(reader->Read2(&pps_length) && 399 RCHECK(reader->Read2(&pps_length) &&
391 reader->ReadVec(&pps_list[i], pps_length)); 400 reader->ReadVec(&pps_list[i], pps_length));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 bool ElementaryStreamDescriptor::Parse(BoxReader* reader) { 471 bool ElementaryStreamDescriptor::Parse(BoxReader* reader) {
463 std::vector<uint8> data; 472 std::vector<uint8> data;
464 ESDescriptor es_desc; 473 ESDescriptor es_desc;
465 474
466 RCHECK(reader->ReadFullBoxHeader()); 475 RCHECK(reader->ReadFullBoxHeader());
467 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos())); 476 RCHECK(reader->ReadVec(&data, reader->size() - reader->pos()));
468 RCHECK(es_desc.Parse(data)); 477 RCHECK(es_desc.Parse(data));
469 478
470 object_type = es_desc.object_type(); 479 object_type = es_desc.object_type();
471 480
472 RCHECK(aac.Parse(es_desc.decoder_specific_info())); 481 if (object_type != 0x40) {
482 MEDIA_LOG(reader->log_cb()) << "Audio codec: mp4a."
483 << std::hex << static_cast<int>(object_type);
484 }
485
486 if (es_desc.IsAAC(object_type))
487 RCHECK(aac.Parse(es_desc.decoder_specific_info(), reader->log_cb()));
473 488
474 return true; 489 return true;
475 } 490 }
476 491
477 AudioSampleEntry::AudioSampleEntry() 492 AudioSampleEntry::AudioSampleEntry()
478 : format(FOURCC_NULL), 493 : format(FOURCC_NULL),
479 data_reference_index(0), 494 data_reference_index(0),
480 channelcount(0), 495 channelcount(0),
481 samplesize(0), 496 samplesize(0),
482 samplerate(0) {} 497 samplerate(0) {}
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 840 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
826 size_t i) const { 841 size_t i) const {
827 if (i >= sample_depends_on_.size()) 842 if (i >= sample_depends_on_.size())
828 return kSampleDependsOnUnknown; 843 return kSampleDependsOnUnknown;
829 844
830 return sample_depends_on_[i]; 845 return sample_depends_on_[i];
831 } 846 }
832 847
833 } // namespace mp4 848 } // namespace mp4
834 } // namespace media 849 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698