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 4959d57ac..961fd3fad 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 @@ 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); 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 33bf373f3..1c1a72018 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_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 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 207ee8c30..d93fae3c3 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 @@ 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(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 8e379c6a8..ba50b0c67 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 @@ int main(int argc, char* argv[]) /* Call getFramelen, only used here for function test */ err = WebRtcIsacfix_ReadFrameLen( reinterpret_cast(streamdata), stream_len, &FL); - declen = WebRtcIsacfix_Decode( ISAC_main_inst, streamdata, stream_len, - decoded, speechType ); + declen = WebRtcIsacfix_Decode( + ISAC_main_inst, + reinterpret_cast(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 81b257c43..6d0c32deb 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 @@ 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); 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 05bdf2ac0..d2260e26b 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 @@ 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) { 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 e7e729ee6..b9fec4b72 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 @@ 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(streamdata), + stream_len, + decoded, + speechType); if(doTransCoding) { - declenTC = WebRtcIsac_DecodeRcu(decoderTransCoding, - streamDataTransCoding, streamLenTransCoding, - decodedTC, speechType); + declenTC = WebRtcIsac_DecodeRcu( + decoderTransCoding, + reinterpret_cast(streamDataTransCoding), + streamLenTransCoding, + decodedTC, + speechType); } } else { - declen = WebRtcIsac_Decode(ISAC_main_inst, streamdata, - stream_len, decoded, speechType); - + declen = WebRtcIsac_Decode( + ISAC_main_inst, + reinterpret_cast(streamdata), + stream_len, + decoded, + speechType); if(doTransCoding) { - declenTC = WebRtcIsac_Decode(decoderTransCoding, - streamDataTransCoding, streamLenTransCoding, - decodedTC, speechType); + declenTC = WebRtcIsac_Decode( + decoderTransCoding, + reinterpret_cast(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 88b0944bf..6ec818ee7 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 @@ int main(int argc, char* argv[]) /**/ // Decode lenDecodedAudio = WebRtcIsac_Decode( - codecInstance[receiverIdx], bitStream, streamLen, - audioBuff60ms, speechType); + codecInstance[receiverIdx], + reinterpret_cast(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 e63e1e090..ce759a430 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 @@ 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"); diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc index 89e52f4b0..6ee268255 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 @@ int ACMISAC::Decode(const uint8_t* encoded, CriticalSectionScoped lock(codec_inst_crit_sect_.get()); int ret = ACM_ISAC_DECODE_B(static_cast(codec_inst_ptr_->inst), - reinterpret_cast(encoded), + encoded, static_cast(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(codec_inst_ptr_->inst), - reinterpret_cast(encoded), + encoded, static_cast(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 028320a24..661f2b11c 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 @@ 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(state_), - reinterpret_cast(encoded), + encoded, static_cast(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(state_), - reinterpret_cast(encoded), + encoded, static_cast(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(state_), - reinterpret_cast(encoded), + encoded, static_cast(encoded_len), decoded, &temp_type); *speech_type = ConvertSpeechType(temp_type);