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

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

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, 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // Accepts deinterleaved float audio with the range [-1, 1]. Each element 304 // Accepts deinterleaved float audio with the range [-1, 1]. Each element
305 // of |src| points to a channel buffer, arranged according to 305 // of |src| points to a channel buffer, arranged according to
306 // |input_layout|. At output, the channels will be arranged according to 306 // |input_layout|. At output, the channels will be arranged according to
307 // |output_layout| at |output_sample_rate_hz| in |dest|. 307 // |output_layout| at |output_sample_rate_hz| in |dest|.
308 // 308 //
309 // The output layout must have one channel or as many channels as the input. 309 // The output layout must have one channel or as many channels as the input.
310 // |src| and |dest| may use the same memory, if desired. 310 // |src| and |dest| may use the same memory, if desired.
311 // 311 //
312 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 312 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
313 virtual int ProcessStream(const float* const* src, 313 virtual int ProcessStream(const float* const* src,
314 int samples_per_channel, 314 size_t samples_per_channel,
315 int input_sample_rate_hz, 315 int input_sample_rate_hz,
316 ChannelLayout input_layout, 316 ChannelLayout input_layout,
317 int output_sample_rate_hz, 317 int output_sample_rate_hz,
318 ChannelLayout output_layout, 318 ChannelLayout output_layout,
319 float* const* dest) = 0; 319 float* const* dest) = 0;
320 320
321 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of 321 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
322 // |src| points to a channel buffer, arranged according to |input_stream|. At 322 // |src| points to a channel buffer, arranged according to |input_stream|. At
323 // output, the channels will be arranged according to |output_stream| in 323 // output, the channels will be arranged according to |output_stream| in
324 // |dest|. 324 // |dest|.
(...skipping 25 matching lines...) Expand all
350 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0; 350 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0;
351 351
352 // Same as |AnalyzeReverseStream|, but may modify |frame| if intelligibility 352 // Same as |AnalyzeReverseStream|, but may modify |frame| if intelligibility
353 // is enabled. 353 // is enabled.
354 virtual int ProcessReverseStream(AudioFrame* frame) = 0; 354 virtual int ProcessReverseStream(AudioFrame* frame) = 0;
355 355
356 // Accepts deinterleaved float audio with the range [-1, 1]. Each element 356 // Accepts deinterleaved float audio with the range [-1, 1]. Each element
357 // of |data| points to a channel buffer, arranged according to |layout|. 357 // of |data| points to a channel buffer, arranged according to |layout|.
358 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 358 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
359 virtual int AnalyzeReverseStream(const float* const* data, 359 virtual int AnalyzeReverseStream(const float* const* data,
360 int samples_per_channel, 360 size_t samples_per_channel,
361 int rev_sample_rate_hz, 361 int rev_sample_rate_hz,
362 ChannelLayout layout) = 0; 362 ChannelLayout layout) = 0;
363 363
364 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of 364 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
365 // |data| points to a channel buffer, arranged according to |reverse_config|. 365 // |data| points to a channel buffer, arranged according to |reverse_config|.
366 virtual int ProcessReverseStream(const float* const* src, 366 virtual int ProcessReverseStream(const float* const* src,
367 const StreamConfig& reverse_input_config, 367 const StreamConfig& reverse_input_config,
368 const StreamConfig& reverse_output_config, 368 const StreamConfig& reverse_output_config,
369 float* const* dest) = 0; 369 float* const* dest) = 0;
370 370
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 void set_num_channels(int value) { num_channels_ = value; } 503 void set_num_channels(int value) { num_channels_ = value; }
504 void set_has_keyboard(bool value) { has_keyboard_ = value; } 504 void set_has_keyboard(bool value) { has_keyboard_ = value; }
505 505
506 int sample_rate_hz() const { return sample_rate_hz_; } 506 int sample_rate_hz() const { return sample_rate_hz_; }
507 507
508 // The number of channels in the stream, not including the keyboard channel if 508 // The number of channels in the stream, not including the keyboard channel if
509 // present. 509 // present.
510 int num_channels() const { return num_channels_; } 510 int num_channels() const { return num_channels_; }
511 511
512 bool has_keyboard() const { return has_keyboard_; } 512 bool has_keyboard() const { return has_keyboard_; }
513 int num_frames() const { return num_frames_; } 513 size_t num_frames() const { return num_frames_; }
514 int num_samples() const { return num_channels_ * num_frames_; } 514 size_t num_samples() const { return num_channels_ * num_frames_; }
515 515
516 bool operator==(const StreamConfig& other) const { 516 bool operator==(const StreamConfig& other) const {
517 return sample_rate_hz_ == other.sample_rate_hz_ && 517 return sample_rate_hz_ == other.sample_rate_hz_ &&
518 num_channels_ == other.num_channels_ && 518 num_channels_ == other.num_channels_ &&
519 has_keyboard_ == other.has_keyboard_; 519 has_keyboard_ == other.has_keyboard_;
520 } 520 }
521 521
522 bool operator!=(const StreamConfig& other) const { return !(*this == other); } 522 bool operator!=(const StreamConfig& other) const { return !(*this == other); }
523 523
524 private: 524 private:
525 static int calculate_frames(int sample_rate_hz) { 525 static size_t calculate_frames(int sample_rate_hz) {
526 return AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000; 526 return static_cast<size_t>(
527 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000);
527 } 528 }
528 529
529 int sample_rate_hz_; 530 int sample_rate_hz_;
530 int num_channels_; 531 int num_channels_;
531 bool has_keyboard_; 532 bool has_keyboard_;
532 int num_frames_; 533 size_t num_frames_;
533 }; 534 };
534 535
535 class ProcessingConfig { 536 class ProcessingConfig {
536 public: 537 public:
537 enum StreamName { 538 enum StreamName {
538 kInputStream, 539 kInputStream,
539 kOutputStream, 540 kOutputStream,
540 kReverseInputStream, 541 kReverseInputStream,
541 kReverseOutputStream, 542 kReverseOutputStream,
542 kNumStreamNames, 543 kNumStreamNames,
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // This does not impact the size of frames passed to |ProcessStream()|. 936 // This does not impact the size of frames passed to |ProcessStream()|.
936 virtual int set_frame_size_ms(int size) = 0; 937 virtual int set_frame_size_ms(int size) = 0;
937 virtual int frame_size_ms() const = 0; 938 virtual int frame_size_ms() const = 0;
938 939
939 protected: 940 protected:
940 virtual ~VoiceDetection() {} 941 virtual ~VoiceDetection() {}
941 }; 942 };
942 } // namespace webrtc 943 } // namespace webrtc
943 944
944 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ 945 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698