diff --git a/src/modules/audio_coding/codecs/ilbc/decode.c b/src/modules/audio_coding/codecs/ilbc/decode.c index c1686913df..3bca764cc8 100644 --- a/src/modules/audio_coding/codecs/ilbc/decode.c +++ b/src/modules/audio_coding/codecs/ilbc/decode.c @@ -38,7 +38,7 @@ void WebRtcIlbcfix_DecodeImpl( WebRtc_Word16 *decblock, /* (o) decoded signal block */ - WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ + const WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) the decoder state structure */ WebRtc_Word16 mode /* (i) 0: bad packet, PLC, @@ -54,6 +54,9 @@ void WebRtcIlbcfix_DecodeImpl( WebRtc_Word16 PLCresidual[BLOCKL_MAX + LPC_FILTERORDER]; WebRtc_Word16 syntdenum[NSUB_MAX*(LPC_FILTERORDER+1)]; WebRtc_Word16 PLClpc[LPC_FILTERORDER + 1]; +#ifndef WEBRTC_BIG_ENDIAN + WebRtc_UWord16 swapped[NO_OF_WORDS_30MS]; +#endif iLBC_bits *iLBCbits_inst = (iLBC_bits*)PLCresidual; /* Reuse some buffers that are non overlapping in order to save stack memory */ @@ -63,17 +66,13 @@ void WebRtcIlbcfix_DecodeImpl( /* decode data */ -#ifndef WEBRTC_BIG_ENDIAN - WebRtcIlbcfix_SwapBytes((WebRtc_UWord16*)bytes, iLBCdec_inst->no_of_words); -#endif - /* Unpacketize bits into parameters */ - last_bit = WebRtcIlbcfix_UnpackBits(bytes, iLBCbits_inst, iLBCdec_inst->mode); - #ifndef WEBRTC_BIG_ENDIAN - /* Swap back so that the the input vector "bytes" is unchanged */ - WebRtcIlbcfix_SwapBytes((WebRtc_UWord16*)bytes, iLBCdec_inst->no_of_words); + WebRtcIlbcfix_SwapBytes(bytes, iLBCdec_inst->no_of_words, swapped); + last_bit = WebRtcIlbcfix_UnpackBits(swapped, iLBCbits_inst, iLBCdec_inst->mode); +#else + last_bit = WebRtcIlbcfix_UnpackBits(bytes, iLBCbits_inst, iLBCdec_inst->mode); #endif /* Check for bit errors */ diff --git a/src/modules/audio_coding/codecs/ilbc/decode.h b/src/modules/audio_coding/codecs/ilbc/decode.h index 0252d9c4ce..2c9b5a2e56 100644 --- a/src/modules/audio_coding/codecs/ilbc/decode.h +++ b/src/modules/audio_coding/codecs/ilbc/decode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -27,7 +27,7 @@ void WebRtcIlbcfix_DecodeImpl( WebRtc_Word16 *decblock, /* (o) decoded signal block */ - WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ + const WebRtc_UWord16 *bytes, /* (i) encoded signal bits */ iLBC_Dec_Inst_t *iLBCdec_inst, /* (i/o) the decoder state structure */ WebRtc_Word16 mode /* (i) 0: bad packet, PLC, diff --git a/src/modules/audio_coding/codecs/ilbc/encode.c b/src/modules/audio_coding/codecs/ilbc/encode.c index 8135426390..d3d3ba85f3 100644 --- a/src/modules/audio_coding/codecs/ilbc/encode.c +++ b/src/modules/audio_coding/codecs/ilbc/encode.c @@ -495,10 +495,10 @@ void WebRtcIlbcfix_EncodeImpl( #ifdef SPLIT_10MS if (( (iLBCenc_inst->section == 1) && (iLBCenc_inst->mode == 20) ) || ( (iLBCenc_inst->section == 2) && (iLBCenc_inst->mode == 30) )){ - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words); + WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); } #else - WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words); + WebRtcIlbcfix_SwapBytes(bytes, iLBCenc_inst->no_of_words, bytes); #endif #endif diff --git a/src/modules/audio_coding/codecs/ilbc/ilbc.c b/src/modules/audio_coding/codecs/ilbc/ilbc.c index adf251bbcb..dbd32d191a 100644 --- a/src/modules/audio_coding/codecs/ilbc/ilbc.c +++ b/src/modules/audio_coding/codecs/ilbc/ilbc.c @@ -134,7 +134,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decoderinit30Ms(iLBC_decinst_t *iLBCdec_inst) { WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *encoded, + const WebRtc_Word16 *encoded, WebRtc_Word16 len, WebRtc_Word16 *decoded, WebRtc_Word16 *speechType) @@ -170,7 +170,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, } while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)blockl], (WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); + WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); i++; } /* iLBC does not support VAD/CNG yet */ @@ -179,7 +179,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, } WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *encoded, + const WebRtc_Word16 *encoded, WebRtc_Word16 len, WebRtc_Word16 *decoded, WebRtc_Word16 *speechType) @@ -194,7 +194,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, } while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)blockl], (WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); + WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); i++; } /* iLBC does not support VAD/CNG yet */ @@ -203,7 +203,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, } WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *encoded, + const WebRtc_Word16 *encoded, WebRtc_Word16 len, WebRtc_Word16 *decoded, WebRtc_Word16 *speechType) @@ -218,7 +218,7 @@ WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst, } while ((i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_bytes)blockl], (WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); + WebRtcIlbcfix_DecodeImpl(&decoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->blockl], (const WebRtc_UWord16*) &encoded[i*((iLBC_Dec_Inst_t*)iLBCdec_inst)->no_of_words], (iLBC_Dec_Inst_t*) iLBCdec_inst, 1); i++; } /* iLBC does not support VAD/CNG yet */ diff --git a/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h b/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h index 090d370c3d..6208962c18 100644 --- a/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h +++ b/src/modules/audio_coding/codecs/ilbc/interface/ilbc.h @@ -182,20 +182,20 @@ extern "C" { */ WebRtc_Word16 WebRtcIlbcfix_Decode(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16* encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); + const WebRtc_Word16* encoded, + WebRtc_Word16 len, + WebRtc_Word16 *decoded, + WebRtc_Word16 *speechType); WebRtc_Word16 WebRtcIlbcfix_Decode20Ms(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); + const WebRtc_Word16 *encoded, + WebRtc_Word16 len, + WebRtc_Word16 *decoded, + WebRtc_Word16 *speechType); WebRtc_Word16 WebRtcIlbcfix_Decode30Ms(iLBC_decinst_t *iLBCdec_inst, - WebRtc_Word16 *encoded, - WebRtc_Word16 len, - WebRtc_Word16 *decoded, - WebRtc_Word16 *speechType); + const WebRtc_Word16 *encoded, + WebRtc_Word16 len, + WebRtc_Word16 *decoded, + WebRtc_Word16 *speechType); /**************************************************************************** * WebRtcIlbcfix_DecodePlc(...) diff --git a/src/modules/audio_coding/codecs/ilbc/swap_bytes.c b/src/modules/audio_coding/codecs/ilbc/swap_bytes.c index 61b8b7bd27..a48a06644b 100644 --- a/src/modules/audio_coding/codecs/ilbc/swap_bytes.c +++ b/src/modules/audio_coding/codecs/ilbc/swap_bytes.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -23,14 +23,13 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_SwapBytes( - WebRtc_UWord16 *sequence, /* (i/o) the sequence to swap */ - WebRtc_Word16 wordLength /* (i) number or WebRtc_UWord16 to swap */ + const WebRtc_UWord16* input, /* (i) the sequence to swap */ + WebRtc_Word16 wordLength, /* (i) number or WebRtc_UWord16 to swap */ + WebRtc_UWord16* output /* (o) the swapped sequence */ ) { int k; - WebRtc_UWord16 temp=0; - for( k=wordLength; k>0; k-- ) { - temp = (*sequence >> 8)|(*sequence << 8); - *sequence++ = temp; - //*sequence++ = (*sequence >> 8) | (*sequence << 8); + for (k = wordLength; k > 0; k--) { + *output++ = (*input >> 8)|(*input << 8); + input++; } } diff --git a/src/modules/audio_coding/codecs/ilbc/swap_bytes.h b/src/modules/audio_coding/codecs/ilbc/swap_bytes.h index 2f2b3eb1cc..1632311277 100644 --- a/src/modules/audio_coding/codecs/ilbc/swap_bytes.h +++ b/src/modules/audio_coding/codecs/ilbc/swap_bytes.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -26,8 +26,9 @@ *---------------------------------------------------------------*/ void WebRtcIlbcfix_SwapBytes( - WebRtc_UWord16 *sequence, /* (i/o) the sequence to swap */ - WebRtc_Word16 wordLength /* (i) number or WebRtc_UWord16 to swap */ + const WebRtc_UWord16* input, /* (i) the sequence to swap */ + WebRtc_Word16 wordLength, /* (i) number or WebRtc_UWord16 to swap */ + WebRtc_UWord16* output /* (o) the swapped sequence */ ); #endif diff --git a/src/modules/audio_coding/codecs/ilbc/unpack_bits.c b/src/modules/audio_coding/codecs/ilbc/unpack_bits.c index 6c883a7ba0..6ed92656b6 100644 --- a/src/modules/audio_coding/codecs/ilbc/unpack_bits.c +++ b/src/modules/audio_coding/codecs/ilbc/unpack_bits.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -23,11 +23,11 @@ *---------------------------------------------------------------*/ WebRtc_Word16 WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */ - WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ + const WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */ WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ ) { - WebRtc_UWord16 *bitstreamPtr; + const WebRtc_UWord16 *bitstreamPtr; int i, k; WebRtc_Word16 *tmpPtr; diff --git a/src/modules/audio_coding/codecs/ilbc/unpack_bits.h b/src/modules/audio_coding/codecs/ilbc/unpack_bits.h index 864865f091..31c728eb81 100644 --- a/src/modules/audio_coding/codecs/ilbc/unpack_bits.h +++ b/src/modules/audio_coding/codecs/ilbc/unpack_bits.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -26,7 +26,7 @@ *---------------------------------------------------------------*/ WebRtc_Word16 WebRtcIlbcfix_UnpackBits( /* (o) "Empty" frame indicator */ - WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ + const WebRtc_UWord16 *bitstream, /* (i) The packatized bitstream */ iLBC_bits *enc_bits, /* (o) Paramerers from bitstream */ WebRtc_Word16 mode /* (i) Codec mode (20 or 30) */ );