aboutsummaryrefslogtreecommitdiff
path: root/webrtc/common_audio/blocker.cc
diff options
context:
space:
mode:
authorPeter Kasting <pkasting@google.com>2015-08-24 14:52:23 -0700
committerPeter Kasting <pkasting@google.com>2015-08-24 21:52:45 +0000
commitdce40cf804019a9898b6ab8d8262466b697c56e0 (patch)
tree83ae06d5acc897bbf2fe73ea0c944b5ea4a0414d /webrtc/common_audio/blocker.cc
parentb594041ec8a3ae9f501260e2456d9d5ce6482819 (diff)
downloadwebrtc-dce40cf804019a9898b6ab8d8262466b697c56e0.tar.gz
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t. This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects. This was be reviewed and approved in pieces: https://codereview.webrtc.org/1224093003 https://codereview.webrtc.org/1224123002 https://codereview.webrtc.org/1224163002 https://codereview.webrtc.org/1225133003 https://codereview.webrtc.org/1225173002 https://codereview.webrtc.org/1227163003 https://codereview.webrtc.org/1227203003 https://codereview.webrtc.org/1227213002 https://codereview.webrtc.org/1227893002 https://codereview.webrtc.org/1228793004 https://codereview.webrtc.org/1228803003 https://codereview.webrtc.org/1228823002 https://codereview.webrtc.org/1228823003 https://codereview.webrtc.org/1228843002 https://codereview.webrtc.org/1230693002 https://codereview.webrtc.org/1231713002 The change is being landed as TBR to all the folks who reviewed the above. BUG=chromium:81439 TEST=none R=andrew@webrtc.org, pbos@webrtc.org TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher Review URL: https://codereview.webrtc.org/1230503003 . Cr-Commit-Position: refs/heads/master@{#9768}
Diffstat (limited to 'webrtc/common_audio/blocker.cc')
-rw-r--r--webrtc/common_audio/blocker.cc42
1 files changed, 21 insertions, 21 deletions
diff --git a/webrtc/common_audio/blocker.cc b/webrtc/common_audio/blocker.cc
index 6d171ca87c..359e881a4b 100644
--- a/webrtc/common_audio/blocker.cc
+++ b/webrtc/common_audio/blocker.cc
@@ -18,15 +18,15 @@ namespace {
// Adds |a| and |b| frame by frame into |result| (basically matrix addition).
void AddFrames(const float* const* a,
- int a_start_index,
+ size_t a_start_index,
const float* const* b,
int b_start_index,
- int num_frames,
+ size_t num_frames,
int num_channels,
float* const* result,
- int result_start_index) {
+ size_t result_start_index) {
for (int i = 0; i < num_channels; ++i) {
- for (int j = 0; j < num_frames; ++j) {
+ for (size_t j = 0; j < num_frames; ++j) {
result[i][j + result_start_index] =
a[i][j + a_start_index] + b[i][j + b_start_index];
}
@@ -35,11 +35,11 @@ void AddFrames(const float* const* a,
// Copies |src| into |dst| channel by channel.
void CopyFrames(const float* const* src,
- int src_start_index,
- int num_frames,
+ size_t src_start_index,
+ size_t num_frames,
int num_channels,
float* const* dst,
- int dst_start_index) {
+ size_t dst_start_index) {
for (int i = 0; i < num_channels; ++i) {
memcpy(&dst[i][dst_start_index],
&src[i][src_start_index],
@@ -49,11 +49,11 @@ void CopyFrames(const float* const* src,
// Moves |src| into |dst| channel by channel.
void MoveFrames(const float* const* src,
- int src_start_index,
- int num_frames,
+ size_t src_start_index,
+ size_t num_frames,
int num_channels,
float* const* dst,
- int dst_start_index) {
+ size_t dst_start_index) {
for (int i = 0; i < num_channels; ++i) {
memmove(&dst[i][dst_start_index],
&src[i][src_start_index],
@@ -62,8 +62,8 @@ void MoveFrames(const float* const* src,
}
void ZeroOut(float* const* buffer,
- int starting_idx,
- int num_frames,
+ size_t starting_idx,
+ size_t num_frames,
int num_channels) {
for (int i = 0; i < num_channels; ++i) {
memset(&buffer[i][starting_idx], 0,
@@ -74,18 +74,18 @@ void ZeroOut(float* const* buffer,
// Pointwise multiplies each channel of |frames| with |window|. Results are
// stored in |frames|.
void ApplyWindow(const float* window,
- int num_frames,
+ size_t num_frames,
int num_channels,
float* const* frames) {
for (int i = 0; i < num_channels; ++i) {
- for (int j = 0; j < num_frames; ++j) {
+ for (size_t j = 0; j < num_frames; ++j) {
frames[i][j] = frames[i][j] * window[j];
}
}
}
-int gcd(int a, int b) {
- int tmp;
+size_t gcd(size_t a, size_t b) {
+ size_t tmp;
while (b) {
tmp = a;
a = b;
@@ -98,12 +98,12 @@ int gcd(int a, int b) {
namespace webrtc {
-Blocker::Blocker(int chunk_size,
- int block_size,
+Blocker::Blocker(size_t chunk_size,
+ size_t block_size,
int num_input_channels,
int num_output_channels,
const float* window,
- int shift_amount,
+ size_t shift_amount,
BlockerCallback* callback)
: chunk_size_(chunk_size),
block_size_(block_size),
@@ -165,7 +165,7 @@ Blocker::Blocker(int chunk_size,
//
// TODO(claguna): Look at using ring buffers to eliminate some copies.
void Blocker::ProcessChunk(const float* const* input,
- int chunk_size,
+ size_t chunk_size,
int num_input_channels,
int num_output_channels,
float* const* output) {
@@ -174,7 +174,7 @@ void Blocker::ProcessChunk(const float* const* input,
CHECK_EQ(num_output_channels, num_output_channels_);
input_buffer_.Write(input, num_input_channels, chunk_size_);
- int first_frame_in_block = frame_offset_;
+ size_t first_frame_in_block = frame_offset_;
// Loop through blocks.
while (first_frame_in_block < chunk_size_) {