niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 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 | */ |
Mirko Bonadei | 2bf82c1 | 2018-02-01 14:25:11 +0100 | [diff] [blame] | 10 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 11 | #include <string.h> |
Mirko Bonadei | 2bf82c1 | 2018-02-01 14:25:11 +0100 | [diff] [blame] | 12 | |
Artem Titov | e095b81 | 2018-07-25 12:10:22 +0200 | [diff] [blame] | 13 | #include "modules/third_party/g711/g711.h" |
Mirko Bonadei | 2bf82c1 | 2018-02-01 14:25:11 +0100 | [diff] [blame] | 14 | #include "modules/audio_coding/codecs/g711/g711_interface.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 16 | size_t WebRtcG711_EncodeA(const int16_t* speechIn, |
| 17 | size_t len, |
| 18 | uint8_t* encoded) { |
| 19 | size_t n; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 20 | for (n = 0; n < len; n++) |
| 21 | encoded[n] = linear_to_alaw(speechIn[n]); |
| 22 | return len; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | } |
| 24 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 25 | size_t WebRtcG711_EncodeU(const int16_t* speechIn, |
| 26 | size_t len, |
| 27 | uint8_t* encoded) { |
| 28 | size_t n; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 29 | for (n = 0; n < len; n++) |
| 30 | encoded[n] = linear_to_ulaw(speechIn[n]); |
| 31 | return len; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 34 | size_t WebRtcG711_DecodeA(const uint8_t* encoded, |
| 35 | size_t len, |
| 36 | int16_t* decoded, |
| 37 | int16_t* speechType) { |
| 38 | size_t n; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 39 | for (n = 0; n < len; n++) |
| 40 | decoded[n] = alaw_to_linear(encoded[n]); |
pbos@webrtc.org | ae4e2b3 | 2013-03-21 13:38:29 +0000 | [diff] [blame] | 41 | *speechType = 1; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 42 | return len; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 45 | size_t WebRtcG711_DecodeU(const uint8_t* encoded, |
| 46 | size_t len, |
| 47 | int16_t* decoded, |
| 48 | int16_t* speechType) { |
| 49 | size_t n; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 50 | for (n = 0; n < len; n++) |
| 51 | decoded[n] = ulaw_to_linear(encoded[n]); |
pbos@webrtc.org | ae4e2b3 | 2013-03-21 13:38:29 +0000 | [diff] [blame] | 52 | *speechType = 1; |
kwiberg@webrtc.org | 1c6239a | 2015-02-09 12:55:48 +0000 | [diff] [blame] | 53 | return len; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | } |
| 55 | |
pbos@webrtc.org | ae4e2b3 | 2013-03-21 13:38:29 +0000 | [diff] [blame] | 56 | int16_t WebRtcG711_Version(char* version, int16_t lenBytes) { |
| 57 | strncpy(version, "2.0.0", lenBytes); |
| 58 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | } |