WebRtcIsac_Decode et al.: Type encoded data as uint8[], not uint16[]
This patch changes WebRtcIsac_Decode, WebRtcIsac_DecodeRcu, and
WebRtcIsacfix_Decode so that they read the encoded data from a uint8
array instead of a uint16 array.
BUG=909
R=aluebs@webrtc.org, bjornv@webrtc.org, henrik.lundin@webrtc.org, turaj@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/25739004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7431 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h b/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h
index 4959d57..961fd3f 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h
@@ -252,7 +252,7 @@
*/
int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
- const uint16_t *encoded,
+ const uint8_t* encoded,
int16_t len,
int16_t *decoded,
int16_t *speechType);
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
index 33bf373..1c1a720 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/isacfix.c
@@ -805,7 +805,7 @@
int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
- const uint16_t *encoded,
+ const uint8_t* encoded,
int16_t len,
int16_t *decoded,
int16_t *speechType)
@@ -844,10 +844,13 @@
/* convert bitstream from int16_t to bytes */
#ifndef WEBRTC_ARCH_BIG_ENDIAN
for (k=0; k<(len>>1); k++) {
- (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (uint16_t) ((encoded[k] >> 8)|((encoded[k] & 0xFF)<<8));
+ uint16_t ek = ((const uint16_t*)encoded)[k];
+ ISAC_inst->ISACdec_obj.bitstr_obj.stream[k] =
+ (uint16_t)((ek >> 8) | ((ek & 0xff) << 8));
}
if (len & 0x0001)
- (ISAC_inst->ISACdec_obj.bitstr_obj).stream[k] = (uint16_t) ((encoded[k] & 0xFF)<<8);
+ ISAC_inst->ISACdec_obj.bitstr_obj.stream[k] =
+ (uint16_t)((((const uint16_t*)encoded)[k] & 0xff) << 8);
#else
memcpy(ISAC_inst->ISACdec_obj.bitstr_obj.stream, encoded, len);
#endif
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
index 207ee8c..d93fae3 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/isac_speed_test.cc
@@ -86,7 +86,7 @@
int16_t audio_type;
clock_t clocks = clock();
value = WebRtcIsacfix_Decode(ISACFIX_main_inst_,
- reinterpret_cast<const uint16_t*>(bit_stream),
+ bit_stream,
encoded_bytes, out_data, &audio_type);
clocks = clock() - clocks;
EXPECT_EQ(output_length_sample_, value);
diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc b/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
index 8e379c6..ba50b0c 100644
--- a/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/fix/test/kenny.cc
@@ -746,8 +746,12 @@
/* Call getFramelen, only used here for function test */
err = WebRtcIsacfix_ReadFrameLen(
reinterpret_cast<const uint8_t*>(streamdata), stream_len, &FL);
- declen = WebRtcIsacfix_Decode( ISAC_main_inst, streamdata, stream_len,
- decoded, speechType );
+ declen = WebRtcIsacfix_Decode(
+ ISAC_main_inst,
+ reinterpret_cast<const uint8_t*>(streamdata),
+ stream_len,
+ decoded,
+ speechType);
/* Error check */
if (err<0 || declen<0 || FL!=declen) {
errtype=WebRtcIsacfix_GetErrorCode(ISAC_main_inst);
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h b/webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h
index 81b257c..6d0c32d 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h
+++ b/webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h
@@ -216,7 +216,7 @@
int16_t WebRtcIsac_Decode(
ISACStruct* ISAC_main_inst,
- const uint16_t* encoded,
+ const uint8_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType);
@@ -703,7 +703,7 @@
*/
int16_t WebRtcIsac_DecodeRcu(
ISACStruct* ISAC_main_inst,
- const uint16_t* encoded,
+ const uint8_t* encoded,
int16_t len,
int16_t* decoded,
int16_t* speechType);
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c b/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
index 05bdf2a..d2260e2 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/isac.c
@@ -1046,7 +1046,7 @@
}
static int16_t Decode(ISACStruct* ISAC_main_inst,
- const uint16_t* encoded,
+ const uint8_t* encoded,
int16_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType,
@@ -1065,7 +1065,6 @@
int16_t lenEncodedLBBytes;
int16_t validChecksum = 1;
int16_t k;
- uint8_t* ptrEncodedUW8 = (uint8_t*)encoded;
uint16_t numLayer;
int16_t totSizeBytes;
int16_t err;
@@ -1094,7 +1093,7 @@
STREAM_SIZE_MAX : lenEncodedBytes;
/* Copy to lower-band bit-stream structure. */
- memcpy(instISAC->instLB.ISACdecLB_obj.bitstr_obj.stream, ptrEncodedUW8,
+ memcpy(instISAC->instLB.ISACdecLB_obj.bitstr_obj.stream, encoded,
lenEncodedLBBytes);
/* Regardless of that the current codec is setup to work in
@@ -1116,12 +1115,12 @@
totSizeBytes = numDecodedBytesLB;
while (totSizeBytes != lenEncodedBytes) {
if ((totSizeBytes > lenEncodedBytes) ||
- (ptrEncodedUW8[totSizeBytes] == 0) ||
+ (encoded[totSizeBytes] == 0) ||
(numLayer > MAX_NUM_LAYERS)) {
instISAC->errorCode = ISAC_LENGTH_MISMATCH;
return -1;
}
- totSizeBytes += ptrEncodedUW8[totSizeBytes];
+ totSizeBytes += encoded[totSizeBytes];
numLayer++;
}
@@ -1160,7 +1159,7 @@
instISAC->resetFlag_8kHz = 2;
} else {
/* This includes the checksum and the bytes that stores the length. */
- int16_t lenNextStream = ptrEncodedUW8[numDecodedBytesLB];
+ int16_t lenNextStream = encoded[numDecodedBytesLB];
/* Is this garbage or valid super-wideband bit-stream?
* Check if checksum is valid. */
@@ -1170,14 +1169,13 @@
validChecksum = 0;
} else {
/* Run CRC to see if the checksum match. */
- WebRtcIsac_GetCrc((int16_t*)(
- &ptrEncodedUW8[numDecodedBytesLB + 1]),
+ WebRtcIsac_GetCrc((int16_t*)(&encoded[numDecodedBytesLB + 1]),
lenNextStream - LEN_CHECK_SUM_WORD8 - 1, &crc);
validChecksum = 1;
for (k = 0; k < LEN_CHECK_SUM_WORD8; k++) {
validChecksum &= (((crc >> (24 - k * 8)) & 0xFF) ==
- ptrEncodedUW8[numDecodedBytesLB + lenNextStream -
+ encoded[numDecodedBytesLB + lenNextStream -
LEN_CHECK_SUM_WORD8 + k]);
}
}
@@ -1209,7 +1207,7 @@
lenNextStream -= (LEN_CHECK_SUM_WORD8 + 1);
memcpy(decInstUB->bitstr_obj.stream,
- &ptrEncodedUW8[numDecodedBytesLB + 1], lenNextStream);
+ &encoded[numDecodedBytesLB + 1], lenNextStream);
/* Reset bit-stream object, this is the first decoding. */
WebRtcIsac_ResetBitstream(&(decInstUB->bitstr_obj));
@@ -1283,7 +1281,7 @@
/* It might be less due to garbage. */
if ((numDecodedBytesUB != lenNextStream) &&
(numDecodedBytesUB != (lenNextStream -
- ptrEncodedUW8[numDecodedBytesLB + 1 + numDecodedBytesUB]))) {
+ encoded[numDecodedBytesLB + 1 + numDecodedBytesUB]))) {
instISAC->errorCode = ISAC_LENGTH_MISMATCH;
return -1;
}
@@ -1346,7 +1344,7 @@
*/
int16_t WebRtcIsac_Decode(ISACStruct* ISAC_main_inst,
- const uint16_t* encoded,
+ const uint8_t* encoded,
int16_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType) {
@@ -1378,7 +1376,7 @@
int16_t WebRtcIsac_DecodeRcu(ISACStruct* ISAC_main_inst,
- const uint16_t* encoded,
+ const uint8_t* encoded,
int16_t lenEncodedBytes,
int16_t* decoded,
int16_t* speechType) {
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
index e7e729e..b9fec4b 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/main/test/ReleaseTest-API/ReleaseTest-API.cc
@@ -909,26 +909,39 @@
if(lostFrame)
{
- declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, streamdata,
- stream_len, decoded, speechType);
+ declen = WebRtcIsac_DecodeRcu(
+ ISAC_main_inst,
+ reinterpret_cast<const uint8_t*>(streamdata),
+ stream_len,
+ decoded,
+ speechType);
if(doTransCoding)
{
- declenTC = WebRtcIsac_DecodeRcu(decoderTransCoding,
- streamDataTransCoding, streamLenTransCoding,
- decodedTC, speechType);
+ declenTC = WebRtcIsac_DecodeRcu(
+ decoderTransCoding,
+ reinterpret_cast<const uint8_t*>(streamDataTransCoding),
+ streamLenTransCoding,
+ decodedTC,
+ speechType);
}
}
else
{
- declen = WebRtcIsac_Decode(ISAC_main_inst, streamdata,
- stream_len, decoded, speechType);
-
+ declen = WebRtcIsac_Decode(
+ ISAC_main_inst,
+ reinterpret_cast<const uint8_t*>(streamdata),
+ stream_len,
+ decoded,
+ speechType);
if(doTransCoding)
{
- declenTC = WebRtcIsac_Decode(decoderTransCoding,
- streamDataTransCoding, streamLenTransCoding,
- decodedTC, speechType);
+ declenTC = WebRtcIsac_Decode(
+ decoderTransCoding,
+ reinterpret_cast<const uint8_t*>(streamDataTransCoding),
+ streamLenTransCoding,
+ decodedTC,
+ speechType);
}
}
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc b/webrtc/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
index 88b0944..6ec818e 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
+++ b/webrtc/modules/audio_coding/codecs/isac/main/test/SwitchingSampRate/SwitchingSampRate.cc
@@ -424,8 +424,11 @@
/**/
// Decode
lenDecodedAudio = WebRtcIsac_Decode(
- codecInstance[receiverIdx], bitStream, streamLen,
- audioBuff60ms, speechType);
+ codecInstance[receiverIdx],
+ reinterpret_cast<const uint8_t*>(bitStream),
+ streamLen,
+ audioBuff60ms,
+ speechType);
if(lenDecodedAudio < 0)
{
printf(" Decoder error in client %d \n", receiverIdx + 1);
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c
index e63e1e0..ce759a4 100644
--- a/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c
+++ b/webrtc/modules/audio_coding/codecs/isac/main/test/simpleKenny.c
@@ -458,16 +458,24 @@
if((rand() % 100) < packetLossPercent)
{
- declen = WebRtcIsac_DecodeRcu(ISAC_main_inst, payloadRCU,
- rcuStreamLen, decoded, speechType);
+ declen = WebRtcIsac_DecodeRcu(
+ ISAC_main_inst,
+ (const uint8_t*)payloadRCU,
+ rcuStreamLen,
+ decoded,
+ speechType);
lostPacketCntr++;
}
else
{
- declen = WebRtcIsac_Decode(ISAC_main_inst, payload,
- stream_len, decoded, speechType);
- }
- if(declen <= 0)
+ declen = WebRtcIsac_Decode(
+ ISAC_main_inst,
+ (const uint8_t*)payload,
+ stream_len,
+ decoded,
+ speechType);
+ }
+ if(declen <= 0)
{
//errType=WebRtcIsac_GetErrorCode(ISAC_main_inst);
fprintf(stderr,"\nError in decoder.\n");
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
index 89e52f4..6ee2682 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc
@@ -730,7 +730,7 @@
CriticalSectionScoped lock(codec_inst_crit_sect_.get());
int ret =
ACM_ISAC_DECODE_B(static_cast<ACM_ISAC_STRUCT*>(codec_inst_ptr_->inst),
- reinterpret_cast<const uint16_t*>(encoded),
+ encoded,
static_cast<int16_t>(encoded_len),
decoded,
&temp_type);
@@ -769,7 +769,7 @@
CriticalSectionScoped lock(codec_inst_crit_sect_.get());
int16_t ret =
ACM_ISAC_DECODERCU(static_cast<ACM_ISAC_STRUCT*>(codec_inst_ptr_->inst),
- reinterpret_cast<const uint16_t*>(encoded),
+ encoded,
static_cast<int16_t>(encoded_len),
decoded,
&temp_type);
diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc
index 028320a..661f2b1 100644
--- a/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/audio_decoder_impl.cc
@@ -165,7 +165,7 @@
int16_t* decoded, SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = WebRtcIsac_Decode(static_cast<ISACStruct*>(state_),
- reinterpret_cast<const uint16_t*>(encoded),
+ encoded,
static_cast<int16_t>(encoded_len), decoded,
&temp_type);
*speech_type = ConvertSpeechType(temp_type);
@@ -177,7 +177,7 @@
SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = WebRtcIsac_DecodeRcu(static_cast<ISACStruct*>(state_),
- reinterpret_cast<const uint16_t*>(encoded),
+ encoded,
static_cast<int16_t>(encoded_len), decoded,
&temp_type);
*speech_type = ConvertSpeechType(temp_type);
@@ -236,7 +236,7 @@
int16_t* decoded, SpeechType* speech_type) {
int16_t temp_type = 1; // Default is speech.
int16_t ret = WebRtcIsacfix_Decode(static_cast<ISACFIX_MainStruct*>(state_),
- reinterpret_cast<const uint16_t*>(encoded),
+ encoded,
static_cast<int16_t>(encoded_len), decoded,
&temp_type);
*speech_type = ConvertSpeechType(temp_type);