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

Side by Side Diff: webrtc/common_audio/lapped_transform.h

Issue 1227203003: Update audio code to use size_t more correctly, webrtc/common_audio/ portion. (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
« no previous file with comments | « webrtc/common_audio/include/audio_util.h ('k') | webrtc/common_audio/lapped_transform.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 17 matching lines...) Expand all
28 // is supplied to the given callback for processing. The processed output is 28 // is supplied to the given callback for processing. The processed output is
29 // then inverse transformed into the time domain and spliced back into a chunk 29 // then inverse transformed into the time domain and spliced back into a chunk
30 // which constitutes the final output of this processing module. 30 // which constitutes the final output of this processing module.
31 class LappedTransform { 31 class LappedTransform {
32 public: 32 public:
33 class Callback { 33 class Callback {
34 public: 34 public:
35 virtual ~Callback() {} 35 virtual ~Callback() {}
36 36
37 virtual void ProcessAudioBlock(const std::complex<float>* const* in_block, 37 virtual void ProcessAudioBlock(const std::complex<float>* const* in_block,
38 int num_in_channels, int frames, 38 int num_in_channels, size_t frames,
39 int num_out_channels, 39 int num_out_channels,
40 std::complex<float>* const* out_block) = 0; 40 std::complex<float>* const* out_block) = 0;
41 }; 41 };
42 42
43 // Construct a transform instance. |chunk_length| is the number of samples in 43 // Construct a transform instance. |chunk_length| is the number of samples in
44 // each channel. |window| defines the window, owned by the caller (a copy is 44 // each channel. |window| defines the window, owned by the caller (a copy is
45 // made internally); |window| should have length equal to |block_length|. 45 // made internally); |window| should have length equal to |block_length|.
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(int num_in_channels, int num_out_channels, int chunk_length, 49 LappedTransform(int num_in_channels,
50 const float* window, int block_length, int shift_amount, 50 int num_out_channels,
51 size_t chunk_length,
52 const float* window,
53 size_t block_length,
54 size_t shift_amount,
51 Callback* callback); 55 Callback* callback);
52 ~LappedTransform() {} 56 ~LappedTransform() {}
53 57
54 // Main audio processing helper method. Internally slices |in_chunk| into 58 // Main audio processing helper method. Internally slices |in_chunk| into
55 // blocks, transforms them to frequency domain, calls the callback for each 59 // blocks, transforms them to frequency domain, calls the callback for each
56 // 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
57 // |out_chunk|. Both buffers are caller-owned. 61 // |out_chunk|. Both buffers are caller-owned.
58 void ProcessChunk(const float* const* in_chunk, float* const* out_chunk); 62 void ProcessChunk(const float* const* in_chunk, float* const* out_chunk);
59 63
60 // Get the chunk length. 64 // Get the chunk length.
61 // 65 //
62 // 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
63 // to ProcessChunk via the parameter in_chunk. 67 // to ProcessChunk via the parameter in_chunk.
64 // 68 //
65 // Returns the same chunk_length passed to the LappedTransform constructor. 69 // Returns the same chunk_length passed to the LappedTransform constructor.
66 int chunk_length() const { return chunk_length_; } 70 size_t chunk_length() const { return chunk_length_; }
67 71
68 // Get the number of input channels. 72 // Get the number of input channels.
69 // 73 //
70 // This is the number of arrays that must be passed to ProcessChunk via 74 // This is the number of arrays that must be passed to ProcessChunk via
71 // in_chunk. 75 // in_chunk.
72 // 76 //
73 // Returns the same num_in_channels passed to the LappedTransform constructor. 77 // Returns the same num_in_channels passed to the LappedTransform constructor.
74 int num_in_channels() const { return num_in_channels_; } 78 int num_in_channels() const { return num_in_channels_; }
75 79
76 // Get the number of output channels. 80 // Get the number of output channels.
77 // 81 //
78 // This is the number of arrays that must be passed to ProcessChunk via 82 // This is the number of arrays that must be passed to ProcessChunk via
79 // out_chunk. 83 // out_chunk.
80 // 84 //
81 // Returns the same num_out_channels passed to the LappedTransform 85 // Returns the same num_out_channels passed to the LappedTransform
82 // constructor. 86 // constructor.
83 int num_out_channels() const { return num_out_channels_; } 87 int num_out_channels() const { return num_out_channels_; }
84 88
85 private: 89 private:
86 // Internal middleware callback, given to the blocker. Transforms each block 90 // Internal middleware callback, given to the blocker. Transforms each block
87 // 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.
88 class BlockThunk : public BlockerCallback { 92 class BlockThunk : public BlockerCallback {
89 public: 93 public:
90 explicit BlockThunk(LappedTransform* parent) : parent_(parent) {} 94 explicit BlockThunk(LappedTransform* parent) : parent_(parent) {}
91 95
92 virtual void ProcessBlock(const float* const* input, int num_frames, 96 virtual void ProcessBlock(const float* const* input, size_t num_frames,
93 int num_input_channels, int num_output_channels, 97 int num_input_channels, int num_output_channels,
94 float* const* output); 98 float* const* output);
95 99
96 private: 100 private:
97 LappedTransform* const parent_; 101 LappedTransform* const parent_;
98 } blocker_callback_; 102 } blocker_callback_;
99 103
100 const int num_in_channels_; 104 const int num_in_channels_;
101 const int num_out_channels_; 105 const int num_out_channels_;
102 106
103 const int block_length_; 107 const size_t block_length_;
104 const int chunk_length_; 108 const size_t chunk_length_;
105 109
106 Callback* const block_processor_; 110 Callback* const block_processor_;
107 Blocker blocker_; 111 Blocker blocker_;
108 112
109 rtc::scoped_ptr<RealFourier> fft_; 113 rtc::scoped_ptr<RealFourier> fft_;
110 const int cplx_length_; 114 const size_t cplx_length_;
111 AlignedArray<float> real_buf_; 115 AlignedArray<float> real_buf_;
112 AlignedArray<std::complex<float> > cplx_pre_; 116 AlignedArray<std::complex<float> > cplx_pre_;
113 AlignedArray<std::complex<float> > cplx_post_; 117 AlignedArray<std::complex<float> > cplx_post_;
114 }; 118 };
115 119
116 } // namespace webrtc 120 } // namespace webrtc
117 121
118 #endif // WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_ 122 #endif // WEBRTC_COMMON_AUDIO_LAPPED_TRANSFORM_H_
119 123
OLDNEW
« no previous file with comments | « webrtc/common_audio/include/audio_util.h ('k') | webrtc/common_audio/lapped_transform.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698