OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/video_decoder_config.h" | 5 #include "media/base/video_decoder_config.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| 11 #include "media/base/video_types.h" |
11 | 12 |
12 namespace media { | 13 namespace media { |
13 | 14 |
14 VideoCodec VideoCodecProfileToVideoCodec(VideoCodecProfile profile) { | 15 VideoCodec VideoCodecProfileToVideoCodec(VideoCodecProfile profile) { |
15 switch (profile) { | 16 switch (profile) { |
16 case VIDEO_CODEC_PROFILE_UNKNOWN: | 17 case VIDEO_CODEC_PROFILE_UNKNOWN: |
17 return kUnknownVideoCodec; | 18 return kUnknownVideoCodec; |
18 case H264PROFILE_BASELINE: | 19 case H264PROFILE_BASELINE: |
19 case H264PROFILE_MAIN: | 20 case H264PROFILE_MAIN: |
20 case H264PROFILE_EXTENDED: | 21 case H264PROFILE_EXTENDED: |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const EncryptionScheme& encryption_scheme) { | 61 const EncryptionScheme& encryption_scheme) { |
61 Initialize(codec, profile, format, color_space, coded_size, visible_rect, | 62 Initialize(codec, profile, format, color_space, coded_size, visible_rect, |
62 natural_size, extra_data, encryption_scheme); | 63 natural_size, extra_data, encryption_scheme); |
63 } | 64 } |
64 | 65 |
65 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) = | 66 VideoDecoderConfig::VideoDecoderConfig(const VideoDecoderConfig& other) = |
66 default; | 67 default; |
67 | 68 |
68 VideoDecoderConfig::~VideoDecoderConfig() {} | 69 VideoDecoderConfig::~VideoDecoderConfig() {} |
69 | 70 |
| 71 void VideoDecoderConfig::set_color_space_info( |
| 72 const gfx::ColorSpace& color_space_info) { |
| 73 color_space_info_ = color_space_info; |
| 74 } |
| 75 |
| 76 base::Optional<gfx::ColorSpace> VideoDecoderConfig::color_space_info() const { |
| 77 return color_space_info_; |
| 78 } |
| 79 |
| 80 void VideoDecoderConfig::set_hdr_metadata(const HDRMetadata& hdr_metadata) { |
| 81 hdr_metadata_ = hdr_metadata; |
| 82 } |
| 83 |
| 84 base::Optional<HDRMetadata> VideoDecoderConfig::hdr_metadata() const { |
| 85 return hdr_metadata_; |
| 86 } |
| 87 |
70 void VideoDecoderConfig::Initialize(VideoCodec codec, | 88 void VideoDecoderConfig::Initialize(VideoCodec codec, |
71 VideoCodecProfile profile, | 89 VideoCodecProfile profile, |
72 VideoPixelFormat format, | 90 VideoPixelFormat format, |
73 ColorSpace color_space, | 91 ColorSpace color_space, |
74 const gfx::Size& coded_size, | 92 const gfx::Size& coded_size, |
75 const gfx::Rect& visible_rect, | 93 const gfx::Rect& visible_rect, |
76 const gfx::Size& natural_size, | 94 const gfx::Size& natural_size, |
77 const std::vector<uint8_t>& extra_data, | 95 const std::vector<uint8_t>& extra_data, |
78 const EncryptionScheme& encryption_scheme) { | 96 const EncryptionScheme& encryption_scheme) { |
79 codec_ = codec; | 97 codec_ = codec; |
80 profile_ = profile; | 98 profile_ = profile; |
81 format_ = format; | 99 format_ = format; |
82 color_space_ = color_space; | 100 color_space_ = color_space; |
83 coded_size_ = coded_size; | 101 coded_size_ = coded_size; |
84 visible_rect_ = visible_rect; | 102 visible_rect_ = visible_rect; |
85 natural_size_ = natural_size; | 103 natural_size_ = natural_size; |
86 extra_data_ = extra_data; | 104 extra_data_ = extra_data; |
87 encryption_scheme_ = encryption_scheme; | 105 encryption_scheme_ = encryption_scheme; |
| 106 |
| 107 switch (color_space) { |
| 108 case ColorSpace::COLOR_SPACE_JPEG: |
| 109 color_space_info_ = gfx::ColorSpace::CreateJpeg(); |
| 110 break; |
| 111 case ColorSpace::COLOR_SPACE_HD_REC709: |
| 112 color_space_info_ = gfx::ColorSpace::CreateREC709(); |
| 113 break; |
| 114 case ColorSpace::COLOR_SPACE_SD_REC601: |
| 115 color_space_info_ = gfx::ColorSpace::CreateREC601(); |
| 116 break; |
| 117 case ColorSpace::COLOR_SPACE_UNSPECIFIED: |
| 118 default: |
| 119 break; |
| 120 } |
88 } | 121 } |
89 | 122 |
90 bool VideoDecoderConfig::IsValidConfig() const { | 123 bool VideoDecoderConfig::IsValidConfig() const { |
91 return codec_ != kUnknownVideoCodec && | 124 return codec_ != kUnknownVideoCodec && |
92 natural_size_.width() > 0 && | 125 natural_size_.width() > 0 && |
93 natural_size_.height() > 0 && | 126 natural_size_.height() > 0 && |
94 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, | 127 VideoFrame::IsValidConfig(format_, VideoFrame::STORAGE_UNOWNED_MEMORY, |
95 coded_size_, visible_rect_, natural_size_); | 128 coded_size_, visible_rect_, natural_size_); |
96 } | 129 } |
97 | 130 |
(...skipping 15 matching lines...) Expand all Loading... |
113 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() | 146 << " visible rect: [" << visible_rect().x() << "," << visible_rect().y() |
114 << "," << visible_rect().width() << "," << visible_rect().height() << "]" | 147 << "," << visible_rect().width() << "," << visible_rect().height() << "]" |
115 << " natural size: [" << natural_size().width() << "," | 148 << " natural size: [" << natural_size().width() << "," |
116 << natural_size().height() << "]" | 149 << natural_size().height() << "]" |
117 << " has extra data? " << (extra_data().empty() ? "false" : "true") | 150 << " has extra data? " << (extra_data().empty() ? "false" : "true") |
118 << " encrypted? " << (is_encrypted() ? "true" : "false"); | 151 << " encrypted? " << (is_encrypted() ? "true" : "false"); |
119 return s.str(); | 152 return s.str(); |
120 } | 153 } |
121 | 154 |
122 } // namespace media | 155 } // namespace media |
OLD | NEW |