| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 VideoDecoderConfig::VideoDecoderConfig() | 12 VideoDecoderConfig::VideoDecoderConfig() |
| 13 : codec_(kUnknownVideoCodec), | 13 : codec_(kUnknownVideoCodec), |
| 14 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), | 14 profile_(VIDEO_CODEC_PROFILE_UNKNOWN), |
| 15 format_(VideoFrame::UNKNOWN), | 15 format_(VideoFrame::UNKNOWN), |
| 16 is_encrypted_(false) { | 16 is_encrypted_(false) { |
| 17 } | 17 } |
| 18 | 18 |
| 19 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, | 19 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, |
| 20 VideoCodecProfile profile, | 20 VideoCodecProfile profile, |
| 21 VideoFrame::Format format, | 21 VideoFrame::Format format, |
| 22 VideoFrame::ColorSpace color_space, |
| 22 const gfx::Size& coded_size, | 23 const gfx::Size& coded_size, |
| 23 const gfx::Rect& visible_rect, | 24 const gfx::Rect& visible_rect, |
| 24 const gfx::Size& natural_size, | 25 const gfx::Size& natural_size, |
| 25 const uint8* extra_data, | 26 const uint8* extra_data, |
| 26 size_t extra_data_size, | 27 size_t extra_data_size, |
| 27 bool is_encrypted) { | 28 bool is_encrypted) { |
| 28 Initialize(codec, profile, format, VideoFrame::COLOR_SPACE_UNSPECIFIED, | 29 Initialize(codec, profile, format, color_space, |
| 29 coded_size, visible_rect, natural_size, extra_data, | 30 coded_size, visible_rect, natural_size, extra_data, |
| 30 extra_data_size, is_encrypted, true); | 31 extra_data_size, is_encrypted, true); |
| 31 } | 32 } |
| 32 | 33 |
| 33 VideoDecoderConfig::~VideoDecoderConfig() {} | 34 VideoDecoderConfig::~VideoDecoderConfig() {} |
| 34 | 35 |
| 35 // Some videos just want to watch the world burn, with a height of 0; cap the | 36 // Some videos just want to watch the world burn, with a height of 0; cap the |
| 36 // "infinite" aspect ratio resulting. | 37 // "infinite" aspect ratio resulting. |
| 37 static const int kInfiniteRatio = 99999; | 38 static const int kInfiniteRatio = 99999; |
| 38 | 39 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); | 81 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); |
| 81 UMA_HISTOGRAM_ENUMERATION("Media.VideoFramePixelFormat", format, | 82 UMA_HISTOGRAM_ENUMERATION("Media.VideoFramePixelFormat", format, |
| 82 VideoFrame::FORMAT_MAX + 1); | 83 VideoFrame::FORMAT_MAX + 1); |
| 83 UMA_HISTOGRAM_ENUMERATION("Media.VideoFrameColorSpace", color_space, | 84 UMA_HISTOGRAM_ENUMERATION("Media.VideoFrameColorSpace", color_space, |
| 84 VideoFrame::COLOR_SPACE_MAX + 1); | 85 VideoFrame::COLOR_SPACE_MAX + 1); |
| 85 } | 86 } |
| 86 | 87 |
| 87 codec_ = codec; | 88 codec_ = codec; |
| 88 profile_ = profile; | 89 profile_ = profile; |
| 89 format_ = format; | 90 format_ = format; |
| 91 color_space_ = color_space; |
| 90 coded_size_ = coded_size; | 92 coded_size_ = coded_size; |
| 91 visible_rect_ = visible_rect; | 93 visible_rect_ = visible_rect; |
| 92 natural_size_ = natural_size; | 94 natural_size_ = natural_size; |
| 93 extra_data_.assign(extra_data, extra_data + extra_data_size); | 95 extra_data_.assign(extra_data, extra_data + extra_data_size); |
| 94 is_encrypted_ = is_encrypted; | 96 is_encrypted_ = is_encrypted; |
| 95 } | 97 } |
| 96 | 98 |
| 97 bool VideoDecoderConfig::IsValidConfig() const { | 99 bool VideoDecoderConfig::IsValidConfig() const { |
| 98 return codec_ != kUnknownVideoCodec && | 100 return codec_ != kUnknownVideoCodec && |
| 99 natural_size_.width() > 0 && | 101 natural_size_.width() > 0 && |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return "theora"; | 152 return "theora"; |
| 151 case kCodecVP8: | 153 case kCodecVP8: |
| 152 return "vp8"; | 154 return "vp8"; |
| 153 case kCodecVP9: | 155 case kCodecVP9: |
| 154 return "vp9"; | 156 return "vp9"; |
| 155 } | 157 } |
| 156 NOTREACHED(); | 158 NOTREACHED(); |
| 157 return ""; | 159 return ""; |
| 158 } | 160 } |
| 159 | 161 |
| 160 VideoCodec VideoDecoderConfig::codec() const { | |
| 161 return codec_; | |
| 162 } | |
| 163 | |
| 164 VideoCodecProfile VideoDecoderConfig::profile() const { | |
| 165 return profile_; | |
| 166 } | |
| 167 | |
| 168 VideoFrame::Format VideoDecoderConfig::format() const { | |
| 169 return format_; | |
| 170 } | |
| 171 | |
| 172 gfx::Size VideoDecoderConfig::coded_size() const { | |
| 173 return coded_size_; | |
| 174 } | |
| 175 | |
| 176 gfx::Rect VideoDecoderConfig::visible_rect() const { | |
| 177 return visible_rect_; | |
| 178 } | |
| 179 | |
| 180 gfx::Size VideoDecoderConfig::natural_size() const { | |
| 181 return natural_size_; | |
| 182 } | |
| 183 | |
| 184 const uint8* VideoDecoderConfig::extra_data() const { | 162 const uint8* VideoDecoderConfig::extra_data() const { |
| 185 if (extra_data_.empty()) | 163 if (extra_data_.empty()) |
| 186 return NULL; | 164 return NULL; |
| 187 return &extra_data_[0]; | 165 return &extra_data_[0]; |
| 188 } | 166 } |
| 189 | 167 |
| 190 size_t VideoDecoderConfig::extra_data_size() const { | |
| 191 return extra_data_.size(); | |
| 192 } | |
| 193 | |
| 194 bool VideoDecoderConfig::is_encrypted() const { | |
| 195 return is_encrypted_; | |
| 196 } | |
| 197 | |
| 198 } // namespace media | 168 } // namespace media |
| OLD | NEW |