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 // This tool can be used to measure performace of video frame scaling | 5 // This tool can be used to measure performace of video frame scaling |
6 // code. It times performance of the scaler with and without filtering. | 6 // code. It times performance of the scaler with and without filtering. |
7 // It also measures performance of the Skia scaler for comparison. | 7 // It also measures performance of the Skia scaler for comparison. |
8 | 8 |
9 #include <iostream> | 9 #include <iostream> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 static int dest_width = 1366; | 27 static int dest_width = 1366; |
28 static int dest_height = 768; | 28 static int dest_height = 768; |
29 static int num_frames = 500; | 29 static int num_frames = 500; |
30 static int num_buffers = 50; | 30 static int num_buffers = 50; |
31 | 31 |
32 static double BenchmarkSkia() { | 32 static double BenchmarkSkia() { |
33 std::vector<scoped_refptr<VideoFrame> > source_frames; | 33 std::vector<scoped_refptr<VideoFrame> > source_frames; |
34 ScopedVector<SkBitmap> dest_frames; | 34 ScopedVector<SkBitmap> dest_frames; |
35 for (int i = 0; i < num_buffers; i++) { | 35 for (int i = 0; i < num_buffers; i++) { |
36 source_frames.push_back( | 36 source_frames.push_back( |
37 VideoFrame::CreateBlackFrame(source_width, source_height)); | 37 VideoFrame::CreateBlackFrame(gfx::Size(source_width, source_height))); |
38 | 38 |
39 SkBitmap* bitmap = new SkBitmap(); | 39 SkBitmap* bitmap = new SkBitmap(); |
40 bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 40 bitmap->setConfig(SkBitmap::kARGB_8888_Config, |
41 dest_width, dest_height); | 41 dest_width, dest_height); |
42 bitmap->allocPixels(); | 42 bitmap->allocPixels(); |
43 dest_frames.push_back(bitmap); | 43 dest_frames.push_back(bitmap); |
44 } | 44 } |
45 | 45 |
46 SkBitmap bitmap; | 46 SkBitmap bitmap; |
47 bitmap.setConfig(SkBitmap::kARGB_8888_Config, source_width, source_height); | 47 bitmap.setConfig(SkBitmap::kARGB_8888_Config, source_width, source_height); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 TimeTicks end = TimeTicks::HighResNow(); | 111 TimeTicks end = TimeTicks::HighResNow(); |
112 return static_cast<double>((end - start).InMilliseconds()) / num_frames; | 112 return static_cast<double>((end - start).InMilliseconds()) / num_frames; |
113 } | 113 } |
114 | 114 |
115 static double BenchmarkFilter(media::ScaleFilter filter) { | 115 static double BenchmarkFilter(media::ScaleFilter filter) { |
116 std::vector<scoped_refptr<VideoFrame> > source_frames; | 116 std::vector<scoped_refptr<VideoFrame> > source_frames; |
117 std::vector<scoped_refptr<VideoFrame> > dest_frames; | 117 std::vector<scoped_refptr<VideoFrame> > dest_frames; |
118 | 118 |
119 for (int i = 0; i < num_buffers; i++) { | 119 for (int i = 0; i < num_buffers; i++) { |
120 source_frames.push_back( | 120 source_frames.push_back( |
121 VideoFrame::CreateBlackFrame(source_width, source_height)); | 121 VideoFrame::CreateBlackFrame(gfx::Size(source_width, source_height))); |
122 | 122 |
| 123 gfx::Size dest_size(dest_width, dest_height); |
123 dest_frames.push_back( | 124 dest_frames.push_back( |
124 VideoFrame::CreateFrame(VideoFrame::RGB32, | 125 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, dest_size, |
125 dest_width, | |
126 dest_height, | |
127 TimeDelta::FromSeconds(0))); | 126 TimeDelta::FromSeconds(0))); |
128 } | 127 } |
129 | 128 |
130 TimeTicks start = TimeTicks::HighResNow(); | 129 TimeTicks start = TimeTicks::HighResNow(); |
131 for (int i = 0; i < num_frames; i++) { | 130 for (int i = 0; i < num_frames; i++) { |
132 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; | 131 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; |
133 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; | 132 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; |
134 | 133 |
135 media::ScaleYUVToRGB32(source_frame->data(VideoFrame::kYPlane), | 134 media::ScaleYUVToRGB32(source_frame->data(VideoFrame::kYPlane), |
136 source_frame->data(VideoFrame::kUPlane), | 135 source_frame->data(VideoFrame::kUPlane), |
(...skipping 13 matching lines...) Expand all Loading... |
150 TimeTicks end = TimeTicks::HighResNow(); | 149 TimeTicks end = TimeTicks::HighResNow(); |
151 return static_cast<double>((end - start).InMilliseconds()) / num_frames; | 150 return static_cast<double>((end - start).InMilliseconds()) / num_frames; |
152 } | 151 } |
153 | 152 |
154 static double BenchmarkScaleWithRect() { | 153 static double BenchmarkScaleWithRect() { |
155 std::vector<scoped_refptr<VideoFrame> > source_frames; | 154 std::vector<scoped_refptr<VideoFrame> > source_frames; |
156 std::vector<scoped_refptr<VideoFrame> > dest_frames; | 155 std::vector<scoped_refptr<VideoFrame> > dest_frames; |
157 | 156 |
158 for (int i = 0; i < num_buffers; i++) { | 157 for (int i = 0; i < num_buffers; i++) { |
159 source_frames.push_back( | 158 source_frames.push_back( |
160 VideoFrame::CreateBlackFrame(source_width, source_height)); | 159 VideoFrame::CreateBlackFrame(gfx::Size(source_width, source_height))); |
161 | 160 |
| 161 gfx::Size dest_size(dest_width, dest_height); |
162 dest_frames.push_back( | 162 dest_frames.push_back( |
163 VideoFrame::CreateFrame(VideoFrame::RGB32, | 163 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, dest_size, |
164 dest_width, | |
165 dest_height, | |
166 TimeDelta::FromSeconds(0))); | 164 TimeDelta::FromSeconds(0))); |
167 } | 165 } |
168 | 166 |
169 TimeTicks start = TimeTicks::HighResNow(); | 167 TimeTicks start = TimeTicks::HighResNow(); |
170 for (int i = 0; i < num_frames; i++) { | 168 for (int i = 0; i < num_frames; i++) { |
171 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; | 169 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; |
172 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; | 170 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; |
173 | 171 |
174 media::ScaleYUVToRGB32WithRect( | 172 media::ScaleYUVToRGB32WithRect( |
175 source_frame->data(VideoFrame::kYPlane), | 173 source_frame->data(VideoFrame::kYPlane), |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 std::cout << "Bilinear Horizontal: " | 266 std::cout << "Bilinear Horizontal: " |
269 << BenchmarkFilter(media::FILTER_BILINEAR_H) | 267 << BenchmarkFilter(media::FILTER_BILINEAR_H) |
270 << "ms/frame" << std::endl; | 268 << "ms/frame" << std::endl; |
271 std::cout << "Bilinear: " << BenchmarkFilter(media::FILTER_BILINEAR) | 269 std::cout << "Bilinear: " << BenchmarkFilter(media::FILTER_BILINEAR) |
272 << "ms/frame" << std::endl; | 270 << "ms/frame" << std::endl; |
273 std::cout << "Bilinear with rect: " << BenchmarkScaleWithRect() | 271 std::cout << "Bilinear with rect: " << BenchmarkScaleWithRect() |
274 << "ms/frame" << std::endl; | 272 << "ms/frame" << std::endl; |
275 | 273 |
276 return 0; | 274 return 0; |
277 } | 275 } |
OLD | NEW |