/* * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef COMMON_AUDIO_CHANNEL_BUFFER_H_ #define COMMON_AUDIO_CHANNEL_BUFFER_H_ #include <string.h> #include <memory> #include <vector> #include "api/array_view.h" #include "common_audio/include/audio_util.h" #include "rtc_base/checks.h" #include "rtc_base/gtest_prod_util.h" namespace webrtc { // TODO: b/335805780 - Remove this method. Instead, use Deinterleave() from // audio_util.h which requires size checked buffer views. template <typename T> void Deinterleave(const T* interleaved, size_t samples_per_channel, size_t num_channels, T* const* deinterleaved) { … } // `Interleave()` variant for cases where the deinterleaved channels aren't // represented by a `DeinterleavedView`. // TODO: b/335805780 - Remove this method. Instead, use Deinterleave() from // audio_util.h which requires size checked buffer views. template <typename T> void Interleave(const T* const* deinterleaved, size_t samples_per_channel, size_t num_channels, InterleavedView<T>& interleaved) { … } // Helper to encapsulate a contiguous data buffer, full or split into frequency // bands, with access to a pointer arrays of the deinterleaved channels and // bands. The buffer is zero initialized at creation. // // The buffer structure is showed below for a 2 channel and 2 bands case: // // `data_`: // { [ --- b1ch1 --- ] [ --- b2ch1 --- ] [ --- b1ch2 --- ] [ --- b2ch2 --- ] } // // The pointer arrays for the same example are as follows: // // `channels_`: // { [ b1ch1* ] [ b1ch2* ] [ b2ch1* ] [ b2ch2* ] } // // `bands_`: // { [ b1ch1* ] [ b2ch1* ] [ b1ch2* ] [ b2ch2* ] } template <typename T> class ChannelBuffer { … }; // One int16_t and one float ChannelBuffer that are kept in sync. The sync is // broken when someone requests write access to either ChannelBuffer, and // reestablished when someone requests the outdated ChannelBuffer. It is // therefore safe to use the return value of ibuf_const() and fbuf_const() // until the next call to ibuf() or fbuf(), and the return value of ibuf() and // fbuf() until the next call to any of the other functions. class IFChannelBuffer { … }; } // namespace webrtc #endif // COMMON_AUDIO_CHANNEL_BUFFER_H_