| 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_); |
| 144 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, | 146 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_, |
| 145 0, kVideoRotation_0, &video_frame_)); | 147 0, kVideoRotation_0, input_buffer.get())); |
| 146 | 148 |
| 147 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; | 149 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; |
| 148 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; | 150 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; |
| 149 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = | 151 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = |
| 150 &denoised_frame_sse_neon; | 152 &denoised_frame_sse_neon; |
| 151 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = | 153 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = |
| 152 &denoised_frame_prev_sse_neon; | 154 &denoised_frame_prev_sse_neon; |
| 153 // Swap the buffer to save one memcpy in DenoiseFrame. | 155 // Swap the buffer to save one memcpy in DenoiseFrame. |
| 154 if (denoised_frame_toggle) { | 156 if (denoised_frame_toggle) { |
| 155 p_denoised_c = &denoised_frame_prev_c; | 157 p_denoised_c = &denoised_frame_prev_c; |
| 156 p_denoised_prev_c = &denoised_frame_c; | 158 p_denoised_prev_c = &denoised_frame_c; |
| 157 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; | 159 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; |
| 158 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; | 160 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; |
| 159 } | 161 } |
| 160 denoiser_c.DenoiseFrame(video_frame_.video_frame_buffer(), | 162 denoiser_c.DenoiseFrame(input_buffer, p_denoised_c, p_denoised_prev_c, |
| 161 p_denoised_c, p_denoised_prev_c, | |
| 162 false); | 163 false); |
| 163 denoiser_sse_neon.DenoiseFrame(video_frame_.video_frame_buffer(), | 164 denoiser_sse_neon.DenoiseFrame(input_buffer, p_denoised_sse_neon, |
| 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 |