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

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

Issue 2005733003: Refactor VideoDenoiser to work with I420Buffer, not VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Trivial rebase. Created 4 years, 6 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 EXPECT_EQ(COPY_BLOCK, decision); 125 EXPECT_EQ(COPY_BLOCK, decision);
126 } 126 }
127 127
128 TEST_F(VideoProcessingTest, Denoiser) { 128 TEST_F(VideoProcessingTest, Denoiser) {
129 // Used in swap buffer. 129 // Used in swap buffer.
130 int denoised_frame_toggle = 0; 130 int denoised_frame_toggle = 0;
131 // Create pure C denoiser. 131 // Create pure C denoiser.
132 VideoDenoiser denoiser_c(false); 132 VideoDenoiser denoiser_c(false);
133 // Create SSE or NEON denoiser. 133 // Create SSE or NEON denoiser.
134 VideoDenoiser denoiser_sse_neon(true); 134 VideoDenoiser denoiser_sse_neon(true);
135 VideoFrame denoised_frame_c; 135 rtc::scoped_refptr<I420Buffer> denoised_frame_c;
136 VideoFrame denoised_frame_prev_c; 136 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c;
137 VideoFrame denoised_frame_sse_neon; 137 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon;
138 VideoFrame 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 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_,
145 0, kVideoRotation_0, &video_frame_)); 145 0, kVideoRotation_0, &video_frame_));
146 146
147 VideoFrame* p_denoised_c = &denoised_frame_c; 147 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c;
148 VideoFrame* p_denoised_prev_c = &denoised_frame_prev_c; 148 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c;
149 VideoFrame* p_denoised_sse_neon = &denoised_frame_sse_neon; 149 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon =
150 VideoFrame* p_denoised_prev_sse_neon = &denoised_frame_prev_sse_neon; 150 &denoised_frame_sse_neon;
151 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon =
152 &denoised_frame_prev_sse_neon;
151 // Swap the buffer to save one memcpy in DenoiseFrame. 153 // Swap the buffer to save one memcpy in DenoiseFrame.
152 if (denoised_frame_toggle) { 154 if (denoised_frame_toggle) {
153 p_denoised_c = &denoised_frame_prev_c; 155 p_denoised_c = &denoised_frame_prev_c;
154 p_denoised_prev_c = &denoised_frame_c; 156 p_denoised_prev_c = &denoised_frame_c;
155 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; 157 p_denoised_sse_neon = &denoised_frame_prev_sse_neon;
156 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; 158 p_denoised_prev_sse_neon = &denoised_frame_sse_neon;
157 } 159 }
158 denoiser_c.DenoiseFrame(video_frame_, p_denoised_c, p_denoised_prev_c, 160 denoiser_c.DenoiseFrame(video_frame_.video_frame_buffer(),
161 p_denoised_c, p_denoised_prev_c,
159 false); 162 false);
160 denoiser_sse_neon.DenoiseFrame(video_frame_, p_denoised_sse_neon, 163 denoiser_sse_neon.DenoiseFrame(video_frame_.video_frame_buffer(),
164 p_denoised_sse_neon,
161 p_denoised_prev_sse_neon, false); 165 p_denoised_prev_sse_neon, false);
162 // Invert the flag. 166 // Invert the flag.
163 denoised_frame_toggle ^= 1; 167 denoised_frame_toggle ^= 1;
164 // 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.
165 ASSERT_TRUE(test::FramesEqual(*p_denoised_c, *p_denoised_sse_neon)); 169 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon));
166 } 170 }
167 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; 171 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
168 } 172 }
169 173
170 } // namespace webrtc 174 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698