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

Side by Side Diff: webrtc/modules/video_processing/test/video_processing_unittest.cc

Issue 1888593004: Delete all use of tick_util.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/modules/video_processing/test/video_processing_unittest.h" 11 #include "webrtc/modules/video_processing/test/video_processing_unittest.h"
12 12
13 #include <gflags/gflags.h> 13 #include <gflags/gflags.h>
14 14
15 #include <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 17
18 #include "webrtc/base/timeutils.h"
18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
19 #include "webrtc/system_wrappers/include/tick_util.h"
20 #include "webrtc/test/testsupport/fileutils.h" 20 #include "webrtc/test/testsupport/fileutils.h"
21 21
22 namespace webrtc { 22 namespace webrtc {
23 23
24 namespace { 24 namespace {
25 25
26 // Define command line flag 'gen_files' (default value: false). 26 // Define command line flag 'gen_files' (default value: false).
27 DEFINE_bool(gen_files, false, "Output files for visual inspection."); 27 DEFINE_bool(gen_files, false, "Output files for visual inspection.");
28 28
29 } // namespace 29 } // namespace
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 fread(video_buffer.get(), 1, frame_length_, source_file_)); 241 fread(video_buffer.get(), 1, frame_length_, source_file_));
242 // Using ConvertToI420 to add stride to the image. 242 // Using ConvertToI420 to add stride to the image.
243 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, 243 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
244 0, kVideoRotation_0, &video_frame_)); 244 0, kVideoRotation_0, &video_frame_));
245 // Cropped source frame that will contain the expected visible region. 245 // Cropped source frame that will contain the expected visible region.
246 VideoFrame cropped_source_frame; 246 VideoFrame cropped_source_frame;
247 cropped_source_frame.CopyFrame(video_frame_); 247 cropped_source_frame.CopyFrame(video_frame_);
248 248
249 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) { 249 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) {
250 // Initiate test timer. 250 // Initiate test timer.
251 const TickTime time_start = TickTime::Now(); 251 const int64_t time_start = rtc::TimeNanos();
252 252
253 // Init the sourceFrame with a timestamp. 253 // Init the sourceFrame with a timestamp.
254 video_frame_.set_render_time_ms(time_start.MillisecondTimestamp()); 254 int64_t time_start_ms = time_start / rtc::kNumNanosecsPerMillisec;
255 video_frame_.set_timestamp(time_start.MillisecondTimestamp() * 90); 255 video_frame_.set_render_time_ms(time_start_ms);
256 video_frame_.set_timestamp(time_start_ms * 90);
256 257
257 // Test scaling to different sizes: source is of |width|/|height| = 352/288. 258 // Test scaling to different sizes: source is of |width|/|height| = 352/288.
258 // Pure scaling: 259 // Pure scaling:
259 TestSize(video_frame_, video_frame_, width_ / 4, height_ / 4, 25.2, vp_); 260 TestSize(video_frame_, video_frame_, width_ / 4, height_ / 4, 25.2, vp_);
260 TestSize(video_frame_, video_frame_, width_ / 2, height_ / 2, 28.1, vp_); 261 TestSize(video_frame_, video_frame_, width_ / 2, height_ / 2, 28.1, vp_);
261 // No resampling: 262 // No resampling:
262 TestSize(video_frame_, video_frame_, width_, height_, -1, vp_); 263 TestSize(video_frame_, video_frame_, width_, height_, -1, vp_);
263 TestSize(video_frame_, video_frame_, 2 * width_, 2 * height_, 32.2, vp_); 264 TestSize(video_frame_, video_frame_, 2 * width_, 2 * height_, 32.2, vp_);
264 265
265 // Scaling and cropping. The cropped source frame is the largest center 266 // Scaling and cropping. The cropped source frame is the largest center
(...skipping 22 matching lines...) Expand all
288 // Upsampling to odd size. 289 // Upsampling to odd size.
289 CropFrame(video_buffer.get(), width_, height_, 0, 26, 352, 233, 290 CropFrame(video_buffer.get(), width_, height_, 0, 26, 352, 233,
290 &cropped_source_frame); 291 &cropped_source_frame);
291 TestSize(video_frame_, cropped_source_frame, 501, 333, 32.05, vp_); 292 TestSize(video_frame_, cropped_source_frame, 501, 333, 32.05, vp_);
292 // Downsample to odd size. 293 // Downsample to odd size.
293 CropFrame(video_buffer.get(), width_, height_, 0, 34, 352, 219, 294 CropFrame(video_buffer.get(), width_, height_, 0, 34, 352, 219,
294 &cropped_source_frame); 295 &cropped_source_frame);
295 TestSize(video_frame_, cropped_source_frame, 281, 175, 29.3, vp_); 296 TestSize(video_frame_, cropped_source_frame, 281, 175, 29.3, vp_);
296 297
297 // Stop timer. 298 // Stop timer.
298 const int64_t runtime = (TickTime::Now() - time_start).Microseconds(); 299 const int64_t runtime =
300 (rtc::TimeNanos() - time_start) / rtc::kNumNanosecsPerMicrosec;
299 if (runtime < min_runtime || run_idx == 0) { 301 if (runtime < min_runtime || run_idx == 0) {
300 min_runtime = runtime; 302 min_runtime = runtime;
301 } 303 }
302 total_runtime += runtime; 304 total_runtime += runtime;
303 } 305 }
304 306
305 printf("\nAverage run time = %d us / frame\n", 307 printf("\nAverage run time = %d us / frame\n",
306 static_cast<int>(total_runtime)); 308 static_cast<int>(total_runtime));
307 printf("Min run time = %d us / frame\n\n", static_cast<int>(min_runtime)); 309 printf("Min run time = %d us / frame\n\n", static_cast<int>(min_runtime));
308 } 310 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 std::cout << "Watch " << filename.str() << " and verify that it is okay." 409 std::cout << "Watch " << filename.str() << " and verify that it is okay."
408 << std::endl; 410 << std::endl;
409 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); 411 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb");
410 if (PrintVideoFrame(processed, stand_alone_file) < 0) 412 if (PrintVideoFrame(processed, stand_alone_file) < 0)
411 std::cerr << "Failed to write: " << filename.str() << std::endl; 413 std::cerr << "Failed to write: " << filename.str() << std::endl;
412 if (stand_alone_file) 414 if (stand_alone_file)
413 fclose(stand_alone_file); 415 fclose(stand_alone_file);
414 } 416 }
415 417
416 } // namespace webrtc 418 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698