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

Side by Side Diff: webrtc/common_audio/window_generator.cc

Issue 1230503003: Update a ton of audio code to use size_t more correctly and in general reduce (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 3 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
« no previous file with comments | « webrtc/common_audio/window_generator.h ('k') | webrtc/common_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 28 matching lines...) Expand all
39 39
40 void WindowGenerator::Hanning(int length, float* window) { 40 void WindowGenerator::Hanning(int length, float* window) {
41 CHECK_GT(length, 1); 41 CHECK_GT(length, 1);
42 CHECK(window != nullptr); 42 CHECK(window != nullptr);
43 for (int i = 0; i < length; ++i) { 43 for (int i = 0; i < length; ++i) {
44 window[i] = 0.5f * (1 - cosf(2 * static_cast<float>(M_PI) * i / 44 window[i] = 0.5f * (1 - cosf(2 * static_cast<float>(M_PI) * i /
45 (length - 1))); 45 (length - 1)));
46 } 46 }
47 } 47 }
48 48
49 void WindowGenerator::KaiserBesselDerived(float alpha, int length, 49 void WindowGenerator::KaiserBesselDerived(float alpha, size_t length,
50 float* window) { 50 float* window) {
51 CHECK_GT(length, 1); 51 CHECK_GT(length, 1U);
52 CHECK(window != nullptr); 52 CHECK(window != nullptr);
53 53
54 const int half = (length + 1) / 2; 54 const size_t half = (length + 1) / 2;
55 float sum = 0.0f; 55 float sum = 0.0f;
56 56
57 for (int i = 0; i <= half; ++i) { 57 for (size_t i = 0; i <= half; ++i) {
58 complex<float> r = (4.0f * i) / length - 1.0f; 58 complex<float> r = (4.0f * i) / length - 1.0f;
59 sum += I0(static_cast<float>(M_PI) * alpha * sqrt(1.0f - r * r)).real(); 59 sum += I0(static_cast<float>(M_PI) * alpha * sqrt(1.0f - r * r)).real();
60 window[i] = sum; 60 window[i] = sum;
61 } 61 }
62 for (int i = length - 1; i >= half; --i) { 62 for (size_t i = length - 1; i >= half; --i) {
63 window[length - i - 1] = sqrtf(window[length - i - 1] / sum); 63 window[length - i - 1] = sqrtf(window[length - i - 1] / sum);
64 window[i] = window[length - i - 1]; 64 window[i] = window[length - i - 1];
65 } 65 }
66 if (length % 2 == 1) { 66 if (length % 2 == 1) {
67 window[half - 1] = sqrtf(window[half - 1] / sum); 67 window[half - 1] = sqrtf(window[half - 1] / sum);
68 } 68 }
69 } 69 }
70 70
71 } // namespace webrtc 71 } // namespace webrtc
72 72
OLDNEW
« no previous file with comments | « webrtc/common_audio/window_generator.h ('k') | webrtc/common_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698