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}
This commit is contained in:
@ -19,9 +19,9 @@
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
const int kSamplesPer16kHzChannel = 160;
|
||||
const int kSamplesPer32kHzChannel = 320;
|
||||
const int kSamplesPer48kHzChannel = 480;
|
||||
const size_t kSamplesPer16kHzChannel = 160;
|
||||
const size_t kSamplesPer32kHzChannel = 320;
|
||||
const size_t kSamplesPer48kHzChannel = 480;
|
||||
|
||||
int KeyboardChannelIndex(const StreamConfig& stream_config) {
|
||||
if (!stream_config.has_keyboard()) {
|
||||
@ -32,23 +32,22 @@ int KeyboardChannelIndex(const StreamConfig& stream_config) {
|
||||
return stream_config.num_channels();
|
||||
}
|
||||
|
||||
int NumBandsFromSamplesPerChannel(int num_frames) {
|
||||
int num_bands = 1;
|
||||
size_t NumBandsFromSamplesPerChannel(size_t num_frames) {
|
||||
size_t num_bands = 1;
|
||||
if (num_frames == kSamplesPer32kHzChannel ||
|
||||
num_frames == kSamplesPer48kHzChannel) {
|
||||
num_bands = rtc::CheckedDivExact(num_frames,
|
||||
static_cast<int>(kSamplesPer16kHzChannel));
|
||||
num_bands = rtc::CheckedDivExact(num_frames, kSamplesPer16kHzChannel);
|
||||
}
|
||||
return num_bands;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AudioBuffer::AudioBuffer(int input_num_frames,
|
||||
AudioBuffer::AudioBuffer(size_t input_num_frames,
|
||||
int num_input_channels,
|
||||
int process_num_frames,
|
||||
size_t process_num_frames,
|
||||
int num_process_channels,
|
||||
int output_num_frames)
|
||||
size_t output_num_frames)
|
||||
: input_num_frames_(input_num_frames),
|
||||
num_input_channels_(num_input_channels),
|
||||
proc_num_frames_(process_num_frames),
|
||||
@ -345,20 +344,20 @@ void AudioBuffer::set_num_channels(int num_channels) {
|
||||
num_channels_ = num_channels;
|
||||
}
|
||||
|
||||
int AudioBuffer::num_frames() const {
|
||||
size_t AudioBuffer::num_frames() const {
|
||||
return proc_num_frames_;
|
||||
}
|
||||
|
||||
int AudioBuffer::num_frames_per_band() const {
|
||||
size_t AudioBuffer::num_frames_per_band() const {
|
||||
return num_split_frames_;
|
||||
}
|
||||
|
||||
int AudioBuffer::num_keyboard_frames() const {
|
||||
size_t AudioBuffer::num_keyboard_frames() const {
|
||||
// We don't resample the keyboard channel.
|
||||
return input_num_frames_;
|
||||
}
|
||||
|
||||
int AudioBuffer::num_bands() const {
|
||||
size_t AudioBuffer::num_bands() const {
|
||||
return num_bands_;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user