Index: webrtc/modules/audio_processing/test/vector_based_audio_frame.h |
diff --git a/webrtc/modules/audio_processing/test/vector_based_audio_frame.h b/webrtc/modules/audio_processing/test/vector_based_audio_frame.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..df9a6a46240a9e7d78a04962dc62b94ee9706968 |
--- /dev/null |
+++ b/webrtc/modules/audio_processing/test/vector_based_audio_frame.h |
@@ -0,0 +1,69 @@ |
+/* |
+ * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
hlundin-webrtc
2015/12/10 12:12:17
2015
peah-webrtc
2015/12/22 06:28:11
Done.
|
+ * |
+ * 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 WEBRTC_MODULES_AUDIO_PROCESSING_TEST_VECTOR_BASED_AUDIO_FRAME_H_ |
+#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_VECTOR_BASED_AUDIO_FRAME_H_ |
+ |
+#include <math.h> |
+#include <iterator> |
+#include <limits> |
+#include <string> |
+#include <vector> |
+ |
+#include "webrtc/base/constructormagic.h" |
+#include "webrtc/modules/audio_processing/audio_processing_impl.h" |
+#include "webrtc/test/random.h" |
+ |
+namespace webrtc { |
+ |
+// Handles an audio frame represented by a two-dimensional float* array type |
+// using vectors and adds support for common tasks. |
+class VectorBasedAudioFrame { |
the sun
2015/12/10 12:03:54
AudioBuffer already maintains buffers for the audi
peah-webrtc
2015/12/22 06:28:10
Of course, you are right. Have now done that, whic
|
+ public: |
+ VectorBasedAudioFrame(size_t frame_length, |
hlundin-webrtc
2015/12/10 12:12:17
Comment that the size of initial_values must be (a
peah-webrtc
2015/12/22 06:28:11
This is no longer applicable in the new code.
Ack
|
+ size_t num_channels, |
+ const float* initial_values); |
+ |
+ VectorBasedAudioFrame(size_t frame_length, size_t num_channels); |
hlundin-webrtc
2015/12/10 12:12:17
What is the initial value in this case?
peah-webrtc
2015/12/22 06:28:11
They are not initialized at all, only allocated. T
|
+ |
+ std::vector<float*>* get_frame() { return &frame_; } |
+ size_t frame_length() const { return frame_length_; } |
+ size_t num_channels() const { return num_channels_; } |
+ |
+ // Fills the frame with random values quantized to 16 bits. |
+ void Randomize(test::Random* rand_gen_) const; |
+ |
+ // Copies the frame to an audiobuffer. |
+ void CopyToAudioBuffer(StreamConfig stream_config, AudioBuffer* buffer); |
+ |
+ // Fill the frame with the content of an audiobuffer. |
+ void CopyFromAudioBuffer(StreamConfig stream_config, AudioBuffer* buffer); |
+ |
+ // Compare the the frame content to the content of another frame using a |
hlundin-webrtc
2015/12/10 12:12:17
Compares
peah-webrtc
2015/12/22 06:28:10
Good catch. Fully changed in the new code though.
|
+ // specified tolerance. |
+ bool CompareTo(VectorBasedAudioFrame* other_frame, float tolerance) const; |
hlundin-webrtc
2015/12/10 12:12:17
Drop To, simply call it Compare (it's shorter, and
hlundin-webrtc
2015/12/10 12:12:17
other_frame should be const, right?
peah-webrtc
2015/12/22 06:28:10
Great point!
This method has been removed in the
peah-webrtc
2015/12/22 06:28:10
True.
Acknowledged.
|
+ |
+ // Prints all the values of the frame. |
hlundin-webrtc
2015/12/10 12:12:17
... to stdout?
peah-webrtc
2015/12/22 06:28:10
Yes, that was how it was. Good point that that sho
|
+ void PrintValues(); |
+ |
+ // Prints a specified number of values from the frame. |
hlundin-webrtc
2015/12/10 12:12:17
... to stdout?
peah-webrtc
2015/12/22 06:28:10
The function is now removed.
Acknowledged.
|
+ void PrintValues(size_t num_samples_per_channel); |
+ |
+ private: |
+ const size_t frame_length_; |
hlundin-webrtc
2015/12/10 12:12:17
Do you need frame_length_ and num_channels_ as exp
peah-webrtc
2015/12/22 06:28:10
Fully true! That would be better.
The new impleme
|
+ const size_t num_channels_; |
+ std::vector<float*> frame_; |
+ std::vector<float> channels_; |
+ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(VectorBasedAudioFrame); |
+}; |
+ |
+} // namespace webrtc |
+ |
+#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_VECTOR_BASED_AUDIO_FRAME_H_ |