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

Side by Side Diff: webrtc/common_audio/signal_processing/signal_processing_unittest.cc

Issue 2014023002: Add clz functions (Count number of Leading Zero bits), 32-and 64-bit variants (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@bug601787-1
Patch Set: fix comments 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 INT32_MIN, std::min<int64_t>(INT32_MAX, static_cast<int64_t>(a) - b)); 135 INT32_MIN, std::min<int64_t>(INT32_MAX, static_cast<int64_t>(a) - b));
136 std::ostringstream ss; 136 std::ostringstream ss;
137 ss << a << " +/- " << b << ": sum " << sum << ", diff " << diff; 137 ss << a << " +/- " << b << ": sum " << sum << ", diff " << diff;
138 SCOPED_TRACE(ss.str()); 138 SCOPED_TRACE(ss.str());
139 EXPECT_EQ(sum, WebRtcSpl_AddSatW32(a, b)); 139 EXPECT_EQ(sum, WebRtcSpl_AddSatW32(a, b));
140 EXPECT_EQ(diff, WebRtcSpl_SubSatW32(a, b)); 140 EXPECT_EQ(diff, WebRtcSpl_SubSatW32(a, b));
141 } 141 }
142 } 142 }
143 } 143 }
144 144
145 TEST_F(SplTest, CountLeadingZeros32) {
146 EXPECT_EQ(32, WebRtcSpl_CountLeadingZeros32(0));
147 EXPECT_EQ(32, WebRtcSpl_CountLeadingZeros32_NotBuiltin(0));
148 for (int i = 0; i < 32; ++i) {
149 const uint32_t single_one = uint32_t{1} << i;
150 const uint32_t all_ones = 2 * single_one - 1;
151 EXPECT_EQ(31 - i, WebRtcSpl_CountLeadingZeros32(single_one));
152 EXPECT_EQ(31 - i, WebRtcSpl_CountLeadingZeros32_NotBuiltin(single_one));
153 EXPECT_EQ(31 - i, WebRtcSpl_CountLeadingZeros32(all_ones));
154 EXPECT_EQ(31 - i, WebRtcSpl_CountLeadingZeros32_NotBuiltin(all_ones));
155 }
156 }
157
158 TEST_F(SplTest, CountLeadingZeros64) {
159 EXPECT_EQ(64, WebRtcSpl_CountLeadingZeros64(0));
160 EXPECT_EQ(64, WebRtcSpl_CountLeadingZeros64_NotBuiltin(0));
161 for (int i = 0; i < 64; ++i) {
162 const uint64_t single_one = uint64_t{1} << i;
163 const uint64_t all_ones = 2 * single_one - 1;
164 EXPECT_EQ(63 - i, WebRtcSpl_CountLeadingZeros64(single_one));
165 EXPECT_EQ(63 - i, WebRtcSpl_CountLeadingZeros64_NotBuiltin(single_one));
166 EXPECT_EQ(63 - i, WebRtcSpl_CountLeadingZeros64(all_ones));
167 EXPECT_EQ(63 - i, WebRtcSpl_CountLeadingZeros64_NotBuiltin(all_ones));
168 }
169 }
170
145 TEST_F(SplTest, MathOperationsTest) { 171 TEST_F(SplTest, MathOperationsTest) {
146 int A = 1134567892; 172 int A = 1134567892;
147 int32_t num = 117; 173 int32_t num = 117;
148 int32_t den = -5; 174 int32_t den = -5;
149 uint16_t denU = 5; 175 uint16_t denU = 5;
150 EXPECT_EQ(33700, WebRtcSpl_Sqrt(A)); 176 EXPECT_EQ(33700, WebRtcSpl_Sqrt(A));
151 EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A)); 177 EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A));
152 178
153 179
154 EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num)); 180 EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num));
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 // 12-15 are skipped to account for the filter lag. 598 // 12-15 are skipped to account for the filter lag.
573 for (size_t i = 0; i < 12; ++i) { 599 for (size_t i = 0; i < 12; ++i) {
574 EXPECT_EQ(kRefValue32kHz1, out_vector[i]); 600 EXPECT_EQ(kRefValue32kHz1, out_vector[i]);
575 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]); 601 EXPECT_EQ(kRefValue16kHz1, out_vector_w16[i]);
576 } 602 }
577 for (size_t i = 16; i < 2 * kBlockSize; ++i) { 603 for (size_t i = 16; i < 2 * kBlockSize; ++i) {
578 EXPECT_EQ(kRefValue32kHz2, out_vector[i]); 604 EXPECT_EQ(kRefValue32kHz2, out_vector[i]);
579 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]); 605 EXPECT_EQ(kRefValue16kHz2, out_vector_w16[i]);
580 } 606 }
581 } 607 }
OLDNEW
« no previous file with comments | « webrtc/common_audio/signal_processing/include/spl_inl.h ('k') | webrtc/common_audio/signal_processing/spl_inl.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698