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 */
10#include <string.h>
11#include "g711.h"
12#include "g711_interface.h"
13#include "webrtc/typedefs.h"
14
15size_t WebRtcG711_EncodeA(const int16_t* speechIn,
16                          size_t len,
17                          uint8_t* encoded) {
18  size_t n;
19  for (n = 0; n < len; n++)
20    encoded[n] = linear_to_alaw(speechIn[n]);
21  return len;
22}
23
24size_t WebRtcG711_EncodeU(const int16_t* speechIn,
25                          size_t len,
26                          uint8_t* encoded) {
27  size_t n;
28  for (n = 0; n < len; n++)
29    encoded[n] = linear_to_ulaw(speechIn[n]);
30  return len;
31}
32
33size_t WebRtcG711_DecodeA(const uint8_t* encoded,
34                          size_t len,
35                          int16_t* decoded,
36                          int16_t* speechType) {
37  size_t n;
38  for (n = 0; n < len; n++)
39    decoded[n] = alaw_to_linear(encoded[n]);
40  *speechType = 1;
41  return len;
42}
43
44size_t WebRtcG711_DecodeU(const uint8_t* encoded,
45                          size_t len,
46                          int16_t* decoded,
47                          int16_t* speechType) {
48  size_t n;
49  for (n = 0; n < len; n++)
50    decoded[n] = ulaw_to_linear(encoded[n]);
51  *speechType = 1;
52  return len;
53}
54
55int16_t WebRtcG711_Version(char* version, int16_t lenBytes) {
56  strncpy(version, "2.0.0", lenBytes);
57  return 0;
58}
59