Chromium Code Reviews| Index: media/formats/mp4/dolby_vision.cc |
| diff --git a/media/formats/mp4/dolby_vision.cc b/media/formats/mp4/dolby_vision.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..79ec609cd1724dddec1054380a3bf4ed04cfb0d8 |
| --- /dev/null |
| +++ b/media/formats/mp4/dolby_vision.cc |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/formats/mp4/dolby_vision.h" |
| + |
| +#include "base/logging.h" |
| +#include "media/base/video_codecs.h" |
| +#include "media/formats/mp4/box_definitions.h" |
| +#include "media/formats/mp4/box_reader.h" |
| + |
| +namespace media { |
| +namespace mp4 { |
| + |
| +DolbyVisionConfiguration::DolbyVisionConfiguration() |
| + : dv_version_major(0), |
| + dv_version_minor(0), |
| + dv_profile(0), |
| + dv_level(0), |
| + rpu_present_flag(0), |
| + el_present_flag(0), |
| + bl_present_flag(0), |
| + codec_profile(VIDEO_CODEC_PROFILE_UNKNOWN) {} |
| + |
| +DolbyVisionConfiguration::~DolbyVisionConfiguration() {} |
| + |
| +FourCC DolbyVisionConfiguration::BoxType() const { |
| + return FOURCC_DVCC; |
| +} |
| + |
| +bool DolbyVisionConfiguration::Parse(BoxReader* reader) { |
| + return ParseInternal(reader, reader->media_log()); |
| +} |
| + |
| +bool DolbyVisionConfiguration::Parse(const uint8_t* data, int data_size) { |
| + BufferReader reader(data, data_size); |
| + return ParseInternal(&reader, new MediaLog()); |
| +} |
| + |
| +bool DolbyVisionConfiguration::ParseInternal( |
| + BufferReader* reader, |
| + const scoped_refptr<MediaLog>& media_log) { |
| + uint16_t profile_track_indication = 0; |
| + RCHECK(reader->Read1(&dv_version_major) && reader->Read1(&dv_version_minor) && |
| + reader->Read2(&profile_track_indication)); |
| + |
| + dv_profile = profile_track_indication >> 9; |
| + dv_level = (profile_track_indication >> 3) & 0x3F; |
| + rpu_present_flag = (profile_track_indication >> 2) & 1; |
| + el_present_flag = (profile_track_indication >> 1) & 1; |
| + bl_present_flag = profile_track_indication & 1; |
| + |
| + if (media_log.get()) { |
| + DVLOG(2) << "Dolby Vision profile:" << static_cast<int>(dv_profile) |
| + << " level:" << static_cast<int>(dv_level) |
| + << " has_bl:" << static_cast<int>(bl_present_flag) |
| + << " has_el:" << static_cast<int>(el_present_flag) |
| + << " has_rpu:" << static_cast<int>(rpu_present_flag) |
| + << " profile type:" << codec_profile; |
|
wolenetz
2017/01/25 23:42:42
|codec_profile| isn't set yet.
erickung1
2017/02/03 18:18:32
Done.
|
| + } |
| + |
| + switch (dv_profile) { |
| + case 0: |
| + codec_profile = DOLBYVISION_PROFILE0; |
| + break; |
| + case 4: |
| + codec_profile = DOLBYVISION_PROFILE4; |
| + break; |
| + case 5: |
| + codec_profile = DOLBYVISION_PROFILE5; |
| + break; |
| + case 7: |
| + codec_profile = DOLBYVISION_PROFILE7; |
| + break; |
| + default: |
| + // Deprecated profiles. |
| + NOTREACHED(); |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| +} // namespace mp4 |
| +} // namespace media |