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

Unified Diff: webrtc/common_audio/include/audio_util.h

Issue 1234463003: Integrate Intelligibility with APM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix Mac Error (3) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/media/webrtc/fakewebrtcvoiceengine.h ('k') | webrtc/modules/audio_processing/audio_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/common_audio/include/audio_util.h
diff --git a/webrtc/common_audio/include/audio_util.h b/webrtc/common_audio/include/audio_util.h
index b217c683fd05815a7f10f95b000371f03e2db393..99771dd6003497b143bfad561b2ec1690eb3565a 100644
--- a/webrtc/common_audio/include/audio_util.h
+++ b/webrtc/common_audio/include/audio_util.h
@@ -65,6 +65,21 @@ void FloatS16ToS16(const float* src, size_t size, int16_t* dest);
void FloatToFloatS16(const float* src, size_t size, float* dest);
void FloatS16ToFloat(const float* src, size_t size, float* dest);
+// Copy audio from |src| channels to |dest| channels unless |src| and |dest|
+// point to the same address. |src| and |dest| must have the same number of
+// channels, and there must be sufficient space allocated in |dest|.
+template <typename T>
+void CopyAudioIfNeeded(const T* const* src,
+ int num_frames,
+ int num_channels,
+ T* const* dest) {
+ for (int i = 0; i < num_channels; ++i) {
+ if (src[i] != dest[i]) {
+ std::copy(src[i], src[i] + num_frames, dest[i]);
+ }
+ }
+}
+
// Deinterleave audio from |interleaved| to the channel buffers pointed to
// by |deinterleaved|. There must be sufficient space allocated in the
// |deinterleaved| buffers (|num_channel| buffers with |samples_per_channel|
@@ -102,6 +117,22 @@ void Interleave(const T* const* deinterleaved,
}
}
+// Copies audio from a single channel buffer pointed to by |mono| to each
+// channel of |interleaved|. There must be sufficient space allocated in
+// |interleaved| (|samples_per_channel| * |num_channels|).
+template <typename T>
+void UpmixMonoToInterleaved(const T* mono,
+ int num_frames,
+ int num_channels,
+ T* interleaved) {
+ int interleaved_idx = 0;
+ for (int i = 0; i < num_frames; ++i) {
+ for (int j = 0; j < num_channels; ++j) {
+ interleaved[interleaved_idx++] = mono[i];
+ }
+ }
+}
+
template <typename T, typename Intermediate>
void DownmixToMono(const T* const* input_channels,
int num_frames,
« no previous file with comments | « talk/media/webrtc/fakewebrtcvoiceengine.h ('k') | webrtc/modules/audio_processing/audio_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698