| 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 const gfx::Size& coded_size, | 22 const gfx::Size& coded_size, |
| 23 const gfx::Rect& visible_rect, | 23 const gfx::Rect& visible_rect, |
| 24 const gfx::Size& natural_size, | 24 const gfx::Size& natural_size, |
| 25 const uint8* extra_data, | 25 const uint8* extra_data, |
| 26 size_t extra_data_size, | 26 size_t extra_data_size, |
| 27 bool is_encrypted) { | 27 bool is_encrypted, |
| 28 bool live_mode) { |
| 28 Initialize(codec, profile, format, coded_size, visible_rect, natural_size, | 29 Initialize(codec, profile, format, coded_size, visible_rect, natural_size, |
| 29 extra_data, extra_data_size, is_encrypted, true); | 30 extra_data, extra_data_size, is_encrypted, live_mode, true); |
| 30 } | 31 } |
| 31 | 32 |
| 32 VideoDecoderConfig::~VideoDecoderConfig() {} | 33 VideoDecoderConfig::~VideoDecoderConfig() {} |
| 33 | 34 |
| 34 // Some videos just want to watch the world burn, with a height of 0; cap the | 35 // Some videos just want to watch the world burn, with a height of 0; cap the |
| 35 // "infinite" aspect ratio resulting. | 36 // "infinite" aspect ratio resulting. |
| 36 static const int kInfiniteRatio = 99999; | 37 static const int kInfiniteRatio = 99999; |
| 37 | 38 |
| 38 // Common aspect ratios (multiplied by 100 and truncated) used for histogramming | 39 // Common aspect ratios (multiplied by 100 and truncated) used for histogramming |
| 39 // video sizes. These were taken on 20111103 from | 40 // video sizes. These were taken on 20111103 from |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 | 56 |
| 56 void VideoDecoderConfig::Initialize(VideoCodec codec, | 57 void VideoDecoderConfig::Initialize(VideoCodec codec, |
| 57 VideoCodecProfile profile, | 58 VideoCodecProfile profile, |
| 58 VideoFrame::Format format, | 59 VideoFrame::Format format, |
| 59 const gfx::Size& coded_size, | 60 const gfx::Size& coded_size, |
| 60 const gfx::Rect& visible_rect, | 61 const gfx::Rect& visible_rect, |
| 61 const gfx::Size& natural_size, | 62 const gfx::Size& natural_size, |
| 62 const uint8* extra_data, | 63 const uint8* extra_data, |
| 63 size_t extra_data_size, | 64 size_t extra_data_size, |
| 64 bool is_encrypted, | 65 bool is_encrypted, |
| 66 bool live_mode, |
| 65 bool record_stats) { | 67 bool record_stats) { |
| 66 CHECK((extra_data_size != 0) == (extra_data != NULL)); | 68 CHECK((extra_data_size != 0) == (extra_data != NULL)); |
| 67 | 69 |
| 68 if (record_stats) { | 70 if (record_stats) { |
| 69 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1); | 71 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1); |
| 70 // Drop UNKNOWN because U_H_E() uses one bucket for all values less than 1. | 72 // Drop UNKNOWN because U_H_E() uses one bucket for all values less than 1. |
| 71 if (profile >= 0) { | 73 if (profile >= 0) { |
| 72 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodecProfile", profile, | 74 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodecProfile", profile, |
| 73 VIDEO_CODEC_PROFILE_MAX + 1); | 75 VIDEO_CODEC_PROFILE_MAX + 1); |
| 74 } | 76 } |
| 75 UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width()); | 77 UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width()); |
| 76 UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size); | 78 UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size); |
| 77 UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width()); | 79 UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width()); |
| 78 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); | 80 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); |
| 79 UMA_HISTOGRAM_ENUMERATION( | 81 UMA_HISTOGRAM_ENUMERATION( |
| 80 "Media.VideoPixelFormat", format, VideoFrame::FORMAT_MAX + 1); | 82 "Media.VideoPixelFormat", format, VideoFrame::FORMAT_MAX + 1); |
| 81 } | 83 } |
| 82 | 84 |
| 83 codec_ = codec; | 85 codec_ = codec; |
| 84 profile_ = profile; | 86 profile_ = profile; |
| 85 format_ = format; | 87 format_ = format; |
| 86 coded_size_ = coded_size; | 88 coded_size_ = coded_size; |
| 87 visible_rect_ = visible_rect; | 89 visible_rect_ = visible_rect; |
| 88 natural_size_ = natural_size; | 90 natural_size_ = natural_size; |
| 89 extra_data_.assign(extra_data, extra_data + extra_data_size); | 91 extra_data_.assign(extra_data, extra_data + extra_data_size); |
| 90 is_encrypted_ = is_encrypted; | 92 is_encrypted_ = is_encrypted; |
| 93 live_mode_ = live_mode; |
| 91 } | 94 } |
| 92 | 95 |
| 93 bool VideoDecoderConfig::IsValidConfig() const { | 96 bool VideoDecoderConfig::IsValidConfig() const { |
| 94 return codec_ != kUnknownVideoCodec && | 97 return codec_ != kUnknownVideoCodec && |
| 95 natural_size_.width() > 0 && | 98 natural_size_.width() > 0 && |
| 96 natural_size_.height() > 0 && | 99 natural_size_.height() > 0 && |
| 97 VideoFrame::IsValidConfig(format_, coded_size_, visible_rect_, | 100 VideoFrame::IsValidConfig(format_, coded_size_, visible_rect_, |
| 98 natural_size_); | 101 natural_size_); |
| 99 } | 102 } |
| 100 | 103 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 163 } |
| 161 | 164 |
| 162 size_t VideoDecoderConfig::extra_data_size() const { | 165 size_t VideoDecoderConfig::extra_data_size() const { |
| 163 return extra_data_.size(); | 166 return extra_data_.size(); |
| 164 } | 167 } |
| 165 | 168 |
| 166 bool VideoDecoderConfig::is_encrypted() const { | 169 bool VideoDecoderConfig::is_encrypted() const { |
| 167 return is_encrypted_; | 170 return is_encrypted_; |
| 168 } | 171 } |
| 169 | 172 |
| 173 bool VideoDecoderConfig::live_mode() const { |
| 174 return live_mode_; |
| 175 } |
| 176 |
| 170 } // namespace media | 177 } // namespace media |
| OLD | NEW |