WebRtcIsac_UpdateBwEstimate et al.: Type byte streams as uint8, not uint16

This patch changes the signature of WebRtcIsac_UpdateBwEstimate,
WebRtcIsacfix_UpdateBwEstimate, and WebRtcIsacfix_UpdateBwEstimate1 so
that they expect the encoded data to be uint8 arrays, not uint16,
which is more natural. The implementations of the functions are left
unchanged for now.

BUG=909
R=aluebs@webrtc.org, bjornv@webrtc.org, henrik.lundin@webrtc.org, turaj@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7430 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kwiberg@webrtc.org 2014-10-13 11:07:06 +00:00
parent 1172988c79
commit 3f7f899a15
11 changed files with 45 additions and 36 deletions

View File

@ -201,7 +201,7 @@ extern "C" {
*/
int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t arr_ts);
@ -226,7 +226,7 @@ extern "C" {
*/
int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,

View File

@ -636,7 +636,7 @@ int16_t WebRtcIsacfix_DecoderInit(ISACFIX_MainStruct *ISAC_main_inst)
*/
int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t arr_ts)
@ -673,7 +673,8 @@ int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
#ifndef WEBRTC_ARCH_BIG_ENDIAN
for (k = 0; k < kRequiredEncodedLenBytes / 2; k++) {
streamdata.stream[k] = (uint16_t) (((uint16_t)encoded[k] >> 8)|((encoded[k] & 0xFF)<<8));
uint16_t ek = ((const uint16_t*)encoded)[k];
streamdata.stream[k] = (uint16_t) ((ek >> 8)|((ek & 0xff) << 8));
}
#else
memcpy(streamdata.stream, encoded, kRequiredEncodedLenBytes);
@ -717,7 +718,7 @@ int16_t WebRtcIsacfix_UpdateBwEstimate1(ISACFIX_MainStruct *ISAC_main_inst,
*/
int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
const uint16_t *encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
@ -758,7 +759,8 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
#ifndef WEBRTC_ARCH_BIG_ENDIAN
for (k = 0; k < kRequiredEncodedLenBytes / 2; k++) {
streamdata.stream[k] = (uint16_t) ((encoded[k] >> 8)|((encoded[k] & 0xFF)<<8));
uint16_t ek = ((const uint16_t*)encoded)[k];
streamdata.stream[k] = (uint16_t) ((ek >> 8)|((ek & 0xff) <<8 ));
}
#else
memcpy(streamdata.stream, encoded, kRequiredEncodedLenBytes);

View File

@ -700,12 +700,13 @@ int main(int argc, char* argv[])
}
if (testNum != 9) {
err = WebRtcIsacfix_UpdateBwEstimate(ISAC_main_inst,
streamdata,
stream_len,
BN_data.rtp_number,
BN_data.send_time,
BN_data.arrival_time);
err = WebRtcIsacfix_UpdateBwEstimate(
ISAC_main_inst,
reinterpret_cast<const uint8_t*>(streamdata),
stream_len,
BN_data.rtp_number,
BN_data.send_time,
BN_data.arrival_time);
if (err < 0) {
/* exit if returned with error */

View File

@ -187,7 +187,7 @@ extern "C" {
int16_t WebRtcIsac_UpdateBwEstimate(
ISACStruct* ISAC_main_inst,
const uint16_t* encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,

View File

@ -996,7 +996,7 @@ int16_t WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst) {
* -1 - Error
*/
int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
const uint16_t* encoded,
const uint8_t* encoded,
int32_t packet_size,
uint16_t rtp_seq_number,
uint32_t send_ts,
@ -1026,8 +1026,8 @@ int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
#ifndef WEBRTC_ARCH_BIG_ENDIAN
for (k = 0; k < 10; k++) {
streamdata.stream[k] = (uint8_t)((encoded[k >> 1] >>
((k & 1) << 3)) & 0xFF);
uint16_t ek = ((const uint16_t*)encoded)[k >> 1];
streamdata.stream[k] = (uint8_t)((ek >> ((k & 1) << 3)) & 0xff);
}
#else
memcpy(streamdata.stream, encoded, 10);

View File

@ -79,13 +79,10 @@ TEST_F(IsacTest, IsacUpdateBWE) {
WebRtcIsac_EncoderInit(isac_codec_, 0);
WebRtcIsac_DecoderInit(isac_codec_);
// Encode & decode.
int16_t encoded_bytes;
uint16_t* coded = reinterpret_cast<uint16_t*>(bitstream_);
uint16_t* coded_small = reinterpret_cast<uint16_t*>(bitstream_small_);
// Test with call with a small packet (sync packet).
EXPECT_EQ(-1, WebRtcIsac_UpdateBwEstimate(isac_codec_, coded_small, 7, 1,
EXPECT_EQ(-1, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_small_, 7, 1,
12345, 56789));
// Encode 60 ms of data (needed to create a first packet).
@ -102,8 +99,8 @@ TEST_F(IsacTest, IsacUpdateBWE) {
encoded_bytes = WebRtcIsac_Encode(isac_codec_, speech_data_, bitstream_);
// Call to update bandwidth estimator with real data.
EXPECT_EQ(0, WebRtcIsac_UpdateBwEstimate(isac_codec_, coded, encoded_bytes, 1,
12345, 56789));
EXPECT_EQ(0, WebRtcIsac_UpdateBwEstimate(isac_codec_, bitstream_,
encoded_bytes, 1, 12345, 56789));
// Free memory.
EXPECT_EQ(0, WebRtcIsac_Free(isac_codec_));

View File

@ -857,9 +857,13 @@ int main(int argc, char* argv[])
if(testNum != 9)
{
err = WebRtcIsac_UpdateBwEstimate(ISAC_main_inst, streamdata,
stream_len, BN_data.rtp_number, BN_data.sample_count,
BN_data.arrival_time);
err = WebRtcIsac_UpdateBwEstimate(
ISAC_main_inst,
reinterpret_cast<const uint8_t*>(streamdata),
stream_len,
BN_data.rtp_number,
BN_data.sample_count,
BN_data.arrival_time);
if(err < 0)
{

View File

@ -411,11 +411,13 @@ int main(int argc, char* argv[])
}
// BWE
if(WebRtcIsac_UpdateBwEstimate(codecInstance[receiverIdx],
bitStream, streamLen, packetData[senderIdx]->rtp_number,
packetData[senderIdx]->sample_count,
packetData[senderIdx]->arrival_time) < 0)
{
if (WebRtcIsac_UpdateBwEstimate(
codecInstance[receiverIdx],
reinterpret_cast<const uint8_t*>(bitStream),
streamLen,
packetData[senderIdx]->rtp_number,
packetData[senderIdx]->sample_count,
packetData[senderIdx]->arrival_time) < 0) {
printf(" BWE Error at client %d \n", receiverIdx + 1);
return -1;
}

View File

@ -401,9 +401,12 @@ valid values are 8 and 16.\n", sampFreqKHz);
get_arrival_time(cur_framesmpls, stream_len, bottleneck, &packetData,
sampFreqKHz * 1000, sampFreqKHz * 1000);
if(WebRtcIsac_UpdateBwEstimate(ISAC_main_inst,
payload, stream_len, packetData.rtp_number,
packetData.sample_count,
packetData.arrival_time) < 0)
(const uint8_t*)payload,
stream_len,
packetData.rtp_number,
packetData.sample_count,
packetData.arrival_time)
< 0)
{
printf(" BWE Error at client\n");
return -1;

View File

@ -754,7 +754,7 @@ int ACMISAC::IncomingPacket(const uint8_t* payload,
CriticalSectionScoped lock(codec_inst_crit_sect_.get());
return ACM_ISAC_DECODE_BWE(
static_cast<ACM_ISAC_STRUCT*>(codec_inst_ptr_->inst),
reinterpret_cast<const uint16_t*>(payload),
payload,
static_cast<uint32_t>(payload_len),
rtp_sequence_number,
rtp_timestamp,

View File

@ -199,7 +199,7 @@ int AudioDecoderIsac::IncomingPacket(const uint8_t* payload,
uint32_t rtp_timestamp,
uint32_t arrival_timestamp) {
return WebRtcIsac_UpdateBwEstimate(static_cast<ISACStruct*>(state_),
reinterpret_cast<const uint16_t*>(payload),
payload,
static_cast<int32_t>(payload_len),
rtp_sequence_number,
rtp_timestamp,
@ -254,7 +254,7 @@ int AudioDecoderIsacFix::IncomingPacket(const uint8_t* payload,
uint32_t arrival_timestamp) {
return WebRtcIsacfix_UpdateBwEstimate(
static_cast<ISACFIX_MainStruct*>(state_),
reinterpret_cast<const uint16_t*>(payload),
payload,
static_cast<int32_t>(payload_len),
rtp_sequence_number, rtp_timestamp, arrival_timestamp);
}