 Chromium Code Reviews
 Chromium Code Reviews Issue 1234463003:
  Integrate Intelligibility with APM  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 1234463003:
  Integrate Intelligibility with APM  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| 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..64bd0555083a70d9249953398bb0c3c05f38b69d 100644 | 
| --- a/webrtc/common_audio/include/audio_util.h | 
| +++ b/webrtc/common_audio/include/audio_util.h | 
| @@ -65,6 +65,23 @@ 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. |src| and |dest| must | 
| +// have the same number of channels, and there must be sufficient space | 
| +// allocated in the |dest| channels. | 
| +template <typename T> | 
| +void CopyAudio(const T* const* src, | 
| 
Andrew MacDonald
2015/08/05 06:18:18
Perhaps call this CopyAudioIfNeeded() and check if
 
ekm
2015/08/07 06:05:59
Nice. Done.
 | 
| + int samples_per_channel, | 
| 
Andrew MacDonald
2015/08/05 06:18:17
num_frames is the new way.
 
ekm
2015/08/07 06:05:59
Done.
 | 
| + int num_channels, | 
| + T* const* dest) { | 
| + for (int i = 0; i < num_channels; ++i) { | 
| + const T* src_channel = src[i]; | 
| + T* dest_channel = dest[i]; | 
| + for (int j = 0; j < samples_per_channel; ++j) { | 
| + dest_channel[j] = src_channel[j]; | 
| 
Andrew MacDonald
2015/08/05 06:18:18
Do a memcpy (or std::copy) instead of individual a
 
ekm
2015/08/07 06:05:59
Done.
 | 
| + } | 
| + } | 
| +} | 
| + | 
| // 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 +119,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, |