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

Side by Side Diff: webrtc/modules/video_processing/main/test/unit_test/deflickering_test.cc

Issue 1410663004: modules/video_processing: refactor interface->include + more. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased Created 5 years, 1 month 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
(Empty)
1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13
14 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
15 #include "webrtc/modules/video_processing/main/interface/video_processing.h"
16 #include "webrtc/modules/video_processing/main/test/unit_test/video_processing_u nittest.h"
17 #include "webrtc/system_wrappers/include/tick_util.h"
18 #include "webrtc/test/testsupport/fileutils.h"
19 #include "webrtc/test/testsupport/gtest_disable.h"
20
21 namespace webrtc {
22
23 TEST_F(VideoProcessingModuleTest, DISABLED_ON_IOS(Deflickering))
24 {
25 enum { NumRuns = 30 };
26 uint32_t frameNum = 0;
27 const uint32_t frame_rate = 15;
28
29 int64_t min_runtime = 0;
30 int64_t avg_runtime = 0;
31
32 // Close automatically opened Foreman.
33 fclose(source_file_);
34 const std::string input_file =
35 webrtc::test::ResourcePath("deflicker_before_cif_short", "yuv");
36 source_file_ = fopen(input_file.c_str(), "rb");
37 ASSERT_TRUE(source_file_ != NULL) <<
38 "Cannot read input file: " << input_file << "\n";
39
40 const std::string output_file =
41 webrtc::test::OutputPath() + "deflicker_output_cif_short.yuv";
42 FILE* deflickerFile = fopen(output_file.c_str(), "wb");
43 ASSERT_TRUE(deflickerFile != NULL) <<
44 "Could not open output file: " << output_file << "\n";
45
46 printf("\nRun time [us / frame]:\n");
47 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
48 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++)
49 {
50 TickTime t0;
51 TickTime t1;
52 TickInterval acc_ticks;
53 uint32_t timeStamp = 1;
54
55 frameNum = 0;
56 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
57 frame_length_)
58 {
59 frameNum++;
60 EXPECT_EQ(
61 0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_,
62 height_, 0, kVideoRotation_0, &video_frame_));
63 video_frame_.set_timestamp(timeStamp);
64
65 t0 = TickTime::Now();
66 VideoProcessingModule::FrameStats stats;
67 ASSERT_EQ(0, vpm_->GetFrameStats(&stats, video_frame_));
68 ASSERT_EQ(0, vpm_->Deflickering(&video_frame_, &stats));
69 t1 = TickTime::Now();
70 acc_ticks += (t1 - t0);
71
72 if (run_idx == 0)
73 {
74 if (PrintVideoFrame(video_frame_, deflickerFile) < 0) {
75 return;
76 }
77 }
78 timeStamp += (90000 / frame_rate);
79 }
80 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
81
82 printf("%u\n", static_cast<int>(acc_ticks.Microseconds() / frameNum));
83 if (acc_ticks.Microseconds() < min_runtime || run_idx == 0)
84 {
85 min_runtime = acc_ticks.Microseconds();
86 }
87 avg_runtime += acc_ticks.Microseconds();
88
89 rewind(source_file_);
90 }
91 ASSERT_EQ(0, fclose(deflickerFile));
92 // TODO(kjellander): Add verification of deflicker output file.
93
94 printf("\nAverage run time = %d us / frame\n",
95 static_cast<int>(avg_runtime / frameNum / NumRuns));
96 printf("Min run time = %d us / frame\n\n",
97 static_cast<int>(min_runtime / frameNum));
98 }
99
100 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698