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

Unified Diff: media/formats/mp4/box_definitions.cc

Issue 2640113004: Introduce Dolby Vision video codec and Demuxer support (Closed)
Patch Set: fix CQ failure Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/formats/mp4/box_definitions.cc
diff --git a/media/formats/mp4/box_definitions.cc b/media/formats/mp4/box_definitions.cc
index b6ea088aff8abb45112a30c87a97ac779d58a3d2..03c14bd6226e00adefee4990cb20c6ed9cbadcb0 100644
--- a/media/formats/mp4/box_definitions.cc
+++ b/media/formats/mp4/box_definitions.cc
@@ -20,6 +20,10 @@
#include "media/formats/mp4/rcheck.h"
#include "media/media_features.h"
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+#include "media/formats/mp4/dolby_vision.h"
+#endif
+
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
#include "media/formats/mp4/hevc.h"
#endif
@@ -706,8 +710,10 @@ bool VideoSampleEntry::Parse(BoxReader* reader) {
reader->Read2(&height) &&
reader->SkipBytes(50));
- RCHECK(reader->ScanChildren() &&
- reader->MaybeReadChild(&pixel_aspect));
+ RCHECK(reader->ScanChildren());
+ if (reader->HasChild(&pixel_aspect)) {
+ RCHECK(reader->MaybeReadChild(&pixel_aspect));
+ }
if (format == FOURCC_ENCV) {
// Continue scanning until a recognized protection scheme is found, or until
@@ -732,6 +738,17 @@ bool VideoSampleEntry::Parse(BoxReader* reader) {
avcConfig->profile_indication);
frame_bitstream_converter =
make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+ // It can be Dolby Vision stream if there is DVCC box.
+ DolbyVisionConfiguration dvccConfig;
+ if (reader->HasChild(&dvccConfig) && reader->ReadChild(&dvccConfig)) {
+ DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
+ static_cast<AVCBitstreamConverter*>(frame_bitstream_converter.get())
+ ->DisablePostAnnexbValidation();
+ video_codec = kCodecDolbyVision;
+ video_codec_profile = dvccConfig.codec_profile;
+ }
+#endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
break;
}
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
@@ -745,9 +762,52 @@ bool VideoSampleEntry::Parse(BoxReader* reader) {
video_codec_profile = hevcConfig->GetVideoProfile();
frame_bitstream_converter =
make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+ // It can be Dolby Vision stream if there is DVCC box.
+ DolbyVisionConfiguration dvccConfig;
+ if (reader->HasChild(&dvccConfig) && reader->ReadChild(&dvccConfig)) {
+ DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
+ video_codec = kCodecDolbyVision;
+ video_codec_profile = dvccConfig.codec_profile;
+ }
+#endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
break;
}
-#endif
+#endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+ case FOURCC_DVA1:
+ case FOURCC_DVAV: {
+ DVLOG(2) << __func__ << " reading AVCDecoderConfigurationRecord (avcC)";
+ std::unique_ptr<AVCDecoderConfigurationRecord> avcConfig(
+ new AVCDecoderConfigurationRecord());
+ RCHECK(reader->ReadChild(avcConfig.get()));
+ frame_bitstream_converter =
+ make_scoped_refptr(new AVCBitstreamConverter(std::move(avcConfig)));
+ DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
+ DolbyVisionConfiguration dvccConfig;
+ RCHECK(reader->ReadChild(&dvccConfig));
+ video_codec = kCodecDolbyVision;
+ video_codec_profile = dvccConfig.codec_profile;
+ break;
+ }
+#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
+ case FOURCC_DVH1:
+ case FOURCC_DVHE: {
+ DVLOG(2) << __func__ << " reading HEVCDecoderConfigurationRecord (hvcC)";
+ std::unique_ptr<HEVCDecoderConfigurationRecord> hevcConfig(
+ new HEVCDecoderConfigurationRecord());
+ RCHECK(reader->ReadChild(hevcConfig.get()));
+ frame_bitstream_converter =
+ make_scoped_refptr(new HEVCBitstreamConverter(std::move(hevcConfig)));
+ DVLOG(2) << __func__ << " reading DolbyVisionConfiguration (dvcC)";
+ DolbyVisionConfiguration dvccConfig;
+ RCHECK(reader->ReadChild(&dvccConfig));
+ video_codec = kCodecDolbyVision;
+ video_codec_profile = dvccConfig.codec_profile;
+ break;
+ }
+#endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
+#endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
case FOURCC_VP09:
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableVp9InMp4)) {
@@ -783,7 +843,15 @@ bool VideoSampleEntry::IsFormatValid() const {
#if BUILDFLAG(ENABLE_HEVC_DEMUXING)
case FOURCC_HEV1:
case FOURCC_HVC1:
-#endif
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+ case FOURCC_DVH1:
+ case FOURCC_DVHE:
+#endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+#endif // BUILDFLAG(ENABLE_HEVC_DEMUXING)
+#if BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
+ case FOURCC_DVA1:
+ case FOURCC_DVAV:
+#endif // BUILDFLAG(ENABLE_DOLBY_VISION_DEMUXING)
return true;
case FOURCC_VP09:
return base::CommandLine::ForCurrentProcess()->HasSwitch(

Powered by Google App Engine
This is Rietveld 408576698