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

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

Issue 2362683002: New helper function test::ReadI420Buffer, refactor FrameReader to use it. (Closed)
Patch Set: Another try to fix the 64-bit windows build. Created 4 years, 2 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 } 119 }
120 memset(dst, 0, 16 * 16); 120 memset(dst, 0, 16 * 16);
121 DenoiserDecision decision = 121 DenoiserDecision decision =
122 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1); 122 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
123 EXPECT_EQ(COPY_BLOCK, decision); 123 EXPECT_EQ(COPY_BLOCK, decision);
124 decision = df_sse_neon->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1); 124 decision = df_sse_neon->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
125 EXPECT_EQ(COPY_BLOCK, decision); 125 EXPECT_EQ(COPY_BLOCK, decision);
126 } 126 }
127 127
128 // TODO(nisse): Refactor to not use test fixture. Can use some static
129 // helper method to open the input file.
128 TEST_F(VideoProcessingTest, Denoiser) { 130 TEST_F(VideoProcessingTest, Denoiser) {
129 // Used in swap buffer. 131 // Used in swap buffer.
130 int denoised_frame_toggle = 0; 132 int denoised_frame_toggle = 0;
131 // Create pure C denoiser. 133 // Create pure C denoiser.
132 VideoDenoiser denoiser_c(false); 134 VideoDenoiser denoiser_c(false);
133 // Create SSE or NEON denoiser. 135 // Create SSE or NEON denoiser.
134 VideoDenoiser denoiser_sse_neon(true); 136 VideoDenoiser denoiser_sse_neon(true);
135 rtc::scoped_refptr<I420Buffer> denoised_frame_c; 137 rtc::scoped_refptr<I420Buffer> denoised_frame_c;
136 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c; 138 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_c;
137 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon; 139 rtc::scoped_refptr<I420Buffer> denoised_frame_sse_neon;
138 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon; 140 rtc::scoped_refptr<I420Buffer> denoised_frame_prev_sse_neon;
139 141
140 std::unique_ptr<uint8_t[]> video_buffer(new uint8_t[frame_length_]); 142 for (;;) {
141 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == 143 rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer(
142 frame_length_) { 144 test::ReadI420Buffer(width_, height_, source_file_));
143 // Using ConvertToI420 to add stride to the image. 145 if (!video_frame_buffer)
144 rtc::scoped_refptr<webrtc::I420Buffer> input_buffer = 146 break;
145 I420Buffer::Create(width_, height_, width_, half_width_, half_width_);
146 EXPECT_EQ(0, ConvertToI420(kI420, video_buffer.get(), 0, 0, width_, height_,
147 0, kVideoRotation_0, input_buffer.get()));
148 147
149 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c; 148 rtc::scoped_refptr<I420Buffer>* p_denoised_c = &denoised_frame_c;
150 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c; 149 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_c = &denoised_frame_prev_c;
151 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon = 150 rtc::scoped_refptr<I420Buffer>* p_denoised_sse_neon =
152 &denoised_frame_sse_neon; 151 &denoised_frame_sse_neon;
153 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon = 152 rtc::scoped_refptr<I420Buffer>* p_denoised_prev_sse_neon =
154 &denoised_frame_prev_sse_neon; 153 &denoised_frame_prev_sse_neon;
155 // Swap the buffer to save one memcpy in DenoiseFrame. 154 // Swap the buffer to save one memcpy in DenoiseFrame.
156 if (denoised_frame_toggle) { 155 if (denoised_frame_toggle) {
157 p_denoised_c = &denoised_frame_prev_c; 156 p_denoised_c = &denoised_frame_prev_c;
158 p_denoised_prev_c = &denoised_frame_c; 157 p_denoised_prev_c = &denoised_frame_c;
159 p_denoised_sse_neon = &denoised_frame_prev_sse_neon; 158 p_denoised_sse_neon = &denoised_frame_prev_sse_neon;
160 p_denoised_prev_sse_neon = &denoised_frame_sse_neon; 159 p_denoised_prev_sse_neon = &denoised_frame_sse_neon;
161 } 160 }
162 denoiser_c.DenoiseFrame(input_buffer, p_denoised_c, p_denoised_prev_c, 161 denoiser_c.DenoiseFrame(video_frame_buffer,
162 p_denoised_c, p_denoised_prev_c,
163 false); 163 false);
164 denoiser_sse_neon.DenoiseFrame(input_buffer, p_denoised_sse_neon, 164 denoiser_sse_neon.DenoiseFrame(video_frame_buffer,
165 p_denoised_sse_neon,
165 p_denoised_prev_sse_neon, false); 166 p_denoised_prev_sse_neon, false);
166 // Invert the flag. 167 // Invert the flag.
167 denoised_frame_toggle ^= 1; 168 denoised_frame_toggle ^= 1;
168 // Denoising results should be the same for C and SSE/NEON denoiser. 169 // Denoising results should be the same for C and SSE/NEON denoiser.
169 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon)); 170 ASSERT_TRUE(test::FrameBufsEqual(*p_denoised_c, *p_denoised_sse_neon));
170 } 171 }
171 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; 172 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
172 } 173 }
173 174
174 } // namespace webrtc 175 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698