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

Side by Side Diff: webrtc/modules/audio_processing/include/audio_processing.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) 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Accepts deinterleaved float audio with the range [-1, 1]. Each element 292 // Accepts deinterleaved float audio with the range [-1, 1]. Each element
293 // of |src| points to a channel buffer, arranged according to 293 // of |src| points to a channel buffer, arranged according to
294 // |input_layout|. At output, the channels will be arranged according to 294 // |input_layout|. At output, the channels will be arranged according to
295 // |output_layout| at |output_sample_rate_hz| in |dest|. 295 // |output_layout| at |output_sample_rate_hz| in |dest|.
296 // 296 //
297 // The output layout must have one channel or as many channels as the input. 297 // The output layout must have one channel or as many channels as the input.
298 // |src| and |dest| may use the same memory, if desired. 298 // |src| and |dest| may use the same memory, if desired.
299 // 299 //
300 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 300 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
301 virtual int ProcessStream(const float* const* src, 301 virtual int ProcessStream(const float* const* src,
302 int samples_per_channel, 302 size_t samples_per_channel,
303 int input_sample_rate_hz, 303 int input_sample_rate_hz,
304 ChannelLayout input_layout, 304 ChannelLayout input_layout,
305 int output_sample_rate_hz, 305 int output_sample_rate_hz,
306 ChannelLayout output_layout, 306 ChannelLayout output_layout,
307 float* const* dest) = 0; 307 float* const* dest) = 0;
308 308
309 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of 309 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
310 // |src| points to a channel buffer, arranged according to |input_stream|. At 310 // |src| points to a channel buffer, arranged according to |input_stream|. At
311 // output, the channels will be arranged according to |output_stream| in 311 // output, the channels will be arranged according to |output_stream| in
312 // |dest|. 312 // |dest|.
(...skipping 20 matching lines...) Expand all
333 // |input_sample_rate_hz()| 333 // |input_sample_rate_hz()|
334 // 334 //
335 // TODO(ajm): add const to input; requires an implementation fix. 335 // TODO(ajm): add const to input; requires an implementation fix.
336 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0; 336 virtual int AnalyzeReverseStream(AudioFrame* frame) = 0;
337 337
338 // Accepts deinterleaved float audio with the range [-1, 1]. Each element 338 // Accepts deinterleaved float audio with the range [-1, 1]. Each element
339 // of |data| points to a channel buffer, arranged according to |layout|. 339 // of |data| points to a channel buffer, arranged according to |layout|.
340 // 340 //
341 // TODO(mgraczyk): Remove once clients are updated to use the new interface. 341 // TODO(mgraczyk): Remove once clients are updated to use the new interface.
342 virtual int AnalyzeReverseStream(const float* const* data, 342 virtual int AnalyzeReverseStream(const float* const* data,
343 int samples_per_channel, 343 size_t samples_per_channel,
344 int sample_rate_hz, 344 int sample_rate_hz,
345 ChannelLayout layout) = 0; 345 ChannelLayout layout) = 0;
346 346
347 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of 347 // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
348 // |data| points to a channel buffer, arranged according to |reverse_config|. 348 // |data| points to a channel buffer, arranged according to |reverse_config|.
349 virtual int AnalyzeReverseStream(const float* const* data, 349 virtual int AnalyzeReverseStream(const float* const* data,
350 const StreamConfig& reverse_config) = 0; 350 const StreamConfig& reverse_config) = 0;
351 351
352 // This must be called if and only if echo processing is enabled. 352 // This must be called if and only if echo processing is enabled.
353 // 353 //
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 void set_num_channels(int value) { num_channels_ = value; } 484 void set_num_channels(int value) { num_channels_ = value; }
485 void set_has_keyboard(bool value) { has_keyboard_ = value; } 485 void set_has_keyboard(bool value) { has_keyboard_ = value; }
486 486
487 int sample_rate_hz() const { return sample_rate_hz_; } 487 int sample_rate_hz() const { return sample_rate_hz_; }
488 488
489 // The number of channels in the stream, not including the keyboard channel if 489 // The number of channels in the stream, not including the keyboard channel if
490 // present. 490 // present.
491 int num_channels() const { return num_channels_; } 491 int num_channels() const { return num_channels_; }
492 492
493 bool has_keyboard() const { return has_keyboard_; } 493 bool has_keyboard() const { return has_keyboard_; }
494 int num_frames() const { return num_frames_; } 494 size_t num_frames() const { return num_frames_; }
495 495
496 bool operator==(const StreamConfig& other) const { 496 bool operator==(const StreamConfig& other) const {
497 return sample_rate_hz_ == other.sample_rate_hz_ && 497 return sample_rate_hz_ == other.sample_rate_hz_ &&
498 num_channels_ == other.num_channels_ && 498 num_channels_ == other.num_channels_ &&
499 has_keyboard_ == other.has_keyboard_; 499 has_keyboard_ == other.has_keyboard_;
500 } 500 }
501 501
502 bool operator!=(const StreamConfig& other) const { return !(*this == other); } 502 bool operator!=(const StreamConfig& other) const { return !(*this == other); }
503 503
504 private: 504 private:
505 static int calculate_frames(int sample_rate_hz) { 505 static size_t calculate_frames(int sample_rate_hz) {
506 return AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000; 506 return static_cast<size_t>(
507 AudioProcessing::kChunkSizeMs * sample_rate_hz / 1000);
507 } 508 }
508 509
509 int sample_rate_hz_; 510 int sample_rate_hz_;
510 int num_channels_; 511 int num_channels_;
511 bool has_keyboard_; 512 bool has_keyboard_;
512 int num_frames_; 513 size_t num_frames_;
513 }; 514 };
514 515
515 class ProcessingConfig { 516 class ProcessingConfig {
516 public: 517 public:
517 enum StreamName { 518 enum StreamName {
518 kInputStream, 519 kInputStream,
519 kOutputStream, 520 kOutputStream,
520 kReverseStream, 521 kReverseStream,
521 kNumStreamNames, 522 kNumStreamNames,
522 }; 523 };
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 // This does not impact the size of frames passed to |ProcessStream()|. 907 // This does not impact the size of frames passed to |ProcessStream()|.
907 virtual int set_frame_size_ms(int size) = 0; 908 virtual int set_frame_size_ms(int size) = 0;
908 virtual int frame_size_ms() const = 0; 909 virtual int frame_size_ms() const = 0;
909 910
910 protected: 911 protected:
911 virtual ~VoiceDetection() {} 912 virtual ~VoiceDetection() {}
912 }; 913 };
913 } // namespace webrtc 914 } // namespace webrtc
914 915
915 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_ 916 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_INCLUDE_AUDIO_PROCESSING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698