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

Side by Side Diff: webrtc/modules/video_processing/main/test/unit_test/brightness_detection_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) 2011 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 "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
12 #include "webrtc/modules/video_processing/main/interface/video_processing.h"
13 #include "webrtc/modules/video_processing/main/test/unit_test/video_processing_u nittest.h"
14 #include "webrtc/test/testsupport/gtest_disable.h"
15
16 using namespace webrtc;
17
18 TEST_F(VideoProcessingModuleTest, DISABLED_ON_IOS(BrightnessDetection))
19 {
20 uint32_t frameNum = 0;
21 int32_t brightnessWarning = 0;
22 uint32_t warningCount = 0;
23 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
24 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
25 frame_length_)
26 {
27 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_,
28 height_, 0, kVideoRotation_0, &video_frame_));
29 frameNum++;
30 VideoProcessingModule::FrameStats stats;
31 ASSERT_EQ(0, vpm_->GetFrameStats(&stats, video_frame_));
32 ASSERT_GE(brightnessWarning = vpm_->BrightnessDetection(video_frame_,
33 stats), 0);
34 if (brightnessWarning != VideoProcessingModule::kNoWarning)
35 {
36 warningCount++;
37 }
38 }
39 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
40
41 // Expect few warnings
42 float warningProportion = static_cast<float>(warningCount) / frameNum * 100;
43 printf("\nWarning proportions:\n");
44 printf("Stock foreman: %.1f %%\n", warningProportion);
45 EXPECT_LT(warningProportion, 10);
46
47 rewind(source_file_);
48 frameNum = 0;
49 warningCount = 0;
50 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
51 frame_length_ &&
52 frameNum < 300)
53 {
54 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_,
55 height_, 0, kVideoRotation_0, &video_frame_));
56 frameNum++;
57
58 uint8_t* frame = video_frame_.buffer(kYPlane);
59 uint32_t yTmp = 0;
60 for (int yIdx = 0; yIdx < width_ * height_; yIdx++)
61 {
62 yTmp = frame[yIdx] << 1;
63 if (yTmp > 255)
64 {
65 yTmp = 255;
66 }
67 frame[yIdx] = static_cast<uint8_t>(yTmp);
68 }
69
70 VideoProcessingModule::FrameStats stats;
71 ASSERT_EQ(0, vpm_->GetFrameStats(&stats, video_frame_));
72 ASSERT_GE(brightnessWarning = vpm_->BrightnessDetection(video_frame_,
73 stats), 0);
74 EXPECT_NE(VideoProcessingModule::kDarkWarning, brightnessWarning);
75 if (brightnessWarning == VideoProcessingModule::kBrightWarning)
76 {
77 warningCount++;
78 }
79 }
80 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
81
82 // Expect many brightness warnings
83 warningProportion = static_cast<float>(warningCount) / frameNum * 100;
84 printf("Bright foreman: %.1f %%\n", warningProportion);
85 EXPECT_GT(warningProportion, 95);
86
87 rewind(source_file_);
88 frameNum = 0;
89 warningCount = 0;
90 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
91 frame_length_ && frameNum < 300)
92 {
93 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_,
94 height_, 0, kVideoRotation_0, &video_frame_));
95 frameNum++;
96
97 uint8_t* y_plane = video_frame_.buffer(kYPlane);
98 int32_t yTmp = 0;
99 for (int yIdx = 0; yIdx < width_ * height_; yIdx++)
100 {
101 yTmp = y_plane[yIdx] >> 1;
102 y_plane[yIdx] = static_cast<uint8_t>(yTmp);
103 }
104
105 VideoProcessingModule::FrameStats stats;
106 ASSERT_EQ(0, vpm_->GetFrameStats(&stats, video_frame_));
107 ASSERT_GE(brightnessWarning = vpm_->BrightnessDetection(video_frame_,
108 stats), 0);
109 EXPECT_NE(VideoProcessingModule::kBrightWarning, brightnessWarning);
110 if (brightnessWarning == VideoProcessingModule::kDarkWarning)
111 {
112 warningCount++;
113 }
114 }
115 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
116
117 // Expect many darkness warnings
118 warningProportion = static_cast<float>(warningCount) / frameNum * 100;
119 printf("Dark foreman: %.1f %%\n\n", warningProportion);
120 EXPECT_GT(warningProportion, 90);
121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698