OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <string.h> | 11 #include <string.h> |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "webrtc/common_video/include/video_frame_buffer.h" | 15 #include "webrtc/common_video/include/i420_buffer_pool.h" |
16 #include "webrtc/modules/video_processing/video_denoiser.h" | 16 #include "webrtc/modules/video_processing/video_denoiser.h" |
17 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
18 #include "webrtc/test/frame_utils.h" | 18 #include "webrtc/test/frame_utils.h" |
19 #include "webrtc/test/testsupport/fileutils.h" | 19 #include "webrtc/test/testsupport/fileutils.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 TEST(VideoDenoiserTest, CopyMem) { | 23 TEST(VideoDenoiserTest, CopyMem) { |
24 std::unique_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false, nullptr)); | 24 std::unique_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false, nullptr)); |
25 std::unique_ptr<DenoiserFilter> df_sse_neon( | 25 std::unique_ptr<DenoiserFilter> df_sse_neon( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 TEST(VideoDenoiserTest, Denoiser) { | 128 TEST(VideoDenoiserTest, Denoiser) { |
129 const int kWidth = 352; | 129 const int kWidth = 352; |
130 const int kHeight = 288; | 130 const int kHeight = 288; |
131 | 131 |
132 const std::string video_file = | 132 const std::string video_file = |
133 webrtc::test::ResourcePath("foreman_cif", "yuv"); | 133 webrtc::test::ResourcePath("foreman_cif", "yuv"); |
134 FILE* source_file = fopen(video_file.c_str(), "rb"); | 134 FILE* source_file = fopen(video_file.c_str(), "rb"); |
135 ASSERT_TRUE(source_file != nullptr) | 135 ASSERT_TRUE(source_file != nullptr) |
136 << "Cannot open source file: " << video_file; | 136 << "Cannot open source file: " << video_file; |
137 | 137 |
138 // Used in swap buffer. | |
139 int denoised_frame_toggle = 0; | |
140 // Create pure C denoiser. | 138 // Create pure C denoiser. |
141 VideoDenoiser denoiser_c(false); | 139 VideoDenoiser denoiser_c(false); |
142 // Create SSE or NEON denoiser. | 140 // Create SSE or NEON denoiser. |
143 VideoDenoiser denoiser_sse_neon(true); | 141 VideoDenoiser denoiser_sse_neon(true); |
144 rtc::scoped_refptr<I420Buffer> denoised_frame_c; | |
145 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c; | |
146 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon; | |
147 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon; | |
148 | 142 |
149 for (;;) { | 143 for (;;) { |
150 rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer( | 144 rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer( |
151 test::ReadI420Buffer(kWidth, kHeight, source_file)); | 145 test::ReadI420Buffer(kWidth, kHeight, source_file)); |
152 if (!video_frame_buffer) | 146 if (!video_frame_buffer) |
153 break; | 147 break; |
154 | 148 |
155 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; | 149 rtc::scoped_refptr<VideoFrameBuffer> denoised_frame_c( |
156 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; | 150 denoiser_c.DenoiseFrame(video_frame_buffer, false)); |
157 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = | 151 rtc::scoped_refptr<VideoFrameBuffer> denoised_frame_sse_neon( |
158 &denoised_frame_sse_neon; | 152 denoiser_sse_neon.DenoiseFrame(video_frame_buffer, false)); |
159 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = | 153 |
160 &denoised_frame_prev_sse_neon; | |
161 // Swap the buffer to save one memcpy in DenoiseFrame. | |
162 if (denoised_frame_toggle) { | |
163 p_denoised_c = &denoised_frame_prev_c; | |
164 p_denoised_prev_c = &denoised_frame_c; | |
165 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; | |
166 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; | |
167 } | |
168 denoiser_c.DenoiseFrame(video_frame_buffer, | |
169 p_denoised_c, p_denoised_prev_c, | |
170 false); | |
171 denoiser_sse_neon.DenoiseFrame(video_frame_buffer, | |
172 p_denoised_sse_neon, | |
173 p_denoised_prev_sse_neon, false); | |
174 // Invert the flag. | |
175 denoised_frame_toggle ^= 1; | |
176 // Denoising results should be the same for C and SSE/NEON denoiser. | 154 // Denoising results should be the same for C and SSE/NEON denoiser. |
177 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon)); | 155 ASSERT_TRUE( |
| 156 test::FrameBufsEqual(denoised_frame_c, denoised_frame_sse_neon)); |
178 } | 157 } |
179 ASSERT_NE(0, feof(source_file)) << "Error reading source file"; | 158 ASSERT_NE(0, feof(source_file)) << "Error reading source file"; |
180 } | 159 } |
181 | 160 |
182 } // namespace webrtc | 161 } // namespace webrtc |
OLD | NEW |