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
This commit is contained in:
kwiberg@webrtc.org
2015-02-10 09:18:28 +00:00
parent 948d61724c
commit 648f5d6dc7
8 changed files with 40 additions and 153 deletions

View File

@ -31,7 +31,7 @@ ConstantPcmPacketSource::ConstantPcmPacketSource(size_t payload_len_samples,
seq_number_(0),
timestamp_(0),
payload_ssrc_(0xABCD1234) {
int encoded_len = WebRtcPcm16b_EncodeW16(&sample_value, 1, &encoded_sample_);
int encoded_len = WebRtcPcm16b_Encode(&sample_value, 1, encoded_sample_);
CHECK_EQ(encoded_len, 2);
}
@ -39,9 +39,8 @@ Packet* ConstantPcmPacketSource::NextPacket() {
CHECK_GT(packet_len_bytes_, kHeaderLenBytes);
uint8_t* packet_memory = new uint8_t[packet_len_bytes_];
// Fill the payload part of the packet memory with the pre-encoded value.
std::fill_n(reinterpret_cast<int16_t*>(packet_memory + kHeaderLenBytes),
payload_len_samples_,
encoded_sample_);
for (unsigned i = 0; i < 2 * payload_len_samples_; ++i)
packet_memory[kHeaderLenBytes + i] = encoded_sample_[i % 2];
WriteHeader(packet_memory);
// |packet| assumes ownership of |packet_memory|.
Packet* packet =

View File

@ -41,7 +41,7 @@ class ConstantPcmPacketSource : public PacketSource {
const size_t kHeaderLenBytes = 12;
const size_t payload_len_samples_;
const size_t packet_len_bytes_;
int16_t encoded_sample_;
uint8_t encoded_sample_[2];
const int samples_per_ms_;
double next_arrival_time_ms_;
const int payload_type_;