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

Side by Side Diff: webrtc/modules/audio_processing/rms_level.h

Issue 1227213002: Update audio code to use size_t more correctly, webrtc/modules/audio_processing/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync Created 5 years, 4 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) 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
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
13 13
14 #include <cstddef>
15
14 #include "webrtc/typedefs.h" 16 #include "webrtc/typedefs.h"
15 17
16 namespace webrtc { 18 namespace webrtc {
17 19
18 // Computes the root mean square (RMS) level in dBFs (decibels from digital 20 // Computes the root mean square (RMS) level in dBFs (decibels from digital
19 // full-scale) of audio data. The computation follows RFC 6465: 21 // full-scale) of audio data. The computation follows RFC 6465:
20 // https://tools.ietf.org/html/rfc6465 22 // https://tools.ietf.org/html/rfc6465
21 // with the intent that it can provide the RTP audio level indication. 23 // with the intent that it can provide the RTP audio level indication.
22 // 24 //
23 // The expected approach is to provide constant-sized chunks of audio to 25 // The expected approach is to provide constant-sized chunks of audio to
24 // Process(). When enough chunks have been accumulated to form a packet, call 26 // Process(). When enough chunks have been accumulated to form a packet, call
25 // RMS() to get the audio level indicator for the RTP header. 27 // RMS() to get the audio level indicator for the RTP header.
26 class RMSLevel { 28 class RMSLevel {
27 public: 29 public:
28 static const int kMinLevel = 127; 30 static const int kMinLevel = 127;
29 31
30 RMSLevel(); 32 RMSLevel();
31 ~RMSLevel(); 33 ~RMSLevel();
32 34
33 // Can be called to reset internal states, but is not required during normal 35 // Can be called to reset internal states, but is not required during normal
34 // operation. 36 // operation.
35 void Reset(); 37 void Reset();
36 38
37 // Pass each chunk of audio to Process() to accumulate the level. 39 // Pass each chunk of audio to Process() to accumulate the level.
38 void Process(const int16_t* data, int length); 40 void Process(const int16_t* data, size_t length);
39 41
40 // If all samples with the given |length| have a magnitude of zero, this is 42 // If all samples with the given |length| have a magnitude of zero, this is
41 // a shortcut to avoid some computation. 43 // a shortcut to avoid some computation.
42 void ProcessMuted(int length); 44 void ProcessMuted(size_t length);
43 45
44 // Computes the RMS level over all data passed to Process() since the last 46 // Computes the RMS level over all data passed to Process() since the last
45 // call to RMS(). The returned value is positive but should be interpreted as 47 // call to RMS(). The returned value is positive but should be interpreted as
46 // negative as per the RFC. It is constrained to [0, 127]. 48 // negative as per the RFC. It is constrained to [0, 127].
47 int RMS(); 49 int RMS();
48 50
49 private: 51 private:
50 float sum_square_; 52 float sum_square_;
51 int sample_count_; 53 size_t sample_count_;
52 }; 54 };
53 55
54 } // namespace webrtc 56 } // namespace webrtc
55 57
56 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_ 58 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_RMS_LEVEL_H_
57 59
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/ns/nsx_core_neon.c ('k') | webrtc/modules/audio_processing/rms_level.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698