OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // |block_length| defines the length of a block, in samples. | 46 // |block_length| defines the length of a block, in samples. |
47 // |shift_amount| is in samples. |callback| is the caller-owned audio | 47 // |shift_amount| is in samples. |callback| is the caller-owned audio |
48 // processing function called for each block of the input chunk. | 48 // processing function called for each block of the input chunk. |
49 LappedTransform(size_t num_in_channels, | 49 LappedTransform(size_t num_in_channels, |
50 size_t num_out_channels, | 50 size_t num_out_channels, |
51 size_t chunk_length, | 51 size_t chunk_length, |
52 const float* window, | 52 const float* window, |
53 size_t block_length, | 53 size_t block_length, |
54 size_t shift_amount, | 54 size_t shift_amount, |
55 Callback* callback); | 55 Callback* callback); |
56 ~LappedTransform() {} | 56 ~LappedTransform(); |
57 | 57 |
58 // Main audio processing helper method. Internally slices |in_chunk| into | 58 // Main audio processing helper method. Internally slices |in_chunk| into |
59 // blocks, transforms them to frequency domain, calls the callback for each | 59 // blocks, transforms them to frequency domain, calls the callback for each |
60 // block and returns a de-blocked time domain chunk of audio through | 60 // block and returns a de-blocked time domain chunk of audio through |
61 // |out_chunk|. Both buffers are caller-owned. | 61 // |out_chunk|. Both buffers are caller-owned. |
62 void ProcessChunk(const float* const* in_chunk, float* const* out_chunk); | 62 void ProcessChunk(const float* const* in_chunk, float* const* out_chunk); |
63 | 63 |
64 // Get the chunk length. | 64 // Get the chunk length. |
65 // | 65 // |
66 // The chunk length is the number of samples per channel that must be passed | 66 // The chunk length is the number of samples per channel that must be passed |
(...skipping 19 matching lines...) Expand all Loading... |
86 // constructor. | 86 // constructor. |
87 size_t num_out_channels() const { return num_out_channels_; } | 87 size_t num_out_channels() const { return num_out_channels_; } |
88 | 88 |
89 private: | 89 private: |
90 // Internal middleware callback, given to the blocker. Transforms each block | 90 // Internal middleware callback, given to the blocker. Transforms each block |
91 // and hands it over to the processing method given at construction time. | 91 // and hands it over to the processing method given at construction time. |
92 class BlockThunk : public BlockerCallback { | 92 class BlockThunk : public BlockerCallback { |
93 public: | 93 public: |
94 explicit BlockThunk(LappedTransform* parent) : parent_(parent) {} | 94 explicit BlockThunk(LappedTransform* parent) : parent_(parent) {} |
95 | 95 |
96 virtual void ProcessBlock(const float* const* input, | 96 void ProcessBlock(const float* const* input, |
97 size_t num_frames, | 97 size_t num_frames, |
98 size_t num_input_channels, | 98 size_t num_input_channels, |
99 size_t num_output_channels, | 99 size_t num_output_channels, |
100 float* const* output); | 100 float* const* output) override; |
101 | 101 |
102 private: | 102 private: |
103 LappedTransform* const parent_; | 103 LappedTransform* const parent_; |
104 } blocker_callback_; | 104 } blocker_callback_; |
105 | 105 |
106 const size_t num_in_channels_; | 106 const size_t num_in_channels_; |
107 const size_t num_out_channels_; | 107 const size_t num_out_channels_; |
108 | 108 |
109 const size_t block_length_; | 109 const size_t block_length_; |
110 const size_t chunk_length_; | 110 const size_t chunk_length_; |
111 | 111 |
112 Callback* const block_processor_; | 112 Callback* const block_processor_; |
113 Blocker blocker_; | 113 Blocker blocker_; |
114 | 114 |
115 std::unique_ptr<RealFourier> fft_; | 115 std::unique_ptr<RealFourier> fft_; |
116 const size_t cplx_length_; | 116 const size_t cplx_length_; |
117 AlignedArray<float> real_buf_; | 117 AlignedArray<float> real_buf_; |
118 AlignedArray<std::complex<float> > cplx_pre_; | 118 AlignedArray<std::complex<float> > cplx_pre_; |
119 AlignedArray<std::complex<float> > cplx_post_; | 119 AlignedArray<std::complex<float> > cplx_post_; |
120 }; | 120 }; |
121 | 121 |
122 } // namespace webrtc | 122 } // namespace webrtc |
123 | 123 |
124 #endif // WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_ | 124 #endif // WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_ |
125 | 125 |
OLD | NEW |