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

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

Issue 1871853003: External VNR speed improvement and more. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More clean-up. Created 4 years, 8 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 13 matching lines...) Expand all
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(
26 DenoiserFilter::Create(true, nullptr)); 26 DenoiserFilter::Create(true, nullptr));
27 uint8_t src[16 * 16], dst[16 * 16]; 27 uint8_t src[16 * 16], dst[16 * 16];
28 for (int i = 0; i < 16; ++i) { 28 for (int i = 0; i < 16; ++i) {
29 for (int j = 0; j < 16; ++j) { 29 for (int j = 0; j < 16; ++j) {
30 src[i * 16 + j] = i * 16 + j; 30 src[i * 16 + j] = i * 16 + j;
31 } 31 }
32 } 32 }
33 33
34 memset(dst, 0, 8 * 8);
35 df_c->CopyMem8x8(src, 8, dst, 8);
36 EXPECT_EQ(0, memcmp(src, dst, 8 * 8));
37
38 memset(dst, 0, 16 * 16); 34 memset(dst, 0, 16 * 16);
39 df_c->CopyMem16x16(src, 16, dst, 16); 35 df_c->CopyMem16x16(src, 16, dst, 16);
40 EXPECT_EQ(0, memcmp(src, dst, 16 * 16)); 36 EXPECT_EQ(0, memcmp(src, dst, 16 * 16));
41 37
42 memset(dst, 0, 8 * 8);
43 df_sse_neon->CopyMem16x16(src, 8, dst, 8);
44 EXPECT_EQ(0, memcmp(src, dst, 8 * 8));
45
46 memset(dst, 0, 16 * 16); 38 memset(dst, 0, 16 * 16);
47 df_sse_neon->CopyMem16x16(src, 16, dst, 16); 39 df_sse_neon->CopyMem16x16(src, 16, dst, 16);
48 EXPECT_EQ(0, memcmp(src, dst, 16 * 16)); 40 EXPECT_EQ(0, memcmp(src, dst, 16 * 16));
49 } 41 }
50 42
51 TEST_F(VideoProcessingTest, Variance) { 43 TEST_F(VideoProcessingTest, Variance) {
52 std::unique_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false, nullptr)); 44 std::unique_ptr<DenoiserFilter> df_c(DenoiserFilter::Create(false, nullptr));
53 std::unique_ptr<DenoiserFilter> df_sse_neon( 45 std::unique_ptr<DenoiserFilter> df_sse_neon(
54 DenoiserFilter::Create(true, nullptr)); 46 DenoiserFilter::Create(true, nullptr));
55 uint8_t src[16 * 16], dst[16 * 16]; 47 uint8_t src[16 * 16], dst[16 * 16];
(...skipping 24 matching lines...) Expand all
80 uint8_t dst[16 * 16], dst_sse_neon[16 * 16]; 72 uint8_t dst[16 * 16], dst_sse_neon[16 * 16];
81 73
82 // Test case: |diff| <= |3 + shift_inc1| 74 // Test case: |diff| <= |3 + shift_inc1|
83 for (int i = 0; i < 16; ++i) { 75 for (int i = 0; i < 16; ++i) {
84 for (int j = 0; j < 16; ++j) { 76 for (int j = 0; j < 16; ++j) {
85 running_src[i * 16 + j] = i * 11 + j; 77 running_src[i * 16 + j] = i * 11 + j;
86 src[i * 16 + j] = i * 11 + j + 2; 78 src[i * 16 + j] = i * 11 + j + 2;
87 } 79 }
88 } 80 }
89 memset(dst, 0, 16 * 16); 81 memset(dst, 0, 16 * 16);
90 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1, false); 82 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
91 memset(dst_sse_neon, 0, 16 * 16); 83 memset(dst_sse_neon, 0, 16 * 16);
92 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1, 84 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1);
93 false);
94 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16)); 85 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16));
95 86
96 // Test case: |diff| >= |4 + shift_inc1| 87 // Test case: |diff| >= |4 + shift_inc1|
97 for (int i = 0; i < 16; ++i) { 88 for (int i = 0; i < 16; ++i) {
98 for (int j = 0; j < 16; ++j) { 89 for (int j = 0; j < 16; ++j) {
99 running_src[i * 16 + j] = i * 11 + j; 90 running_src[i * 16 + j] = i * 11 + j;
100 src[i * 16 + j] = i * 11 + j + 5; 91 src[i * 16 + j] = i * 11 + j + 5;
101 } 92 }
102 } 93 }
103 memset(dst, 0, 16 * 16); 94 memset(dst, 0, 16 * 16);
104 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1, false); 95 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
105 memset(dst_sse_neon, 0, 16 * 16); 96 memset(dst_sse_neon, 0, 16 * 16);
106 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1, 97 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1);
107 false);
108 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16)); 98 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16));
109 99
110 // Test case: |diff| >= 8 100 // Test case: |diff| >= 8
111 for (int i = 0; i < 16; ++i) { 101 for (int i = 0; i < 16; ++i) {
112 for (int j = 0; j < 16; ++j) { 102 for (int j = 0; j < 16; ++j) {
113 running_src[i * 16 + j] = i * 11 + j; 103 running_src[i * 16 + j] = i * 11 + j;
114 src[i * 16 + j] = i * 11 + j + 8; 104 src[i * 16 + j] = i * 11 + j + 8;
115 } 105 }
116 } 106 }
117 memset(dst, 0, 16 * 16); 107 memset(dst, 0, 16 * 16);
118 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1, false); 108 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
119 memset(dst_sse_neon, 0, 16 * 16); 109 memset(dst_sse_neon, 0, 16 * 16);
120 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1, 110 df_sse_neon->MbDenoise(running_src, 16, dst_sse_neon, 16, src, 16, 0, 1);
121 false);
122 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16)); 111 EXPECT_EQ(0, memcmp(dst, dst_sse_neon, 16 * 16));
123 112
124 // Test case: |diff| > 15 113 // Test case: |diff| > 15
125 for (int i = 0; i < 16; ++i) { 114 for (int i = 0; i < 16; ++i) {
126 for (int j = 0; j < 16; ++j) { 115 for (int j = 0; j < 16; ++j) {
127 running_src[i * 16 + j] = i * 11 + j; 116 running_src[i * 16 + j] = i * 11 + j;
128 src[i * 16 + j] = i * 11 + j + 16; 117 src[i * 16 + j] = i * 11 + j + 16;
129 } 118 }
130 } 119 }
131 memset(dst, 0, 16 * 16); 120 memset(dst, 0, 16 * 16);
132 DenoiserDecision decision = 121 DenoiserDecision decision =
133 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1, false); 122 df_c->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
134 EXPECT_EQ(COPY_BLOCK, decision); 123 EXPECT_EQ(COPY_BLOCK, decision);
135 decision = 124 decision = df_sse_neon->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1);
136 df_sse_neon->MbDenoise(running_src, 16, dst, 16, src, 16, 0, 1, false);
137 EXPECT_EQ(COPY_BLOCK, decision); 125 EXPECT_EQ(COPY_BLOCK, decision);
138 } 126 }
139 127
140 TEST_F(VideoProcessingTest, Denoiser) { 128 TEST_F(VideoProcessingTest, Denoiser) {
129 // Used in swap buffer.
130 int denoised_frame_toggle = 0;
141 // Create pure C denoiser. 131 // Create pure C denoiser.
142 VideoDenoiser denoiser_c(false); 132 VideoDenoiser denoiser_c(false);
143 // Create SSE or NEON denoiser. 133 // Create SSE or NEON denoiser.
144 VideoDenoiser denoiser_sse_neon(true); 134 VideoDenoiser denoiser_sse_neon(true);
145 VideoFrame denoised_frame_c; 135 VideoFrame denoised_frame_c;
146 VideoFrame denoised_frame_track_c; 136 VideoFrame denoised_frame_prev_c;
147 VideoFrame denoised_frame_sse_neon; 137 VideoFrame denoised_frame_sse_neon;
148 VideoFrame denoised_frame_track_sse_neon; 138 VideoFrame denoised_frame_prev_sse_neon;
149 139
150 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_]);
151 while (fread(video_buffer.get(), 1, frame_length_, source_file_) == 141 while (fread(video_buffer.get(), 1, frame_length_, source_file_) ==
152 frame_length_) { 142 frame_length_) {
153 // Using ConvertToI420 to add stride to the image. 143 // Using ConvertToI420 to add stride to the image.
154 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_,
155 0, kVideoRotation_0, &video_frame_)); 145 0, kVideoRotation_0, &video_frame_));
156 146
157 denoiser_c.DenoiseFrame(video_frame_, &denoised_frame_c, 147 VideoFrame* p_denoised_c = &denoised_frame_c;
158 &denoised_frame_track_c, -1); 148 VideoFrame* p_denoised_prev_c = &denoised_frame_prev_c;
159 denoiser_sse_neon.DenoiseFrame(video_frame_, &denoised_frame_sse_neon, 149 VideoFrame* p_denoised_sse_neon = &denoised_frame_sse_neon;
160 &denoised_frame_track_sse_neon, -1); 150 VideoFrame* p_denoised_prev_sse_neon = &denoised_frame_prev_sse_neon;
161 151 // Swap the buffer to save one memcpy in DenoiseFrame.
152 if (denoised_frame_toggle) {
153 p_denoised_c = &denoised_frame_prev_c;
154 p_denoised_prev_c = &denoised_frame_c;
155 p_denoised_sse_neon = &denoised_frame_prev_sse_neon;
156 p_denoised_prev_sse_neon = &denoised_frame_sse_neon;
157 }
158 denoiser_c.DenoiseFrame(video_frame_, p_denoised_c, p_denoised_prev_c,
159 false);
160 denoiser_sse_neon.DenoiseFrame(video_frame_, p_denoised_sse_neon,
161 p_denoised_prev_sse_neon, false);
162 // Invert the flag.
163 denoised_frame_toggle ^= 1;
162 // Denoising results should be the same for C and SSE/NEON denoiser. 164 // Denoising results should be the same for C and SSE/NEON denoiser.
163 ASSERT_TRUE(test::FramesEqual(denoised_frame_c, denoised_frame_sse_neon)); 165 ASSERT_TRUE(test::FramesEqual(*p_denoised_c, *p_denoised_sse_neon));
164 } 166 }
165 ASSERT_NE(0, feof(source_file_)) << "Error reading source file"; 167 ASSERT_NE(0, feof(source_file_)) << "Error reading source file";
166 } 168 }
167 169
168 } // namespace webrtc 170 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_processing/frame_preprocessor.cc ('k') | webrtc/modules/video_processing/util/denoiser_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698