| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(gfx::Size(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 gfx::Size dest_size(dest_width, dest_height); |
| 124 dest_frames.push_back( | 124 dest_frames.push_back( |
| 125 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, dest_size, | 125 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, |
| 126 gfx::Rect(dest_size), dest_size, |
| 126 TimeDelta::FromSeconds(0))); | 127 TimeDelta::FromSeconds(0))); |
| 127 } | 128 } |
| 128 | 129 |
| 129 TimeTicks start = TimeTicks::HighResNow(); | 130 TimeTicks start = TimeTicks::HighResNow(); |
| 130 for (int i = 0; i < num_frames; i++) { | 131 for (int i = 0; i < num_frames; i++) { |
| 131 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; | 132 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; |
| 132 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; | 133 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; |
| 133 | 134 |
| 134 media::ScaleYUVToRGB32(source_frame->data(VideoFrame::kYPlane), | 135 media::ScaleYUVToRGB32(source_frame->data(VideoFrame::kYPlane), |
| 135 source_frame->data(VideoFrame::kUPlane), | 136 source_frame->data(VideoFrame::kUPlane), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 153 static double BenchmarkScaleWithRect() { | 154 static double BenchmarkScaleWithRect() { |
| 154 std::vector<scoped_refptr<VideoFrame> > source_frames; | 155 std::vector<scoped_refptr<VideoFrame> > source_frames; |
| 155 std::vector<scoped_refptr<VideoFrame> > dest_frames; | 156 std::vector<scoped_refptr<VideoFrame> > dest_frames; |
| 156 | 157 |
| 157 for (int i = 0; i < num_buffers; i++) { | 158 for (int i = 0; i < num_buffers; i++) { |
| 158 source_frames.push_back( | 159 source_frames.push_back( |
| 159 VideoFrame::CreateBlackFrame(gfx::Size(source_width, source_height))); | 160 VideoFrame::CreateBlackFrame(gfx::Size(source_width, source_height))); |
| 160 | 161 |
| 161 gfx::Size dest_size(dest_width, dest_height); | 162 gfx::Size dest_size(dest_width, dest_height); |
| 162 dest_frames.push_back( | 163 dest_frames.push_back( |
| 163 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, dest_size, | 164 VideoFrame::CreateFrame(VideoFrame::RGB32, dest_size, |
| 165 gfx::Rect(dest_size), dest_size, |
| 164 TimeDelta::FromSeconds(0))); | 166 TimeDelta::FromSeconds(0))); |
| 165 } | 167 } |
| 166 | 168 |
| 167 TimeTicks start = TimeTicks::HighResNow(); | 169 TimeTicks start = TimeTicks::HighResNow(); |
| 168 for (int i = 0; i < num_frames; i++) { | 170 for (int i = 0; i < num_frames; i++) { |
| 169 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; | 171 scoped_refptr<VideoFrame> source_frame = source_frames[i % num_buffers]; |
| 170 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; | 172 scoped_refptr<VideoFrame> dest_frame = dest_frames[i % num_buffers]; |
| 171 | 173 |
| 172 media::ScaleYUVToRGB32WithRect( | 174 media::ScaleYUVToRGB32WithRect( |
| 173 source_frame->data(VideoFrame::kYPlane), | 175 source_frame->data(VideoFrame::kYPlane), |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 std::cout << "Bilinear Horizontal: " | 268 std::cout << "Bilinear Horizontal: " |
| 267 << BenchmarkFilter(media::FILTER_BILINEAR_H) | 269 << BenchmarkFilter(media::FILTER_BILINEAR_H) |
| 268 << "ms/frame" << std::endl; | 270 << "ms/frame" << std::endl; |
| 269 std::cout << "Bilinear: " << BenchmarkFilter(media::FILTER_BILINEAR) | 271 std::cout << "Bilinear: " << BenchmarkFilter(media::FILTER_BILINEAR) |
| 270 << "ms/frame" << std::endl; | 272 << "ms/frame" << std::endl; |
| 271 std::cout << "Bilinear with rect: " << BenchmarkScaleWithRect() | 273 std::cout << "Bilinear with rect: " << BenchmarkScaleWithRect() |
| 272 << "ms/frame" << std::endl; | 274 << "ms/frame" << std::endl; |
| 273 | 275 |
| 274 return 0; | 276 return 0; |
| 275 } | 277 } |
| OLD | NEW |