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

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, 9 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 "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 video_codec(kUnknownVideoCodec), 468 video_codec(kUnknownVideoCodec),
469 video_codec_profile(VIDEO_CODEC_PROFILE_UNKNOWN) {} 469 video_codec_profile(VIDEO_CODEC_PROFILE_UNKNOWN) {}
470 470
471 VideoSampleEntry::~VideoSampleEntry() {} 471 VideoSampleEntry::~VideoSampleEntry() {}
472 FourCC VideoSampleEntry::BoxType() const { 472 FourCC VideoSampleEntry::BoxType() const {
473 DCHECK(false) << "VideoSampleEntry should be parsed according to the " 473 DCHECK(false) << "VideoSampleEntry should be parsed according to the "
474 << "handler type recovered in its Media ancestor."; 474 << "handler type recovered in its Media ancestor.";
475 return FOURCC_NULL; 475 return FOURCC_NULL;
476 } 476 }
477 477
478 namespace {
479
480 bool IsFormatValidH264(const FourCC& format,
481 const ProtectionSchemeInfo& sinf) {
482 return format == FOURCC_AVC1 || format == FOURCC_AVC3 ||
483 (format == FOURCC_ENCV && (sinf.format.format == FOURCC_AVC1 ||
484 sinf.format.format == FOURCC_AVC3));
485 }
486
487 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
488 bool IsFormatValidHEVC(const FourCC& format,
489 const ProtectionSchemeInfo& sinf) {
490 return format == FOURCC_HEV1 || format == FOURCC_HVC1 ||
491 (format == FOURCC_ENCV && (sinf.format.format == FOURCC_HEV1 ||
492 sinf.format.format == FOURCC_HVC1));
493 }
494 #endif
495
496 }
497
498 bool VideoSampleEntry::Parse(BoxReader* reader) { 478 bool VideoSampleEntry::Parse(BoxReader* reader) {
499 format = reader->type(); 479 format = reader->type();
500 RCHECK(reader->SkipBytes(6) && 480 RCHECK(reader->SkipBytes(6) &&
501 reader->Read2(&data_reference_index) && 481 reader->Read2(&data_reference_index) &&
502 reader->SkipBytes(16) && 482 reader->SkipBytes(16) &&
503 reader->Read2(&width) && 483 reader->Read2(&width) &&
504 reader->Read2(&height) && 484 reader->Read2(&height) &&
505 reader->SkipBytes(50)); 485 reader->SkipBytes(50));
506 486
507 RCHECK(reader->ScanChildren() && 487 RCHECK(reader->ScanChildren() &&
508 reader->MaybeReadChild(&pixel_aspect)); 488 reader->MaybeReadChild(&pixel_aspect));
509 489
510 if (format == FOURCC_ENCV) { 490 if (format == FOURCC_ENCV) {
511 // Continue scanning until a recognized protection scheme is found, or until 491 // Continue scanning until a recognized protection scheme is found, or until
512 // we run out of protection schemes. 492 // we run out of protection schemes.
513 while (sinf.type.type != FOURCC_CENC) { 493 while (sinf.type.type != FOURCC_CENC) {
514 if (!reader->ReadChild(&sinf)) 494 if (!reader->ReadChild(&sinf))
515 return false; 495 return false;
516 } 496 }
517 } 497 }
518 498
519 if (IsFormatValidH264(format, sinf)) { 499 const FourCC actual_format =
520 DVLOG(2) << __FUNCTION__ 500 format == FOURCC_ENCV ? sinf.format.format : format;
521 << " reading AVCDecoderConfigurationRecord (avcC)"; 501 switch (actual_format) {
522 scoped_ptr<AVCDecoderConfigurationRecord> avcConfig( 502 case FOURCC_AVC1:
523 new AVCDecoderConfigurationRecord()); 503 case FOURCC_AVC3: {
524 RCHECK(reader->ReadChild(avcConfig.get())); 504 DVLOG(2) << __FUNCTION__
525 frame_bitstream_converter = 505 << " reading AVCDecoderConfigurationRecord (avcC)";
526 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig))); 506 scoped_ptr<AVCDecoderConfigurationRecord> avcConfig(
527 video_codec = kCodecH264; 507 new AVCDecoderConfigurationRecord());
528 video_codec_profile = H264PROFILE_MAIN; 508 RCHECK(reader->ReadChild(avcConfig.get()));
509 frame_bitstream_converter =
510 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
511 video_codec = kCodecH264;
512 video_codec_profile = H264PROFILE_MAIN;
513 break;
514 }
529 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 515 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
530 } else if (IsFormatValidHEVC(format, sinf)) { 516 case FOURCC_HEV1:
531 DVLOG(2) << __FUNCTION__ 517 case FOURCC_HVC1: {
532 << " parsing HEVCDecoderConfigurationRecord (hvcC)"; 518 DVLOG(2) << __FUNCTION__
533 scoped_ptr<HEVCDecoderConfigurationRecord> hevcConfig( 519 << " parsing HEVCDecoderConfigurationRecord (hvcC)";
534 new HEVCDecoderConfigurationRecord()); 520 scoped_ptr<HEVCDecoderConfigurationRecord> hevcConfig(
535 RCHECK(reader->ReadChild(hevcConfig.get())); 521 new HEVCDecoderConfigurationRecord());
536 frame_bitstream_converter = 522 RCHECK(reader->ReadChild(hevcConfig.get()));
537 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig))); 523 frame_bitstream_converter =
538 video_codec = kCodecHEVC; 524 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
525 video_codec = kCodecHEVC;
526 break;
527 }
539 #endif 528 #endif
540 } else { 529 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
541 // Unknown/unsupported format 530 case FOURCC_VP09:
542 MEDIA_LOG(ERROR, reader->media_log()) << __FUNCTION__ 531 frame_bitstream_converter = NULL;
543 << " unsupported video format " 532 video_codec = kCodecVP9;
544 << FourCCToString(format); 533 video_codec_profile = VP9PROFILE_ANY;
545 return false; 534 break;
535 #endif
536 default:
537 // Unknown/unsupported format
538 MEDIA_LOG(ERROR, reader->media_log()) << __FUNCTION__
539 << " unsupported video format "
540 << FourCCToString(actual_format);
541 return false;
546 } 542 }
547 543
548 return true; 544 return true;
549 } 545 }
550 546
551 bool VideoSampleEntry::IsFormatValid() const { 547 bool VideoSampleEntry::IsFormatValid() const {
548 const FourCC actual_format =
549 format == FOURCC_ENCV ? sinf.format.format : format;
550 switch (actual_format) {
551 case FOURCC_AVC1:
552 case FOURCC_AVC3:
552 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 553 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
553 if (IsFormatValidHEVC(format, sinf)) 554 case FOURCC_HEV1:
554 return true; 555 case FOURCC_HVC1:
555 #endif 556 #endif
556 return IsFormatValidH264(format, sinf); 557 #if BUILDFLAG(ENABLE_MP4_VP9_DEMUXING)
558 case FOURCC_VP09:
559 #endif
560 return true;
561 default:
562 return false;
563 }
557 } 564 }
558 565
559 ElementaryStreamDescriptor::ElementaryStreamDescriptor() 566 ElementaryStreamDescriptor::ElementaryStreamDescriptor()
560 : object_type(kForbidden) {} 567 : object_type(kForbidden) {}
561 568
562 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {} 569 ElementaryStreamDescriptor::~ElementaryStreamDescriptor() {}
563 570
564 FourCC ElementaryStreamDescriptor::BoxType() const { 571 FourCC ElementaryStreamDescriptor::BoxType() const {
565 return FOURCC_ESDS; 572 return FOURCC_ESDS;
566 } 573 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 1048 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
1042 size_t i) const { 1049 size_t i) const {
1043 if (i >= sample_depends_on_.size()) 1050 if (i >= sample_depends_on_.size())
1044 return kSampleDependsOnUnknown; 1051 return kSampleDependsOnUnknown;
1045 1052
1046 return sample_depends_on_[i]; 1053 return sample_depends_on_[i];
1047 } 1054 }
1048 1055
1049 } // namespace mp4 1056 } // namespace mp4
1050 } // namespace media 1057 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698