blob: b1e4d9ac3c8911bfb3cf502160bf78c9aa788b21 [file] [log] [blame]
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +00001/*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "common_audio/include/audio_util.h"
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000012
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000013namespace webrtc {
14
Per Åhgren928146f2019-08-20 09:19:21 +020015void FloatToS16(const float* src, size_t size, int16_t* dest) {
16 for (size_t i = 0; i < size; ++i)
17 dest[i] = FloatToS16(src[i]);
18}
19
andrew@webrtc.org4fc4add2014-10-30 03:40:10 +000020void S16ToFloat(const int16_t* src, size_t size, float* dest) {
kwiberg@webrtc.orgefb81d82014-07-16 08:36:52 +000021 for (size_t i = 0; i < size; ++i)
andrew@webrtc.org4fc4add2014-10-30 03:40:10 +000022 dest[i] = S16ToFloat(src[i]);
andrew@webrtc.org17e40642014-03-04 20:58:13 +000023}
24
Per Åhgren928146f2019-08-20 09:19:21 +020025void S16ToFloatS16(const int16_t* src, size_t size, float* dest) {
26 for (size_t i = 0; i < size; ++i)
27 dest[i] = src[i];
28}
29
andrew@webrtc.org4fc4add2014-10-30 03:40:10 +000030void FloatS16ToS16(const float* src, size_t size, int16_t* dest) {
kwiberg@webrtc.orgefb81d82014-07-16 08:36:52 +000031 for (size_t i = 0; i < size; ++i)
andrew@webrtc.org4fc4add2014-10-30 03:40:10 +000032 dest[i] = FloatS16ToS16(src[i]);
33}
34
35void FloatToFloatS16(const float* src, size_t size, float* dest) {
36 for (size_t i = 0; i < size; ++i)
37 dest[i] = FloatToFloatS16(src[i]);
38}
39
40void FloatS16ToFloat(const float* src, size_t size, float* dest) {
41 for (size_t i = 0; i < size; ++i)
42 dest[i] = FloatS16ToFloat(src[i]);
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000043}
44
Michael Graczyk86c6d332015-07-23 11:41:39 -070045template <>
46void DownmixInterleavedToMono<int16_t>(const int16_t* interleaved,
Peter Kastingdce40cf2015-08-24 14:52:23 -070047 size_t num_frames,
Michael Graczyk86c6d332015-07-23 11:41:39 -070048 int num_channels,
49 int16_t* deinterleaved) {
andrew7a1c24f2015-07-24 17:10:52 -070050 DownmixInterleavedToMonoImpl<int16_t, int32_t>(interleaved, num_frames,
51 num_channels, deinterleaved);
Michael Graczyk86c6d332015-07-23 11:41:39 -070052}
53
andrew@webrtc.org50b2efe2013-04-29 17:27:29 +000054} // namespace webrtc