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

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

Issue 1624703002: Implement support for vp9 in ISO-BMFF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/video_types.h" 10 #include "media/base/video_types.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 471
472 VideoSampleEntry::~VideoSampleEntry() {} 472 VideoSampleEntry::~VideoSampleEntry() {}
473 FourCC VideoSampleEntry::BoxType() const { 473 FourCC VideoSampleEntry::BoxType() const {
474 DCHECK(false) << "VideoSampleEntry should be parsed according to the " 474 DCHECK(false) << "VideoSampleEntry should be parsed according to the "
475 << "handler type recovered in its Media ancestor."; 475 << "handler type recovered in its Media ancestor.";
476 return FOURCC_NULL; 476 return FOURCC_NULL;
477 } 477 }
478 478
479 namespace { 479 namespace {
480 480
481 bool IsFormatValidH264(const FourCC& format, 481 bool IsFormatValidH264(FourCC format) {
482 const ProtectionSchemeInfo& sinf) { 482 return format == FOURCC_AVC1 || format == FOURCC_AVC3;
483 return format == FOURCC_AVC1 || format == FOURCC_AVC3 ||
484 (format == FOURCC_ENCV && (sinf.format.format == FOURCC_AVC1 ||
485 sinf.format.format == FOURCC_AVC3));
486 } 483 }
487 484
488 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 485 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
489 bool IsFormatValidHEVC(const FourCC& format, 486 bool IsFormatValidHEVC(FourCC format) {
490 const ProtectionSchemeInfo& sinf) { 487 return format == FOURCC_HEV1 || format == FOURCC_HVC1;
491 return format == FOURCC_HEV1 || format == FOURCC_HVC1 ||
492 (format == FOURCC_ENCV && (sinf.format.format == FOURCC_HEV1 ||
493 sinf.format.format == FOURCC_HVC1));
494 } 488 }
495 #endif 489 #endif
496 490
491 bool IsFormatValidVpx(FourCC format) {
492 return format == FOURCC_VP08 || format == FOURCC_VP09;
493 }
494
497 } 495 }
498 496
499 bool VideoSampleEntry::Parse(BoxReader* reader) { 497 bool VideoSampleEntry::Parse(BoxReader* reader) {
500 format = reader->type(); 498 format = reader->type();
501 RCHECK(reader->SkipBytes(6) && 499 RCHECK(reader->SkipBytes(6) &&
502 reader->Read2(&data_reference_index) && 500 reader->Read2(&data_reference_index) &&
503 reader->SkipBytes(16) && 501 reader->SkipBytes(16) &&
504 reader->Read2(&width) && 502 reader->Read2(&width) &&
505 reader->Read2(&height) && 503 reader->Read2(&height) &&
506 reader->SkipBytes(50)); 504 reader->SkipBytes(50));
507 505
508 RCHECK(reader->ScanChildren() && 506 RCHECK(reader->ScanChildren() &&
509 reader->MaybeReadChild(&pixel_aspect)); 507 reader->MaybeReadChild(&pixel_aspect));
510 508
511 if (format == FOURCC_ENCV) { 509 if (format == FOURCC_ENCV) {
512 // Continue scanning until a recognized protection scheme is found, or until 510 // Continue scanning until a recognized protection scheme is found, or until
513 // we run out of protection schemes. 511 // we run out of protection schemes.
514 while (sinf.type.type != FOURCC_CENC) { 512 while (sinf.type.type != FOURCC_CENC) {
515 if (!reader->ReadChild(&sinf)) 513 if (!reader->ReadChild(&sinf))
516 return false; 514 return false;
517 } 515 }
518 } 516 }
519 517
520 if (IsFormatValidH264(format, sinf)) { 518 const FourCC actual_format =
519 format == FOURCC_ENCV ? sinf.format.format : format;
520 if (IsFormatValidH264(actual_format)) {
521 DVLOG(2) << __FUNCTION__ 521 DVLOG(2) << __FUNCTION__
522 << " reading AVCDecoderConfigurationRecord (avcC)"; 522 << " reading AVCDecoderConfigurationRecord (avcC)";
523 scoped_ptr<AVCDecoderConfigurationRecord> avcConfig( 523 scoped_ptr<AVCDecoderConfigurationRecord> avcConfig(
524 new AVCDecoderConfigurationRecord()); 524 new AVCDecoderConfigurationRecord());
525 RCHECK(reader->ReadChild(avcConfig.get())); 525 RCHECK(reader->ReadChild(avcConfig.get()));
526 frame_bitstream_converter = 526 frame_bitstream_converter =
527 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig))); 527 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
528 video_codec = kCodecH264; 528 video_codec = kCodecH264;
529 video_codec_profile = H264PROFILE_MAIN; 529 video_codec_profile = H264PROFILE_MAIN;
530 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 530 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
531 } else if (IsFormatValidHEVC(format, sinf)) { 531 } else if (IsFormatValidHEVC(actual_format)) {
532 DVLOG(2) << __FUNCTION__ 532 DVLOG(2) << __FUNCTION__
533 << " parsing HEVCDecoderConfigurationRecord (hvcC)"; 533 << " parsing HEVCDecoderConfigurationRecord (hvcC)";
534 scoped_ptr<HEVCDecoderConfigurationRecord> hevcConfig( 534 scoped_ptr<HEVCDecoderConfigurationRecord> hevcConfig(
535 new HEVCDecoderConfigurationRecord()); 535 new HEVCDecoderConfigurationRecord());
536 RCHECK(reader->ReadChild(hevcConfig.get())); 536 RCHECK(reader->ReadChild(hevcConfig.get()));
537 frame_bitstream_converter = 537 frame_bitstream_converter =
538 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig))); 538 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
539 video_codec = kCodecHEVC; 539 video_codec = kCodecHEVC;
540 #endif 540 #endif
541 } else if (IsFormatValidVpx(actual_format)) {
542 frame_bitstream_converter = NULL;
543 switch (actual_format) {
544 case FOURCC_VP08:
545 video_codec = kCodecVP8;
546 video_codec_profile = VP8PROFILE_ANY;
547 break;
548 case FOURCC_VP09:
549 video_codec = kCodecVP9;
550 video_codec_profile = VP9PROFILE_ANY;
551 break;
552 default:
553 NOTREACHED() << "Unexpected format " << actual_format;
554 }
541 } else { 555 } else {
542 // Unknown/unsupported format 556 // Unknown/unsupported format
543 MEDIA_LOG(ERROR, reader->media_log()) << __FUNCTION__ 557 MEDIA_LOG(ERROR, reader->media_log()) << __FUNCTION__
544 << " unsupported video format " 558 << " unsupported video format "
545 << FourCCToString(format); 559 << FourCCToString(format);
546 return false; 560 return false;
547 } 561 }
548 562
549 return true; 563 return true;
550 } 564 }
551 565
552 bool VideoSampleEntry::IsFormatValid() const { 566 bool VideoSampleEntry::IsFormatValid() const {
567 const FourCC actual_format =
568 format == FOURCC_ENCV ? sinf.format.format : format;
553 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 569 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
554 if (IsFormatValidHEVC(format, sinf)) 570 if (IsFormatValidHEVC(actual_format))
555 return true; 571 return true;
556 #endif 572 #endif
557 return IsFormatValidH264(format, sinf); 573 if (IsFormatValidH264(actual_format))
574 return true;
575 if (IsFormatValidVpx(actual_format))
576 return true;
577 return false;
558 } 578 }
559 579
560 ElementaryStreamDescriptor::ElementaryStreamDescriptor() 580 ElementaryStreamDescriptor::ElementaryStreamDescriptor()
561 : object_type(kForbidden) {} 581 : object_type(kForbidden) {}
562 582
563 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {} 583 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {}
564 584
565 FourCC ElementaryStreamDescriptor::BoxType() const { 585 FourCC ElementaryStreamDescriptor::BoxType() const {
566 return FOURCC_ESDS; 586 return FOURCC_ESDS;
567 } 587 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 1062 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
1043 size_t i) const { 1063 size_t i) const {
1044 if (i >= sample_depends_on_.size()) 1064 if (i >= sample_depends_on_.size())
1045 return kSampleDependsOnUnknown; 1065 return kSampleDependsOnUnknown;
1046 1066
1047 return sample_depends_on_[i]; 1067 return sample_depends_on_[i];
1048 } 1068 }
1049 1069
1050 } // namespace mp4 1070 } // namespace mp4
1051 } // namespace media 1071 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698