OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/formats/mp4/dolby_vision.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "media/base/video_codecs.h" | |
9 #include "media/formats/mp4/box_definitions.h" | |
10 #include "media/formats/mp4/box_reader.h" | |
11 | |
12 namespace media { | |
13 namespace mp4 { | |
14 | |
15 DolbyVisionConfiguration::DolbyVisionConfiguration() | |
16 : dv_version_major(0), | |
17 dv_version_minor(0), | |
18 dv_profile(0), | |
19 dv_level(0), | |
20 rpu_present_flag(0), | |
21 el_present_flag(0), | |
22 bl_present_flag(0), | |
23 codec_profile(VIDEO_CODEC_PROFILE_UNKNOWN) {} | |
24 | |
25 DolbyVisionConfiguration::~DolbyVisionConfiguration() {} | |
26 | |
27 FourCC DolbyVisionConfiguration::BoxType() const { | |
28 return FOURCC_DVCC; | |
29 } | |
30 | |
31 bool DolbyVisionConfiguration::Parse(BoxReader* reader) { | |
32 return ParseInternal(reader, reader->media_log()); | |
33 } | |
34 | |
35 bool DolbyVisionConfiguration::Parse(const uint8_t* data, int data_size) { | |
36 BufferReader reader(data, data_size); | |
37 return ParseInternal(&reader, new MediaLog()); | |
38 } | |
39 | |
40 bool DolbyVisionConfiguration::ParseInternal( | |
41 BufferReader* reader, | |
42 const scoped_refptr<MediaLog>& media_log) { | |
43 uint16_t profile_track_indication = 0; | |
44 RCHECK(reader->Read1(&dv_version_major) && reader->Read1(&dv_version_minor) && | |
45 reader->Read2(&profile_track_indication)); | |
46 | |
47 dv_profile = profile_track_indication >> 9; | |
48 dv_level = (profile_track_indication >> 3) & 0x3F; | |
49 rpu_present_flag = (profile_track_indication >> 2) & 1; | |
50 el_present_flag = (profile_track_indication >> 1) & 1; | |
51 bl_present_flag = profile_track_indication & 1; | |
52 | |
53 if (media_log.get()) { | |
54 DVLOG(2) << "Dolby Vision profile:" << static_cast<int>(dv_profile) | |
55 << " level:" << static_cast<int>(dv_level) | |
56 << " has_bl:" << static_cast<int>(bl_present_flag) | |
57 << " has_el:" << static_cast<int>(el_present_flag) | |
58 << " has_rpu:" << static_cast<int>(rpu_present_flag) | |
59 << " 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.
| |
60 } | |
61 | |
62 switch (dv_profile) { | |
63 case 0: | |
64 codec_profile = DOLBYVISION_PROFILE0; | |
65 break; | |
66 case 4: | |
67 codec_profile = DOLBYVISION_PROFILE4; | |
68 break; | |
69 case 5: | |
70 codec_profile = DOLBYVISION_PROFILE5; | |
71 break; | |
72 case 7: | |
73 codec_profile = DOLBYVISION_PROFILE7; | |
74 break; | |
75 default: | |
76 // Deprecated profiles. | |
77 NOTREACHED(); | |
78 return false; | |
79 } | |
80 | |
81 return true; | |
82 } | |
83 | |
84 } // namespace mp4 | |
85 } // namespace media | |
OLD | NEW |