Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: media/base/video_decoder_config.cc

Issue 8897022: Revert 113895 - <video> decode in hardware! (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/video_decoder_config.h ('k') | media/base/video_frame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "media/base/limits.h" 11 #include "media/base/limits.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 VideoDecoderConfig::VideoDecoderConfig() 15 VideoDecoderConfig::VideoDecoderConfig()
16 : codec_(kUnknownVideoCodec), 16 : codec_(kUnknownVideoCodec),
17 profile_(VIDEO_CODEC_PROFILE_UNKNOWN),
18 format_(VideoFrame::INVALID), 17 format_(VideoFrame::INVALID),
19 frame_rate_numerator_(0), 18 frame_rate_numerator_(0),
20 frame_rate_denominator_(0), 19 frame_rate_denominator_(0),
21 aspect_ratio_numerator_(0), 20 aspect_ratio_numerator_(0),
22 aspect_ratio_denominator_(0), 21 aspect_ratio_denominator_(0),
23 extra_data_size_(0) { 22 extra_data_size_(0) {
24 } 23 }
25 24
26 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec, 25 VideoDecoderConfig::VideoDecoderConfig(VideoCodec codec,
27 VideoCodecProfile profile,
28 VideoFrame::Format format, 26 VideoFrame::Format format,
29 const gfx::Size& coded_size, 27 const gfx::Size& coded_size,
30 const gfx::Rect& visible_rect, 28 const gfx::Rect& visible_rect,
31 int frame_rate_numerator, 29 int frame_rate_numerator,
32 int frame_rate_denominator, 30 int frame_rate_denominator,
33 int aspect_ratio_numerator, 31 int aspect_ratio_numerator,
34 int aspect_ratio_denominator, 32 int aspect_ratio_denominator,
35 const uint8* extra_data, 33 const uint8* extra_data,
36 size_t extra_data_size) { 34 size_t extra_data_size) {
37 Initialize(codec, profile, format, coded_size, visible_rect, 35 Initialize(codec, format, coded_size, visible_rect,
38 frame_rate_numerator, frame_rate_denominator, 36 frame_rate_numerator, frame_rate_denominator,
39 aspect_ratio_numerator, aspect_ratio_denominator, 37 aspect_ratio_numerator, aspect_ratio_denominator,
40 extra_data, extra_data_size); 38 extra_data, extra_data_size);
41 } 39 }
42 40
43 VideoDecoderConfig::~VideoDecoderConfig() {} 41 VideoDecoderConfig::~VideoDecoderConfig() {}
44 42
45 // Some videos just want to watch the world burn, with a height of 0; cap the 43 // Some videos just want to watch the world burn, with a height of 0; cap the
46 // "infinite" aspect ratio resulting. 44 // "infinite" aspect ratio resulting.
47 static const int kInfiniteRatio = 99999; 45 static const int kInfiniteRatio = 99999;
48 46
49 // Common aspect ratios (multiplied by 100 and truncated) used for histogramming 47 // Common aspect ratios (multiplied by 100 and truncated) used for histogramming
50 // video sizes. These were taken on 20111103 from 48 // video sizes. These were taken on 20111103 from
51 // http://wikipedia.org/wiki/Aspect_ratio_(image)#Previous_and_currently_used_as pect_ratios 49 // http://wikipedia.org/wiki/Aspect_ratio_(image)#Previous_and_currently_used_as pect_ratios
52 static const int kCommonAspectRatios100[] = { 50 static const int kCommonAspectRatios100[] = {
53 100, 115, 133, 137, 143, 150, 155, 160, 166, 175, 177, 185, 200, 210, 220, 51 100, 115, 133, 137, 143, 150, 155, 160, 166, 175, 177, 185, 200, 210, 220,
54 221, 235, 237, 240, 255, 259, 266, 276, 293, 400, 1200, kInfiniteRatio, 52 221, 235, 237, 240, 255, 259, 266, 276, 293, 400, 1200, kInfiniteRatio,
55 }; 53 };
56 54
57 template<class T> // T has int width() & height() methods. 55 template<class T> // T has int width() & height() methods.
58 static void UmaHistogramAspectRatio(const char* name, const T& size) { 56 static void UmaHistogramAspectRatio(const char* name, const T& size) {
59 UMA_HISTOGRAM_CUSTOM_ENUMERATION( 57 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
60 name, 58 name,
61 // Intentionally use integer division to truncate the result. 59 // Intentionally use integer division to truncate the result.
62 size.height() ? (size.width() * 100) / size.height() : kInfiniteRatio, 60 size.height() ? (size.width() * 100) / size.height() : kInfiniteRatio,
63 base::CustomHistogram::ArrayToCustomRanges( 61 base::CustomHistogram::ArrayToCustomRanges(
64 kCommonAspectRatios100, arraysize(kCommonAspectRatios100))); 62 kCommonAspectRatios100, arraysize(kCommonAspectRatios100)));
65 } 63 }
66 64
67 void VideoDecoderConfig::Initialize(VideoCodec codec, 65 void VideoDecoderConfig::Initialize(VideoCodec codec, VideoFrame::Format format,
68 VideoCodecProfile profile,
69 VideoFrame::Format format,
70 const gfx::Size& coded_size, 66 const gfx::Size& coded_size,
71 const gfx::Rect& visible_rect, 67 const gfx::Rect& visible_rect,
72 int frame_rate_numerator, 68 int frame_rate_numerator,
73 int frame_rate_denominator, 69 int frame_rate_denominator,
74 int aspect_ratio_numerator, 70 int aspect_ratio_numerator,
75 int aspect_ratio_denominator, 71 int aspect_ratio_denominator,
76 const uint8* extra_data, 72 const uint8* extra_data,
77 size_t extra_data_size) { 73 size_t extra_data_size) {
78 CHECK((extra_data_size != 0) == (extra_data != NULL)); 74 CHECK((extra_data_size != 0) == (extra_data != NULL));
79 75
80 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1); 76 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodec", codec, kVideoCodecMax + 1);
81 UMA_HISTOGRAM_ENUMERATION("Media.VideoCodecProfile", profile,
82 VIDEO_CODEC_PROFILE_MAX + 1);
83 UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width()); 77 UMA_HISTOGRAM_COUNTS_10000("Media.VideoCodedWidth", coded_size.width());
84 UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size); 78 UmaHistogramAspectRatio("Media.VideoCodedAspectRatio", coded_size);
85 UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width()); 79 UMA_HISTOGRAM_COUNTS_10000("Media.VideoVisibleWidth", visible_rect.width());
86 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect); 80 UmaHistogramAspectRatio("Media.VideoVisibleAspectRatio", visible_rect);
87 81
88 codec_ = codec; 82 codec_ = codec;
89 profile_ = profile;
90 format_ = format; 83 format_ = format;
91 coded_size_ = coded_size; 84 coded_size_ = coded_size;
92 visible_rect_ = visible_rect; 85 visible_rect_ = visible_rect;
93 frame_rate_numerator_ = frame_rate_numerator; 86 frame_rate_numerator_ = frame_rate_numerator;
94 frame_rate_denominator_ = frame_rate_denominator; 87 frame_rate_denominator_ = frame_rate_denominator;
95 aspect_ratio_numerator_ = aspect_ratio_numerator; 88 aspect_ratio_numerator_ = aspect_ratio_numerator;
96 aspect_ratio_denominator_ = aspect_ratio_denominator; 89 aspect_ratio_denominator_ = aspect_ratio_denominator;
97 extra_data_size_ = extra_data_size; 90 extra_data_size_ = extra_data_size;
98 91
99 if (extra_data_size_ > 0) { 92 if (extra_data_size_ > 0) {
(...skipping 25 matching lines...) Expand all
125 format_ != VideoFrame::INVALID && 118 format_ != VideoFrame::INVALID &&
126 frame_rate_numerator_ > 0 && 119 frame_rate_numerator_ > 0 &&
127 frame_rate_denominator_ > 0 && 120 frame_rate_denominator_ > 0 &&
128 aspect_ratio_numerator_ > 0 && 121 aspect_ratio_numerator_ > 0 &&
129 aspect_ratio_denominator_ > 0 && 122 aspect_ratio_denominator_ > 0 &&
130 natural_size_.width() <= limits::kMaxDimension && 123 natural_size_.width() <= limits::kMaxDimension &&
131 natural_size_.height() <= limits::kMaxDimension && 124 natural_size_.height() <= limits::kMaxDimension &&
132 natural_size_.GetArea() <= limits::kMaxCanvas; 125 natural_size_.GetArea() <= limits::kMaxCanvas;
133 } 126 }
134 127
135 std::string VideoDecoderConfig::AsHumanReadableString() const {
136 std::ostringstream s;
137 s << "codec: " << codec()
138 << " format: " << format()
139 << " coded size: [" << coded_size().width()
140 << "," << coded_size().height() << "]"
141 << " visible rect: [" << visible_rect().x()
142 << "," << visible_rect().y()
143 << "," << visible_rect().width()
144 << "," << visible_rect().height() << "]"
145 << " natural size: [" << natural_size().width()
146 << "," << natural_size().height() << "]"
147 << " frame rate: " << frame_rate_numerator()
148 << "/" << frame_rate_denominator()
149 << " aspect ratio: " << aspect_ratio_numerator()
150 << "/" << aspect_ratio_denominator();
151 return s.str();
152 }
153
154 VideoCodec VideoDecoderConfig::codec() const { 128 VideoCodec VideoDecoderConfig::codec() const {
155 return codec_; 129 return codec_;
156 } 130 }
157 131
158 VideoCodecProfile VideoDecoderConfig::profile() const {
159 return profile_;
160 }
161
162 VideoFrame::Format VideoDecoderConfig::format() const { 132 VideoFrame::Format VideoDecoderConfig::format() const {
163 return format_; 133 return format_;
164 } 134 }
165 135
166 gfx::Size VideoDecoderConfig::coded_size() const { 136 gfx::Size VideoDecoderConfig::coded_size() const {
167 return coded_size_; 137 return coded_size_;
168 } 138 }
169 139
170 gfx::Rect VideoDecoderConfig::visible_rect() const { 140 gfx::Rect VideoDecoderConfig::visible_rect() const {
171 return visible_rect_; 141 return visible_rect_;
(...skipping 21 matching lines...) Expand all
193 163
194 uint8* VideoDecoderConfig::extra_data() const { 164 uint8* VideoDecoderConfig::extra_data() const {
195 return extra_data_.get(); 165 return extra_data_.get();
196 } 166 }
197 167
198 size_t VideoDecoderConfig::extra_data_size() const { 168 size_t VideoDecoderConfig::extra_data_size() const {
199 return extra_data_size_; 169 return extra_data_size_;
200 } 170 }
201 171
202 } // namespace media 172 } // namespace media
OLDNEW
« no previous file with comments | « media/base/video_decoder_config.h ('k') | media/base/video_frame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698