aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/audio_processing/common.h
diff options
context:
space:
mode:
authoraluebs@webrtc.org <aluebs@webrtc.org>2014-11-27 23:40:25 +0000
committeraluebs@webrtc.org <aluebs@webrtc.org>2014-11-27 23:40:25 +0000
commit8789376cd35e055765a72248a8ad444ea2e9438c (patch)
tree6dc4d848f7dc0bc00c8f0d8ebf7cb92d7ec7778c /webrtc/modules/audio_processing/common.h
parentd87213af495ed36c8cdf59b3b364112f56a05b14 (diff)
downloadwebrtc-8789376cd35e055765a72248a8ad444ea2e9438c.tar.gz
Move ChannelBuffer class to channel_buffer file
No change in functionallity. BUG=webrtc:3146 R=andrew@webrtc.org, bjornv@webrtc.org, kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/28109004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7760 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc/modules/audio_processing/common.h')
-rw-r--r--webrtc/modules/audio_processing/common.h76
1 files changed, 0 insertions, 76 deletions
diff --git a/webrtc/modules/audio_processing/common.h b/webrtc/modules/audio_processing/common.h
index 98c624127c..ed8a0544c3 100644
--- a/webrtc/modules/audio_processing/common.h
+++ b/webrtc/modules/audio_processing/common.h
@@ -12,11 +12,8 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_
#include <assert.h>
-#include <string.h>
-#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
-#include "webrtc/system_wrappers/interface/scoped_ptr.h"
namespace webrtc {
@@ -33,79 +30,6 @@ static inline int ChannelsFromLayout(AudioProcessing::ChannelLayout layout) {
return -1;
}
-// Helper to encapsulate a contiguous data buffer with access to a pointer
-// array of the deinterleaved channels.
-template <typename T>
-class ChannelBuffer {
- public:
- ChannelBuffer(int samples_per_channel, int num_channels)
- : data_(new T[samples_per_channel * num_channels]),
- channels_(new T*[num_channels]),
- samples_per_channel_(samples_per_channel),
- num_channels_(num_channels) {
- Initialize();
- }
-
- ChannelBuffer(const T* data, int samples_per_channel, int num_channels)
- : data_(new T[samples_per_channel * num_channels]),
- channels_(new T*[num_channels]),
- samples_per_channel_(samples_per_channel),
- num_channels_(num_channels) {
- Initialize();
- memcpy(data_.get(), data, length() * sizeof(T));
- }
-
- ChannelBuffer(const T* const* channels, int samples_per_channel,
- int num_channels)
- : data_(new T[samples_per_channel * num_channels]),
- channels_(new T*[num_channels]),
- samples_per_channel_(samples_per_channel),
- num_channels_(num_channels) {
- Initialize();
- for (int i = 0; i < num_channels_; ++i)
- CopyFrom(channels[i], i);
- }
-
- ~ChannelBuffer() {}
-
- void CopyFrom(const void* channel_ptr, int i) {
- DCHECK_LT(i, num_channels_);
- memcpy(channels_[i], channel_ptr, samples_per_channel_ * sizeof(T));
- }
-
- T* data() { return data_.get(); }
- const T* data() const { return data_.get(); }
-
- const T* channel(int i) const {
- DCHECK_GE(i, 0);
- DCHECK_LT(i, num_channels_);
- return channels_[i];
- }
- T* channel(int i) {
- const ChannelBuffer<T>* t = this;
- return const_cast<T*>(t->channel(i));
- }
-
- T* const* channels() { return channels_.get(); }
- const T* const* channels() const { return channels_.get(); }
-
- int samples_per_channel() const { return samples_per_channel_; }
- int num_channels() const { return num_channels_; }
- int length() const { return samples_per_channel_ * num_channels_; }
-
- private:
- void Initialize() {
- memset(data_.get(), 0, sizeof(T) * length());
- for (int i = 0; i < num_channels_; ++i)
- channels_[i] = &data_[i * samples_per_channel_];
- }
-
- scoped_ptr<T[]> data_;
- scoped_ptr<T*[]> channels_;
- const int samples_per_channel_;
- const int num_channels_;
-};
-
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_COMMON_H_