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
This commit is contained in:
parent
3f7f899a15
commit
396a5e0001
@ -252,7 +252,7 @@ extern "C" {
|
||||
*/
|
||||
|
||||
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);
|
||||
|
@ -805,7 +805,7 @@ int16_t WebRtcIsacfix_UpdateBwEstimate(ISACFIX_MainStruct *ISAC_main_inst,
|
||||
|
||||
|
||||
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 @@ int16_t WebRtcIsacfix_Decode(ISACFIX_MainStruct *ISAC_main_inst,
|
||||
/* 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
|
||||
|
@ -86,7 +86,7 @@ float IsacSpeedTest::DecodeABlock(const uint8_t* bit_stream, int encoded_bytes,
|
||||
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);
|
||||
|
@ -746,8 +746,12 @@ int main(int argc, char* argv[])
|
||||
/* 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);
|
||||
|
@ -216,7 +216,7 @@ extern "C" {
|
||||
|
||||
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 @@ extern "C" {
|
||||
*/
|
||||
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);
|
||||
|
@ -1046,7 +1046,7 @@ int16_t WebRtcIsac_UpdateBwEstimate(ISACStruct* ISAC_main_inst,
|
||||
}
|
||||
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
/* 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 @@ static int16_t Decode(ISACStruct* ISAC_main_inst,
|
||||
*/
|
||||
|
||||
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_Decode(ISACStruct* ISAC_main_inst,
|
||||
|
||||
|
||||
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) {
|
||||
|
@ -909,26 +909,39 @@ int main(int argc, char* argv[])
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,8 +424,11 @@ int main(int argc, char* argv[])
|
||||
/**/
|
||||
// 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);
|
||||
|
@ -458,16 +458,24 @@ valid values are 8 and 16.\n", sampFreqKHz);
|
||||
|
||||
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");
|
||||
|
@ -730,7 +730,7 @@ int ACMISAC::Decode(const uint8_t* encoded,
|
||||
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 @@ int ACMISAC::DecodeRedundant(const uint8_t* encoded,
|
||||
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);
|
||||
|
@ -165,7 +165,7 @@ int AudioDecoderIsac::Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
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 @@ int AudioDecoderIsac::DecodeRedundant(const uint8_t* encoded,
|
||||
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 @@ int AudioDecoderIsacFix::Decode(const uint8_t* encoded, size_t encoded_len,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user