OLD | NEW |
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 <string> | 16 #include <string> |
16 | 17 |
17 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 18 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
18 #include "webrtc/system_wrappers/include/tick_util.h" | 19 #include "webrtc/system_wrappers/include/tick_util.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 20 #include "webrtc/test/testsupport/fileutils.h" |
20 | 21 |
21 namespace webrtc { | 22 namespace webrtc { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 EXPECT_EQ(-3, vp_->BrightnessDetection(videoFrame, stats)); | 110 EXPECT_EQ(-3, vp_->BrightnessDetection(videoFrame, stats)); |
110 } | 111 } |
111 | 112 |
112 #if defined(WEBRTC_IOS) | 113 #if defined(WEBRTC_IOS) |
113 TEST_F(VideoProcessingTest, DISABLED_HandleBadStats) { | 114 TEST_F(VideoProcessingTest, DISABLED_HandleBadStats) { |
114 #else | 115 #else |
115 TEST_F(VideoProcessingTest, HandleBadStats) { | 116 TEST_F(VideoProcessingTest, HandleBadStats) { |
116 #endif | 117 #endif |
117 VideoProcessing::FrameStats stats; | 118 VideoProcessing::FrameStats stats; |
118 vp_->ClearFrameStats(&stats); | 119 vp_->ClearFrameStats(&stats); |
119 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 120 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
120 ASSERT_EQ(frame_length_, | 121 ASSERT_EQ(frame_length_, |
121 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 122 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
122 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 123 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
123 0, kVideoRotation_0, &video_frame_)); | 124 0, kVideoRotation_0, &video_frame_)); |
124 | 125 |
125 EXPECT_EQ(-1, vp_->Deflickering(&video_frame_, &stats)); | 126 EXPECT_EQ(-1, vp_->Deflickering(&video_frame_, &stats)); |
126 | 127 |
127 EXPECT_EQ(-3, vp_->BrightnessDetection(video_frame_, stats)); | 128 EXPECT_EQ(-3, vp_->BrightnessDetection(video_frame_, stats)); |
128 } | 129 } |
129 | 130 |
130 #if defined(WEBRTC_IOS) | 131 #if defined(WEBRTC_IOS) |
131 TEST_F(VideoProcessingTest, DISABLED_IdenticalResultsAfterReset) { | 132 TEST_F(VideoProcessingTest, DISABLED_IdenticalResultsAfterReset) { |
132 #else | 133 #else |
133 TEST_F(VideoProcessingTest, IdenticalResultsAfterReset) { | 134 TEST_F(VideoProcessingTest, IdenticalResultsAfterReset) { |
134 #endif | 135 #endif |
135 VideoFrame video_frame2; | 136 VideoFrame video_frame2; |
136 VideoProcessing::FrameStats stats; | 137 VideoProcessing::FrameStats stats; |
137 // Only testing non-static functions here. | 138 // Only testing non-static functions here. |
138 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 139 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
139 ASSERT_EQ(frame_length_, | 140 ASSERT_EQ(frame_length_, |
140 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 141 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
141 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 142 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
142 0, kVideoRotation_0, &video_frame_)); | 143 0, kVideoRotation_0, &video_frame_)); |
143 vp_->GetFrameStats(video_frame_, &stats); | 144 vp_->GetFrameStats(video_frame_, &stats); |
144 EXPECT_GT(stats.num_pixels, 0u); | 145 EXPECT_GT(stats.num_pixels, 0u); |
145 video_frame2.CopyFrame(video_frame_); | 146 video_frame2.CopyFrame(video_frame_); |
146 ASSERT_EQ(0, vp_->Deflickering(&video_frame_, &stats)); | 147 ASSERT_EQ(0, vp_->Deflickering(&video_frame_, &stats)); |
147 | 148 |
148 // Retrieve frame stats again in case Deflickering() has zeroed them. | 149 // Retrieve frame stats again in case Deflickering() has zeroed them. |
(...skipping 15 matching lines...) Expand all Loading... |
164 EXPECT_TRUE(CompareFrames(video_frame_, video_frame2)); | 165 EXPECT_TRUE(CompareFrames(video_frame_, video_frame2)); |
165 } | 166 } |
166 | 167 |
167 #if defined(WEBRTC_IOS) | 168 #if defined(WEBRTC_IOS) |
168 TEST_F(VideoProcessingTest, DISABLED_FrameStats) { | 169 TEST_F(VideoProcessingTest, DISABLED_FrameStats) { |
169 #else | 170 #else |
170 TEST_F(VideoProcessingTest, FrameStats) { | 171 TEST_F(VideoProcessingTest, FrameStats) { |
171 #endif | 172 #endif |
172 VideoProcessing::FrameStats stats; | 173 VideoProcessing::FrameStats stats; |
173 vp_->ClearFrameStats(&stats); | 174 vp_->ClearFrameStats(&stats); |
174 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 175 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
175 ASSERT_EQ(frame_length_, | 176 ASSERT_EQ(frame_length_, |
176 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 177 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
177 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 178 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
178 0, kVideoRotation_0, &video_frame_)); | 179 0, kVideoRotation_0, &video_frame_)); |
179 | 180 |
180 EXPECT_FALSE(vp_->ValidFrameStats(stats)); | 181 EXPECT_FALSE(vp_->ValidFrameStats(stats)); |
181 vp_->GetFrameStats(video_frame_, &stats); | 182 vp_->GetFrameStats(video_frame_, &stats); |
182 EXPECT_GT(stats.num_pixels, 0u); | 183 EXPECT_GT(stats.num_pixels, 0u); |
183 EXPECT_TRUE(vp_->ValidFrameStats(stats)); | 184 EXPECT_TRUE(vp_->ValidFrameStats(stats)); |
184 | 185 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 229 |
229 rewind(source_file_); | 230 rewind(source_file_); |
230 ASSERT_TRUE(source_file_ != NULL) << "Cannot read input file \n"; | 231 ASSERT_TRUE(source_file_ != NULL) << "Cannot read input file \n"; |
231 | 232 |
232 // CA not needed here | 233 // CA not needed here |
233 vp_->EnableContentAnalysis(false); | 234 vp_->EnableContentAnalysis(false); |
234 // no temporal decimation | 235 // no temporal decimation |
235 vp_->EnableTemporalDecimation(false); | 236 vp_->EnableTemporalDecimation(false); |
236 | 237 |
237 // Reading test frame | 238 // Reading test frame |
238 rtc::scoped_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 239 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
239 ASSERT_EQ(frame_length_, | 240 ASSERT_EQ(frame_length_, |
240 fread(video_buffer.get(), 1, frame_length_, source_file_)); | 241 fread(video_buffer.get(), 1, frame_length_, source_file_)); |
241 // Using ConvertToI420 to add stride to the image. | 242 // Using ConvertToI420 to add stride to the image. |
242 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_, |
243 0, kVideoRotation_0, &video_frame_)); | 244 0, kVideoRotation_0, &video_frame_)); |
244 // Cropped source frame that will contain the expected visible region. | 245 // Cropped source frame that will contain the expected visible region. |
245 VideoFrame cropped_source_frame; | 246 VideoFrame cropped_source_frame; |
246 cropped_source_frame.CopyFrame(video_frame_); | 247 cropped_source_frame.CopyFrame(video_frame_); |
247 | 248 |
248 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) { | 249 for (uint32_t run_idx = 0; run_idx < NumRuns; run_idx++) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 std::cout << "Watch " << filename.str() << " and verify that it is okay." | 407 std::cout << "Watch " << filename.str() << " and verify that it is okay." |
407 << std::endl; | 408 << std::endl; |
408 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); | 409 FILE* stand_alone_file = fopen(filename.str().c_str(), "wb"); |
409 if (PrintVideoFrame(processed, stand_alone_file) < 0) | 410 if (PrintVideoFrame(processed, stand_alone_file) < 0) |
410 std::cerr << "Failed to write: " << filename.str() << std::endl; | 411 std::cerr << "Failed to write: " << filename.str() << std::endl; |
411 if (stand_alone_file) | 412 if (stand_alone_file) |
412 fclose(stand_alone_file); | 413 fclose(stand_alone_file); |
413 } | 414 } |
414 | 415 |
415 } // namespace webrtc | 416 } // namespace webrtc |
OLD | NEW |