tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

push_resampler.h (1944B)


      1 /*
      2 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
      3 *
      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
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_
     12 #define COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_
     13 
     14 #include <cstddef>
     15 #include <memory>
     16 #include <vector>
     17 
     18 #include "api/audio/audio_view.h"
     19 
     20 namespace webrtc {
     21 
     22 class PushSincResampler;
     23 
     24 // Wraps PushSincResampler to provide stereo support.
     25 // Note: This implementation assumes 10ms buffer sizes throughout.
     26 template <typename T>
     27 class PushResampler final {
     28 public:
     29  PushResampler();
     30  PushResampler(size_t src_samples_per_channel,
     31                size_t dst_samples_per_channel,
     32                size_t num_channels);
     33  ~PushResampler();
     34 
     35  void Resample(InterleavedView<const T> src, InterleavedView<T> dst);
     36  // For when a deinterleaved (or mono) channel already exists and we can skip
     37  // the deinterleaved operation.
     38  void Resample(MonoView<const T> src, MonoView<T> dst);
     39 
     40 private:
     41  // Ensures that source and destination buffers for deinterleaving are
     42  // correctly configured prior to resampling that requires deinterleaving.
     43  void EnsureInitialized(size_t src_samples_per_channel,
     44                         size_t dst_samples_per_channel,
     45                         size_t num_channels);
     46 
     47  // Buffers used for when a deinterleaving step is necessary.
     48  std::unique_ptr<T[]> source_;
     49  std::unique_ptr<T[]> destination_;
     50  DeinterleavedView<T> source_view_;
     51  DeinterleavedView<T> destination_view_;
     52 
     53  std::vector<std::unique_ptr<PushSincResampler>> resamplers_;
     54 };
     55 }  // namespace webrtc
     56 
     57 #endif  // COMMON_AUDIO_RESAMPLER_INCLUDE_PUSH_RESAMPLER_H_