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

Side by Side Diff: webrtc/modules/audio_processing/beamformer/array_util.cc

Issue 2535593002: RTC_[D]CHECK_op: Remove "u" suffix on integer constants (Closed)
Patch Set: Created 4 years 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
11 #include "webrtc/modules/audio_processing/beamformer/array_util.h" 11 #include "webrtc/modules/audio_processing/beamformer/array_util.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 15
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 namespace { 19 namespace {
20 20
21 const float kMaxDotProduct = 1e-6f; 21 const float kMaxDotProduct = 1e-6f;
22 22
23 } // namespace 23 } // namespace
24 24
25 float GetMinimumSpacing(const std::vector<Point>& array_geometry) { 25 float GetMinimumSpacing(const std::vector<Point>& array_geometry) {
26 RTC_CHECK_GT(array_geometry.size(), 1u); 26 RTC_CHECK_GT(array_geometry.size(), 1);
27 float mic_spacing = std::numeric_limits<float>::max(); 27 float mic_spacing = std::numeric_limits<float>::max();
28 for (size_t i = 0; i < (array_geometry.size() - 1); ++i) { 28 for (size_t i = 0; i < (array_geometry.size() - 1); ++i) {
29 for (size_t j = i + 1; j < array_geometry.size(); ++j) { 29 for (size_t j = i + 1; j < array_geometry.size(); ++j) {
30 mic_spacing = 30 mic_spacing =
31 std::min(mic_spacing, Distance(array_geometry[i], array_geometry[j])); 31 std::min(mic_spacing, Distance(array_geometry[i], array_geometry[j]));
32 } 32 }
33 } 33 }
34 return mic_spacing; 34 return mic_spacing;
35 } 35 }
36 36
(...skipping 14 matching lines...) Expand all
51 Point cross_product = CrossProduct(a, b); 51 Point cross_product = CrossProduct(a, b);
52 return DotProduct(cross_product, cross_product) < kMaxDotProduct; 52 return DotProduct(cross_product, cross_product) < kMaxDotProduct;
53 } 53 }
54 54
55 bool ArePerpendicular(const Point& a, const Point& b) { 55 bool ArePerpendicular(const Point& a, const Point& b) {
56 return std::abs(DotProduct(a, b)) < kMaxDotProduct; 56 return std::abs(DotProduct(a, b)) < kMaxDotProduct;
57 } 57 }
58 58
59 rtc::Optional<Point> GetDirectionIfLinear( 59 rtc::Optional<Point> GetDirectionIfLinear(
60 const std::vector<Point>& array_geometry) { 60 const std::vector<Point>& array_geometry) {
61 RTC_DCHECK_GT(array_geometry.size(), 1u); 61 RTC_DCHECK_GT(array_geometry.size(), 1);
62 const Point first_pair_direction = 62 const Point first_pair_direction =
63 PairDirection(array_geometry[0], array_geometry[1]); 63 PairDirection(array_geometry[0], array_geometry[1]);
64 for (size_t i = 2u; i < array_geometry.size(); ++i) { 64 for (size_t i = 2u; i < array_geometry.size(); ++i) {
65 const Point pair_direction = 65 const Point pair_direction =
66 PairDirection(array_geometry[i - 1], array_geometry[i]); 66 PairDirection(array_geometry[i - 1], array_geometry[i]);
67 if (!AreParallel(first_pair_direction, pair_direction)) { 67 if (!AreParallel(first_pair_direction, pair_direction)) {
68 return rtc::Optional<Point>(); 68 return rtc::Optional<Point>();
69 } 69 }
70 } 70 }
71 return rtc::Optional<Point>(first_pair_direction); 71 return rtc::Optional<Point>(first_pair_direction);
72 } 72 }
73 73
74 rtc::Optional<Point> GetNormalIfPlanar( 74 rtc::Optional<Point> GetNormalIfPlanar(
75 const std::vector<Point>& array_geometry) { 75 const std::vector<Point>& array_geometry) {
76 RTC_DCHECK_GT(array_geometry.size(), 1u); 76 RTC_DCHECK_GT(array_geometry.size(), 1);
77 const Point first_pair_direction = 77 const Point first_pair_direction =
78 PairDirection(array_geometry[0], array_geometry[1]); 78 PairDirection(array_geometry[0], array_geometry[1]);
79 Point pair_direction(0.f, 0.f, 0.f); 79 Point pair_direction(0.f, 0.f, 0.f);
80 size_t i = 2u; 80 size_t i = 2u;
81 bool is_linear = true; 81 bool is_linear = true;
82 for (; i < array_geometry.size() && is_linear; ++i) { 82 for (; i < array_geometry.size() && is_linear; ++i) {
83 pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]); 83 pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]);
84 if (!AreParallel(first_pair_direction, pair_direction)) { 84 if (!AreParallel(first_pair_direction, pair_direction)) {
85 is_linear = false; 85 is_linear = false;
86 } 86 }
(...skipping 23 matching lines...) Expand all
110 return normal; 110 return normal;
111 } 111 }
112 return rtc::Optional<Point>(); 112 return rtc::Optional<Point>();
113 } 113 }
114 114
115 Point AzimuthToPoint(float azimuth) { 115 Point AzimuthToPoint(float azimuth) {
116 return Point(std::cos(azimuth), std::sin(azimuth), 0.f); 116 return Point(std::cos(azimuth), std::sin(azimuth), 0.f);
117 } 117 }
118 118
119 } // namespace webrtc 119 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698