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

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

Issue 1901393003: Delete unused methods of the VideoProcessing class. And fix a typo. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added GUARDED_BY annotation. Created 4 years, 7 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
(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 <memory>
12
13 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
14 #include "webrtc/modules/video_processing/include/video_processing.h"
15 #include "webrtc/modules/video_processing/test/video_processing_unittest.h"
16
17 namespace webrtc {
18
19 #if defined(WEBRTC_IOS)
20 #define MAYBE_BrightnessDetection DISABLED_BrightnessDetection
21 #else
22 #define MAYBE_BrightnessDetection BrightnessDetection
23 #endif
24 TEST_F(VideoProcessingTest, MAYBE_BrightnessDetection) {
25 uint32_t frameNum = 0;
26 int32_t brightnessWarning = 0;
27 uint32_t warningCount = 0;
28 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]);
29 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
30 frame_length_) {
31 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
32 0, kVideoRotation_0, &video_frame_));
33 frameNum++;
34 VideoProcessing::FrameStats stats;
35 vp_->GetFrameStats(video_frame_, &stats);
36 EXPECT_GT(stats.num_pixels, 0u);
37 ASSERT_GE(brightnessWarning = vp_->BrightnessDetection(video_frame_, stats),
38 0);
39 if (brightnessWarning != VideoProcessing::kNoWarning) {
40 warningCount++;
41 }
42 }
43 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
44
45 // Expect few warnings
46 float warningProportion = static_cast<float>(warningCount) / frameNum * 100;
47 printf("\nWarning proportions:\n");
48 printf("Stock foreman: %.1f %%\n", warningProportion);
49 EXPECT_LT(warningProportion, 10);
50
51 rewind(source_file_);
52 frameNum = 0;
53 warningCount = 0;
54 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
55 frame_length_ &&
56 frameNum < 300) {
57 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
58 0, kVideoRotation_0, &video_frame_));
59 frameNum++;
60
61 uint8_t* frame = video_frame_.buffer(kYPlane);
62 uint32_t yTmp = 0;
63 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) {
64 yTmp = frame[yIdx] << 1;
65 if (yTmp > 255) {
66 yTmp = 255;
67 }
68 frame[yIdx] = static_cast<uint8_t>(yTmp);
69 }
70
71 VideoProcessing::FrameStats stats;
72 vp_->GetFrameStats(video_frame_, &stats);
73 EXPECT_GT(stats.num_pixels, 0u);
74 ASSERT_GE(brightnessWarning = vp_->BrightnessDetection(video_frame_, stats),
75 0);
76 EXPECT_NE(VideoProcessing::kDarkWarning, brightnessWarning);
77 if (brightnessWarning == VideoProcessing::kBrightWarning) {
78 warningCount++;
79 }
80 }
81 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
82
83 // Expect many brightness warnings
84 warningProportion = static_cast<float>(warningCount) / frameNum * 100;
85 printf("Bright foreman: %.1f %%\n", warningProportion);
86 EXPECT_GT(warningProportion, 95);
87
88 rewind(source_file_);
89 frameNum = 0;
90 warningCount = 0;
91 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
92 frame_length_ &&
93 frameNum < 300) {
94 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
95 0, kVideoRotation_0, &video_frame_));
96 frameNum++;
97
98 uint8_t* y_plane = video_frame_.buffer(kYPlane);
99 int32_t yTmp = 0;
100 for (int yIdx = 0; yIdx < width_ * height_; yIdx++) {
101 yTmp = y_plane[yIdx] >> 1;
102 y_plane[yIdx] = static_cast<uint8_t>(yTmp);
103 }
104
105 VideoProcessing::FrameStats stats;
106 vp_->GetFrameStats(video_frame_, &stats);
107 EXPECT_GT(stats.num_pixels, 0u);
108 ASSERT_GE(brightnessWarning = vp_->BrightnessDetection(video_frame_, stats),
109 0);
110 EXPECT_NE(VideoProcessing::kBrightWarning, brightnessWarning);
111 if (brightnessWarning == VideoProcessing::kDarkWarning) {
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 }
122 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_processing/include/video_processing.h ('k') | webrtc/modules/video_processing/test/deflickering_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698