| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "pcm16b.h" | 11 #include "pcm16b.h" |
| 12 | 12 |
| 13 #include "webrtc/typedefs.h" | 13 #include "webrtc/typedefs.h" |
| 14 | 14 |
| 15 int16_t WebRtcPcm16b_Encode(const int16_t* speech, | 15 size_t WebRtcPcm16b_Encode(const int16_t* speech, |
| 16 int16_t len, | 16 size_t len, |
| 17 uint8_t* encoded) { | 17 uint8_t* encoded) { |
| 18 int i; | 18 size_t i; |
| 19 for (i = 0; i < len; ++i) { | 19 for (i = 0; i < len; ++i) { |
| 20 uint16_t s = speech[i]; | 20 uint16_t s = speech[i]; |
| 21 encoded[2 * i] = s >> 8; | 21 encoded[2 * i] = s >> 8; |
| 22 encoded[2 * i + 1] = s; | 22 encoded[2 * i + 1] = s; |
| 23 } | 23 } |
| 24 return 2 * len; | 24 return 2 * len; |
| 25 } | 25 } |
| 26 | 26 |
| 27 int16_t WebRtcPcm16b_Decode(const uint8_t* encoded, | 27 size_t WebRtcPcm16b_Decode(const uint8_t* encoded, |
| 28 int16_t len, | 28 size_t len, |
| 29 int16_t* speech) { | 29 int16_t* speech) { |
| 30 int i; | 30 size_t i; |
| 31 for (i = 0; i < len / 2; ++i) | 31 for (i = 0; i < len / 2; ++i) |
| 32 speech[i] = encoded[2 * i] << 8 | encoded[2 * i + 1]; | 32 speech[i] = encoded[2 * i] << 8 | encoded[2 * i + 1]; |
| 33 return len / 2; | 33 return len / 2; |
| 34 } | 34 } |
| OLD | NEW |