Files
platform-external-webrtc/webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.c
kwiberg@webrtc.org 648f5d6dc7 pcm16b: Make input arrays const and use uint8_t[] for byte arrays
There were both uint8 and uint16 versions of the pcm16b encode and
decode functions; this patch removes the latter.

BUG=909
R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/34139004

Cr-Commit-Position: refs/heads/master@{#8309}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8309 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-10 09:19:09 +00:00

35 lines
1013 B
C

/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "pcm16b.h"
#include "webrtc/typedefs.h"
int16_t WebRtcPcm16b_Encode(const int16_t* speech,
int16_t len,
uint8_t* encoded) {
int i;
for (i = 0; i < len; ++i) {
uint16_t s = speech[i];
encoded[2 * i] = s >> 8;
encoded[2 * i + 1] = s;
}
return 2 * len;
}
int16_t WebRtcPcm16b_Decode(const uint8_t* encoded,
int16_t len,
int16_t* speech) {
int i;
for (i = 0; i < len / 2; ++i)
speech[i] = encoded[2 * i] << 8 | encoded[2 * i + 1];
return len / 2;
}