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

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

Issue 2640113004: Introduce Dolby Vision video codec and Demuxer support (Closed)
Patch Set: fix build break on Android Created 3 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
« no previous file with comments | « media/formats/mp4/avc_unittest.cc ('k') | media/formats/mp4/dolby_vision.h » ('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/box_definitions.h" 5 #include "media/formats/mp4/box_definitions.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/numerics/safe_math.h" 12 #include "base/numerics/safe_math.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "media/base/media_switches.h" 14 #include "media/base/media_switches.h"
15 #include "media/base/video_types.h" 15 #include "media/base/video_types.h"
16 #include "media/base/video_util.h" 16 #include "media/base/video_util.h"
17 #include "media/filters/h264_parser.h" 17 #include "media/filters/h264_parser.h"
18 #include "media/formats/mp4/avc.h" 18 #include "media/formats/mp4/avc.h"
19 #include "media/formats/mp4/es_descriptor.h" 19 #include "media/formats/mp4/es_descriptor.h"
20 #include "media/formats/mp4/rcheck.h" 20 #include "media/formats/mp4/rcheck.h"
21 #include "media/media_features.h" 21 #include "media/media_features.h"
22 22
23 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
24 #include "media/formats/mp4/dolby_vision.h"
25 #endif
26
23 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 27 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
24 #include "media/formats/mp4/hevc.h" 28 #include "media/formats/mp4/hevc.h"
25 #endif 29 #endif
26 30
27 namespace media { 31 namespace media {
28 namespace mp4 { 32 namespace mp4 {
29 33
30 namespace { 34 namespace {
31 35
32 const size_t kKeyIdSize = 16; 36 const size_t kKeyIdSize = 16;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 698
695 bool VideoSampleEntry::Parse(BoxReader* reader) { 699 bool VideoSampleEntry::Parse(BoxReader* reader) {
696 format = reader->type(); 700 format = reader->type();
697 RCHECK(reader->SkipBytes(6) && 701 RCHECK(reader->SkipBytes(6) &&
698 reader->Read2(&data_reference_index) && 702 reader->Read2(&data_reference_index) &&
699 reader->SkipBytes(16) && 703 reader->SkipBytes(16) &&
700 reader->Read2(&width) && 704 reader->Read2(&width) &&
701 reader->Read2(&height) && 705 reader->Read2(&height) &&
702 reader->SkipBytes(50)); 706 reader->SkipBytes(50));
703 707
704 RCHECK(reader->ScanChildren() && 708 RCHECK(reader->ScanChildren());
705 reader->MaybeReadChild(&pixel_aspect)); 709 if (reader->HasChild(&pixel_aspect)) {
710 RCHECK(reader->MaybeReadChild(&pixel_aspect));
711 }
706 712
707 if (format == FOURCC_ENCV) { 713 if (format == FOURCC_ENCV) {
708 // Continue scanning until a recognized protection scheme is found, or until 714 // Continue scanning until a recognized protection scheme is found, or until
709 // we run out of protection schemes. 715 // we run out of protection schemes.
710 while (!sinf.HasSupportedScheme()) { 716 while (!sinf.HasSupportedScheme()) {
711 if (!reader->ReadChild(&sinf)) 717 if (!reader->ReadChild(&sinf))
712 return false; 718 return false;
713 } 719 }
714 } 720 }
715 721
716 const FourCC actual_format = 722 const FourCC actual_format =
717 format == FOURCC_ENCV ? sinf.format.format : format; 723 format == FOURCC_ENCV ? sinf.format.format : format;
718 switch (actual_format) { 724 switch (actual_format) {
719 case FOURCC_AVC1: 725 case FOURCC_AVC1:
720 case FOURCC_AVC3: { 726 case FOURCC_AVC3: {
721 DVLOG(2) << __func__ << " reading AVCDecoderConfigurationRecord (avcC)"; 727 DVLOG(2) << __func__ << " reading AVCDecoderConfigurationRecord (avcC)";
722 std::unique_ptr<AVCDecoderConfigurationRecord> avcConfig( 728 std::unique_ptr<AVCDecoderConfigurationRecord> avcConfig(
723 new AVCDecoderConfigurationRecord()); 729 new AVCDecoderConfigurationRecord());
724 RCHECK(reader->ReadChild(avcConfig.get())); 730 RCHECK(reader->ReadChild(avcConfig.get()));
725 video_codec = kCodecH264; 731 video_codec = kCodecH264;
726 video_codec_profile = H264Parser::ProfileIDCToVideoCodecProfile( 732 video_codec_profile = H264Parser::ProfileIDCToVideoCodecProfile(
727 avcConfig->profile_indication); 733 avcConfig->profile_indication);
728 frame_bitstream_converter = 734 frame_bitstream_converter =
729 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig))); 735 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
736 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
737 // It can be Dolby Vision stream if there is DVCC box.
738 DolbyVisionConfiguration dvccConfig;
739 if (reader->HasChild(&dvccConfig) && reader->ReadChild(&dvccConfig)) {
740 DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
741 static_cast<AVCBitstreamConverter*>(frame_bitstream_converter.get())
742 ->DisablePostAnnexbValidation();
743 video_codec = kCodecDolbyVision;
744 video_codec_profile = dvccConfig.codec_profile;
745 }
746 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
730 break; 747 break;
731 } 748 }
732 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 749 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
733 case FOURCC_HEV1: 750 case FOURCC_HEV1:
734 case FOURCC_HVC1: { 751 case FOURCC_HVC1: {
735 DVLOG(2) << __func__ << " parsing HEVCDecoderConfigurationRecord (hvcC)"; 752 DVLOG(2) << __func__ << " parsing HEVCDecoderConfigurationRecord (hvcC)";
736 std::unique_ptr<HEVCDecoderConfigurationRecord> hevcConfig( 753 std::unique_ptr<HEVCDecoderConfigurationRecord> hevcConfig(
737 new HEVCDecoderConfigurationRecord()); 754 new HEVCDecoderConfigurationRecord());
738 RCHECK(reader->ReadChild(hevcConfig.get())); 755 RCHECK(reader->ReadChild(hevcConfig.get()));
739 video_codec = kCodecHEVC; 756 video_codec = kCodecHEVC;
740 video_codec_profile = hevcConfig->GetVideoProfile(); 757 video_codec_profile = hevcConfig->GetVideoProfile();
741 frame_bitstream_converter = 758 frame_bitstream_converter =
742 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig))); 759 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
760 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
761 // It can be Dolby Vision stream if there is DVCC box.
762 DolbyVisionConfiguration dvccConfig;
763 if (reader->HasChild(&dvccConfig) && reader->ReadChild(&dvccConfig)) {
764 DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
765 video_codec = kCodecDolbyVision;
766 video_codec_profile = dvccConfig.codec_profile;
767 }
768 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
743 break; 769 break;
744 } 770 }
745 #endif 771 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
772 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
773 case FOURCC_DVA1:
774 case FOURCC_DVAV: {
775 DVLOG(2) << __func__ << " reading AVCDecoderConfigurationRecord (avcC)";
776 std::unique_ptr<AVCDecoderConfigurationRecord> avcConfig(
777 new AVCDecoderConfigurationRecord());
778 RCHECK(reader->ReadChild(avcConfig.get()));
779 frame_bitstream_converter =
780 make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
781 DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
782 DolbyVisionConfiguration dvccConfig;
783 RCHECK(reader->ReadChild(&dvccConfig));
784 video_codec = kCodecDolbyVision;
785 video_codec_profile = dvccConfig.codec_profile;
786 break;
787 }
788 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
789 case FOURCC_DVH1:
790 case FOURCC_DVHE: {
791 DVLOG(2) << __func__ << " reading HEVCDecoderConfigurationRecord (hvcC)";
792 std::unique_ptr<HEVCDecoderConfigurationRecord> hevcConfig(
793 new HEVCDecoderConfigurationRecord());
794 RCHECK(reader->ReadChild(hevcConfig.get()));
795 frame_bitstream_converter =
796 make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
797 DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
798 DolbyVisionConfiguration dvccConfig;
799 RCHECK(reader->ReadChild(&dvccConfig));
800 video_codec = kCodecDolbyVision;
801 video_codec_profile = dvccConfig.codec_profile;
802 break;
803 }
804 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
805 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
746 case FOURCC_VP09: 806 case FOURCC_VP09:
747 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 807 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
748 switches::kEnableVp9InMp4)) { 808 switches::kEnableVp9InMp4)) {
749 DVLOG(2) << __func__ << " parsing VPCodecConfigurationRecord (vpcC)"; 809 DVLOG(2) << __func__ << " parsing VPCodecConfigurationRecord (vpcC)";
750 std::unique_ptr<VPCodecConfigurationRecord> vp_config( 810 std::unique_ptr<VPCodecConfigurationRecord> vp_config(
751 new VPCodecConfigurationRecord()); 811 new VPCodecConfigurationRecord());
752 RCHECK(reader->ReadChild(vp_config.get())); 812 RCHECK(reader->ReadChild(vp_config.get()));
753 frame_bitstream_converter = nullptr; 813 frame_bitstream_converter = nullptr;
754 video_codec = kCodecVP9; 814 video_codec = kCodecVP9;
755 video_codec_profile = vp_config->profile; 815 video_codec_profile = vp_config->profile;
(...skipping 15 matching lines...) Expand all
771 831
772 bool VideoSampleEntry::IsFormatValid() const { 832 bool VideoSampleEntry::IsFormatValid() const {
773 const FourCC actual_format = 833 const FourCC actual_format =
774 format == FOURCC_ENCV ? sinf.format.format : format; 834 format == FOURCC_ENCV ? sinf.format.format : format;
775 switch (actual_format) { 835 switch (actual_format) {
776 case FOURCC_AVC1: 836 case FOURCC_AVC1:
777 case FOURCC_AVC3: 837 case FOURCC_AVC3:
778 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) 838 #if BUILDFLAG(ENABLE_HEVC_DEMUXING)
779 case FOURCC_HEV1: 839 case FOURCC_HEV1:
780 case FOURCC_HVC1: 840 case FOURCC_HVC1:
781 #endif 841 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
842 case FOURCC_DVH1:
843 case FOURCC_DVHE:
844 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
845 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
846 #if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
847 case FOURCC_DVA1:
848 case FOURCC_DVAV:
849 #endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
782 return true; 850 return true;
783 case FOURCC_VP09: 851 case FOURCC_VP09:
784 return base::CommandLine::ForCurrentProcess()->HasSwitch( 852 return base::CommandLine::ForCurrentProcess()->HasSwitch(
785 switches::kEnableVp9InMp4); 853 switches::kEnableVp9InMp4);
786 default: 854 default:
787 return false; 855 return false;
788 } 856 }
789 } 857 }
790 858
791 ElementaryStreamDescriptor::ElementaryStreamDescriptor() 859 ElementaryStreamDescriptor::ElementaryStreamDescriptor()
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on( 1458 SampleDependsOn IndependentAndDisposableSamples::sample_depends_on(
1391 size_t i) const { 1459 size_t i) const {
1392 if (i >= sample_depends_on_.size()) 1460 if (i >= sample_depends_on_.size())
1393 return kSampleDependsOnUnknown; 1461 return kSampleDependsOnUnknown;
1394 1462
1395 return sample_depends_on_[i]; 1463 return sample_depends_on_[i];
1396 } 1464 }
1397 1465
1398 } // namespace mp4 1466 } // namespace mp4
1399 } // namespace media 1467 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/avc_unittest.cc ('k') | media/formats/mp4/dolby_vision.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698