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 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 VideoDenoiser denoiser_sse_neon(true); | 134 VideoDenoiser denoiser_sse_neon(true); |
135 rtc::scoped_refptr<I420Buffer> denoised_frame_c; | 135 rtc::scoped_refptr<I420Buffer> denoised_frame_c; |
136 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c; | 136 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c; |
137 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon; | 137 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon; |
138 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon; | 138 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon; |
139 | 139 |
140 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); | 140 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); |
141 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == | 141 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == |
142 frame_length_) { | 142 frame_length_) { |
143 // Using ConvertToI420 to add stride to the image. | 143 // Using ConvertToI420 to add stride to the image. |
144 rtc::scoped_refptr<webrtc::I420Buffer> input_buffer = | |
145 I420Buffer::Create(width_, height_, width_, half_width_, half_width_); | |
146 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 144 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
147 0, kVideoRotation_0, input_buffer.get())); | 145 0, kVideoRotation_0, &video_frame_)); |
148 | 146 |
149 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; | 147 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; |
150 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; | 148 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; |
151 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = | 149 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = |
152 &denoised_frame_sse_neon; | 150 &denoised_frame_sse_neon; |
153 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = | 151 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = |
154 &denoised_frame_prev_sse_neon; | 152 &denoised_frame_prev_sse_neon; |
155 // Swap the buffer to save one memcpy in DenoiseFrame. | 153 // Swap the buffer to save one memcpy in DenoiseFrame. |
156 if (denoised_frame_toggle) { | 154 if (denoised_frame_toggle) { |
157 p_denoised_c = &denoised_frame_prev_c; | 155 p_denoised_c = &denoised_frame_prev_c; |
158 p_denoised_prev_c = &denoised_frame_c; | 156 p_denoised_prev_c = &denoised_frame_c; |
159 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; | 157 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; |
160 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; | 158 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; |
161 } | 159 } |
162 denoiser_c.DenoiseFrame(input_buffer, p_denoised_c, p_denoised_prev_c, | 160 denoiser_c.DenoiseFrame(video_frame_.video_frame_buffer(), |
| 161 p_denoised_c, p_denoised_prev_c, |
163 false); | 162 false); |
164 denoiser_sse_neon.DenoiseFrame(input_buffer, p_denoised_sse_neon, | 163 denoiser_sse_neon.DenoiseFrame(video_frame_.video_frame_buffer(), |
| 164 p_denoised_sse_neon, |
165 p_denoised_prev_sse_neon, false); | 165 p_denoised_prev_sse_neon, false); |
166 // Invert the flag. | 166 // Invert the flag. |
167 denoised_frame_toggle ^= 1; | 167 denoised_frame_toggle ^= 1; |
168 // Denoising results should be the same for C and SSE/NEON denoiser. | 168 // Denoising results should be the same for C and SSE/NEON denoiser. |
169 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon)); | 169 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon)); |
170 } | 170 } |
171 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; | 171 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; |
172 } | 172 } |
173 | 173 |
174 } // namespace webrtc | 174 } // namespace webrtc |
OLD | NEW |