WebRtc_Word32 -> int32_t in common_audio/

BUG=314

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3803 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2013-04-09 16:40:28 +00:00
parent 7da3459b2a
commit b09130763b
34 changed files with 1104 additions and 1126 deletions

View File

@ -77,14 +77,14 @@ public:
int ResetIfNeeded(int inFreq, int outFreq, ResamplerType type); int ResetIfNeeded(int inFreq, int outFreq, ResamplerType type);
// Synchronous resampling, all output samples are written to samplesOut // Synchronous resampling, all output samples are written to samplesOut
int Push(const WebRtc_Word16* samplesIn, int lengthIn, WebRtc_Word16* samplesOut, int Push(const int16_t* samplesIn, int lengthIn, int16_t* samplesOut,
int maxLen, int &outLen); int maxLen, int &outLen);
// Asynchronous resampling, input // Asynchronous resampling, input
int Insert(WebRtc_Word16* samplesIn, int lengthIn); int Insert(int16_t* samplesIn, int lengthIn);
// Asynchronous resampling output, remaining samples are buffered // Asynchronous resampling output, remaining samples are buffered
int Pull(WebRtc_Word16* samplesOut, int desiredLen, int &outLen); int Pull(int16_t* samplesOut, int desiredLen, int &outLen);
private: private:
// Generic pointers since we don't know what states we'll need // Generic pointers since we don't know what states we'll need
@ -93,8 +93,8 @@ private:
void* state3_; void* state3_;
// Storage if needed // Storage if needed
WebRtc_Word16* in_buffer_; int16_t* in_buffer_;
WebRtc_Word16* out_buffer_; int16_t* out_buffer_;
int in_buffer_size_; int in_buffer_size_;
int out_buffer_size_; int out_buffer_size_;
int in_buffer_size_max_; int in_buffer_size_max_;

View File

@ -282,8 +282,8 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
// No state needed; // No state needed;
break; break;
case kResamplerMode1To2: case kResamplerMode1To2:
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode1To3: case kResamplerMode1To3:
state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz));
@ -291,27 +291,27 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
break; break;
case kResamplerMode1To4: case kResamplerMode1To4:
// 1:2 // 1:2
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 2:4 // 2:4
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode1To6: case kResamplerMode1To6:
// 1:2 // 1:2
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 2:6 // 2:6
state2_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); state2_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz));
WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state2_); WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state2_);
break; break;
case kResamplerMode1To12: case kResamplerMode1To12:
// 1:2 // 1:2
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 2:4 // 2:4
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
// 4:12 // 4:12
state3_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); state3_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz));
WebRtcSpl_ResetResample16khzTo48khz( WebRtcSpl_ResetResample16khzTo48khz(
@ -322,12 +322,12 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz)); state1_ = malloc(sizeof(WebRtcSpl_State16khzTo48khz));
WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state1_); WebRtcSpl_ResetResample16khzTo48khz((WebRtcSpl_State16khzTo48khz *)state1_);
// 6:3 // 6:3
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode2To11: case kResamplerMode2To11:
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
state2_ = malloc(sizeof(WebRtcSpl_State8khzTo22khz)); state2_ = malloc(sizeof(WebRtcSpl_State8khzTo22khz));
WebRtcSpl_ResetResample8khzTo22khz((WebRtcSpl_State8khzTo22khz *)state2_); WebRtcSpl_ResetResample8khzTo22khz((WebRtcSpl_State8khzTo22khz *)state2_);
@ -341,29 +341,29 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
WebRtcSpl_ResetResample16khzTo22khz((WebRtcSpl_State16khzTo22khz *)state1_); WebRtcSpl_ResetResample16khzTo22khz((WebRtcSpl_State16khzTo22khz *)state1_);
break; break;
case kResamplerMode11To16: case kResamplerMode11To16:
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz)); state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz));
WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_); WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_);
break; break;
case kResamplerMode11To32: case kResamplerMode11To32:
// 11 -> 22 // 11 -> 22
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 22 -> 16 // 22 -> 16
state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz)); state2_ = malloc(sizeof(WebRtcSpl_State22khzTo16khz));
WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_); WebRtcSpl_ResetResample22khzTo16khz((WebRtcSpl_State22khzTo16khz *)state2_);
// 16 -> 32 // 16 -> 32
state3_ = malloc(8 * sizeof(WebRtc_Word32)); state3_ = malloc(8 * sizeof(int32_t));
memset(state3_, 0, 8 * sizeof(WebRtc_Word32)); memset(state3_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode2To1: case kResamplerMode2To1:
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode3To1: case kResamplerMode3To1:
state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz));
@ -371,19 +371,19 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
break; break;
case kResamplerMode4To1: case kResamplerMode4To1:
// 4:2 // 4:2
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 2:1 // 2:1
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode6To1: case kResamplerMode6To1:
// 6:2 // 6:2
state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); state1_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz));
WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state1_); WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state1_);
// 2:1 // 2:1
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode12To1: case kResamplerMode12To1:
// 12:4 // 12:4
@ -391,16 +391,16 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
WebRtcSpl_ResetResample48khzTo16khz( WebRtcSpl_ResetResample48khzTo16khz(
(WebRtcSpl_State48khzTo16khz*) state1_); (WebRtcSpl_State48khzTo16khz*) state1_);
// 4:2 // 4:2
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
// 2:1 // 2:1
state3_ = malloc(8 * sizeof(WebRtc_Word32)); state3_ = malloc(8 * sizeof(int32_t));
memset(state3_, 0, 8 * sizeof(WebRtc_Word32)); memset(state3_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode3To2: case kResamplerMode3To2:
// 3:6 // 3:6
state1_ = malloc(8 * sizeof(WebRtc_Word32)); state1_ = malloc(8 * sizeof(int32_t));
memset(state1_, 0, 8 * sizeof(WebRtc_Word32)); memset(state1_, 0, 8 * sizeof(int32_t));
// 6:2 // 6:2
state2_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz)); state2_ = malloc(sizeof(WebRtcSpl_State48khzTo16khz));
WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state2_); WebRtcSpl_ResetResample48khzTo16khz((WebRtcSpl_State48khzTo16khz *)state2_);
@ -409,8 +409,8 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
state1_ = malloc(sizeof(WebRtcSpl_State22khzTo8khz)); state1_ = malloc(sizeof(WebRtcSpl_State22khzTo8khz));
WebRtcSpl_ResetResample22khzTo8khz((WebRtcSpl_State22khzTo8khz *)state1_); WebRtcSpl_ResetResample22khzTo8khz((WebRtcSpl_State22khzTo8khz *)state1_);
state2_ = malloc(8 * sizeof(WebRtc_Word32)); state2_ = malloc(8 * sizeof(int32_t));
memset(state2_, 0, 8 * sizeof(WebRtc_Word32)); memset(state2_, 0, 8 * sizeof(int32_t));
break; break;
case kResamplerMode11To4: case kResamplerMode11To4:
@ -428,7 +428,7 @@ int Resampler::Reset(int inFreq, int outFreq, ResamplerType type)
} }
// Synchronous resampling, all output samples are written to samplesOut // Synchronous resampling, all output samples are written to samplesOut
int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16* samplesOut, int Resampler::Push(const int16_t * samplesIn, int lengthIn, int16_t* samplesOut,
int maxLen, int &outLen) int maxLen, int &outLen)
{ {
// Check that the resampler is not in asynchronous mode // Check that the resampler is not in asynchronous mode
@ -443,11 +443,11 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
// Split up the signal and call the slave object for each channel // Split up the signal and call the slave object for each channel
WebRtc_Word16* left = (WebRtc_Word16*)malloc(lengthIn * sizeof(WebRtc_Word16) / 2); int16_t* left = (int16_t*)malloc(lengthIn * sizeof(int16_t) / 2);
WebRtc_Word16* right = (WebRtc_Word16*)malloc(lengthIn * sizeof(WebRtc_Word16) / 2); int16_t* right = (int16_t*)malloc(lengthIn * sizeof(int16_t) / 2);
WebRtc_Word16* out_left = (WebRtc_Word16*)malloc(maxLen / 2 * sizeof(WebRtc_Word16)); int16_t* out_left = (int16_t*)malloc(maxLen / 2 * sizeof(int16_t));
WebRtc_Word16* out_right = int16_t* out_right =
(WebRtc_Word16*)malloc(maxLen / 2 * sizeof(WebRtc_Word16)); (int16_t*)malloc(maxLen / 2 * sizeof(int16_t));
int res = 0; int res = 0;
for (int i = 0; i < lengthIn; i += 2) for (int i = 0; i < lengthIn; i += 2)
{ {
@ -489,15 +489,15 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
} }
// Containers for temp samples // Containers for temp samples
WebRtc_Word16* tmp; int16_t* tmp;
WebRtc_Word16* tmp_2; int16_t* tmp_2;
// tmp data for resampling routines // tmp data for resampling routines
WebRtc_Word32* tmp_mem; int32_t* tmp_mem;
switch (my_mode_) switch (my_mode_)
{ {
case kResamplerMode1To1: case kResamplerMode1To1:
memcpy(samplesOut, samplesIn, lengthIn * sizeof(WebRtc_Word16)); memcpy(samplesOut, samplesIn, lengthIn * sizeof(int16_t));
outLen = lengthIn; outLen = lengthIn;
break; break;
case kResamplerMode1To2: case kResamplerMode1To2:
@ -505,7 +505,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (int32_t*)state1_);
outLen = lengthIn * 2; outLen = lengthIn * 2;
return 0; return 0;
case kResamplerMode1To3: case kResamplerMode1To3:
@ -520,7 +520,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(336 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 160) for (int i = 0; i < lengthIn; i += 160)
{ {
@ -537,11 +537,11 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); tmp = (int16_t*)malloc(sizeof(int16_t) * 2 * lengthIn);
// 1:2 // 1:2
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
// 2:4 // 2:4
WebRtcSpl_UpsampleBy2(tmp, lengthIn * 2, samplesOut, (WebRtc_Word32*)state2_); WebRtcSpl_UpsampleBy2(tmp, lengthIn * 2, samplesOut, (int32_t*)state2_);
outLen = lengthIn * 4; outLen = lengthIn * 4;
free(tmp); free(tmp);
return 0; return 0;
@ -559,10 +559,10 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
//1:2 //1:2
tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(336 * sizeof(int32_t));
tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); tmp = (int16_t*)malloc(sizeof(int16_t) * 2 * lengthIn);
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
outLen = lengthIn * 2; outLen = lengthIn * 2;
for (int i = 0; i < outLen; i += 160) for (int i = 0; i < outLen; i += 160)
@ -586,14 +586,14 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*) malloc(336 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*) malloc(336 * sizeof(int32_t));
tmp = (WebRtc_Word16*) malloc(sizeof(WebRtc_Word16) * 4 * lengthIn); tmp = (int16_t*) malloc(sizeof(int16_t) * 4 * lengthIn);
//1:2 //1:2
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut,
(WebRtc_Word32*) state1_); (int32_t*) state1_);
outLen = lengthIn * 2; outLen = lengthIn * 2;
//2:4 //2:4
WebRtcSpl_UpsampleBy2(samplesOut, outLen, tmp, (WebRtc_Word32*) state2_); WebRtcSpl_UpsampleBy2(samplesOut, outLen, tmp, (int32_t*) state2_);
outLen = outLen * 2; outLen = outLen * 2;
// 4:12 // 4:12
for (int i = 0; i < outLen; i += 160) { for (int i = 0; i < outLen; i += 160) {
@ -623,8 +623,8 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp = static_cast<WebRtc_Word16*> (malloc(sizeof(WebRtc_Word16) * lengthIn * 3)); tmp = static_cast<int16_t*> (malloc(sizeof(int16_t) * lengthIn * 3));
tmp_mem = (WebRtc_Word32*)malloc(336 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(336 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 160) for (int i = 0; i < lengthIn; i += 160)
{ {
WebRtcSpl_Resample16khzTo48khz(samplesIn + i, tmp + i * 3, WebRtcSpl_Resample16khzTo48khz(samplesIn + i, tmp + i * 3,
@ -633,7 +633,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
} }
lengthIn = lengthIn * 3; lengthIn = lengthIn * 3;
// 6:3 // 6:3
WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (WebRtc_Word32*)state2_); WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (int32_t*)state2_);
outLen = lengthIn / 2; outLen = lengthIn / 2;
free(tmp); free(tmp);
free(tmp_mem); free(tmp_mem);
@ -650,12 +650,12 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * 2 * lengthIn); tmp = (int16_t*)malloc(sizeof(int16_t) * 2 * lengthIn);
// 1:2 // 1:2
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
lengthIn *= 2; lengthIn *= 2;
tmp_mem = (WebRtc_Word32*)malloc(98 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(98 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 80) for (int i = 0; i < lengthIn; i += 80)
{ {
@ -679,7 +679,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(98 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(98 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 80) for (int i = 0; i < lengthIn; i += 80)
{ {
@ -701,7 +701,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(88 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(88 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 160) for (int i = 0; i < lengthIn; i += 160)
{ {
@ -724,10 +724,10 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(104 * sizeof(int32_t));
tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn * 2)); tmp = (int16_t*)malloc((sizeof(int16_t) * lengthIn * 2));
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
for (int i = 0; i < (lengthIn * 2); i += 220) for (int i = 0; i < (lengthIn * 2); i += 220)
{ {
@ -754,11 +754,11 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(104 * sizeof(int32_t));
tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn * 2)); tmp = (int16_t*)malloc((sizeof(int16_t) * lengthIn * 2));
// 11 -> 22 kHz in samplesOut // 11 -> 22 kHz in samplesOut
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, samplesOut, (int32_t*)state1_);
// 22 -> 16 in tmp // 22 -> 16 in tmp
for (int i = 0; i < (lengthIn * 2); i += 220) for (int i = 0; i < (lengthIn * 2); i += 220)
@ -770,7 +770,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
// 16 -> 32 in samplesOut // 16 -> 32 in samplesOut
WebRtcSpl_UpsampleBy2(tmp, (lengthIn * 16) / 11, samplesOut, WebRtcSpl_UpsampleBy2(tmp, (lengthIn * 16) / 11, samplesOut,
(WebRtc_Word32*)state3_); (int32_t*)state3_);
outLen = (lengthIn * 32) / 11; outLen = (lengthIn * 32) / 11;
@ -783,7 +783,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, samplesOut, (WebRtc_Word32*)state1_); WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, samplesOut, (int32_t*)state1_);
outLen = lengthIn / 2; outLen = lengthIn / 2;
return 0; return 0;
case kResamplerMode3To1: case kResamplerMode3To1:
@ -797,7 +797,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(496 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 480) for (int i = 0; i < lengthIn; i += 480)
{ {
@ -813,11 +813,11 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp = (WebRtc_Word16*)malloc(sizeof(WebRtc_Word16) * lengthIn / 2); tmp = (int16_t*)malloc(sizeof(int16_t) * lengthIn / 2);
// 4:2 // 4:2
WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_DownsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
// 2:1 // 2:1
WebRtcSpl_DownsampleBy2(tmp, lengthIn / 2, samplesOut, (WebRtc_Word32*)state2_); WebRtcSpl_DownsampleBy2(tmp, lengthIn / 2, samplesOut, (int32_t*)state2_);
outLen = lengthIn / 4; outLen = lengthIn / 4;
free(tmp); free(tmp);
return 0; return 0;
@ -834,8 +834,8 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(496 * sizeof(int32_t));
tmp = (WebRtc_Word16*)malloc((sizeof(WebRtc_Word16) * lengthIn) / 3); tmp = (int16_t*)malloc((sizeof(int16_t) * lengthIn) / 3);
for (int i = 0; i < lengthIn; i += 480) for (int i = 0; i < lengthIn; i += 480)
{ {
@ -845,7 +845,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
} }
outLen = lengthIn / 3; outLen = lengthIn / 3;
free(tmp_mem); free(tmp_mem);
WebRtcSpl_DownsampleBy2(tmp, outLen, samplesOut, (WebRtc_Word32*)state2_); WebRtcSpl_DownsampleBy2(tmp, outLen, samplesOut, (int32_t*)state2_);
free(tmp); free(tmp);
outLen = outLen / 2; outLen = outLen / 2;
return 0; return 0;
@ -859,9 +859,9 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*) malloc(496 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*) malloc(496 * sizeof(int32_t));
tmp = (WebRtc_Word16*) malloc((sizeof(WebRtc_Word16) * lengthIn) / 3); tmp = (int16_t*) malloc((sizeof(int16_t) * lengthIn) / 3);
tmp_2 = (WebRtc_Word16*) malloc((sizeof(WebRtc_Word16) * lengthIn) / 6); tmp_2 = (int16_t*) malloc((sizeof(int16_t) * lengthIn) / 6);
// 12:4 // 12:4
for (int i = 0; i < lengthIn; i += 480) { for (int i = 0; i < lengthIn; i += 480) {
// WebRtcSpl_Resample48khzTo16khz() takes a block of 480 samples // WebRtcSpl_Resample48khzTo16khz() takes a block of 480 samples
@ -877,12 +877,12 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
free(tmp_mem); free(tmp_mem);
// 4:2 // 4:2
WebRtcSpl_DownsampleBy2(tmp, outLen, tmp_2, WebRtcSpl_DownsampleBy2(tmp, outLen, tmp_2,
(WebRtc_Word32*) state2_); (int32_t*) state2_);
outLen = outLen / 2; outLen = outLen / 2;
free(tmp); free(tmp);
// 2:1 // 2:1
WebRtcSpl_DownsampleBy2(tmp_2, outLen, samplesOut, WebRtcSpl_DownsampleBy2(tmp_2, outLen, samplesOut,
(WebRtc_Word32*) state3_); (int32_t*) state3_);
free(tmp_2); free(tmp_2);
outLen = outLen / 2; outLen = outLen / 2;
return 0; return 0;
@ -892,8 +892,8 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
return -1; return -1;
} }
// 3:6 // 3:6
tmp = static_cast<WebRtc_Word16*> (malloc(sizeof(WebRtc_Word16) * lengthIn * 2)); tmp = static_cast<int16_t*> (malloc(sizeof(int16_t) * lengthIn * 2));
WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (WebRtc_Word32*)state1_); WebRtcSpl_UpsampleBy2(samplesIn, lengthIn, tmp, (int32_t*)state1_);
lengthIn *= 2; lengthIn *= 2;
// 6:2 // 6:2
// We can only handle blocks of 480 samples // We can only handle blocks of 480 samples
@ -903,7 +903,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
free(tmp); free(tmp);
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(496 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(496 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 480) for (int i = 0; i < lengthIn; i += 480)
{ {
WebRtcSpl_Resample48khzTo16khz(tmp + i, samplesOut + i / 3, WebRtcSpl_Resample48khzTo16khz(tmp + i, samplesOut + i / 3,
@ -925,8 +925,8 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(126 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(126 * sizeof(int32_t));
tmp = (WebRtc_Word16*)malloc((lengthIn * 4) / 11 * sizeof(WebRtc_Word16)); tmp = (int16_t*)malloc((lengthIn * 4) / 11 * sizeof(int16_t));
for (int i = 0; i < lengthIn; i += 220) for (int i = 0; i < lengthIn; i += 220)
{ {
@ -936,7 +936,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
} }
lengthIn = (lengthIn * 4) / 11; lengthIn = (lengthIn * 4) / 11;
WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (WebRtc_Word32*)state2_); WebRtcSpl_DownsampleBy2(tmp, lengthIn, samplesOut, (int32_t*)state2_);
outLen = lengthIn / 2; outLen = lengthIn / 2;
free(tmp_mem); free(tmp_mem);
@ -953,7 +953,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(126 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(126 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 220) for (int i = 0; i < lengthIn; i += 220)
{ {
@ -975,7 +975,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
{ {
return -1; return -1;
} }
tmp_mem = (WebRtc_Word32*)malloc(104 * sizeof(WebRtc_Word32)); tmp_mem = (int32_t*)malloc(104 * sizeof(int32_t));
for (int i = 0; i < lengthIn; i += 220) for (int i = 0; i < lengthIn; i += 220)
{ {
@ -993,7 +993,7 @@ int Resampler::Push(const WebRtc_Word16 * samplesIn, int lengthIn, WebRtc_Word16
} }
// Asynchronous resampling, input // Asynchronous resampling, input
int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn) int Resampler::Insert(int16_t * samplesIn, int lengthIn)
{ {
if (my_type_ != kResamplerAsynchronous) if (my_type_ != kResamplerAsynchronous)
{ {
@ -1009,7 +1009,7 @@ int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn)
// Round the value upwards to complete 10 ms blocks // Round the value upwards to complete 10 ms blocks
tenMsblock = my_out_frequency_khz_ * 10; tenMsblock = my_out_frequency_khz_ * 10;
sizeNeeded = (sizeNeeded / tenMsblock + 1) * tenMsblock; sizeNeeded = (sizeNeeded / tenMsblock + 1) * tenMsblock;
out_buffer_ = (WebRtc_Word16*)realloc(out_buffer_, sizeNeeded * sizeof(WebRtc_Word16)); out_buffer_ = (int16_t*)realloc(out_buffer_, sizeNeeded * sizeof(int16_t));
out_buffer_size_max_ = sizeNeeded; out_buffer_size_max_ = sizeNeeded;
} }
@ -1023,12 +1023,12 @@ int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn)
{ {
// Round the value upwards to complete 10 ms blocks // Round the value upwards to complete 10 ms blocks
sizeNeeded = ((in_buffer_size_ + lengthIn) / tenMsblock + 1) * tenMsblock; sizeNeeded = ((in_buffer_size_ + lengthIn) / tenMsblock + 1) * tenMsblock;
in_buffer_ = (WebRtc_Word16*)realloc(in_buffer_, in_buffer_ = (int16_t*)realloc(in_buffer_,
sizeNeeded * sizeof(WebRtc_Word16)); sizeNeeded * sizeof(int16_t));
in_buffer_size_max_ = sizeNeeded; in_buffer_size_max_ = sizeNeeded;
} }
// Copy in data to input buffer // Copy in data to input buffer
memcpy(in_buffer_ + in_buffer_size_, samplesIn, lengthIn * sizeof(WebRtc_Word16)); memcpy(in_buffer_ + in_buffer_size_, samplesIn, lengthIn * sizeof(int16_t));
// Resample all available 10 ms blocks // Resample all available 10 ms blocks
int lenOut; int lenOut;
@ -1039,7 +1039,7 @@ int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn)
// Save the rest // Save the rest
memmove(in_buffer_, in_buffer_ + dataLenToResample, memmove(in_buffer_, in_buffer_ + dataLenToResample,
(in_buffer_size_ - dataLenToResample) * sizeof(WebRtc_Word16)); (in_buffer_size_ - dataLenToResample) * sizeof(int16_t));
in_buffer_size_ -= dataLenToResample; in_buffer_size_ -= dataLenToResample;
} else } else
{ {
@ -1054,7 +1054,7 @@ int Resampler::Insert(WebRtc_Word16 * samplesIn, int lengthIn)
} }
// Asynchronous resampling output, remaining samples are buffered // Asynchronous resampling output, remaining samples are buffered
int Resampler::Pull(WebRtc_Word16* samplesOut, int desiredLen, int &outLen) int Resampler::Pull(int16_t* samplesOut, int desiredLen, int &outLen)
{ {
if (my_type_ != kResamplerAsynchronous) if (my_type_ != kResamplerAsynchronous)
{ {
@ -1065,11 +1065,11 @@ int Resampler::Pull(WebRtc_Word16* samplesOut, int desiredLen, int &outLen)
if (desiredLen <= out_buffer_size_) if (desiredLen <= out_buffer_size_)
{ {
// Give out the date // Give out the date
memcpy(samplesOut, out_buffer_, desiredLen * sizeof(WebRtc_Word32)); memcpy(samplesOut, out_buffer_, desiredLen * sizeof(int32_t));
// Shuffle down remaining // Shuffle down remaining
memmove(out_buffer_, out_buffer_ + desiredLen, memmove(out_buffer_, out_buffer_ + desiredLen,
(out_buffer_size_ - desiredLen) * sizeof(WebRtc_Word16)); (out_buffer_size_ - desiredLen) * sizeof(int16_t));
// Update remaining size // Update remaining size
out_buffer_size_ -= desiredLen; out_buffer_size_ -= desiredLen;

View File

@ -17,13 +17,13 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32 *R, int use_order, WebRtc_Word16 *K) void WebRtcSpl_AutoCorrToReflCoef(G_CONST int32_t *R, int use_order, int16_t *K)
{ {
int i, n; int i, n;
WebRtc_Word16 tmp; int16_t tmp;
G_CONST WebRtc_Word32 *rptr; G_CONST int32_t *rptr;
WebRtc_Word32 L_num, L_den; int32_t L_num, L_den;
WebRtc_Word16 *acfptr, *pptr, *wptr, *p1ptr, *w1ptr, ACF[WEBRTC_SPL_MAX_LPC_ORDER], int16_t *acfptr, *pptr, *wptr, *p1ptr, *w1ptr, ACF[WEBRTC_SPL_MAX_LPC_ORDER],
P[WEBRTC_SPL_MAX_LPC_ORDER], W[WEBRTC_SPL_MAX_LPC_ORDER]; P[WEBRTC_SPL_MAX_LPC_ORDER], W[WEBRTC_SPL_MAX_LPC_ORDER];
// Initialize loop and pointers. // Initialize loop and pointers.
@ -36,13 +36,13 @@ void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32 *R, int use_order, WebRt
// First loop; n=0. Determine shifting. // First loop; n=0. Determine shifting.
tmp = WebRtcSpl_NormW32(*R); tmp = WebRtcSpl_NormW32(*R);
*acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); *acfptr = (int16_t)((*rptr++ << tmp) >> 16);
*pptr++ = *acfptr++; *pptr++ = *acfptr++;
// Initialize ACF, P and W. // Initialize ACF, P and W.
for (i = 1; i <= use_order; i++) for (i = 1; i <= use_order; i++)
{ {
*acfptr = (WebRtc_Word16)((*rptr++ << tmp) >> 16); *acfptr = (int16_t)((*rptr++ << tmp) >> 16);
*wptr++ = *acfptr; *wptr++ = *acfptr;
*pptr++ = *acfptr++; *pptr++ = *acfptr++;
} }
@ -87,15 +87,15 @@ void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32 *R, int use_order, WebRt
// Schur recursion. // Schur recursion.
pptr = P; pptr = P;
wptr = w1ptr; wptr = w1ptr;
tmp = (WebRtc_Word16)(((WebRtc_Word32)*p1ptr * (WebRtc_Word32)*K + 16384) >> 15); tmp = (int16_t)(((int32_t)*p1ptr * (int32_t)*K + 16384) >> 15);
*pptr = WEBRTC_SPL_ADD_SAT_W16( *pptr, tmp ); *pptr = WEBRTC_SPL_ADD_SAT_W16( *pptr, tmp );
pptr++; pptr++;
for (i = 1; i <= use_order - n; i++) for (i = 1; i <= use_order - n; i++)
{ {
tmp = (WebRtc_Word16)(((WebRtc_Word32)*wptr * (WebRtc_Word32)*K + 16384) >> 15); tmp = (int16_t)(((int32_t)*wptr * (int32_t)*K + 16384) >> 15);
*pptr = WEBRTC_SPL_ADD_SAT_W16( *(pptr+1), tmp ); *pptr = WEBRTC_SPL_ADD_SAT_W16( *(pptr+1), tmp );
pptr++; pptr++;
tmp = (WebRtc_Word16)(((WebRtc_Word32)*pptr * (WebRtc_Word32)*K + 16384) >> 15); tmp = (int16_t)(((int32_t)*pptr * (int32_t)*K + 16384) >> 15);
*wptr = WEBRTC_SPL_ADD_SAT_W16( *wptr, tmp ); *wptr = WEBRTC_SPL_ADD_SAT_W16( *wptr, tmp );
wptr++; wptr++;
} }

View File

@ -24,7 +24,7 @@
#define CIFFTSFT 14 #define CIFFTSFT 14
#define CIFFTRND 1 #define CIFFTRND 1
static const WebRtc_Word16 kSinTable1024[] = { static const int16_t kSinTable1024[] = {
0, 201, 402, 603, 804, 1005, 1206, 1406, 0, 201, 402, 603, 804, 1005, 1206, 1406,
1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011, 1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011,
3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608, 3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608,
@ -156,11 +156,11 @@ static const WebRtc_Word16 kSinTable1024[] = {
-1607, -1406, -1206, -1005, -804, -603, -402, -201 -1607, -1406, -1206, -1005, -804, -603, -402, -201
}; };
int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode) int WebRtcSpl_ComplexFFT(int16_t frfi[], int stages, int mode)
{ {
int i, j, l, k, istep, n, m; int i, j, l, k, istep, n, m;
WebRtc_Word16 wr, wi; int16_t wr, wi;
WebRtc_Word32 tr32, ti32, qr32, qi32; int32_t tr32, ti32, qr32, qi32;
/* The 1024-value is a constant given from the size of kSinTable1024[], /* The 1024-value is a constant given from the size of kSinTable1024[],
* and should not be changed depending on the input parameter 'stages' * and should not be changed depending on the input parameter 'stages'
@ -201,12 +201,12 @@ int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode)
ti32 = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) ti32 = WEBRTC_SPL_RSHIFT_W32((WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1])
+ WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j])), 15); + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j])), 15);
qr32 = (WebRtc_Word32)frfi[2 * i]; qr32 = (int32_t)frfi[2 * i];
qi32 = (WebRtc_Word32)frfi[2 * i + 1]; qi32 = (int32_t)frfi[2 * i + 1];
frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, 1); frfi[2 * j] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, 1);
frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, 1); frfi[2 * j + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, 1);
frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, 1); frfi[2 * i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, 1);
frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, 1); frfi[2 * i + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, 1);
} }
} }
@ -234,10 +234,10 @@ int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode)
wi = -kSinTable1024[j]; wi = -kSinTable1024[j];
#ifdef WEBRTC_ARCH_ARM_V7 #ifdef WEBRTC_ARCH_ARM_V7
WebRtc_Word32 wri = 0; int32_t wri = 0;
WebRtc_Word32 frfi_r = 0; int32_t frfi_r = 0;
__asm __volatile("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) : __asm __volatile("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) :
"r"((WebRtc_Word32)wr), "r"((WebRtc_Word32)wi)); "r"((int32_t)wr), "r"((int32_t)wi));
#endif #endif
for (i = m; i < n; i += istep) for (i = m; i < n; i += istep)
@ -252,8 +252,8 @@ int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode)
:[frfi_r]"+r"(frfi_r), :[frfi_r]"+r"(frfi_r),
[tr32]"=r"(tr32), [tr32]"=r"(tr32),
[ti32]"=r"(ti32) [ti32]"=r"(ti32)
:[frfi_even]"r"((WebRtc_Word32)frfi[2*j]), :[frfi_even]"r"((int32_t)frfi[2*j]),
[frfi_odd]"r"((WebRtc_Word32)frfi[2*j +1]), [frfi_odd]"r"((int32_t)frfi[2*j +1]),
[wri]"r"(wri), [wri]"r"(wri),
[cfftrnd]"r"(CFFTRND) [cfftrnd]"r"(CFFTRND)
); );
@ -269,16 +269,16 @@ int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode)
tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CFFTSFT); tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CFFTSFT);
ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CFFTSFT); ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CFFTSFT);
qr32 = ((WebRtc_Word32)frfi[2 * i]) << CFFTSFT; qr32 = ((int32_t)frfi[2 * i]) << CFFTSFT;
qi32 = ((WebRtc_Word32)frfi[2 * i + 1]) << CFFTSFT; qi32 = ((int32_t)frfi[2 * i + 1]) << CFFTSFT;
frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * j] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qr32 - tr32 + CFFTRND2), 1 + CFFTSFT); (qr32 - tr32 + CFFTRND2), 1 + CFFTSFT);
frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * j + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qi32 - ti32 + CFFTRND2), 1 + CFFTSFT); (qi32 - ti32 + CFFTRND2), 1 + CFFTSFT);
frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qr32 + tr32 + CFFTRND2), 1 + CFFTSFT); (qr32 + tr32 + CFFTRND2), 1 + CFFTSFT);
frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * i + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qi32 + ti32 + CFFTRND2), 1 + CFFTSFT); (qi32 + ti32 + CFFTRND2), 1 + CFFTSFT);
} }
} }
@ -290,12 +290,12 @@ int WebRtcSpl_ComplexFFT(WebRtc_Word16 frfi[], int stages, int mode)
return 0; return 0;
} }
int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode) int WebRtcSpl_ComplexIFFT(int16_t frfi[], int stages, int mode)
{ {
int i, j, l, k, istep, n, m, scale, shift; int i, j, l, k, istep, n, m, scale, shift;
WebRtc_Word16 wr, wi; int16_t wr, wi;
WebRtc_Word32 tr32, ti32, qr32, qi32; int32_t tr32, ti32, qr32, qi32;
WebRtc_Word32 tmp32, round2; int32_t tmp32, round2;
/* The 1024-value is a constant given from the size of kSinTable1024[], /* The 1024-value is a constant given from the size of kSinTable1024[],
* and should not be changed depending on the input parameter 'stages' * and should not be changed depending on the input parameter 'stages'
@ -316,7 +316,7 @@ int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode)
shift = 0; shift = 0;
round2 = 8192; round2 = 8192;
tmp32 = (WebRtc_Word32)WebRtcSpl_MaxAbsValueW16(frfi, 2 * n); tmp32 = (int32_t)WebRtcSpl_MaxAbsValueW16(frfi, 2 * n);
if (tmp32 > 13573) if (tmp32 > 13573)
{ {
shift++; shift++;
@ -357,12 +357,12 @@ int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode)
(WEBRTC_SPL_MUL_16_16_RSFT(wr, frfi[2 * j + 1], 0) (WEBRTC_SPL_MUL_16_16_RSFT(wr, frfi[2 * j + 1], 0)
+ WEBRTC_SPL_MUL_16_16_RSFT(wi,frfi[2*j],0)), 15); + WEBRTC_SPL_MUL_16_16_RSFT(wi,frfi[2*j],0)), 15);
qr32 = (WebRtc_Word32)frfi[2 * i]; qr32 = (int32_t)frfi[2 * i];
qi32 = (WebRtc_Word32)frfi[2 * i + 1]; qi32 = (int32_t)frfi[2 * i + 1];
frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, shift); frfi[2 * j] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qr32 - tr32, shift);
frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, shift); frfi[2 * j + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qi32 - ti32, shift);
frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, shift); frfi[2 * i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qr32 + tr32, shift);
frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, shift); frfi[2 * i + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(qi32 + ti32, shift);
} }
} }
} else } else
@ -381,10 +381,10 @@ int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode)
wi = kSinTable1024[j]; wi = kSinTable1024[j];
#ifdef WEBRTC_ARCH_ARM_V7 #ifdef WEBRTC_ARCH_ARM_V7
WebRtc_Word32 wri = 0; int32_t wri = 0;
WebRtc_Word32 frfi_r = 0; int32_t frfi_r = 0;
__asm __volatile("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) : __asm __volatile("pkhbt %0, %1, %2, lsl #16" : "=r"(wri) :
"r"((WebRtc_Word32)wr), "r"((WebRtc_Word32)wi)); "r"((int32_t)wr), "r"((int32_t)wi));
#endif #endif
for (i = m; i < n; i += istep) for (i = m; i < n; i += istep)
@ -399,8 +399,8 @@ int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode)
:[frfi_r]"+r"(frfi_r), :[frfi_r]"+r"(frfi_r),
[tr32]"=r"(tr32), [tr32]"=r"(tr32),
[ti32]"=r"(ti32) [ti32]"=r"(ti32)
:[frfi_even]"r"((WebRtc_Word32)frfi[2*j]), :[frfi_even]"r"((int32_t)frfi[2*j]),
[frfi_odd]"r"((WebRtc_Word32)frfi[2*j +1]), [frfi_odd]"r"((int32_t)frfi[2*j +1]),
[wri]"r"(wri), [wri]"r"(wri),
[cifftrnd]"r"(CIFFTRND) [cifftrnd]"r"(CIFFTRND)
); );
@ -415,16 +415,16 @@ int WebRtcSpl_ComplexIFFT(WebRtc_Word16 frfi[], int stages, int mode)
tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CIFFTSFT); tr32 = WEBRTC_SPL_RSHIFT_W32(tr32, 15 - CIFFTSFT);
ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CIFFTSFT); ti32 = WEBRTC_SPL_RSHIFT_W32(ti32, 15 - CIFFTSFT);
qr32 = ((WebRtc_Word32)frfi[2 * i]) << CIFFTSFT; qr32 = ((int32_t)frfi[2 * i]) << CIFFTSFT;
qi32 = ((WebRtc_Word32)frfi[2 * i + 1]) << CIFFTSFT; qi32 = ((int32_t)frfi[2 * i + 1]) << CIFFTSFT;
frfi[2 * j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((qr32 - tr32+round2), frfi[2 * j] = (int16_t)WEBRTC_SPL_RSHIFT_W32((qr32 - tr32+round2),
shift+CIFFTSFT); shift+CIFFTSFT);
frfi[2 * j + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * j + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qi32 - ti32 + round2), shift + CIFFTSFT); (qi32 - ti32 + round2), shift + CIFFTSFT);
frfi[2 * i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((qr32 + tr32 + round2), frfi[2 * i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((qr32 + tr32 + round2),
shift + CIFFTSFT); shift + CIFFTSFT);
frfi[2 * i + 1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32( frfi[2 * i + 1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(
(qi32 + ti32 + round2), shift + CIFFTSFT); (qi32 + ti32 + round2), shift + CIFFTSFT);
} }
} }

View File

@ -28,10 +28,10 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_MemSetW16(WebRtc_Word16 *ptr, WebRtc_Word16 set_value, int length) void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, int length)
{ {
int j; int j;
WebRtc_Word16 *arrptr = ptr; int16_t *arrptr = ptr;
for (j = length; j > 0; j--) for (j = length; j > 0; j--)
{ {
@ -39,10 +39,10 @@ void WebRtcSpl_MemSetW16(WebRtc_Word16 *ptr, WebRtc_Word16 set_value, int length
} }
} }
void WebRtcSpl_MemSetW32(WebRtc_Word32 *ptr, WebRtc_Word32 set_value, int length) void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, int length)
{ {
int j; int j;
WebRtc_Word32 *arrptr = ptr; int32_t *arrptr = ptr;
for (j = length; j > 0; j--) for (j = length; j > 0; j--)
{ {
@ -50,11 +50,11 @@ void WebRtcSpl_MemSetW32(WebRtc_Word32 *ptr, WebRtc_Word32 set_value, int length
} }
} }
void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* dest, WebRtc_Word16* source, int length) void WebRtcSpl_MemCpyReversedOrder(int16_t* dest, int16_t* source, int length)
{ {
int j; int j;
WebRtc_Word16* destPtr = dest; int16_t* destPtr = dest;
WebRtc_Word16* sourcePtr = source; int16_t* sourcePtr = source;
for (j = 0; j < length; j++) for (j = 0; j < length; j++)
{ {
@ -62,10 +62,10 @@ void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* dest, WebRtc_Word16* source, i
} }
} }
WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 *vector_in, int16_t WebRtcSpl_CopyFromEndW16(G_CONST int16_t *vector_in,
WebRtc_Word16 length, int16_t length,
WebRtc_Word16 samples, int16_t samples,
WebRtc_Word16 *vector_out) int16_t *vector_out)
{ {
// Copy the last <samples> of the input vector to vector_out // Copy the last <samples> of the input vector to vector_out
WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples); WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples);
@ -73,22 +73,22 @@ WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16 *vector_in,
return samples; return samples;
} }
WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) int16_t WebRtcSpl_ZerosArrayW16(int16_t *vector, int16_t length)
{ {
WebRtcSpl_MemSetW16(vector, 0, length); WebRtcSpl_MemSetW16(vector, 0, length);
return length; return length;
} }
WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) int16_t WebRtcSpl_ZerosArrayW32(int32_t *vector, int16_t length)
{ {
WebRtcSpl_MemSetW32(vector, 0, length); WebRtcSpl_MemSetW32(vector, 0, length);
return length; return length;
} }
WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length) int16_t WebRtcSpl_OnesArrayW16(int16_t *vector, int16_t length)
{ {
WebRtc_Word16 i; int16_t i;
WebRtc_Word16 *tmpvec = vector; int16_t *tmpvec = vector;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
*tmpvec++ = 1; *tmpvec++ = 1;
@ -96,10 +96,10 @@ WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16 *vector, WebRtc_Word16 length
return length; return length;
} }
WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32 *vector, WebRtc_Word16 length) int16_t WebRtcSpl_OnesArrayW32(int32_t *vector, int16_t length)
{ {
WebRtc_Word16 i; int16_t i;
WebRtc_Word32 *tmpvec = vector; int32_t *tmpvec = vector;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
*tmpvec++ = 1; *tmpvec++ = 1;

View File

@ -100,13 +100,13 @@ POST_LOOP_DIM_SEQ_RESIDUAL: @ Sum the results up and do the shift.
bx lr bx lr
@ TODO(kma): Place this piece of reference code into a C code file. @ TODO(kma): Place this piece of reference code into a C code file.
@ void WebRtcSpl_CrossCorrelationNeon(WebRtc_Word32* cross_correlation, @ void WebRtcSpl_CrossCorrelationNeon(int32_t* cross_correlation,
@ WebRtc_Word16* seq1, @ int16_t* seq1,
@ WebRtc_Word16* seq2, @ int16_t* seq2,
@ WebRtc_Word16 dim_seq, @ int16_t dim_seq,
@ WebRtc_Word16 dim_cross_correlation, @ int16_t dim_cross_correlation,
@ WebRtc_Word16 right_shifts, @ int16_t right_shifts,
@ WebRtc_Word16 step_seq2) { @ int16_t step_seq2) {
@ int i = 0; @ int i = 0;
@ int j = 0; @ int j = 0;
@ int inner_loop_len1 = dim_seq >> 3; @ int inner_loop_len1 = dim_seq >> 3;

View File

@ -23,47 +23,47 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
WebRtc_UWord32 WebRtcSpl_DivU32U16(WebRtc_UWord32 num, WebRtc_UWord16 den) uint32_t WebRtcSpl_DivU32U16(uint32_t num, uint16_t den)
{ {
// Guard against division with 0 // Guard against division with 0
if (den != 0) if (den != 0)
{ {
return (WebRtc_UWord32)(num / den); return (uint32_t)(num / den);
} else } else
{ {
return (WebRtc_UWord32)0xFFFFFFFF; return (uint32_t)0xFFFFFFFF;
} }
} }
WebRtc_Word32 WebRtcSpl_DivW32W16(WebRtc_Word32 num, WebRtc_Word16 den) int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den)
{ {
// Guard against division with 0 // Guard against division with 0
if (den != 0) if (den != 0)
{ {
return (WebRtc_Word32)(num / den); return (int32_t)(num / den);
} else } else
{ {
return (WebRtc_Word32)0x7FFFFFFF; return (int32_t)0x7FFFFFFF;
} }
} }
WebRtc_Word16 WebRtcSpl_DivW32W16ResW16(WebRtc_Word32 num, WebRtc_Word16 den) int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den)
{ {
// Guard against division with 0 // Guard against division with 0
if (den != 0) if (den != 0)
{ {
return (WebRtc_Word16)(num / den); return (int16_t)(num / den);
} else } else
{ {
return (WebRtc_Word16)0x7FFF; return (int16_t)0x7FFF;
} }
} }
WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den) int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den)
{ {
WebRtc_Word32 L_num = num; int32_t L_num = num;
WebRtc_Word32 L_den = den; int32_t L_den = den;
WebRtc_Word32 div = 0; int32_t div = 0;
int k = 31; int k = 31;
int change_sign = 0; int change_sign = 0;
@ -97,13 +97,12 @@ WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den)
return div; return div;
} }
WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi, int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low)
WebRtc_Word16 den_low)
{ {
WebRtc_Word16 approx, tmp_hi, tmp_low, num_hi, num_low; int16_t approx, tmp_hi, tmp_low, num_hi, num_low;
WebRtc_Word32 tmpW32; int32_t tmpW32;
approx = (WebRtc_Word16)WebRtcSpl_DivW32W16((WebRtc_Word32)0x1FFFFFFF, den_hi); approx = (int16_t)WebRtcSpl_DivW32W16((int32_t)0x1FFFFFFF, den_hi);
// result in Q14 (Note: 3FFFFFFF = 0.5 in Q30) // result in Q14 (Note: 3FFFFFFF = 0.5 in Q30)
// tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30) // tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30)
@ -111,26 +110,26 @@ WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi,
+ ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1); + ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1);
// tmpW32 = den * approx // tmpW32 = den * approx
tmpW32 = (WebRtc_Word32)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx)) tmpW32 = (int32_t)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx))
// Store tmpW32 in hi and low format // Store tmpW32 in hi and low format
tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16);
tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((tmpW32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
// tmpW32 = 1/den in Q29 // tmpW32 = 1/den in Q29
tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx) tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx)
>> 15)) << 1); >> 15)) << 1);
// 1/den in hi and low format // 1/den in hi and low format
tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16); tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmpW32, 16);
tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((tmpW32 tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((tmpW32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
// Store num in hi and low format // Store num in hi and low format
num_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(num, 16); num_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(num, 16);
num_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((num num_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((num
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)num_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)num_hi, 16)), 1);
// num * (1/den) by 32 bit multiplication (result in Q28) // num * (1/den) by 32 bit multiplication (result in Q28)

View File

@ -17,13 +17,13 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
WebRtc_Word32 WebRtcSpl_Energy(WebRtc_Word16* vector, int vector_length, int* scale_factor) int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor)
{ {
WebRtc_Word32 en = 0; int32_t en = 0;
int i; int i;
int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length); int scaling = WebRtcSpl_GetScalingSquare(vector, vector_length, vector_length);
int looptimes = vector_length; int looptimes = vector_length;
WebRtc_Word16 *vectorptr = vector; int16_t *vectorptr = vector;
for (i = 0; i < looptimes; i++) for (i = 0; i < looptimes; i++)
{ {

View File

@ -17,36 +17,36 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* a, int WebRtcSpl_FilterAR(G_CONST int16_t* a,
int a_length, int a_length,
G_CONST WebRtc_Word16* x, G_CONST int16_t* x,
int x_length, int x_length,
WebRtc_Word16* state, int16_t* state,
int state_length, int state_length,
WebRtc_Word16* state_low, int16_t* state_low,
int state_low_length, int state_low_length,
WebRtc_Word16* filtered, int16_t* filtered,
WebRtc_Word16* filtered_low, int16_t* filtered_low,
int filtered_low_length) int filtered_low_length)
{ {
WebRtc_Word32 o; int32_t o;
WebRtc_Word32 oLOW; int32_t oLOW;
int i, j, stop; int i, j, stop;
G_CONST WebRtc_Word16* x_ptr = &x[0]; G_CONST int16_t* x_ptr = &x[0];
WebRtc_Word16* filteredFINAL_ptr = filtered; int16_t* filteredFINAL_ptr = filtered;
WebRtc_Word16* filteredFINAL_LOW_ptr = filtered_low; int16_t* filteredFINAL_LOW_ptr = filtered_low;
for (i = 0; i < x_length; i++) for (i = 0; i < x_length; i++)
{ {
// Calculate filtered[i] and filtered_low[i] // Calculate filtered[i] and filtered_low[i]
G_CONST WebRtc_Word16* a_ptr = &a[1]; G_CONST int16_t* a_ptr = &a[1];
WebRtc_Word16* filtered_ptr = &filtered[i - 1]; int16_t* filtered_ptr = &filtered[i - 1];
WebRtc_Word16* filtered_low_ptr = &filtered_low[i - 1]; int16_t* filtered_low_ptr = &filtered_low[i - 1];
WebRtc_Word16* state_ptr = &state[state_length - 1]; int16_t* state_ptr = &state[state_length - 1];
WebRtc_Word16* state_low_ptr = &state_low[state_length - 1]; int16_t* state_low_ptr = &state_low[state_length - 1];
o = (WebRtc_Word32)(*x_ptr++) << 12; o = (int32_t)(*x_ptr++) << 12;
oLOW = (WebRtc_Word32)0; oLOW = (int32_t)0;
stop = (i < a_length) ? i + 1 : a_length; stop = (i < a_length) ? i + 1 : a_length;
for (j = 1; j < stop; j++) for (j = 1; j < stop; j++)
@ -61,8 +61,8 @@ int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* a,
} }
o += (oLOW >> 12); o += (oLOW >> 12);
*filteredFINAL_ptr = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); *filteredFINAL_ptr = (int16_t)((o + (int32_t)2048) >> 12);
*filteredFINAL_LOW_ptr++ = (WebRtc_Word16)(o - ((WebRtc_Word32)(*filteredFINAL_ptr++) *filteredFINAL_LOW_ptr++ = (int16_t)(o - ((int32_t)(*filteredFINAL_ptr++)
<< 12)); << 12));
} }

View File

@ -17,20 +17,20 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_ptr, void WebRtcSpl_FilterMAFastQ12(int16_t* in_ptr,
WebRtc_Word16* out_ptr, int16_t* out_ptr,
WebRtc_Word16* B, int16_t* B,
WebRtc_Word16 B_length, int16_t B_length,
WebRtc_Word16 length) int16_t length)
{ {
WebRtc_Word32 o; int32_t o;
int i, j; int i, j;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
G_CONST WebRtc_Word16* b_ptr = &B[0]; G_CONST int16_t* b_ptr = &B[0];
G_CONST WebRtc_Word16* x_ptr = &in_ptr[i]; G_CONST int16_t* x_ptr = &in_ptr[i];
o = (WebRtc_Word32)0; o = (int32_t)0;
for (j = 0; j < B_length; j++) for (j = 0; j < B_length; j++)
{ {
@ -41,9 +41,9 @@ void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_ptr,
// 2^27 = 134217728, which corresponds to 32768 in Q12 // 2^27 = 134217728, which corresponds to 32768 in Q12
// Saturate the output // Saturate the output
o = WEBRTC_SPL_SAT((WebRtc_Word32)134215679, o, (WebRtc_Word32)-134217728); o = WEBRTC_SPL_SAT((int32_t)134215679, o, (int32_t)-134217728);
*out_ptr++ = (WebRtc_Word16)((o + (WebRtc_Word32)2048) >> 12); *out_ptr++ = (int16_t)((o + (int32_t)2048) >> 12);
} }
return; return;
} }

View File

@ -18,7 +18,7 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
// Hanning table with 256 entries // Hanning table with 256 entries
static const WebRtc_Word16 kHanningTable[] = { static const int16_t kHanningTable[] = {
1, 2, 6, 10, 15, 22, 30, 39, 1, 2, 6, 10, 15, 22, 30, 39,
50, 62, 75, 89, 104, 121, 138, 157, 50, 62, 75, 89, 104, 121, 138, 157,
178, 199, 222, 246, 271, 297, 324, 353, 178, 199, 222, 246, 271, 297, 324, 353,
@ -53,19 +53,19 @@ static const WebRtc_Word16 kHanningTable[] = {
16354, 16362, 16369, 16374, 16378, 16382, 16383, 16384 16354, 16362, 16369, 16374, 16378, 16382, 16383, 16384
}; };
void WebRtcSpl_GetHanningWindow(WebRtc_Word16 *v, WebRtc_Word16 size) void WebRtcSpl_GetHanningWindow(int16_t *v, int16_t size)
{ {
int jj; int jj;
WebRtc_Word16 *vptr1; int16_t *vptr1;
WebRtc_Word32 index; int32_t index;
WebRtc_Word32 factor = ((WebRtc_Word32)0x40000000); int32_t factor = ((int32_t)0x40000000);
factor = WebRtcSpl_DivW32W16(factor, size); factor = WebRtcSpl_DivW32W16(factor, size);
if (size < 513) if (size < 513)
index = (WebRtc_Word32)-0x200000; index = (int32_t)-0x200000;
else else
index = (WebRtc_Word32)-0x100000; index = (int32_t)-0x100000;
vptr1 = v; vptr1 = v;
for (jj = 0; jj < size; jj++) for (jj = 0; jj < size; jj++)

View File

@ -17,13 +17,13 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
int WebRtcSpl_GetScalingSquare(WebRtc_Word16 *in_vector, int in_vector_length, int times) int WebRtcSpl_GetScalingSquare(int16_t *in_vector, int in_vector_length, int times)
{ {
int nbits = WebRtcSpl_GetSizeInBits(times); int nbits = WebRtcSpl_GetSizeInBits(times);
int i; int i;
WebRtc_Word16 smax = -1; int16_t smax = -1;
WebRtc_Word16 sabs; int16_t sabs;
WebRtc_Word16 *sptr = in_vector; int16_t *sptr = in_vector;
int t; int t;
int looptimes = in_vector_length; int looptimes = in_vector_length;

View File

@ -21,81 +21,81 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_ReverseOrderMultArrayElements(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in, void WebRtcSpl_ReverseOrderMultArrayElements(int16_t *out, G_CONST int16_t *in,
G_CONST WebRtc_Word16 *win, G_CONST int16_t *win,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
int i; int i;
WebRtc_Word16 *outptr = out; int16_t *outptr = out;
G_CONST WebRtc_Word16 *inptr = in; G_CONST int16_t *inptr = in;
G_CONST WebRtc_Word16 *winptr = win; G_CONST int16_t *winptr = win;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++,
*winptr--, right_shifts); *winptr--, right_shifts);
} }
} }
void WebRtcSpl_ElementwiseVectorMult(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in, void WebRtcSpl_ElementwiseVectorMult(int16_t *out, G_CONST int16_t *in,
G_CONST WebRtc_Word16 *win, WebRtc_Word16 vector_length, G_CONST int16_t *win, int16_t vector_length,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
int i; int i;
WebRtc_Word16 *outptr = out; int16_t *outptr = out;
G_CONST WebRtc_Word16 *inptr = in; G_CONST int16_t *inptr = in;
G_CONST WebRtc_Word16 *winptr = win; G_CONST int16_t *winptr = win;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++,
*winptr++, right_shifts); *winptr++, right_shifts);
} }
} }
void WebRtcSpl_AddVectorsAndShift(WebRtc_Word16 *out, G_CONST WebRtc_Word16 *in1, void WebRtcSpl_AddVectorsAndShift(int16_t *out, G_CONST int16_t *in1,
G_CONST WebRtc_Word16 *in2, WebRtc_Word16 vector_length, G_CONST int16_t *in2, int16_t vector_length,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
int i; int i;
WebRtc_Word16 *outptr = out; int16_t *outptr = out;
G_CONST WebRtc_Word16 *in1ptr = in1; G_CONST int16_t *in1ptr = in1;
G_CONST WebRtc_Word16 *in2ptr = in2; G_CONST int16_t *in2ptr = in2;
for (i = vector_length; i > 0; i--) for (i = vector_length; i > 0; i--)
{ {
(*outptr++) = (WebRtc_Word16)(((*in1ptr++) + (*in2ptr++)) >> right_shifts); (*outptr++) = (int16_t)(((*in1ptr++) + (*in2ptr++)) >> right_shifts);
} }
} }
void WebRtcSpl_AddAffineVectorToVector(WebRtc_Word16 *out, WebRtc_Word16 *in, void WebRtcSpl_AddAffineVectorToVector(int16_t *out, int16_t *in,
WebRtc_Word16 gain, WebRtc_Word32 add_constant, int16_t gain, int32_t add_constant,
WebRtc_Word16 right_shifts, int vector_length) int16_t right_shifts, int vector_length)
{ {
WebRtc_Word16 *inPtr; int16_t *inPtr;
WebRtc_Word16 *outPtr; int16_t *outPtr;
int i; int i;
inPtr = in; inPtr = in;
outPtr = out; outPtr = out;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outPtr++) += (WebRtc_Word16)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) (*outPtr++) += (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain)
+ (WebRtc_Word32)add_constant) >> right_shifts); + (int32_t)add_constant) >> right_shifts);
} }
} }
void WebRtcSpl_AffineTransformVector(WebRtc_Word16 *out, WebRtc_Word16 *in, void WebRtcSpl_AffineTransformVector(int16_t *out, int16_t *in,
WebRtc_Word16 gain, WebRtc_Word32 add_constant, int16_t gain, int32_t add_constant,
WebRtc_Word16 right_shifts, int vector_length) int16_t right_shifts, int vector_length)
{ {
WebRtc_Word16 *inPtr; int16_t *inPtr;
WebRtc_Word16 *outPtr; int16_t *outPtr;
int i; int i;
inPtr = in; inPtr = in;
outPtr = out; outPtr = out;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outPtr++) = (WebRtc_Word16)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) (*outPtr++) = (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain)
+ (WebRtc_Word32)add_constant) >> right_shifts); + (int32_t)add_constant) >> right_shifts);
} }
} }

View File

@ -24,8 +24,8 @@
// Macros specific for the fixed point implementation // Macros specific for the fixed point implementation
#define WEBRTC_SPL_WORD16_MAX 32767 #define WEBRTC_SPL_WORD16_MAX 32767
#define WEBRTC_SPL_WORD16_MIN -32768 #define WEBRTC_SPL_WORD16_MIN -32768
#define WEBRTC_SPL_WORD32_MAX (WebRtc_Word32)0x7fffffff #define WEBRTC_SPL_WORD32_MAX (int32_t)0x7fffffff
#define WEBRTC_SPL_WORD32_MIN (WebRtc_Word32)0x80000000 #define WEBRTC_SPL_WORD32_MIN (int32_t)0x80000000
#define WEBRTC_SPL_MAX_LPC_ORDER 14 #define WEBRTC_SPL_MAX_LPC_ORDER 14
#define WEBRTC_SPL_MAX_SEED_USED 0x80000000L #define WEBRTC_SPL_MAX_SEED_USED 0x80000000L
#define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value #define WEBRTC_SPL_MIN(A, B) (A < B ? A : B) // Get min value
@ -33,83 +33,83 @@
// TODO(kma/bjorn): For the next two macros, investigate how to correct the code // TODO(kma/bjorn): For the next two macros, investigate how to correct the code
// for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN. // for inputs of a = WEBRTC_SPL_WORD16_MIN or WEBRTC_SPL_WORD32_MIN.
#define WEBRTC_SPL_ABS_W16(a) \ #define WEBRTC_SPL_ABS_W16(a) \
(((WebRtc_Word16)a >= 0) ? ((WebRtc_Word16)a) : -((WebRtc_Word16)a)) (((int16_t)a >= 0) ? ((int16_t)a) : -((int16_t)a))
#define WEBRTC_SPL_ABS_W32(a) \ #define WEBRTC_SPL_ABS_W32(a) \
(((WebRtc_Word32)a >= 0) ? ((WebRtc_Word32)a) : -((WebRtc_Word32)a)) (((int32_t)a >= 0) ? ((int32_t)a) : -((int32_t)a))
#ifdef WEBRTC_ARCH_LITTLE_ENDIAN #ifdef WEBRTC_ARCH_LITTLE_ENDIAN
#define WEBRTC_SPL_GET_BYTE(a, nr) (((WebRtc_Word8 *)a)[nr]) #define WEBRTC_SPL_GET_BYTE(a, nr) (((int8_t *)a)[nr])
#define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \ #define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \
(((WebRtc_Word8 *)d_ptr)[index] = (val)) (((int8_t *)d_ptr)[index] = (val))
#else #else
#define WEBRTC_SPL_GET_BYTE(a, nr) \ #define WEBRTC_SPL_GET_BYTE(a, nr) \
((((WebRtc_Word16 *)a)[nr >> 1]) >> (((nr + 1) & 0x1) * 8) & 0x00ff) ((((int16_t *)a)[nr >> 1]) >> (((nr + 1) & 0x1) * 8) & 0x00ff)
#define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \ #define WEBRTC_SPL_SET_BYTE(d_ptr, val, index) \
((WebRtc_Word16 *)d_ptr)[index >> 1] = \ ((int16_t *)d_ptr)[index >> 1] = \
((((WebRtc_Word16 *)d_ptr)[index >> 1]) \ ((((int16_t *)d_ptr)[index >> 1]) \
& (0x00ff << (8 * ((index) & 0x1)))) | (val << (8 * ((index + 1) & 0x1))) & (0x00ff << (8 * ((index) & 0x1)))) | (val << (8 * ((index + 1) & 0x1)))
#endif #endif
#define WEBRTC_SPL_MUL(a, b) \ #define WEBRTC_SPL_MUL(a, b) \
((WebRtc_Word32) ((WebRtc_Word32)(a) * (WebRtc_Word32)(b))) ((int32_t) ((int32_t)(a) * (int32_t)(b)))
#define WEBRTC_SPL_UMUL(a, b) \ #define WEBRTC_SPL_UMUL(a, b) \
((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord32)(b))) ((uint32_t) ((uint32_t)(a) * (uint32_t)(b)))
#define WEBRTC_SPL_UMUL_RSFT16(a, b) \ #define WEBRTC_SPL_UMUL_RSFT16(a, b) \
((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord32)(b)) >> 16) ((uint32_t) ((uint32_t)(a) * (uint32_t)(b)) >> 16)
#define WEBRTC_SPL_UMUL_16_16(a, b) \ #define WEBRTC_SPL_UMUL_16_16(a, b) \
((WebRtc_UWord32) (WebRtc_UWord16)(a) * (WebRtc_UWord16)(b)) ((uint32_t) (uint16_t)(a) * (uint16_t)(b))
#define WEBRTC_SPL_UMUL_16_16_RSFT16(a, b) \ #define WEBRTC_SPL_UMUL_16_16_RSFT16(a, b) \
(((WebRtc_UWord32) (WebRtc_UWord16)(a) * (WebRtc_UWord16)(b)) >> 16) (((uint32_t) (uint16_t)(a) * (uint16_t)(b)) >> 16)
#define WEBRTC_SPL_UMUL_32_16(a, b) \ #define WEBRTC_SPL_UMUL_32_16(a, b) \
((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord16)(b))) ((uint32_t) ((uint32_t)(a) * (uint16_t)(b)))
#define WEBRTC_SPL_UMUL_32_16_RSFT16(a, b) \ #define WEBRTC_SPL_UMUL_32_16_RSFT16(a, b) \
((WebRtc_UWord32) ((WebRtc_UWord32)(a) * (WebRtc_UWord16)(b)) >> 16) ((uint32_t) ((uint32_t)(a) * (uint16_t)(b)) >> 16)
#define WEBRTC_SPL_MUL_16_U16(a, b) \ #define WEBRTC_SPL_MUL_16_U16(a, b) \
((WebRtc_Word32)(WebRtc_Word16)(a) * (WebRtc_UWord16)(b)) ((int32_t)(int16_t)(a) * (uint16_t)(b))
#define WEBRTC_SPL_DIV(a, b) \ #define WEBRTC_SPL_DIV(a, b) \
((WebRtc_Word32) ((WebRtc_Word32)(a) / (WebRtc_Word32)(b))) ((int32_t) ((int32_t)(a) / (int32_t)(b)))
#define WEBRTC_SPL_UDIV(a, b) \ #define WEBRTC_SPL_UDIV(a, b) \
((WebRtc_UWord32) ((WebRtc_UWord32)(a) / (WebRtc_UWord32)(b))) ((uint32_t) ((uint32_t)(a) / (uint32_t)(b)))
#ifndef WEBRTC_ARCH_ARM_V7 #ifndef WEBRTC_ARCH_ARM_V7
// For ARMv7 platforms, these are inline functions in spl_inl_armv7.h // For ARMv7 platforms, these are inline functions in spl_inl_armv7.h
#define WEBRTC_SPL_MUL_16_16(a, b) \ #define WEBRTC_SPL_MUL_16_16(a, b) \
((WebRtc_Word32) (((WebRtc_Word16)(a)) * ((WebRtc_Word16)(b)))) ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
#define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \ #define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \
(WEBRTC_SPL_MUL_16_16(a, b >> 16) \ (WEBRTC_SPL_MUL_16_16(a, b >> 16) \
+ ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15)) + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15))
#define WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, b32) \ #define WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, b32) \
((WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT16(a32a, b32) \ ((int32_t)(WEBRTC_SPL_MUL_16_32_RSFT16(a32a, b32) \
+ (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32) >> 16))) + (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32) >> 16)))
#define WEBRTC_SPL_MUL_32_32_RSFT32BI(a32, b32) \ #define WEBRTC_SPL_MUL_32_32_RSFT32BI(a32, b32) \
((WebRtc_Word32)(WEBRTC_SPL_MUL_16_32_RSFT16(( \ ((int32_t)(WEBRTC_SPL_MUL_16_32_RSFT16(( \
(WebRtc_Word16)(a32 >> 16)), b32) + \ (int16_t)(a32 >> 16)), b32) + \
(WEBRTC_SPL_MUL_16_32_RSFT16(( \ (WEBRTC_SPL_MUL_16_32_RSFT16(( \
(WebRtc_Word16)((a32 & 0x0000FFFF) >> 1)), b32) >> 15))) (int16_t)((a32 & 0x0000FFFF) >> 1)), b32) >> 15)))
#endif #endif
#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \ #define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 5) \ ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 5) \
+ (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x0200) >> 10)) + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10))
#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \ #define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 2) \ ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 2) \
+ (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x1000) >> 13)) + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13))
#define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \ #define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \
((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 1) \ ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 1) \
+ (((WEBRTC_SPL_MUL_16_U16(a, (WebRtc_UWord16)(b)) >> 1) + 0x2000) >> 14)) + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14))
#define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \ #define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \
(WEBRTC_SPL_MUL_16_16(a, b) >> (c)) (WEBRTC_SPL_MUL_16_16(a, b) >> (c))
#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \ #define WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, c) \
((WEBRTC_SPL_MUL_16_16(a, b) + ((WebRtc_Word32) \ ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) \
(((WebRtc_Word32)1) << ((c) - 1)))) >> (c)) (((int32_t)1) << ((c) - 1)))) >> (c))
#define WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(a, b) \ #define WEBRTC_SPL_MUL_16_16_RSFT_WITH_FIXROUND(a, b) \
((WEBRTC_SPL_MUL_16_16(a, b) + ((WebRtc_Word32) (1 << 14))) >> 15) ((WEBRTC_SPL_MUL_16_16(a, b) + ((int32_t) (1 << 14))) >> 15)
// C + the 32 most significant bits of A * B // C + the 32 most significant bits of A * B
#define WEBRTC_SPL_SCALEDIFF32(A, B, C) \ #define WEBRTC_SPL_SCALEDIFF32(A, B, C) \
(C + (B >> 16) * A + (((WebRtc_UWord32)(0x0000FFFF & B) * A) >> 16)) (C + (B >> 16) * A + (((uint32_t)(0x0000FFFF & B) * A) >> 16))
#define WEBRTC_SPL_ADD_SAT_W32(a, b) WebRtcSpl_AddSatW32(a, b) #define WEBRTC_SPL_ADD_SAT_W32(a, b) WebRtcSpl_AddSatW32(a, b)
#define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b) #define WEBRTC_SPL_SAT(a, b, c) (b > a ? a : b < c ? c : b)
@ -135,16 +135,16 @@
#define WEBRTC_SPL_RSHIFT_W32(x, c) ((x) >> (c)) #define WEBRTC_SPL_RSHIFT_W32(x, c) ((x) >> (c))
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c)) #define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))
#define WEBRTC_SPL_RSHIFT_U16(x, c) ((WebRtc_UWord16)(x) >> (c)) #define WEBRTC_SPL_RSHIFT_U16(x, c) ((uint16_t)(x) >> (c))
#define WEBRTC_SPL_LSHIFT_U16(x, c) ((WebRtc_UWord16)(x) << (c)) #define WEBRTC_SPL_LSHIFT_U16(x, c) ((uint16_t)(x) << (c))
#define WEBRTC_SPL_RSHIFT_U32(x, c) ((WebRtc_UWord32)(x) >> (c)) #define WEBRTC_SPL_RSHIFT_U32(x, c) ((uint32_t)(x) >> (c))
#define WEBRTC_SPL_LSHIFT_U32(x, c) ((WebRtc_UWord32)(x) << (c)) #define WEBRTC_SPL_LSHIFT_U32(x, c) ((uint32_t)(x) << (c))
#define WEBRTC_SPL_VNEW(t, n) (t *) malloc (sizeof (t) * (n)) #define WEBRTC_SPL_VNEW(t, n) (t *) malloc (sizeof (t) * (n))
#define WEBRTC_SPL_FREE free #define WEBRTC_SPL_FREE free
#define WEBRTC_SPL_RAND(a) \ #define WEBRTC_SPL_RAND(a) \
((WebRtc_Word16)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff)) ((int16_t)(WEBRTC_SPL_MUL_16_16_RSFT((a), 18816, 7) & 0x00007fff))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -153,10 +153,10 @@ extern "C" {
#define WEBRTC_SPL_MEMCPY_W8(v1, v2, length) \ #define WEBRTC_SPL_MEMCPY_W8(v1, v2, length) \
memcpy(v1, v2, (length) * sizeof(char)) memcpy(v1, v2, (length) * sizeof(char))
#define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \ #define WEBRTC_SPL_MEMCPY_W16(v1, v2, length) \
memcpy(v1, v2, (length) * sizeof(WebRtc_Word16)) memcpy(v1, v2, (length) * sizeof(int16_t))
#define WEBRTC_SPL_MEMMOVE_W16(v1, v2, length) \ #define WEBRTC_SPL_MEMMOVE_W16(v1, v2, length) \
memmove(v1, v2, (length) * sizeof(WebRtc_Word16)) memmove(v1, v2, (length) * sizeof(int16_t))
// inline functions: // inline functions:
#include "webrtc/common_audio/signal_processing/include/spl_inl.h" #include "webrtc/common_audio/signal_processing/include/spl_inl.h"
@ -172,36 +172,35 @@ extern "C" {
void WebRtcSpl_Init(); void WebRtcSpl_Init();
// Get SPL Version // Get SPL Version
WebRtc_Word16 WebRtcSpl_get_version(char* version, int16_t WebRtcSpl_get_version(char* version, int16_t length_in_bytes);
WebRtc_Word16 length_in_bytes);
int WebRtcSpl_GetScalingSquare(WebRtc_Word16* in_vector, int WebRtcSpl_GetScalingSquare(int16_t* in_vector,
int in_vector_length, int in_vector_length,
int times); int times);
// Copy and set operations. Implementation in copy_set_operations.c. // Copy and set operations. Implementation in copy_set_operations.c.
// Descriptions at bottom of file. // Descriptions at bottom of file.
void WebRtcSpl_MemSetW16(WebRtc_Word16* vector, void WebRtcSpl_MemSetW16(int16_t* vector,
WebRtc_Word16 set_value, int16_t set_value,
int vector_length); int vector_length);
void WebRtcSpl_MemSetW32(WebRtc_Word32* vector, void WebRtcSpl_MemSetW32(int32_t* vector,
WebRtc_Word32 set_value, int32_t set_value,
int vector_length); int vector_length);
void WebRtcSpl_MemCpyReversedOrder(WebRtc_Word16* out_vector, void WebRtcSpl_MemCpyReversedOrder(int16_t* out_vector,
WebRtc_Word16* in_vector, int16_t* in_vector,
int vector_length); int vector_length);
WebRtc_Word16 WebRtcSpl_CopyFromEndW16(G_CONST WebRtc_Word16* in_vector, int16_t WebRtcSpl_CopyFromEndW16(G_CONST int16_t* in_vector,
WebRtc_Word16 in_vector_length, int16_t in_vector_length,
WebRtc_Word16 samples, int16_t samples,
WebRtc_Word16* out_vector); int16_t* out_vector);
WebRtc_Word16 WebRtcSpl_ZerosArrayW16(WebRtc_Word16* vector, int16_t WebRtcSpl_ZerosArrayW16(int16_t* vector,
WebRtc_Word16 vector_length); int16_t vector_length);
WebRtc_Word16 WebRtcSpl_ZerosArrayW32(WebRtc_Word32* vector, int16_t WebRtcSpl_ZerosArrayW32(int32_t* vector,
WebRtc_Word16 vector_length); int16_t vector_length);
WebRtc_Word16 WebRtcSpl_OnesArrayW16(WebRtc_Word16* vector, int16_t WebRtcSpl_OnesArrayW16(int16_t* vector,
WebRtc_Word16 vector_length); int16_t vector_length);
WebRtc_Word16 WebRtcSpl_OnesArrayW32(WebRtc_Word32* vector, int16_t WebRtcSpl_OnesArrayW32(int32_t* vector,
WebRtc_Word16 vector_length); int16_t vector_length);
// End: Copy and set operations. // End: Copy and set operations.
@ -386,33 +385,33 @@ int WebRtcSpl_MinIndexW32(const int32_t* vector, int length);
// Vector scaling operations. Implementation in vector_scaling_operations.c. // Vector scaling operations. Implementation in vector_scaling_operations.c.
// Description at bottom of file. // Description at bottom of file.
void WebRtcSpl_VectorBitShiftW16(WebRtc_Word16* out_vector, void WebRtcSpl_VectorBitShiftW16(int16_t* out_vector,
WebRtc_Word16 vector_length, int16_t vector_length,
G_CONST WebRtc_Word16* in_vector, G_CONST int16_t* in_vector,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_VectorBitShiftW32(WebRtc_Word32* out_vector, void WebRtcSpl_VectorBitShiftW32(int32_t* out_vector,
WebRtc_Word16 vector_length, int16_t vector_length,
G_CONST WebRtc_Word32* in_vector, G_CONST int32_t* in_vector,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_VectorBitShiftW32ToW16(int16_t* out_vector, void WebRtcSpl_VectorBitShiftW32ToW16(int16_t* out_vector,
int vector_length, int vector_length,
const int32_t* in_vector, const int32_t* in_vector,
int right_shifts); int right_shifts);
void WebRtcSpl_ScaleVector(G_CONST WebRtc_Word16* in_vector, void WebRtcSpl_ScaleVector(G_CONST int16_t* in_vector,
WebRtc_Word16* out_vector, int16_t* out_vector,
WebRtc_Word16 gain, int16_t gain,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_ScaleVectorWithSat(G_CONST WebRtc_Word16* in_vector, void WebRtcSpl_ScaleVectorWithSat(G_CONST int16_t* in_vector,
WebRtc_Word16* out_vector, int16_t* out_vector,
WebRtc_Word16 gain, int16_t gain,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_ScaleAndAddVectors(G_CONST WebRtc_Word16* in_vector1, void WebRtcSpl_ScaleAndAddVectors(G_CONST int16_t* in_vector1,
WebRtc_Word16 gain1, int right_shifts1, int16_t gain1, int right_shifts1,
G_CONST WebRtc_Word16* in_vector2, G_CONST int16_t* in_vector2,
WebRtc_Word16 gain2, int right_shifts2, int16_t gain2, int right_shifts2,
WebRtc_Word16* out_vector, int16_t* out_vector,
int vector_length); int vector_length);
// The functions (with related pointer) perform the vector operation: // The functions (with related pointer) perform the vector operation:
@ -461,32 +460,32 @@ int WebRtcSpl_ScaleAndAddVectorsWithRoundNeon(const int16_t* in_vector1,
// iLBC specific functions. Implementations in ilbc_specific_functions.c. // iLBC specific functions. Implementations in ilbc_specific_functions.c.
// Description at bottom of file. // Description at bottom of file.
void WebRtcSpl_ReverseOrderMultArrayElements(WebRtc_Word16* out_vector, void WebRtcSpl_ReverseOrderMultArrayElements(int16_t* out_vector,
G_CONST WebRtc_Word16* in_vector, G_CONST int16_t* in_vector,
G_CONST WebRtc_Word16* window, G_CONST int16_t* window,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_ElementwiseVectorMult(WebRtc_Word16* out_vector, void WebRtcSpl_ElementwiseVectorMult(int16_t* out_vector,
G_CONST WebRtc_Word16* in_vector, G_CONST int16_t* in_vector,
G_CONST WebRtc_Word16* window, G_CONST int16_t* window,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_AddVectorsAndShift(WebRtc_Word16* out_vector, void WebRtcSpl_AddVectorsAndShift(int16_t* out_vector,
G_CONST WebRtc_Word16* in_vector1, G_CONST int16_t* in_vector1,
G_CONST WebRtc_Word16* in_vector2, G_CONST int16_t* in_vector2,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_Word16 right_shifts); int16_t right_shifts);
void WebRtcSpl_AddAffineVectorToVector(WebRtc_Word16* out_vector, void WebRtcSpl_AddAffineVectorToVector(int16_t* out_vector,
WebRtc_Word16* in_vector, int16_t* in_vector,
WebRtc_Word16 gain, int16_t gain,
WebRtc_Word32 add_constant, int32_t add_constant,
WebRtc_Word16 right_shifts, int16_t right_shifts,
int vector_length); int vector_length);
void WebRtcSpl_AffineTransformVector(WebRtc_Word16* out_vector, void WebRtcSpl_AffineTransformVector(int16_t* out_vector,
WebRtc_Word16* in_vector, int16_t* in_vector,
WebRtc_Word16 gain, int16_t gain,
WebRtc_Word32 add_constant, int32_t add_constant,
WebRtc_Word16 right_shifts, int16_t right_shifts,
int vector_length); int vector_length);
// End: iLBC specific functions. // End: iLBC specific functions.
@ -531,10 +530,10 @@ int WebRtcSpl_AutoCorrelation(const int16_t* in_vector,
// Q15 // Q15
// //
// Return value : 1 for stable 0 for unstable // Return value : 1 for stable 0 for unstable
WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32* auto_corr, int16_t WebRtcSpl_LevinsonDurbin(int32_t* auto_corr,
WebRtc_Word16* lpc_coef, int16_t* lpc_coef,
WebRtc_Word16* refl_coef, int16_t* refl_coef,
WebRtc_Word16 order); int16_t order);
// Converts reflection coefficients |refl_coef| to LPC coefficients |lpc_coef|. // Converts reflection coefficients |refl_coef| to LPC coefficients |lpc_coef|.
// This version is a 16 bit operation. // This version is a 16 bit operation.
@ -550,9 +549,9 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32* auto_corr,
// //
// Output: // Output:
// - lpc_coef : LPC coefficients in Q12 // - lpc_coef : LPC coefficients in Q12
void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16* refl_coef, void WebRtcSpl_ReflCoefToLpc(G_CONST int16_t* refl_coef,
int use_order, int use_order,
WebRtc_Word16* lpc_coef); int16_t* lpc_coef);
// Converts LPC coefficients |lpc_coef| to reflection coefficients |refl_coef|. // Converts LPC coefficients |lpc_coef| to reflection coefficients |refl_coef|.
// This version is a 16 bit operation. // This version is a 16 bit operation.
@ -565,9 +564,9 @@ void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16* refl_coef,
// //
// Output: // Output:
// - refl_coef : Reflection coefficients in Q15. // - refl_coef : Reflection coefficients in Q15.
void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* lpc_coef, void WebRtcSpl_LpcToReflCoef(int16_t* lpc_coef,
int use_order, int use_order,
WebRtc_Word16* refl_coef); int16_t* refl_coef);
// Calculates reflection coefficients (16 bit) from auto-correlation values // Calculates reflection coefficients (16 bit) from auto-correlation values
// //
@ -577,9 +576,9 @@ void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* lpc_coef,
// //
// Output: // Output:
// - refl_coef : Reflection coefficients in Q15. // - refl_coef : Reflection coefficients in Q15.
void WebRtcSpl_AutoCorrToReflCoef(G_CONST WebRtc_Word32* auto_corr, void WebRtcSpl_AutoCorrToReflCoef(G_CONST int32_t* auto_corr,
int use_order, int use_order,
WebRtc_Word16* refl_coef); int16_t* refl_coef);
// The functions (with related pointer) calculate the cross-correlation between // The functions (with related pointer) calculate the cross-correlation between
// two sequences |seq1| and |seq2|. // two sequences |seq1| and |seq2|.
@ -637,7 +636,7 @@ void WebRtcSpl_CrossCorrelationNeon(int32_t* cross_correlation,
// //
// Output: // Output:
// - window : Hanning vector in Q14. // - window : Hanning vector in Q14.
void WebRtcSpl_GetHanningWindow(WebRtc_Word16* window, WebRtc_Word16 size); void WebRtcSpl_GetHanningWindow(int16_t* window, int16_t size);
// Calculates y[k] = sqrt(1 - x[k]^2) for each element of the input vector // Calculates y[k] = sqrt(1 - x[k]^2) for each element of the input vector
// |in_vector|. Input and output values are in Q15. // |in_vector|. Input and output values are in Q15.
@ -648,40 +647,37 @@ void WebRtcSpl_GetHanningWindow(WebRtc_Word16* window, WebRtc_Word16 size);
// //
// Output: // Output:
// - out_vector : Output values in Q15 // - out_vector : Output values in Q15
void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16* in_vector, void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t* in_vector,
int vector_length, int vector_length,
WebRtc_Word16* out_vector); int16_t* out_vector);
// End: Signal processing operations. // End: Signal processing operations.
// Randomization functions. Implementations collected in // Randomization functions. Implementations collected in
// randomization_functions.c and descriptions at bottom of this file. // randomization_functions.c and descriptions at bottom of this file.
WebRtc_UWord32 WebRtcSpl_IncreaseSeed(WebRtc_UWord32* seed); uint32_t WebRtcSpl_IncreaseSeed(uint32_t* seed);
WebRtc_Word16 WebRtcSpl_RandU(WebRtc_UWord32* seed); int16_t WebRtcSpl_RandU(uint32_t* seed);
WebRtc_Word16 WebRtcSpl_RandN(WebRtc_UWord32* seed); int16_t WebRtcSpl_RandN(uint32_t* seed);
WebRtc_Word16 WebRtcSpl_RandUArray(WebRtc_Word16* vector, int16_t WebRtcSpl_RandUArray(int16_t* vector,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_UWord32* seed); uint32_t* seed);
// End: Randomization functions. // End: Randomization functions.
// Math functions // Math functions
WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value); int32_t WebRtcSpl_Sqrt(int32_t value);
WebRtc_Word32 WebRtcSpl_SqrtFloor(WebRtc_Word32 value); int32_t WebRtcSpl_SqrtFloor(int32_t value);
// Divisions. Implementations collected in division_operations.c and // Divisions. Implementations collected in division_operations.c and
// descriptions at bottom of this file. // descriptions at bottom of this file.
WebRtc_UWord32 WebRtcSpl_DivU32U16(WebRtc_UWord32 num, WebRtc_UWord16 den); uint32_t WebRtcSpl_DivU32U16(uint32_t num, uint16_t den);
WebRtc_Word32 WebRtcSpl_DivW32W16(WebRtc_Word32 num, WebRtc_Word16 den); int32_t WebRtcSpl_DivW32W16(int32_t num, int16_t den);
WebRtc_Word16 WebRtcSpl_DivW32W16ResW16(WebRtc_Word32 num, WebRtc_Word16 den); int16_t WebRtcSpl_DivW32W16ResW16(int32_t num, int16_t den);
WebRtc_Word32 WebRtcSpl_DivResultInQ31(WebRtc_Word32 num, WebRtc_Word32 den); int32_t WebRtcSpl_DivResultInQ31(int32_t num, int32_t den);
WebRtc_Word32 WebRtcSpl_DivW32HiLow(WebRtc_Word32 num, WebRtc_Word16 den_hi, int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low);
WebRtc_Word16 den_low);
// End: Divisions. // End: Divisions.
WebRtc_Word32 WebRtcSpl_Energy(WebRtc_Word16* vector, int32_t WebRtcSpl_Energy(int16_t* vector, int vector_length, int* scale_factor);
int vector_length,
int* scale_factor);
// Calculates the dot product between two (WebRtc_Word16) vectors. // Calculates the dot product between two (int16_t) vectors.
// //
// Input: // Input:
// - vector1 : Vector 1 // - vector1 : Vector 1
@ -698,23 +694,23 @@ int32_t WebRtcSpl_DotProductWithScale(const int16_t* vector1,
int scaling); int scaling);
// Filter operations. // Filter operations.
int WebRtcSpl_FilterAR(G_CONST WebRtc_Word16* ar_coef, int WebRtcSpl_FilterAR(G_CONST int16_t* ar_coef,
int ar_coef_length, int ar_coef_length,
G_CONST WebRtc_Word16* in_vector, G_CONST int16_t* in_vector,
int in_vector_length, int in_vector_length,
WebRtc_Word16* filter_state, int16_t* filter_state,
int filter_state_length, int filter_state_length,
WebRtc_Word16* filter_state_low, int16_t* filter_state_low,
int filter_state_low_length, int filter_state_low_length,
WebRtc_Word16* out_vector, int16_t* out_vector,
WebRtc_Word16* out_vector_low, int16_t* out_vector_low,
int out_vector_low_length); int out_vector_low_length);
void WebRtcSpl_FilterMAFastQ12(WebRtc_Word16* in_vector, void WebRtcSpl_FilterMAFastQ12(int16_t* in_vector,
WebRtc_Word16* out_vector, int16_t* out_vector,
WebRtc_Word16* ma_coef, int16_t* ma_coef,
WebRtc_Word16 ma_coef_length, int16_t ma_coef_length,
WebRtc_Word16 vector_length); int16_t vector_length);
// Performs a AR filtering on a vector in Q12 // Performs a AR filtering on a vector in Q12
// Input: // Input:
@ -780,8 +776,8 @@ int WebRtcSpl_DownsampleFastNeon(const int16_t* data_in,
// FFT operations // FFT operations
int WebRtcSpl_ComplexFFT(WebRtc_Word16 vector[], int stages, int mode); int WebRtcSpl_ComplexFFT(int16_t vector[], int stages, int mode);
int WebRtcSpl_ComplexIFFT(WebRtc_Word16 vector[], int stages, int mode); int WebRtcSpl_ComplexIFFT(int16_t vector[], int stages, int mode);
// Treat a 16-bit complex data buffer |complex_data| as an array of 32-bit // Treat a 16-bit complex data buffer |complex_data| as an array of 32-bit
// values, and swap elements whose indexes are bit-reverses of each other. // values, and swap elements whose indexes are bit-reverses of each other.
@ -820,54 +816,54 @@ void WebRtcSpl_ComplexBitReverse(int16_t* __restrict complex_data, int stages);
// state structure for 22 -> 16 resampler // state structure for 22 -> 16 resampler
typedef struct { typedef struct {
WebRtc_Word32 S_22_44[8]; int32_t S_22_44[8];
WebRtc_Word32 S_44_32[8]; int32_t S_44_32[8];
WebRtc_Word32 S_32_16[8]; int32_t S_32_16[8];
} WebRtcSpl_State22khzTo16khz; } WebRtcSpl_State22khzTo16khz;
void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, void WebRtcSpl_Resample22khzTo16khz(const int16_t* in,
WebRtc_Word16* out, int16_t* out,
WebRtcSpl_State22khzTo16khz* state, WebRtcSpl_State22khzTo16khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state); void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state);
// state structure for 16 -> 22 resampler // state structure for 16 -> 22 resampler
typedef struct { typedef struct {
WebRtc_Word32 S_16_32[8]; int32_t S_16_32[8];
WebRtc_Word32 S_32_22[8]; int32_t S_32_22[8];
} WebRtcSpl_State16khzTo22khz; } WebRtcSpl_State16khzTo22khz;
void WebRtcSpl_Resample16khzTo22khz(const WebRtc_Word16* in, void WebRtcSpl_Resample16khzTo22khz(const int16_t* in,
WebRtc_Word16* out, int16_t* out,
WebRtcSpl_State16khzTo22khz* state, WebRtcSpl_State16khzTo22khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state); void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state);
// state structure for 22 -> 8 resampler // state structure for 22 -> 8 resampler
typedef struct { typedef struct {
WebRtc_Word32 S_22_22[16]; int32_t S_22_22[16];
WebRtc_Word32 S_22_16[8]; int32_t S_22_16[8];
WebRtc_Word32 S_16_8[8]; int32_t S_16_8[8];
} WebRtcSpl_State22khzTo8khz; } WebRtcSpl_State22khzTo8khz;
void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out,
WebRtcSpl_State22khzTo8khz* state, WebRtcSpl_State22khzTo8khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state); void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state);
// state structure for 8 -> 22 resampler // state structure for 8 -> 22 resampler
typedef struct { typedef struct {
WebRtc_Word32 S_8_16[8]; int32_t S_8_16[8];
WebRtc_Word32 S_16_11[8]; int32_t S_16_11[8];
WebRtc_Word32 S_11_22[8]; int32_t S_11_22[8];
} WebRtcSpl_State8khzTo22khz; } WebRtcSpl_State8khzTo22khz;
void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out,
WebRtcSpl_State8khzTo22khz* state, WebRtcSpl_State8khzTo22khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state); void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state);
@ -882,14 +878,14 @@ void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state);
* *
******************************************************************/ ******************************************************************/
void WebRtcSpl_Resample48khzTo32khz(const WebRtc_Word32* In, WebRtc_Word32* Out, void WebRtcSpl_Resample48khzTo32khz(const int32_t* In, int32_t* Out,
const WebRtc_Word32 K); const int32_t K);
void WebRtcSpl_Resample32khzTo24khz(const WebRtc_Word32* In, WebRtc_Word32* Out, void WebRtcSpl_Resample32khzTo24khz(const int32_t* In, int32_t* Out,
const WebRtc_Word32 K); const int32_t K);
void WebRtcSpl_Resample44khzTo32khz(const WebRtc_Word32* In, WebRtc_Word32* Out, void WebRtcSpl_Resample44khzTo32khz(const int32_t* In, int32_t* Out,
const WebRtc_Word32 K); const int32_t K);
/******************************************************************* /*******************************************************************
* resample_48khz.c * resample_48khz.c
@ -903,52 +899,52 @@ void WebRtcSpl_Resample44khzTo32khz(const WebRtc_Word32* In, WebRtc_Word32* Out,
******************************************************************/ ******************************************************************/
typedef struct { typedef struct {
WebRtc_Word32 S_48_48[16]; int32_t S_48_48[16];
WebRtc_Word32 S_48_32[8]; int32_t S_48_32[8];
WebRtc_Word32 S_32_16[8]; int32_t S_32_16[8];
} WebRtcSpl_State48khzTo16khz; } WebRtcSpl_State48khzTo16khz;
void WebRtcSpl_Resample48khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out,
WebRtcSpl_State48khzTo16khz* state, WebRtcSpl_State48khzTo16khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state); void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state);
typedef struct { typedef struct {
WebRtc_Word32 S_16_32[8]; int32_t S_16_32[8];
WebRtc_Word32 S_32_24[8]; int32_t S_32_24[8];
WebRtc_Word32 S_24_48[8]; int32_t S_24_48[8];
} WebRtcSpl_State16khzTo48khz; } WebRtcSpl_State16khzTo48khz;
void WebRtcSpl_Resample16khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out,
WebRtcSpl_State16khzTo48khz* state, WebRtcSpl_State16khzTo48khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state); void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state);
typedef struct { typedef struct {
WebRtc_Word32 S_48_24[8]; int32_t S_48_24[8];
WebRtc_Word32 S_24_24[16]; int32_t S_24_24[16];
WebRtc_Word32 S_24_16[8]; int32_t S_24_16[8];
WebRtc_Word32 S_16_8[8]; int32_t S_16_8[8];
} WebRtcSpl_State48khzTo8khz; } WebRtcSpl_State48khzTo8khz;
void WebRtcSpl_Resample48khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out,
WebRtcSpl_State48khzTo8khz* state, WebRtcSpl_State48khzTo8khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state); void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state);
typedef struct { typedef struct {
WebRtc_Word32 S_8_16[8]; int32_t S_8_16[8];
WebRtc_Word32 S_16_12[8]; int32_t S_16_12[8];
WebRtc_Word32 S_12_24[8]; int32_t S_12_24[8];
WebRtc_Word32 S_24_48[8]; int32_t S_24_48[8];
} WebRtcSpl_State8khzTo48khz; } WebRtcSpl_State8khzTo48khz;
void WebRtcSpl_Resample8khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out,
WebRtcSpl_State8khzTo48khz* state, WebRtcSpl_State8khzTo48khz* state,
WebRtc_Word32* tmpmem); int32_t* tmpmem);
void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state); void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state);
@ -959,25 +955,25 @@ void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state);
* *
******************************************************************/ ******************************************************************/
void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len, void WebRtcSpl_DownsampleBy2(const int16_t* in, const int16_t len,
WebRtc_Word16* out, WebRtc_Word32* filtState); int16_t* out, int32_t* filtState);
void WebRtcSpl_UpsampleBy2(const WebRtc_Word16* in, WebRtc_Word16 len, void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len,
WebRtc_Word16* out, WebRtc_Word32* filtState); int16_t* out, int32_t* filtState);
/************************************************************ /************************************************************
* END OF RESAMPLING FUNCTIONS * END OF RESAMPLING FUNCTIONS
************************************************************/ ************************************************************/
void WebRtcSpl_AnalysisQMF(const WebRtc_Word16* in_data, void WebRtcSpl_AnalysisQMF(const int16_t* in_data,
WebRtc_Word16* low_band, int16_t* low_band,
WebRtc_Word16* high_band, int16_t* high_band,
WebRtc_Word32* filter_state1, int32_t* filter_state1,
WebRtc_Word32* filter_state2); int32_t* filter_state2);
void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band, void WebRtcSpl_SynthesisQMF(const int16_t* low_band,
const WebRtc_Word16* high_band, const int16_t* high_band,
WebRtc_Word16* out_data, int16_t* out_data,
WebRtc_Word32* filter_state1, int32_t* filter_state1,
WebRtc_Word32* filter_state2); int32_t* filter_state2);
#ifdef __cplusplus #ifdef __cplusplus
} }
@ -1066,7 +1062,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// Returns the # of bits required to scale the samples specified in the // Returns the # of bits required to scale the samples specified in the
// |in_vector| parameter so that, if the squares of the samples are added the // |in_vector| parameter so that, if the squares of the samples are added the
// # of times specified by the |times| parameter, the 32-bit addition will not // # of times specified by the |times| parameter, the 32-bit addition will not
// overflow (result in WebRtc_Word32). // overflow (result in int32_t).
// //
// Input: // Input:
// - in_vector : Input vector to check scaling on // - in_vector : Input vector to check scaling on
@ -1080,11 +1076,11 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_MemSetW16(...) // WebRtcSpl_MemSetW16(...)
// //
// Sets all the values in the WebRtc_Word16 vector |vector| of length // Sets all the values in the int16_t vector |vector| of length
// |vector_length| to the specified value |set_value| // |vector_length| to the specified value |set_value|
// //
// Input: // Input:
// - vector : Pointer to the WebRtc_Word16 vector // - vector : Pointer to the int16_t vector
// - set_value : Value specified // - set_value : Value specified
// - vector_length : Length of vector // - vector_length : Length of vector
// //
@ -1092,11 +1088,11 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_MemSetW32(...) // WebRtcSpl_MemSetW32(...)
// //
// Sets all the values in the WebRtc_Word32 vector |vector| of length // Sets all the values in the int32_t vector |vector| of length
// |vector_length| to the specified value |set_value| // |vector_length| to the specified value |set_value|
// //
// Input: // Input:
// - vector : Pointer to the WebRtc_Word16 vector // - vector : Pointer to the int16_t vector
// - set_value : Value specified // - set_value : Value specified
// - vector_length : Length of vector // - vector_length : Length of vector
// //
@ -1104,20 +1100,20 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_MemCpyReversedOrder(...) // WebRtcSpl_MemCpyReversedOrder(...)
// //
// Copies all the values from the source WebRtc_Word16 vector |in_vector| to a // Copies all the values from the source int16_t vector |in_vector| to a
// destination WebRtc_Word16 vector |out_vector|. It is done in reversed order, // destination int16_t vector |out_vector|. It is done in reversed order,
// meaning that the first sample of |in_vector| is copied to the last sample of // meaning that the first sample of |in_vector| is copied to the last sample of
// the |out_vector|. The procedure continues until the last sample of // the |out_vector|. The procedure continues until the last sample of
// |in_vector| has been copied to the first sample of |out_vector|. This // |in_vector| has been copied to the first sample of |out_vector|. This
// creates a reversed vector. Used in e.g. prediction in iLBC. // creates a reversed vector. Used in e.g. prediction in iLBC.
// //
// Input: // Input:
// - in_vector : Pointer to the first sample in a WebRtc_Word16 vector // - in_vector : Pointer to the first sample in a int16_t vector
// of length |length| // of length |length|
// - vector_length : Number of elements to copy // - vector_length : Number of elements to copy
// //
// Output: // Output:
// - out_vector : Pointer to the last sample in a WebRtc_Word16 vector // - out_vector : Pointer to the last sample in a int16_t vector
// of length |length| // of length |length|
// //
@ -1176,7 +1172,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// WebRtcSpl_VectorBitShiftW32(...) // WebRtcSpl_VectorBitShiftW32(...)
// //
// Bit shifts all the values in a vector up or downwards. Different calls for // Bit shifts all the values in a vector up or downwards. Different calls for
// WebRtc_Word16 and WebRtc_Word32 vectors respectively. // int16_t and int32_t vectors respectively.
// //
// Input: // Input:
// - vector_length : Length of vector // - vector_length : Length of vector
@ -1192,7 +1188,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_VectorBitShiftW32ToW16(...) // WebRtcSpl_VectorBitShiftW32ToW16(...)
// //
// Bit shifts all the values in a WebRtc_Word32 vector up or downwards and // Bit shifts all the values in a int32_t vector up or downwards and
// stores the result as an int16_t vector. The function will saturate the // stores the result as an int16_t vector. The function will saturate the
// signal if needed, before storing in the output vector. // signal if needed, before storing in the output vector.
// //
@ -1365,7 +1361,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_RandU(...) // WebRtcSpl_RandU(...)
// //
// Produces a uniformly distributed value in the WebRtc_Word16 range // Produces a uniformly distributed value in the int16_t range
// //
// Input: // Input:
// - seed : Seed for random calculation // - seed : Seed for random calculation
@ -1380,7 +1376,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_RandN(...) // WebRtcSpl_RandN(...)
// //
// Produces a normal distributed value in the WebRtc_Word16 range // Produces a normal distributed value in the int16_t range
// //
// Input: // Input:
// - seed : Seed for random calculation // - seed : Seed for random calculation
@ -1394,7 +1390,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_RandUArray(...) // WebRtcSpl_RandUArray(...)
// //
// Produces a uniformly distributed vector with elements in the WebRtc_Word16 // Produces a uniformly distributed vector with elements in the int16_t
// range // range
// //
// Input: // Input:
@ -1450,53 +1446,53 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_DivU32U16(...) // WebRtcSpl_DivU32U16(...)
// //
// Divides a WebRtc_UWord32 |num| by a WebRtc_UWord16 |den|. // Divides a uint32_t |num| by a uint16_t |den|.
// //
// If |den|==0, (WebRtc_UWord32)0xFFFFFFFF is returned. // If |den|==0, (uint32_t)0xFFFFFFFF is returned.
// //
// Input: // Input:
// - num : Numerator // - num : Numerator
// - den : Denominator // - den : Denominator
// //
// Return value : Result of the division (as a WebRtc_UWord32), i.e., the // Return value : Result of the division (as a uint32_t), i.e., the
// integer part of num/den. // integer part of num/den.
// //
// //
// WebRtcSpl_DivW32W16(...) // WebRtcSpl_DivW32W16(...)
// //
// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|. // Divides a int32_t |num| by a int16_t |den|.
// //
// If |den|==0, (WebRtc_Word32)0x7FFFFFFF is returned. // If |den|==0, (int32_t)0x7FFFFFFF is returned.
// //
// Input: // Input:
// - num : Numerator // - num : Numerator
// - den : Denominator // - den : Denominator
// //
// Return value : Result of the division (as a WebRtc_Word32), i.e., the // Return value : Result of the division (as a int32_t), i.e., the
// integer part of num/den. // integer part of num/den.
// //
// //
// WebRtcSpl_DivW32W16ResW16(...) // WebRtcSpl_DivW32W16ResW16(...)
// //
// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|, assuming that the // Divides a int32_t |num| by a int16_t |den|, assuming that the
// result is less than 32768, otherwise an unpredictable result will occur. // result is less than 32768, otherwise an unpredictable result will occur.
// //
// If |den|==0, (WebRtc_Word16)0x7FFF is returned. // If |den|==0, (int16_t)0x7FFF is returned.
// //
// Input: // Input:
// - num : Numerator // - num : Numerator
// - den : Denominator // - den : Denominator
// //
// Return value : Result of the division (as a WebRtc_Word16), i.e., the // Return value : Result of the division (as a int16_t), i.e., the
// integer part of num/den. // integer part of num/den.
// //
// //
// WebRtcSpl_DivResultInQ31(...) // WebRtcSpl_DivResultInQ31(...)
// //
// Divides a WebRtc_Word32 |num| by a WebRtc_Word16 |den|, assuming that the // Divides a int32_t |num| by a int16_t |den|, assuming that the
// absolute value of the denominator is larger than the numerator, otherwise // absolute value of the denominator is larger than the numerator, otherwise
// an unpredictable result will occur. // an unpredictable result will occur.
// //
@ -1510,7 +1506,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// //
// WebRtcSpl_DivW32HiLow(...) // WebRtcSpl_DivW32HiLow(...)
// //
// Divides a WebRtc_Word32 |num| by a denominator in hi, low format. The // Divides a int32_t |num| by a denominator in hi, low format. The
// absolute value of the denominator has to be larger (or equal to) the // absolute value of the denominator has to be larger (or equal to) the
// numerator. // numerator.
// //
@ -1714,7 +1710,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// - out_data : Super-wideband speech signal, 0-16 kHz // - out_data : Super-wideband speech signal, 0-16 kHz
// //
// WebRtc_Word16 WebRtcSpl_SatW32ToW16(...) // int16_t WebRtcSpl_SatW32ToW16(...)
// //
// This function saturates a 32-bit word into a 16-bit word. // This function saturates a 32-bit word into a 16-bit word.
// //
@ -1738,7 +1734,7 @@ void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band,
// Return Value: The value of a * b + c. // Return Value: The value of a * b + c.
// //
// WebRtc_Word16 WebRtcSpl_get_version(...) // int16_t WebRtcSpl_get_version(...)
// //
// This function gives the version string of the Signal Processing Library. // This function gives the version string of the Signal Processing Library.
// //

View File

@ -19,8 +19,8 @@
#include "spl_inl_armv7.h" #include "spl_inl_armv7.h"
#else #else
static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
WebRtc_Word16 out16 = (WebRtc_Word16) value32; int16_t out16 = (int16_t) value32;
if (value32 > 32767) if (value32 > 32767)
out16 = 32767; out16 = 32767;
@ -30,17 +30,15 @@ static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) {
return out16; return out16;
} }
static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
WebRtc_Word16 b) { return WebRtcSpl_SatW32ToW16((int32_t) a + (int32_t) b);
return WebRtcSpl_SatW32ToW16((WebRtc_Word32) a + (WebRtc_Word32) b);
} }
static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
WebRtc_Word16 var2) { return WebRtcSpl_SatW32ToW16((int32_t) var1 - (int32_t) var2);
return WebRtcSpl_SatW32ToW16((WebRtc_Word32) var1 - (WebRtc_Word32) var2);
} }
static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
int bits; int bits;
if (0xFFFF0000 & n) { if (0xFFFF0000 & n) {
@ -57,7 +55,7 @@ static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) {
return bits; return bits;
} }
static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { static __inline int WebRtcSpl_NormW32(int32_t a) {
int zeros; int zeros;
if (a == 0) { if (a == 0) {
@ -80,7 +78,7 @@ static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) {
return zeros; return zeros;
} }
static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { static __inline int WebRtcSpl_NormU32(uint32_t a) {
int zeros; int zeros;
if (a == 0) return 0; if (a == 0) return 0;
@ -98,7 +96,7 @@ static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) {
return zeros; return zeros;
} }
static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { static __inline int WebRtcSpl_NormW16(int16_t a) {
int zeros; int zeros;
if (a == 0) { if (a == 0) {
@ -120,9 +118,7 @@ static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) {
return zeros; return zeros;
} }
static __inline int32_t WebRtc_MulAccumW16(int16_t a, static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
int16_t b,
int32_t c) {
return (a * b + c); return (a * b + c);
} }
@ -130,40 +126,38 @@ static __inline int32_t WebRtc_MulAccumW16(int16_t a,
// The following functions have no optimized versions. // The following functions have no optimized versions.
// TODO(kma): Consider saturating add/sub instructions in X86 platform. // TODO(kma): Consider saturating add/sub instructions in X86 platform.
static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
WebRtc_Word32 l_var2) { int32_t l_sum;
WebRtc_Word32 l_sum;
// Perform long addition // Perform long addition
l_sum = l_var1 + l_var2; l_sum = l_var1 + l_var2;
if (l_var1 < 0) { // Check for underflow. if (l_var1 < 0) { // Check for underflow.
if ((l_var2 < 0) && (l_sum >= 0)) { if ((l_var2 < 0) && (l_sum >= 0)) {
l_sum = (WebRtc_Word32)0x80000000; l_sum = (int32_t)0x80000000;
} }
} else { // Check for overflow. } else { // Check for overflow.
if ((l_var2 > 0) && (l_sum < 0)) { if ((l_var2 > 0) && (l_sum < 0)) {
l_sum = (WebRtc_Word32)0x7FFFFFFF; l_sum = (int32_t)0x7FFFFFFF;
} }
} }
return l_sum; return l_sum;
} }
static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
WebRtc_Word32 l_var2) { int32_t l_diff;
WebRtc_Word32 l_diff;
// Perform subtraction. // Perform subtraction.
l_diff = l_var1 - l_var2; l_diff = l_var1 - l_var2;
if (l_var1 < 0) { // Check for underflow. if (l_var1 < 0) { // Check for underflow.
if ((l_var2 > 0) && (l_diff > 0)) { if ((l_var2 > 0) && (l_diff > 0)) {
l_diff = (WebRtc_Word32)0x80000000; l_diff = (int32_t)0x80000000;
} }
} else { // Check for overflow. } else { // Check for overflow.
if ((l_var2 < 0) && (l_diff < 0)) { if ((l_var2 < 0) && (l_diff < 0)) {
l_diff = (WebRtc_Word32)0x7FFFFFFF; l_diff = (int32_t)0x7FFFFFFF;
} }
} }

View File

@ -24,9 +24,8 @@
* C version in some cases, although the former is at least as accurate as the * C version in some cases, although the former is at least as accurate as the
* later. * later.
*/ */
static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_32_RSFT16(WebRtc_Word16 a, static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) {
WebRtc_Word32 b) { int32_t tmp = 0;
WebRtc_Word32 tmp = 0;
__asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a)); __asm __volatile ("smulwb %0, %1, %2":"=r"(tmp):"r"(b), "r"(a));
return tmp; return tmp;
} }
@ -35,10 +34,10 @@ static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_32_RSFT16(WebRtc_Word16 a,
* C version in some cases, although the former is at least as accurate as the * C version in some cases, although the former is at least as accurate as the
* later. * later.
*/ */
static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32(WebRtc_Word16 a, static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32(int16_t a,
WebRtc_Word16 b, int16_t b,
WebRtc_Word32 c) { int32_t c) {
WebRtc_Word32 tmp = 0; int32_t tmp = 0;
__asm __volatile ( __asm __volatile (
"pkhbt %[tmp], %[b], %[a], lsl #16\n\t" "pkhbt %[tmp], %[b], %[a], lsl #16\n\t"
"smmulr %[tmp], %[tmp], %[c]\n\t" "smmulr %[tmp], %[tmp], %[c]\n\t"
@ -50,54 +49,47 @@ static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32(WebRtc_Word16 a,
return tmp; return tmp;
} }
static __inline WebRtc_Word32 WEBRTC_SPL_MUL_32_32_RSFT32BI(WebRtc_Word32 a, static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32BI(int32_t a, int32_t b) {
WebRtc_Word32 b) { int32_t tmp = 0;
WebRtc_Word32 tmp = 0;
__asm volatile ("smmulr %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); __asm volatile ("smmulr %0, %1, %2":"=r"(tmp):"r"(a), "r"(b));
return tmp; return tmp;
} }
static __inline WebRtc_Word32 WEBRTC_SPL_MUL_16_16(WebRtc_Word16 a, static __inline int32_t WEBRTC_SPL_MUL_16_16(int16_t a, int16_t b) {
WebRtc_Word16 b) { int32_t tmp = 0;
WebRtc_Word32 tmp = 0;
__asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); __asm __volatile ("smulbb %0, %1, %2":"=r"(tmp):"r"(a), "r"(b));
return tmp; return tmp;
} }
// TODO(kma): add unit test. // TODO(kma): add unit test.
static __inline int32_t WebRtc_MulAccumW16(int16_t a, static __inline int32_t WebRtc_MulAccumW16(int16_t a, int16_t b, int32_t c) {
int16_t b,
int32_t c) {
int32_t tmp = 0; int32_t tmp = 0;
__asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c)); __asm __volatile ("smlabb %0, %1, %2, %3":"=r"(tmp):"r"(a), "r"(b), "r"(c));
return tmp; return tmp;
} }
static __inline WebRtc_Word16 WebRtcSpl_AddSatW16(WebRtc_Word16 a, static __inline int16_t WebRtcSpl_AddSatW16(int16_t a, int16_t b) {
WebRtc_Word16 b) { int32_t s_sum = 0;
WebRtc_Word32 s_sum = 0;
__asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b)); __asm __volatile ("qadd16 %0, %1, %2":"=r"(s_sum):"r"(a), "r"(b));
return (WebRtc_Word16) s_sum; return (int16_t) s_sum;
} }
/* TODO(kma): find the cause of unittest errors by the next two functions: /* TODO(kma): find the cause of unittest errors by the next two functions:
* http://code.google.com/p/webrtc/issues/detail?id=740. * http://code.google.com/p/webrtc/issues/detail?id=740.
*/ */
#if 0 #if 0
static __inline WebRtc_Word32 WebRtcSpl_AddSatW32(WebRtc_Word32 l_var1, static __inline int32_t WebRtcSpl_AddSatW32(int32_t l_var1, int32_t l_var2) {
WebRtc_Word32 l_var2) { int32_t l_sum = 0;
WebRtc_Word32 l_sum = 0;
__asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2)); __asm __volatile ("qadd %0, %1, %2":"=r"(l_sum):"r"(l_var1), "r"(l_var2));
return l_sum; return l_sum;
} }
static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1, static __inline int32_t WebRtcSpl_SubSatW32(int32_t l_var1, int32_t l_var2) {
WebRtc_Word32 l_var2) { int32_t l_sub = 0;
WebRtc_Word32 l_sub = 0;
__asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2)); __asm __volatile ("qsub %0, %1, %2":"=r"(l_sub):"r"(l_var1), "r"(l_var2));
@ -105,25 +97,24 @@ static __inline WebRtc_Word32 WebRtcSpl_SubSatW32(WebRtc_Word32 l_var1,
} }
#endif #endif
static __inline WebRtc_Word16 WebRtcSpl_SubSatW16(WebRtc_Word16 var1, static __inline int16_t WebRtcSpl_SubSatW16(int16_t var1, int16_t var2) {
WebRtc_Word16 var2) { int32_t s_sub = 0;
WebRtc_Word32 s_sub = 0;
__asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2)); __asm __volatile ("qsub16 %0, %1, %2":"=r"(s_sub):"r"(var1), "r"(var2));
return (WebRtc_Word16)s_sub; return (int16_t)s_sub;
} }
static __inline WebRtc_Word16 WebRtcSpl_GetSizeInBits(WebRtc_UWord32 n) { static __inline int16_t WebRtcSpl_GetSizeInBits(uint32_t n) {
WebRtc_Word32 tmp = 0; int32_t tmp = 0;
__asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n)); __asm __volatile ("clz %0, %1":"=r"(tmp):"r"(n));
return (WebRtc_Word16)(32 - tmp); return (int16_t)(32 - tmp);
} }
static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) { static __inline int WebRtcSpl_NormW32(int32_t a) {
WebRtc_Word32 tmp = 0; int32_t tmp = 0;
if (a == 0) { if (a == 0) {
return 0; return 0;
@ -137,7 +128,7 @@ static __inline int WebRtcSpl_NormW32(WebRtc_Word32 a) {
return tmp - 1; return tmp - 1;
} }
static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) { static __inline int WebRtcSpl_NormU32(uint32_t a) {
int tmp = 0; int tmp = 0;
if (a == 0) return 0; if (a == 0) return 0;
@ -147,8 +138,8 @@ static __inline int WebRtcSpl_NormU32(WebRtc_UWord32 a) {
return tmp; return tmp;
} }
static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) { static __inline int WebRtcSpl_NormW16(int16_t a) {
WebRtc_Word32 tmp = 0; int32_t tmp = 0;
if (a == 0) { if (a == 0) {
return 0; return 0;
@ -163,12 +154,12 @@ static __inline int WebRtcSpl_NormW16(WebRtc_Word16 a) {
} }
// TODO(kma): add unit test. // TODO(kma): add unit test.
static __inline WebRtc_Word16 WebRtcSpl_SatW32ToW16(WebRtc_Word32 value32) { static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) {
WebRtc_Word32 out = 0; int32_t out = 0;
__asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32)); __asm __volatile ("ssat %0, #16, %1" : "=r"(out) : "r"(value32));
return (WebRtc_Word16)out; return (int16_t)out;
} }
#endif // WEBRTC_SPL_SPL_INL_ARMV7_H_ #endif // WEBRTC_SPL_SPL_INL_ARMV7_H_

View File

@ -19,23 +19,23 @@
#define SPL_LEVINSON_MAXORDER 20 #define SPL_LEVINSON_MAXORDER 20
WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRtc_Word16 *K, int16_t WebRtcSpl_LevinsonDurbin(int32_t *R, int16_t *A, int16_t *K,
WebRtc_Word16 order) int16_t order)
{ {
WebRtc_Word16 i, j; int16_t i, j;
// Auto-correlation coefficients in high precision // Auto-correlation coefficients in high precision
WebRtc_Word16 R_hi[SPL_LEVINSON_MAXORDER + 1], R_low[SPL_LEVINSON_MAXORDER + 1]; int16_t R_hi[SPL_LEVINSON_MAXORDER + 1], R_low[SPL_LEVINSON_MAXORDER + 1];
// LPC coefficients in high precision // LPC coefficients in high precision
WebRtc_Word16 A_hi[SPL_LEVINSON_MAXORDER + 1], A_low[SPL_LEVINSON_MAXORDER + 1]; int16_t A_hi[SPL_LEVINSON_MAXORDER + 1], A_low[SPL_LEVINSON_MAXORDER + 1];
// LPC coefficients for next iteration // LPC coefficients for next iteration
WebRtc_Word16 A_upd_hi[SPL_LEVINSON_MAXORDER + 1], A_upd_low[SPL_LEVINSON_MAXORDER + 1]; int16_t A_upd_hi[SPL_LEVINSON_MAXORDER + 1], A_upd_low[SPL_LEVINSON_MAXORDER + 1];
// Reflection coefficient in high precision // Reflection coefficient in high precision
WebRtc_Word16 K_hi, K_low; int16_t K_hi, K_low;
// Prediction gain Alpha in high precision and with scale factor // Prediction gain Alpha in high precision and with scale factor
WebRtc_Word16 Alpha_hi, Alpha_low, Alpha_exp; int16_t Alpha_hi, Alpha_low, Alpha_exp;
WebRtc_Word16 tmp_hi, tmp_low; int16_t tmp_hi, tmp_low;
WebRtc_Word32 temp1W32, temp2W32, temp3W32; int32_t temp1W32, temp2W32, temp3W32;
WebRtc_Word16 norm; int16_t norm;
// Normalize the autocorrelation R[0]...R[order+1] // Normalize the autocorrelation R[0]...R[order+1]
@ -45,15 +45,15 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
{ {
temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm); temp1W32 = WEBRTC_SPL_LSHIFT_W32(R[i], norm);
// Put R in hi and low format // Put R in hi and low format
R_hi[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); R_hi[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
R_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 R_low[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[i], 16)), 1);
} }
// K = A[1] = -R[1] / R[0] // K = A[1] = -R[1] / R[0]
temp2W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[1],16) temp2W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[1],16)
+ WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[1],1); // R[1] in Q31 + WEBRTC_SPL_LSHIFT_W32((int32_t)R_low[1],1); // R[1] in Q31
temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); // abs R[1] temp3W32 = WEBRTC_SPL_ABS_W32(temp2W32); // abs R[1]
temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); // abs(R[1])/R[0] in Q31 temp1W32 = WebRtcSpl_DivW32HiLow(temp3W32, R_hi[0], R_low[0]); // abs(R[1])/R[0] in Q31
// Put back the sign on R[1] // Put back the sign on R[1]
@ -63,9 +63,9 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
} }
// Put K in hi and low format // Put K in hi and low format
K_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); K_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 K_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)K_hi, 16)), 1);
// Store first reflection coefficient // Store first reflection coefficient
K[0] = K_hi; K[0] = K_hi;
@ -73,9 +73,9 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
temp1W32 = WEBRTC_SPL_RSHIFT_W32(temp1W32, 4); // A[1] in Q27 temp1W32 = WEBRTC_SPL_RSHIFT_W32(temp1W32, 4); // A[1] in Q27
// Put A[1] in hi and low format // Put A[1] in hi and low format
A_hi[1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); A_hi[1] = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
A_low[1] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 A_low[1] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[1], 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[1], 16)), 1);
// Alpha = R[0] * (1-K^2) // Alpha = R[0] * (1-K^2)
@ -83,12 +83,12 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
<< 1); // temp1W32 = k^2 in Q31 << 1); // temp1W32 = k^2 in Q31
temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0
temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; // temp1W32 = (1 - K[0]*K[0]) in Q31 temp1W32 = (int32_t)0x7fffffffL - temp1W32; // temp1W32 = (1 - K[0]*K[0]) in Q31
// Store temp1W32 = 1 - K[0]*K[0] on hi and low format // Store temp1W32 = 1 - K[0]*K[0] on hi and low format
tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
// Calculate Alpha in Q31 // Calculate Alpha in Q31
temp1W32 = ((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi) temp1W32 = ((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi)
@ -99,9 +99,9 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
Alpha_exp = WebRtcSpl_NormW32(temp1W32); Alpha_exp = WebRtcSpl_NormW32(temp1W32);
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp); temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, Alpha_exp);
Alpha_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); Alpha_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 Alpha_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)Alpha_hi, 16)), 1);
// Perform the iterative calculations in the Levinson-Durbin algorithm // Perform the iterative calculations in the Levinson-Durbin algorithm
@ -125,8 +125,8 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
} }
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4); temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4);
temp1W32 += (WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_hi[i], 16) temp1W32 += (WEBRTC_SPL_LSHIFT_W32((int32_t)R_hi[i], 16)
+ WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)R_low[i], 1)); + WEBRTC_SPL_LSHIFT_W32((int32_t)R_low[i], 1));
// K = -temp1W32 / Alpha // K = -temp1W32 / Alpha
temp2W32 = WEBRTC_SPL_ABS_W32(temp1W32); // abs(temp1W32) temp2W32 = WEBRTC_SPL_ABS_W32(temp1W32); // abs(temp1W32)
@ -147,17 +147,17 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
{ {
if (temp3W32 > 0) if (temp3W32 > 0)
{ {
temp3W32 = (WebRtc_Word32)0x7fffffffL; temp3W32 = (int32_t)0x7fffffffL;
} else } else
{ {
temp3W32 = (WebRtc_Word32)0x80000000L; temp3W32 = (int32_t)0x80000000L;
} }
} }
// Put K on hi and low format // Put K on hi and low format
K_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); K_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16);
K_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 K_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp3W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)K_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)K_hi, 16)), 1);
// Store Reflection coefficient in Q15 // Store Reflection coefficient in Q15
K[i - 1] = K_hi; K[i - 1] = K_hi;
@ -165,7 +165,7 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
// Test for unstable filter. // Test for unstable filter.
// If unstable return 0 and let the user decide what to do in that case // If unstable return 0 and let the user decide what to do in that case
if ((WebRtc_Word32)WEBRTC_SPL_ABS_W16(K_hi) > (WebRtc_Word32)32750) if ((int32_t)WEBRTC_SPL_ABS_W16(K_hi) > (int32_t)32750)
{ {
return 0; // Unstable filter return 0; // Unstable filter
} }
@ -179,8 +179,8 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
for (j = 1; j < i; j++) for (j = 1; j < i; j++)
{ {
// temp1W32 = A[j] in Q27 // temp1W32 = A[j] in Q27
temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[j],16) temp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[j],16)
+ WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[j],1); + WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[j],1);
// temp1W32 += K*A[i-j] in Q27 // temp1W32 += K*A[i-j] in Q27
temp1W32 += ((WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j]) temp1W32 += ((WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j])
@ -188,18 +188,18 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
+ (WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]) >> 15)) << 1); + (WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]) >> 15)) << 1);
// Put Anew in hi and low format // Put Anew in hi and low format
A_upd_hi[j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); A_upd_hi[j] = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
A_upd_low[j] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 A_upd_low[j] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[j], 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)A_upd_hi[j], 16)), 1);
} }
// temp3W32 = K in Q27 (Convert from Q31 to Q27) // temp3W32 = K in Q27 (Convert from Q31 to Q27)
temp3W32 = WEBRTC_SPL_RSHIFT_W32(temp3W32, 4); temp3W32 = WEBRTC_SPL_RSHIFT_W32(temp3W32, 4);
// Store Anew in hi and low format // Store Anew in hi and low format
A_upd_hi[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16); A_upd_hi[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp3W32, 16);
A_upd_low[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp3W32 A_upd_low[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp3W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_upd_hi[i], 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)A_upd_hi[i], 16)), 1);
// Alpha = Alpha * (1-K^2) // Alpha = Alpha * (1-K^2)
@ -207,12 +207,12 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
+ WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) << 1); // K*K in Q31 + WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) << 1); // K*K in Q31
temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0
temp1W32 = (WebRtc_Word32)0x7fffffffL - temp1W32; // 1 - K*K in Q31 temp1W32 = (int32_t)0x7fffffffL - temp1W32; // 1 - K*K in Q31
// Convert 1- K^2 in hi and low format // Convert 1- K^2 in hi and low format
tmp_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); tmp_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
tmp_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 tmp_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)tmp_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)tmp_hi, 16)), 1);
// Calculate Alpha = Alpha * (1-K^2) in Q31 // Calculate Alpha = Alpha * (1-K^2) in Q31
temp1W32 = ((WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi) temp1W32 = ((WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi)
@ -224,9 +224,9 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
norm = WebRtcSpl_NormW32(temp1W32); norm = WebRtcSpl_NormW32(temp1W32);
temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm); temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, norm);
Alpha_hi = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16); Alpha_hi = (int16_t)WEBRTC_SPL_RSHIFT_W32(temp1W32, 16);
Alpha_low = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32 Alpha_low = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32
- WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)Alpha_hi, 16)), 1); - WEBRTC_SPL_LSHIFT_W32((int32_t)Alpha_hi, 16)), 1);
// Update the total normalization of Alpha // Update the total normalization of Alpha
Alpha_exp = Alpha_exp + norm; Alpha_exp = Alpha_exp + norm;
@ -250,10 +250,10 @@ WebRtc_Word16 WebRtcSpl_LevinsonDurbin(WebRtc_Word32 *R, WebRtc_Word16 *A, WebRt
for (i = 1; i <= order; i++) for (i = 1; i <= order; i++)
{ {
// temp1W32 in Q27 // temp1W32 in Q27
temp1W32 = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_hi[i], 16) temp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)A_hi[i], 16)
+ WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)A_low[i], 1); + WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[i], 1);
// Round and store upper word // Round and store upper word
A[i] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32((temp1W32<<1)+(WebRtc_Word32)32768, 16); A[i] = (int16_t)WEBRTC_SPL_RSHIFT_W32((temp1W32<<1)+(int32_t)32768, 16);
} }
return 1; // Stable filters return 1; // Stable filters
} }

View File

@ -19,27 +19,27 @@
#define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50 #define SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER 50
void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* a16, int use_order, WebRtc_Word16* k16) void WebRtcSpl_LpcToReflCoef(int16_t* a16, int use_order, int16_t* k16)
{ {
int m, k; int m, k;
WebRtc_Word32 tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER]; int32_t tmp32[SPL_LPC_TO_REFL_COEF_MAX_AR_MODEL_ORDER];
WebRtc_Word32 tmp_inv_denom32; int32_t tmp_inv_denom32;
WebRtc_Word16 tmp_inv_denom16; int16_t tmp_inv_denom16;
k16[use_order - 1] = WEBRTC_SPL_LSHIFT_W16(a16[use_order], 3); //Q12<<3 => Q15 k16[use_order - 1] = WEBRTC_SPL_LSHIFT_W16(a16[use_order], 3); //Q12<<3 => Q15
for (m = use_order - 1; m > 0; m--) for (m = use_order - 1; m > 0; m--)
{ {
// (1 - k^2) in Q30 // (1 - k^2) in Q30
tmp_inv_denom32 = ((WebRtc_Word32)1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); tmp_inv_denom32 = ((int32_t)1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]);
// (1 - k^2) in Q15 // (1 - k^2) in Q15
tmp_inv_denom16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp_inv_denom32, 15); tmp_inv_denom16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp_inv_denom32, 15);
for (k = 1; k <= m; k++) for (k = 1; k <= m; k++)
{ {
// tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]);
// [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28
tmp32[k] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)a16[k], 16) tmp32[k] = WEBRTC_SPL_LSHIFT_W32((int32_t)a16[k], 16)
- WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1); - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1);
tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13
@ -47,11 +47,11 @@ void WebRtcSpl_LpcToReflCoef(WebRtc_Word16* a16, int use_order, WebRtc_Word16* k
for (k = 1; k < m; k++) for (k = 1; k < m; k++)
{ {
a16[k] = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q13>>1 => Q12 a16[k] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32[k], 1); //Q13>>1 => Q12
} }
tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191); tmp32[m] = WEBRTC_SPL_SAT(8191, tmp32[m], -8191);
k16[m - 1] = (WebRtc_Word16)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15 k16[m - 1] = (int16_t)WEBRTC_SPL_LSHIFT_W32(tmp32[m], 2); //Q13<<2 => Q15
} }
return; return;
} }

View File

@ -20,15 +20,15 @@
// Maximum absolute value of word16 vector. // Maximum absolute value of word16 vector.
int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, int length) { int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, int length) {
WebRtc_Word32 totMax = 0; int32_t totMax = 0;
WebRtc_Word32 tmp32_0, tmp32_1, tmp32_2, tmp32_3; int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3;
int i, loop_size; int i, loop_size;
if (vector == NULL || length <= 0) { if (vector == NULL || length <= 0) {
return -1; return -1;
} }
#if defined(MIPS_DSP_R1) #if defined(MIPS_DSP_R1)
const WebRtc_Word32* tmpvec32 = (WebRtc_Word32*)vector; const int32_t* tmpvec32 = (int32_t*)vector;
loop_size = length >> 4; loop_size = length >> 4;
for (i = 0; i < loop_size; i++) { for (i = 0; i < loop_size; i++) {
@ -104,9 +104,9 @@ int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, int length) {
); );
} }
#else // #if defined(MIPS_DSP_R1) #else // #if defined(MIPS_DSP_R1)
WebRtc_Word32 v16MaxMax = WEBRTC_SPL_WORD16_MAX; int32_t v16MaxMax = WEBRTC_SPL_WORD16_MAX;
WebRtc_Word32 r, r1, r2, r3; int32_t r, r1, r2, r3;
const WebRtc_Word16* tmpvector = vector; const int16_t* tmpvector = vector;
loop_size = length >> 4; loop_size = length >> 4;
for (i = 0; i < loop_size; i++) { for (i = 0; i < loop_size; i++) {
__asm__ volatile ( __asm__ volatile (

View File

@ -22,7 +22,7 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
static const WebRtc_Word16 kRandNTable[] = { static const int16_t kRandNTable[] = {
9178, -7260, 40, 10189, 4894, -3531, -13779, 14764, 9178, -7260, 40, 10189, 4894, -3531, -13779, 14764,
-4008, -8884, -8990, 1008, 7368, 5184, 3251, -5817, -4008, -8884, -8990, 1008, 7368, 5184, 3251, -5817,
-9786, 5963, 1770, 8066, -7135, 10772, -2298, 1361, -9786, 5963, 1770, 8066, -7135, 10772, -2298, 1361,
@ -89,26 +89,26 @@ static const WebRtc_Word16 kRandNTable[] = {
2374, -5797, 11839, 8940, -11874, 18213, 2855, 10492 2374, -5797, 11839, 8940, -11874, 18213, 2855, 10492
}; };
WebRtc_UWord32 WebRtcSpl_IncreaseSeed(WebRtc_UWord32 *seed) uint32_t WebRtcSpl_IncreaseSeed(uint32_t *seed)
{ {
seed[0] = (seed[0] * ((WebRtc_Word32)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1); seed[0] = (seed[0] * ((int32_t)69069) + 1) & (WEBRTC_SPL_MAX_SEED_USED - 1);
return seed[0]; return seed[0];
} }
WebRtc_Word16 WebRtcSpl_RandU(WebRtc_UWord32 *seed) int16_t WebRtcSpl_RandU(uint32_t *seed)
{ {
return (WebRtc_Word16)(WebRtcSpl_IncreaseSeed(seed) >> 16); return (int16_t)(WebRtcSpl_IncreaseSeed(seed) >> 16);
} }
WebRtc_Word16 WebRtcSpl_RandN(WebRtc_UWord32 *seed) int16_t WebRtcSpl_RandN(uint32_t *seed)
{ {
return kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23]; return kRandNTable[WebRtcSpl_IncreaseSeed(seed) >> 23];
} }
// Creates an array of uniformly distributed variables // Creates an array of uniformly distributed variables
WebRtc_Word16 WebRtcSpl_RandUArray(WebRtc_Word16* vector, int16_t WebRtcSpl_RandUArray(int16_t* vector,
WebRtc_Word16 vector_length, int16_t vector_length,
WebRtc_UWord32* seed) uint32_t* seed)
{ {
int i; int i;
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)

View File

@ -17,11 +17,11 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16 *k, int use_order, WebRtc_Word16 *a) void WebRtcSpl_ReflCoefToLpc(G_CONST int16_t *k, int use_order, int16_t *a)
{ {
WebRtc_Word16 any[WEBRTC_SPL_MAX_LPC_ORDER + 1]; int16_t any[WEBRTC_SPL_MAX_LPC_ORDER + 1];
WebRtc_Word16 *aptr, *aptr2, *anyptr; int16_t *aptr, *aptr2, *anyptr;
G_CONST WebRtc_Word16 *kptr; G_CONST int16_t *kptr;
int m, i; int m, i;
kptr = k; kptr = k;
@ -42,7 +42,7 @@ void WebRtcSpl_ReflCoefToLpc(G_CONST WebRtc_Word16 *k, int use_order, WebRtc_Wor
for (i = 0; i < m; i++) for (i = 0; i < m; i++)
{ {
*anyptr = (*aptr) *anyptr = (*aptr)
+ (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15); + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT((*aptr2), (*kptr), 15);
anyptr++; anyptr++;
aptr++; aptr++;
aptr2--; aptr2--;

View File

@ -19,14 +19,14 @@
#include "resample_by_2_internal.h" #include "resample_by_2_internal.h"
// Declaration of internally used functions // Declaration of internally used functions
static void WebRtcSpl_32khzTo22khzIntToShort(const WebRtc_Word32 *In, WebRtc_Word16 *Out, static void WebRtcSpl_32khzTo22khzIntToShort(const int32_t *In, int16_t *Out,
const WebRtc_Word32 K); const int32_t K);
void WebRtcSpl_32khzTo22khzIntToInt(const WebRtc_Word32 *In, WebRtc_Word32 *Out, void WebRtcSpl_32khzTo22khzIntToInt(const int32_t *In, int32_t *Out,
const WebRtc_Word32 K); const int32_t K);
// interpolation coefficients // interpolation coefficients
static const WebRtc_Word16 kCoefficients32To22[5][9] = { static const int16_t kCoefficients32To22[5][9] = {
{127, -712, 2359, -6333, 23456, 16775, -3695, 945, -154}, {127, -712, 2359, -6333, 23456, 16775, -3695, 945, -154},
{-39, 230, -830, 2785, 32366, -2324, 760, -218, 38}, {-39, 230, -830, 2785, 32366, -2324, 760, -218, 38},
{117, -663, 2222, -6133, 26634, 13070, -3174, 831, -137}, {117, -663, 2222, -6133, 26634, 13070, -3174, 831, -137},
@ -42,8 +42,8 @@ static const WebRtc_Word16 kCoefficients32To22[5][9] = {
#define SUB_BLOCKS_22_16 5 #define SUB_BLOCKS_22_16 5
// 22 -> 16 resampler // 22 -> 16 resampler
void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample22khzTo16khz(const int16_t* in, int16_t* out,
WebRtcSpl_State22khzTo16khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State22khzTo16khz* state, int32_t* tmpmem)
{ {
int k; int k;
@ -51,14 +51,14 @@ void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out,
for (k = 0; k < SUB_BLOCKS_22_16; k++) for (k = 0; k < SUB_BLOCKS_22_16; k++)
{ {
///// 22 --> 44 ///// ///// 22 --> 44 /////
// WebRtc_Word16 in[220/SUB_BLOCKS_22_16] // int16_t in[220/SUB_BLOCKS_22_16]
// WebRtc_Word32 out[440/SUB_BLOCKS_22_16] // int32_t out[440/SUB_BLOCKS_22_16]
///// /////
WebRtcSpl_UpBy2ShortToInt(in, 220 / SUB_BLOCKS_22_16, tmpmem + 16, state->S_22_44); WebRtcSpl_UpBy2ShortToInt(in, 220 / SUB_BLOCKS_22_16, tmpmem + 16, state->S_22_44);
///// 44 --> 32 ///// ///// 44 --> 32 /////
// WebRtc_Word32 in[440/SUB_BLOCKS_22_16] // int32_t in[440/SUB_BLOCKS_22_16]
// WebRtc_Word32 out[320/SUB_BLOCKS_22_16] // int32_t out[320/SUB_BLOCKS_22_16]
///// /////
// copy state to and from input array // copy state to and from input array
tmpmem[8] = state->S_44_32[0]; tmpmem[8] = state->S_44_32[0];
@ -81,8 +81,8 @@ void WebRtcSpl_Resample22khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out,
WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 40 / SUB_BLOCKS_22_16); WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 40 / SUB_BLOCKS_22_16);
///// 32 --> 16 ///// ///// 32 --> 16 /////
// WebRtc_Word32 in[320/SUB_BLOCKS_22_16] // int32_t in[320/SUB_BLOCKS_22_16]
// WebRtc_Word32 out[160/SUB_BLOCKS_22_16] // int32_t out[160/SUB_BLOCKS_22_16]
///// /////
WebRtcSpl_DownBy2IntToShort(tmpmem, 320 / SUB_BLOCKS_22_16, out, state->S_32_16); WebRtcSpl_DownBy2IntToShort(tmpmem, 320 / SUB_BLOCKS_22_16, out, state->S_32_16);
@ -112,8 +112,8 @@ void WebRtcSpl_ResetResample22khzTo16khz(WebRtcSpl_State22khzTo16khz* state)
#define SUB_BLOCKS_16_22 4 #define SUB_BLOCKS_16_22 4
// 16 -> 22 resampler // 16 -> 22 resampler
void WebRtcSpl_Resample16khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample16khzTo22khz(const int16_t* in, int16_t* out,
WebRtcSpl_State16khzTo22khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State16khzTo22khz* state, int32_t* tmpmem)
{ {
int k; int k;
@ -121,14 +121,14 @@ void WebRtcSpl_Resample16khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out,
for (k = 0; k < SUB_BLOCKS_16_22; k++) for (k = 0; k < SUB_BLOCKS_16_22; k++)
{ {
///// 16 --> 32 ///// ///// 16 --> 32 /////
// WebRtc_Word16 in[160/SUB_BLOCKS_16_22] // int16_t in[160/SUB_BLOCKS_16_22]
// WebRtc_Word32 out[320/SUB_BLOCKS_16_22] // int32_t out[320/SUB_BLOCKS_16_22]
///// /////
WebRtcSpl_UpBy2ShortToInt(in, 160 / SUB_BLOCKS_16_22, tmpmem + 8, state->S_16_32); WebRtcSpl_UpBy2ShortToInt(in, 160 / SUB_BLOCKS_16_22, tmpmem + 8, state->S_16_32);
///// 32 --> 22 ///// ///// 32 --> 22 /////
// WebRtc_Word32 in[320/SUB_BLOCKS_16_22] // int32_t in[320/SUB_BLOCKS_16_22]
// WebRtc_Word32 out[220/SUB_BLOCKS_16_22] // int32_t out[220/SUB_BLOCKS_16_22]
///// /////
// copy state to and from input array // copy state to and from input array
tmpmem[0] = state->S_32_22[0]; tmpmem[0] = state->S_32_22[0];
@ -175,8 +175,8 @@ void WebRtcSpl_ResetResample16khzTo22khz(WebRtcSpl_State16khzTo22khz* state)
#define SUB_BLOCKS_22_8 2 #define SUB_BLOCKS_22_8 2
// 22 -> 8 resampler // 22 -> 8 resampler
void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample22khzTo8khz(const int16_t* in, int16_t* out,
WebRtcSpl_State22khzTo8khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State22khzTo8khz* state, int32_t* tmpmem)
{ {
int k; int k;
@ -184,14 +184,14 @@ void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out,
for (k = 0; k < SUB_BLOCKS_22_8; k++) for (k = 0; k < SUB_BLOCKS_22_8; k++)
{ {
///// 22 --> 22 lowpass ///// ///// 22 --> 22 lowpass /////
// WebRtc_Word16 in[220/SUB_BLOCKS_22_8] // int16_t in[220/SUB_BLOCKS_22_8]
// WebRtc_Word32 out[220/SUB_BLOCKS_22_8] // int32_t out[220/SUB_BLOCKS_22_8]
///// /////
WebRtcSpl_LPBy2ShortToInt(in, 220 / SUB_BLOCKS_22_8, tmpmem + 16, state->S_22_22); WebRtcSpl_LPBy2ShortToInt(in, 220 / SUB_BLOCKS_22_8, tmpmem + 16, state->S_22_22);
///// 22 --> 16 ///// ///// 22 --> 16 /////
// WebRtc_Word32 in[220/SUB_BLOCKS_22_8] // int32_t in[220/SUB_BLOCKS_22_8]
// WebRtc_Word32 out[160/SUB_BLOCKS_22_8] // int32_t out[160/SUB_BLOCKS_22_8]
///// /////
// copy state to and from input array // copy state to and from input array
tmpmem[8] = state->S_22_16[0]; tmpmem[8] = state->S_22_16[0];
@ -214,8 +214,8 @@ void WebRtcSpl_Resample22khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out,
WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 20 / SUB_BLOCKS_22_8); WebRtcSpl_Resample44khzTo32khz(tmpmem + 8, tmpmem, 20 / SUB_BLOCKS_22_8);
///// 16 --> 8 ///// ///// 16 --> 8 /////
// WebRtc_Word32 in[160/SUB_BLOCKS_22_8] // int32_t in[160/SUB_BLOCKS_22_8]
// WebRtc_Word32 out[80/SUB_BLOCKS_22_8] // int32_t out[80/SUB_BLOCKS_22_8]
///// /////
WebRtcSpl_DownBy2IntToShort(tmpmem, 160 / SUB_BLOCKS_22_8, out, state->S_16_8); WebRtcSpl_DownBy2IntToShort(tmpmem, 160 / SUB_BLOCKS_22_8, out, state->S_16_8);
@ -246,8 +246,8 @@ void WebRtcSpl_ResetResample22khzTo8khz(WebRtcSpl_State22khzTo8khz* state)
#define SUB_BLOCKS_8_22 2 #define SUB_BLOCKS_8_22 2
// 8 -> 22 resampler // 8 -> 22 resampler
void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample8khzTo22khz(const int16_t* in, int16_t* out,
WebRtcSpl_State8khzTo22khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State8khzTo22khz* state, int32_t* tmpmem)
{ {
int k; int k;
@ -255,14 +255,14 @@ void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out,
for (k = 0; k < SUB_BLOCKS_8_22; k++) for (k = 0; k < SUB_BLOCKS_8_22; k++)
{ {
///// 8 --> 16 ///// ///// 8 --> 16 /////
// WebRtc_Word16 in[80/SUB_BLOCKS_8_22] // int16_t in[80/SUB_BLOCKS_8_22]
// WebRtc_Word32 out[160/SUB_BLOCKS_8_22] // int32_t out[160/SUB_BLOCKS_8_22]
///// /////
WebRtcSpl_UpBy2ShortToInt(in, 80 / SUB_BLOCKS_8_22, tmpmem + 18, state->S_8_16); WebRtcSpl_UpBy2ShortToInt(in, 80 / SUB_BLOCKS_8_22, tmpmem + 18, state->S_8_16);
///// 16 --> 11 ///// ///// 16 --> 11 /////
// WebRtc_Word32 in[160/SUB_BLOCKS_8_22] // int32_t in[160/SUB_BLOCKS_8_22]
// WebRtc_Word32 out[110/SUB_BLOCKS_8_22] // int32_t out[110/SUB_BLOCKS_8_22]
///// /////
// copy state to and from input array // copy state to and from input array
tmpmem[10] = state->S_16_11[0]; tmpmem[10] = state->S_16_11[0];
@ -285,8 +285,8 @@ void WebRtcSpl_Resample8khzTo22khz(const WebRtc_Word16* in, WebRtc_Word16* out,
WebRtcSpl_32khzTo22khzIntToInt(tmpmem + 10, tmpmem, 10 / SUB_BLOCKS_8_22); WebRtcSpl_32khzTo22khzIntToInt(tmpmem + 10, tmpmem, 10 / SUB_BLOCKS_8_22);
///// 11 --> 22 ///// ///// 11 --> 22 /////
// WebRtc_Word32 in[110/SUB_BLOCKS_8_22] // int32_t in[110/SUB_BLOCKS_8_22]
// WebRtc_Word16 out[220/SUB_BLOCKS_8_22] // int16_t out[220/SUB_BLOCKS_8_22]
///// /////
WebRtcSpl_UpBy2IntToShort(tmpmem, 110 / SUB_BLOCKS_8_22, out, state->S_11_22); WebRtcSpl_UpBy2IntToShort(tmpmem, 110 / SUB_BLOCKS_8_22, out, state->S_11_22);
@ -309,13 +309,13 @@ void WebRtcSpl_ResetResample8khzTo22khz(WebRtcSpl_State8khzTo22khz* state)
} }
// compute two inner-products and store them to output array // compute two inner-products and store them to output array
static void WebRtcSpl_DotProdIntToInt(const WebRtc_Word32* in1, const WebRtc_Word32* in2, static void WebRtcSpl_DotProdIntToInt(const int32_t* in1, const int32_t* in2,
const WebRtc_Word16* coef_ptr, WebRtc_Word32* out1, const int16_t* coef_ptr, int32_t* out1,
WebRtc_Word32* out2) int32_t* out2)
{ {
WebRtc_Word32 tmp1 = 16384; int32_t tmp1 = 16384;
WebRtc_Word32 tmp2 = 16384; int32_t tmp2 = 16384;
WebRtc_Word16 coef; int16_t coef;
coef = coef_ptr[0]; coef = coef_ptr[0];
tmp1 += coef * in1[0]; tmp1 += coef * in1[0];
@ -355,13 +355,13 @@ static void WebRtcSpl_DotProdIntToInt(const WebRtc_Word32* in1, const WebRtc_Wor
} }
// compute two inner-products and store them to output array // compute two inner-products and store them to output array
static void WebRtcSpl_DotProdIntToShort(const WebRtc_Word32* in1, const WebRtc_Word32* in2, static void WebRtcSpl_DotProdIntToShort(const int32_t* in1, const int32_t* in2,
const WebRtc_Word16* coef_ptr, WebRtc_Word16* out1, const int16_t* coef_ptr, int16_t* out1,
WebRtc_Word16* out2) int16_t* out2)
{ {
WebRtc_Word32 tmp1 = 16384; int32_t tmp1 = 16384;
WebRtc_Word32 tmp2 = 16384; int32_t tmp2 = 16384;
WebRtc_Word16 coef; int16_t coef;
coef = coef_ptr[0]; coef = coef_ptr[0];
tmp1 += coef * in1[0]; tmp1 += coef * in1[0];
@ -401,39 +401,39 @@ static void WebRtcSpl_DotProdIntToShort(const WebRtc_Word32* in1, const WebRtc_W
// scale down, round and saturate // scale down, round and saturate
tmp1 >>= 15; tmp1 >>= 15;
if (tmp1 > (WebRtc_Word32)0x00007FFF) if (tmp1 > (int32_t)0x00007FFF)
tmp1 = 0x00007FFF; tmp1 = 0x00007FFF;
if (tmp1 < (WebRtc_Word32)0xFFFF8000) if (tmp1 < (int32_t)0xFFFF8000)
tmp1 = 0xFFFF8000; tmp1 = 0xFFFF8000;
tmp2 >>= 15; tmp2 >>= 15;
if (tmp2 > (WebRtc_Word32)0x00007FFF) if (tmp2 > (int32_t)0x00007FFF)
tmp2 = 0x00007FFF; tmp2 = 0x00007FFF;
if (tmp2 < (WebRtc_Word32)0xFFFF8000) if (tmp2 < (int32_t)0xFFFF8000)
tmp2 = 0xFFFF8000; tmp2 = 0xFFFF8000;
*out1 = (WebRtc_Word16)tmp1; *out1 = (int16_t)tmp1;
*out2 = (WebRtc_Word16)tmp2; *out2 = (int16_t)tmp2;
} }
// Resampling ratio: 11/16 // Resampling ratio: 11/16
// input: WebRtc_Word32 (normalized, not saturated) :: size 16 * K // input: int32_t (normalized, not saturated) :: size 16 * K
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 11 * K // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 11 * K
// K: Number of blocks // K: Number of blocks
void WebRtcSpl_32khzTo22khzIntToInt(const WebRtc_Word32* In, void WebRtcSpl_32khzTo22khzIntToInt(const int32_t* In,
WebRtc_Word32* Out, int32_t* Out,
const WebRtc_Word32 K) const int32_t K)
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Filter operation: // Filter operation:
// //
// Perform resampling (16 input samples -> 11 output samples); // Perform resampling (16 input samples -> 11 output samples);
// process in sub blocks of size 16 samples. // process in sub blocks of size 16 samples.
WebRtc_Word32 m; int32_t m;
for (m = 0; m < K; m++) for (m = 0; m < K; m++)
{ {
// first output sample // first output sample
Out[0] = ((WebRtc_Word32)In[3] << 15) + (1 << 14); Out[0] = ((int32_t)In[3] << 15) + (1 << 14);
// sum and accumulate filter coefficients and input samples // sum and accumulate filter coefficients and input samples
WebRtcSpl_DotProdIntToInt(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]); WebRtcSpl_DotProdIntToInt(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]);
@ -457,31 +457,31 @@ void WebRtcSpl_32khzTo22khzIntToInt(const WebRtc_Word32* In,
} }
// Resampling ratio: 11/16 // Resampling ratio: 11/16
// input: WebRtc_Word32 (normalized, not saturated) :: size 16 * K // input: int32_t (normalized, not saturated) :: size 16 * K
// output: WebRtc_Word16 (saturated) :: size 11 * K // output: int16_t (saturated) :: size 11 * K
// K: Number of blocks // K: Number of blocks
void WebRtcSpl_32khzTo22khzIntToShort(const WebRtc_Word32 *In, void WebRtcSpl_32khzTo22khzIntToShort(const int32_t *In,
WebRtc_Word16 *Out, int16_t *Out,
const WebRtc_Word32 K) const int32_t K)
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Filter operation: // Filter operation:
// //
// Perform resampling (16 input samples -> 11 output samples); // Perform resampling (16 input samples -> 11 output samples);
// process in sub blocks of size 16 samples. // process in sub blocks of size 16 samples.
WebRtc_Word32 tmp; int32_t tmp;
WebRtc_Word32 m; int32_t m;
for (m = 0; m < K; m++) for (m = 0; m < K; m++)
{ {
// first output sample // first output sample
tmp = In[3]; tmp = In[3];
if (tmp > (WebRtc_Word32)0x00007FFF) if (tmp > (int32_t)0x00007FFF)
tmp = 0x00007FFF; tmp = 0x00007FFF;
if (tmp < (WebRtc_Word32)0xFFFF8000) if (tmp < (int32_t)0xFFFF8000)
tmp = 0xFFFF8000; tmp = 0xFFFF8000;
Out[0] = (WebRtc_Word16)tmp; Out[0] = (int16_t)tmp;
// sum and accumulate filter coefficients and input samples // sum and accumulate filter coefficients and input samples
WebRtcSpl_DotProdIntToShort(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]); WebRtcSpl_DotProdIntToShort(&In[0], &In[22], kCoefficients32To22[0], &Out[1], &Out[10]);

View File

@ -24,27 +24,27 @@
//////////////////////////// ////////////////////////////
// 48 -> 16 resampler // 48 -> 16 resampler
void WebRtcSpl_Resample48khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample48khzTo16khz(const int16_t* in, int16_t* out,
WebRtcSpl_State48khzTo16khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State48khzTo16khz* state, int32_t* tmpmem)
{ {
///// 48 --> 48(LP) ///// ///// 48 --> 48(LP) /////
// WebRtc_Word16 in[480] // int16_t in[480]
// WebRtc_Word32 out[480] // int32_t out[480]
///// /////
WebRtcSpl_LPBy2ShortToInt(in, 480, tmpmem + 16, state->S_48_48); WebRtcSpl_LPBy2ShortToInt(in, 480, tmpmem + 16, state->S_48_48);
///// 48 --> 32 ///// ///// 48 --> 32 /////
// WebRtc_Word32 in[480] // int32_t in[480]
// WebRtc_Word32 out[320] // int32_t out[320]
///// /////
// copy state to and from input array // copy state to and from input array
memcpy(tmpmem + 8, state->S_48_32, 8 * sizeof(WebRtc_Word32)); memcpy(tmpmem + 8, state->S_48_32, 8 * sizeof(int32_t));
memcpy(state->S_48_32, tmpmem + 488, 8 * sizeof(WebRtc_Word32)); memcpy(state->S_48_32, tmpmem + 488, 8 * sizeof(int32_t));
WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 160); WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 160);
///// 32 --> 16 ///// ///// 32 --> 16 /////
// WebRtc_Word32 in[320] // int32_t in[320]
// WebRtc_Word16 out[160] // int16_t out[160]
///// /////
WebRtcSpl_DownBy2IntToShort(tmpmem, 320, out, state->S_32_16); WebRtcSpl_DownBy2IntToShort(tmpmem, 320, out, state->S_32_16);
} }
@ -52,9 +52,9 @@ void WebRtcSpl_Resample48khzTo16khz(const WebRtc_Word16* in, WebRtc_Word16* out,
// initialize state of 48 -> 16 resampler // initialize state of 48 -> 16 resampler
void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state) void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state)
{ {
memset(state->S_48_48, 0, 16 * sizeof(WebRtc_Word32)); memset(state->S_48_48, 0, 16 * sizeof(int32_t));
memset(state->S_48_32, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_48_32, 0, 8 * sizeof(int32_t));
memset(state->S_32_16, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_32_16, 0, 8 * sizeof(int32_t));
} }
//////////////////////////// ////////////////////////////
@ -62,27 +62,27 @@ void WebRtcSpl_ResetResample48khzTo16khz(WebRtcSpl_State48khzTo16khz* state)
//////////////////////////// ////////////////////////////
// 16 -> 48 resampler // 16 -> 48 resampler
void WebRtcSpl_Resample16khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample16khzTo48khz(const int16_t* in, int16_t* out,
WebRtcSpl_State16khzTo48khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State16khzTo48khz* state, int32_t* tmpmem)
{ {
///// 16 --> 32 ///// ///// 16 --> 32 /////
// WebRtc_Word16 in[160] // int16_t in[160]
// WebRtc_Word32 out[320] // int32_t out[320]
///// /////
WebRtcSpl_UpBy2ShortToInt(in, 160, tmpmem + 16, state->S_16_32); WebRtcSpl_UpBy2ShortToInt(in, 160, tmpmem + 16, state->S_16_32);
///// 32 --> 24 ///// ///// 32 --> 24 /////
// WebRtc_Word32 in[320] // int32_t in[320]
// WebRtc_Word32 out[240] // int32_t out[240]
// copy state to and from input array // copy state to and from input array
///// /////
memcpy(tmpmem + 8, state->S_32_24, 8 * sizeof(WebRtc_Word32)); memcpy(tmpmem + 8, state->S_32_24, 8 * sizeof(int32_t));
memcpy(state->S_32_24, tmpmem + 328, 8 * sizeof(WebRtc_Word32)); memcpy(state->S_32_24, tmpmem + 328, 8 * sizeof(int32_t));
WebRtcSpl_Resample32khzTo24khz(tmpmem + 8, tmpmem, 80); WebRtcSpl_Resample32khzTo24khz(tmpmem + 8, tmpmem, 80);
///// 24 --> 48 ///// ///// 24 --> 48 /////
// WebRtc_Word32 in[240] // int32_t in[240]
// WebRtc_Word16 out[480] // int16_t out[480]
///// /////
WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48);
} }
@ -90,9 +90,9 @@ void WebRtcSpl_Resample16khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out,
// initialize state of 16 -> 48 resampler // initialize state of 16 -> 48 resampler
void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state) void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state)
{ {
memset(state->S_16_32, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_16_32, 0, 8 * sizeof(int32_t));
memset(state->S_32_24, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_32_24, 0, 8 * sizeof(int32_t));
memset(state->S_24_48, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_24_48, 0, 8 * sizeof(int32_t));
} }
//////////////////////////// ////////////////////////////
@ -100,33 +100,33 @@ void WebRtcSpl_ResetResample16khzTo48khz(WebRtcSpl_State16khzTo48khz* state)
//////////////////////////// ////////////////////////////
// 48 -> 8 resampler // 48 -> 8 resampler
void WebRtcSpl_Resample48khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample48khzTo8khz(const int16_t* in, int16_t* out,
WebRtcSpl_State48khzTo8khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State48khzTo8khz* state, int32_t* tmpmem)
{ {
///// 48 --> 24 ///// ///// 48 --> 24 /////
// WebRtc_Word16 in[480] // int16_t in[480]
// WebRtc_Word32 out[240] // int32_t out[240]
///// /////
WebRtcSpl_DownBy2ShortToInt(in, 480, tmpmem + 256, state->S_48_24); WebRtcSpl_DownBy2ShortToInt(in, 480, tmpmem + 256, state->S_48_24);
///// 24 --> 24(LP) ///// ///// 24 --> 24(LP) /////
// WebRtc_Word32 in[240] // int32_t in[240]
// WebRtc_Word32 out[240] // int32_t out[240]
///// /////
WebRtcSpl_LPBy2IntToInt(tmpmem + 256, 240, tmpmem + 16, state->S_24_24); WebRtcSpl_LPBy2IntToInt(tmpmem + 256, 240, tmpmem + 16, state->S_24_24);
///// 24 --> 16 ///// ///// 24 --> 16 /////
// WebRtc_Word32 in[240] // int32_t in[240]
// WebRtc_Word32 out[160] // int32_t out[160]
///// /////
// copy state to and from input array // copy state to and from input array
memcpy(tmpmem + 8, state->S_24_16, 8 * sizeof(WebRtc_Word32)); memcpy(tmpmem + 8, state->S_24_16, 8 * sizeof(int32_t));
memcpy(state->S_24_16, tmpmem + 248, 8 * sizeof(WebRtc_Word32)); memcpy(state->S_24_16, tmpmem + 248, 8 * sizeof(int32_t));
WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 80); WebRtcSpl_Resample48khzTo32khz(tmpmem + 8, tmpmem, 80);
///// 16 --> 8 ///// ///// 16 --> 8 /////
// WebRtc_Word32 in[160] // int32_t in[160]
// WebRtc_Word16 out[80] // int16_t out[80]
///// /////
WebRtcSpl_DownBy2IntToShort(tmpmem, 160, out, state->S_16_8); WebRtcSpl_DownBy2IntToShort(tmpmem, 160, out, state->S_16_8);
} }
@ -134,10 +134,10 @@ void WebRtcSpl_Resample48khzTo8khz(const WebRtc_Word16* in, WebRtc_Word16* out,
// initialize state of 48 -> 8 resampler // initialize state of 48 -> 8 resampler
void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state) void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state)
{ {
memset(state->S_48_24, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_48_24, 0, 8 * sizeof(int32_t));
memset(state->S_24_24, 0, 16 * sizeof(WebRtc_Word32)); memset(state->S_24_24, 0, 16 * sizeof(int32_t));
memset(state->S_24_16, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_24_16, 0, 8 * sizeof(int32_t));
memset(state->S_16_8, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_16_8, 0, 8 * sizeof(int32_t));
} }
//////////////////////////// ////////////////////////////
@ -145,33 +145,33 @@ void WebRtcSpl_ResetResample48khzTo8khz(WebRtcSpl_State48khzTo8khz* state)
//////////////////////////// ////////////////////////////
// 8 -> 48 resampler // 8 -> 48 resampler
void WebRtcSpl_Resample8khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out, void WebRtcSpl_Resample8khzTo48khz(const int16_t* in, int16_t* out,
WebRtcSpl_State8khzTo48khz* state, WebRtc_Word32* tmpmem) WebRtcSpl_State8khzTo48khz* state, int32_t* tmpmem)
{ {
///// 8 --> 16 ///// ///// 8 --> 16 /////
// WebRtc_Word16 in[80] // int16_t in[80]
// WebRtc_Word32 out[160] // int32_t out[160]
///// /////
WebRtcSpl_UpBy2ShortToInt(in, 80, tmpmem + 264, state->S_8_16); WebRtcSpl_UpBy2ShortToInt(in, 80, tmpmem + 264, state->S_8_16);
///// 16 --> 12 ///// ///// 16 --> 12 /////
// WebRtc_Word32 in[160] // int32_t in[160]
// WebRtc_Word32 out[120] // int32_t out[120]
///// /////
// copy state to and from input array // copy state to and from input array
memcpy(tmpmem + 256, state->S_16_12, 8 * sizeof(WebRtc_Word32)); memcpy(tmpmem + 256, state->S_16_12, 8 * sizeof(int32_t));
memcpy(state->S_16_12, tmpmem + 416, 8 * sizeof(WebRtc_Word32)); memcpy(state->S_16_12, tmpmem + 416, 8 * sizeof(int32_t));
WebRtcSpl_Resample32khzTo24khz(tmpmem + 256, tmpmem + 240, 40); WebRtcSpl_Resample32khzTo24khz(tmpmem + 256, tmpmem + 240, 40);
///// 12 --> 24 ///// ///// 12 --> 24 /////
// WebRtc_Word32 in[120] // int32_t in[120]
// WebRtc_Word16 out[240] // int16_t out[240]
///// /////
WebRtcSpl_UpBy2IntToInt(tmpmem + 240, 120, tmpmem, state->S_12_24); WebRtcSpl_UpBy2IntToInt(tmpmem + 240, 120, tmpmem, state->S_12_24);
///// 24 --> 48 ///// ///// 24 --> 48 /////
// WebRtc_Word32 in[240] // int32_t in[240]
// WebRtc_Word16 out[480] // int16_t out[480]
///// /////
WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48); WebRtcSpl_UpBy2IntToShort(tmpmem, 240, out, state->S_24_48);
} }
@ -179,8 +179,8 @@ void WebRtcSpl_Resample8khzTo48khz(const WebRtc_Word16* in, WebRtc_Word16* out,
// initialize state of 8 -> 48 resampler // initialize state of 8 -> 48 resampler
void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state) void WebRtcSpl_ResetResample8khzTo48khz(WebRtcSpl_State8khzTo48khz* state)
{ {
memset(state->S_8_16, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_8_16, 0, 8 * sizeof(int32_t));
memset(state->S_16_12, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_16_12, 0, 8 * sizeof(int32_t));
memset(state->S_12_24, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_12_24, 0, 8 * sizeof(int32_t));
memset(state->S_24_48, 0, 8 * sizeof(WebRtc_Word32)); memset(state->S_24_48, 0, 8 * sizeof(int32_t));
} }

View File

@ -20,17 +20,17 @@
#ifdef WEBRTC_ARCH_ARM_V7 #ifdef WEBRTC_ARCH_ARM_V7
// allpass filter coefficients. // allpass filter coefficients.
static const WebRtc_UWord32 kResampleAllpass1[3] = {3284, 24441, 49528 << 15}; static const uint32_t kResampleAllpass1[3] = {3284, 24441, 49528 << 15};
static const WebRtc_UWord32 kResampleAllpass2[3] = static const uint32_t kResampleAllpass2[3] =
{12199, 37471 << 15, 60255 << 15}; {12199, 37471 << 15, 60255 << 15};
// Multiply two 32-bit values and accumulate to another input value. // Multiply two 32-bit values and accumulate to another input value.
// Return: state + ((diff * tbl_value) >> 16) // Return: state + ((diff * tbl_value) >> 16)
static __inline WebRtc_Word32 MUL_ACCUM_1(WebRtc_Word32 tbl_value, static __inline int32_t MUL_ACCUM_1(int32_t tbl_value,
WebRtc_Word32 diff, int32_t diff,
WebRtc_Word32 state) { int32_t state) {
WebRtc_Word32 result; int32_t result;
__asm __volatile ("smlawb %0, %1, %2, %3": "=r"(result): "r"(diff), __asm __volatile ("smlawb %0, %1, %2, %3": "=r"(result): "r"(diff),
"r"(tbl_value), "r"(state)); "r"(tbl_value), "r"(state));
return result; return result;
@ -43,10 +43,10 @@ static __inline WebRtc_Word32 MUL_ACCUM_1(WebRtc_Word32 tbl_value,
// instruction (in MUL_ACCUM_1) due to input value range, we can still use // instruction (in MUL_ACCUM_1) due to input value range, we can still use
// smmla to save some cycles. // smmla to save some cycles.
static __inline WebRtc_Word32 MUL_ACCUM_2(WebRtc_Word32 tbl_value, static __inline int32_t MUL_ACCUM_2(int32_t tbl_value,
WebRtc_Word32 diff, int32_t diff,
WebRtc_Word32 state) { int32_t state) {
WebRtc_Word32 result; int32_t result;
__asm __volatile ("smmla %0, %1, %2, %3": "=r"(result): "r"(diff << 1), __asm __volatile ("smmla %0, %1, %2, %3": "=r"(result): "r"(diff << 1),
"r"(tbl_value), "r"(state)); "r"(tbl_value), "r"(state));
return result; return result;
@ -55,8 +55,8 @@ static __inline WebRtc_Word32 MUL_ACCUM_2(WebRtc_Word32 tbl_value,
#else #else
// allpass filter coefficients. // allpass filter coefficients.
static const WebRtc_UWord16 kResampleAllpass1[3] = {3284, 24441, 49528}; static const uint16_t kResampleAllpass1[3] = {3284, 24441, 49528};
static const WebRtc_UWord16 kResampleAllpass2[3] = {12199, 37471, 60255}; static const uint16_t kResampleAllpass2[3] = {12199, 37471, 60255};
// Multiply a 32-bit value with a 16-bit value and accumulate to another input: // Multiply a 32-bit value with a 16-bit value and accumulate to another input:
#define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) #define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c)
@ -67,23 +67,23 @@ static const WebRtc_UWord16 kResampleAllpass2[3] = {12199, 37471, 60255};
// decimator // decimator
#if !defined(MIPS32_LE) #if !defined(MIPS32_LE)
void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len, void WebRtcSpl_DownsampleBy2(const int16_t* in, const int16_t len,
WebRtc_Word16* out, WebRtc_Word32* filtState) { int16_t* out, int32_t* filtState) {
WebRtc_Word32 tmp1, tmp2, diff, in32, out32; int32_t tmp1, tmp2, diff, in32, out32;
WebRtc_Word16 i; int16_t i;
register WebRtc_Word32 state0 = filtState[0]; register int32_t state0 = filtState[0];
register WebRtc_Word32 state1 = filtState[1]; register int32_t state1 = filtState[1];
register WebRtc_Word32 state2 = filtState[2]; register int32_t state2 = filtState[2];
register WebRtc_Word32 state3 = filtState[3]; register int32_t state3 = filtState[3];
register WebRtc_Word32 state4 = filtState[4]; register int32_t state4 = filtState[4];
register WebRtc_Word32 state5 = filtState[5]; register int32_t state5 = filtState[5];
register WebRtc_Word32 state6 = filtState[6]; register int32_t state6 = filtState[6];
register WebRtc_Word32 state7 = filtState[7]; register int32_t state7 = filtState[7];
for (i = (len >> 1); i > 0; i--) { for (i = (len >> 1); i > 0; i--) {
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32; state0 = in32;
@ -95,7 +95,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len,
state2 = tmp2; state2 = tmp2;
// upper allpass filter // upper allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state5; diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32; state4 = in32;
@ -125,23 +125,23 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, const WebRtc_Word16 len,
#endif // #if defined(MIPS32_LE) #endif // #if defined(MIPS32_LE)
void WebRtcSpl_UpsampleBy2(const WebRtc_Word16* in, WebRtc_Word16 len, void WebRtcSpl_UpsampleBy2(const int16_t* in, int16_t len,
WebRtc_Word16* out, WebRtc_Word32* filtState) { int16_t* out, int32_t* filtState) {
WebRtc_Word32 tmp1, tmp2, diff, in32, out32; int32_t tmp1, tmp2, diff, in32, out32;
WebRtc_Word16 i; int16_t i;
register WebRtc_Word32 state0 = filtState[0]; register int32_t state0 = filtState[0];
register WebRtc_Word32 state1 = filtState[1]; register int32_t state1 = filtState[1];
register WebRtc_Word32 state2 = filtState[2]; register int32_t state2 = filtState[2];
register WebRtc_Word32 state3 = filtState[3]; register int32_t state3 = filtState[3];
register WebRtc_Word32 state4 = filtState[4]; register int32_t state4 = filtState[4];
register WebRtc_Word32 state5 = filtState[5]; register int32_t state5 = filtState[5];
register WebRtc_Word32 state6 = filtState[6]; register int32_t state6 = filtState[6];
register WebRtc_Word32 state7 = filtState[7]; register int32_t state7 = filtState[7];
for (i = len; i > 0; i--) { for (i = len; i > 0; i--) {
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state0);
state0 = in32; state0 = in32;

View File

@ -17,22 +17,22 @@
#include "resample_by_2_internal.h" #include "resample_by_2_internal.h"
// allpass filter coefficients. // allpass filter coefficients.
static const WebRtc_Word16 kResampleAllpass[2][3] = { static const int16_t kResampleAllpass[2][3] = {
{821, 6110, 12382}, {821, 6110, 12382},
{3050, 9368, 15063} {3050, 9368, 15063}
}; };
// //
// decimator // decimator
// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) OVERWRITTEN! // input: int32_t (shifted 15 positions to the left, + offset 16384) OVERWRITTEN!
// output: WebRtc_Word16 (saturated) (of length len/2) // output: int16_t (saturated) (of length len/2)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, void WebRtcSpl_DownBy2IntToShort(int32_t *in, int32_t len, int16_t *out,
WebRtc_Word32 *state) int32_t *state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
len >>= 1; len >>= 1;
@ -102,39 +102,39 @@ void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Wo
// divide by two, add both allpass outputs and round // divide by two, add both allpass outputs and round
tmp0 = (in[i << 1] + in[(i << 1) + 1]) >> 15; tmp0 = (in[i << 1] + in[(i << 1) + 1]) >> 15;
tmp1 = (in[(i << 1) + 2] + in[(i << 1) + 3]) >> 15; tmp1 = (in[(i << 1) + 2] + in[(i << 1) + 3]) >> 15;
if (tmp0 > (WebRtc_Word32)0x00007FFF) if (tmp0 > (int32_t)0x00007FFF)
tmp0 = 0x00007FFF; tmp0 = 0x00007FFF;
if (tmp0 < (WebRtc_Word32)0xFFFF8000) if (tmp0 < (int32_t)0xFFFF8000)
tmp0 = 0xFFFF8000; tmp0 = 0xFFFF8000;
out[i] = (WebRtc_Word16)tmp0; out[i] = (int16_t)tmp0;
if (tmp1 > (WebRtc_Word32)0x00007FFF) if (tmp1 > (int32_t)0x00007FFF)
tmp1 = 0x00007FFF; tmp1 = 0x00007FFF;
if (tmp1 < (WebRtc_Word32)0xFFFF8000) if (tmp1 < (int32_t)0xFFFF8000)
tmp1 = 0xFFFF8000; tmp1 = 0xFFFF8000;
out[i + 1] = (WebRtc_Word16)tmp1; out[i + 1] = (int16_t)tmp1;
} }
} }
// //
// decimator // decimator
// input: WebRtc_Word16 // input: int16_t
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) (of length len/2) // output: int32_t (shifted 15 positions to the left, + offset 16384) (of length len/2)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in, void WebRtcSpl_DownBy2ShortToInt(const int16_t *in,
WebRtc_Word32 len, int32_t len,
WebRtc_Word32 *out, int32_t *out,
WebRtc_Word32 *state) int32_t *state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
len >>= 1; len >>= 1;
// lower allpass filter (operates on even input samples) // lower allpass filter (operates on even input samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
diff = tmp0 - state[1]; diff = tmp0 - state[1];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -164,7 +164,7 @@ void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in,
// upper allpass filter (operates on odd input samples) // upper allpass filter (operates on odd input samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
diff = tmp0 - state[5]; diff = tmp0 - state[5];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -194,19 +194,19 @@ void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in,
// //
// interpolator // interpolator
// input: WebRtc_Word16 // input: int16_t
// output: WebRtc_Word32 (normalized, not saturated) (of length len*2) // output: int32_t (normalized, not saturated) (of length len*2)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, WebRtc_Word32 *out, void WebRtcSpl_UpBy2ShortToInt(const int16_t *in, int32_t len, int32_t *out,
WebRtc_Word32 *state) int32_t *state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
// upper allpass filter (generates odd output samples) // upper allpass filter (generates odd output samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i] << 15) + (1 << 14); tmp0 = ((int32_t)in[i] << 15) + (1 << 14);
diff = tmp0 - state[5]; diff = tmp0 - state[5];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -236,7 +236,7 @@ void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, WebRt
// lower allpass filter (generates even output samples) // lower allpass filter (generates even output samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i] << 15) + (1 << 14); tmp0 = ((int32_t)in[i] << 15) + (1 << 14);
diff = tmp0 - state[1]; diff = tmp0 - state[1];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -264,14 +264,14 @@ void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, WebRt
// //
// interpolator // interpolator
// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) // input: int32_t (shifted 15 positions to the left, + offset 16384)
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) (of length len*2) // output: int32_t (shifted 15 positions to the left, + offset 16384) (of length len*2)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word32 *out, void WebRtcSpl_UpBy2IntToInt(const int32_t *in, int32_t len, int32_t *out,
WebRtc_Word32 *state) int32_t *state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
// upper allpass filter (generates odd output samples) // upper allpass filter (generates odd output samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@ -334,14 +334,14 @@ void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_
// //
// interpolator // interpolator
// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) // input: int32_t (shifted 15 positions to the left, + offset 16384)
// output: WebRtc_Word16 (saturated) (of length len*2) // output: int16_t (saturated) (of length len*2)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, void WebRtcSpl_UpBy2IntToShort(const int32_t *in, int32_t len, int16_t *out,
WebRtc_Word32 *state) int32_t *state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
// upper allpass filter (generates odd output samples) // upper allpass filter (generates odd output samples)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
@ -369,11 +369,11 @@ void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRt
// scale down, saturate and store // scale down, saturate and store
tmp1 = state[7] >> 15; tmp1 = state[7] >> 15;
if (tmp1 > (WebRtc_Word32)0x00007FFF) if (tmp1 > (int32_t)0x00007FFF)
tmp1 = 0x00007FFF; tmp1 = 0x00007FFF;
if (tmp1 < (WebRtc_Word32)0xFFFF8000) if (tmp1 < (int32_t)0xFFFF8000)
tmp1 = 0xFFFF8000; tmp1 = 0xFFFF8000;
out[i << 1] = (WebRtc_Word16)tmp1; out[i << 1] = (int16_t)tmp1;
} }
out++; out++;
@ -404,23 +404,23 @@ void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRt
// scale down, saturate and store // scale down, saturate and store
tmp1 = state[3] >> 15; tmp1 = state[3] >> 15;
if (tmp1 > (WebRtc_Word32)0x00007FFF) if (tmp1 > (int32_t)0x00007FFF)
tmp1 = 0x00007FFF; tmp1 = 0x00007FFF;
if (tmp1 < (WebRtc_Word32)0xFFFF8000) if (tmp1 < (int32_t)0xFFFF8000)
tmp1 = 0xFFFF8000; tmp1 = 0xFFFF8000;
out[i << 1] = (WebRtc_Word16)tmp1; out[i << 1] = (int16_t)tmp1;
} }
} }
// lowpass filter // lowpass filter
// input: WebRtc_Word16 // input: int16_t
// output: WebRtc_Word32 (normalized, not saturated) // output: int32_t (normalized, not saturated)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRtc_Word32* out, void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, int32_t len, int32_t* out,
WebRtc_Word32* state) int32_t* state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
len >>= 1; len >>= 1;
@ -452,14 +452,14 @@ void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRt
// scale down, round and store // scale down, round and store
out[i << 1] = state[3] >> 1; out[i << 1] = state[3] >> 1;
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
} }
in--; in--;
// upper allpass filter: even input -> even output samples // upper allpass filter: even input -> even output samples
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
diff = tmp0 - state[5]; diff = tmp0 - state[5];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -490,7 +490,7 @@ void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRt
// lower allpass filter: even input -> odd output samples // lower allpass filter: even input -> odd output samples
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
diff = tmp0 - state[9]; diff = tmp0 - state[9];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -519,7 +519,7 @@ void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRt
in++; in++;
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
tmp0 = ((WebRtc_Word32)in[i << 1] << 15) + (1 << 14); tmp0 = ((int32_t)in[i << 1] << 15) + (1 << 14);
diff = tmp0 - state[13]; diff = tmp0 - state[13];
// scale down and round // scale down and round
diff = (diff + (1 << 13)) >> 14; diff = (diff + (1 << 13)) >> 14;
@ -546,14 +546,14 @@ void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, WebRt
} }
// lowpass filter // lowpass filter
// input: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) // input: int32_t (shifted 15 positions to the left, + offset 16384)
// output: WebRtc_Word32 (normalized, not saturated) // output: int32_t (normalized, not saturated)
// state: filter state array; length = 8 // state: filter state array; length = 8
void WebRtcSpl_LPBy2IntToInt(const WebRtc_Word32* in, WebRtc_Word32 len, WebRtc_Word32* out, void WebRtcSpl_LPBy2IntToInt(const int32_t* in, int32_t len, int32_t* out,
WebRtc_Word32* state) int32_t* state)
{ {
WebRtc_Word32 tmp0, tmp1, diff; int32_t tmp0, tmp1, diff;
WebRtc_Word32 i; int32_t i;
len >>= 1; len >>= 1;

View File

@ -23,25 +23,25 @@
* resample_by_2_fast.c * resample_by_2_fast.c
* Functions for internal use in the other resample functions * Functions for internal use in the other resample functions
******************************************************************/ ******************************************************************/
void WebRtcSpl_DownBy2IntToShort(WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word16 *out, void WebRtcSpl_DownBy2IntToShort(int32_t *in, int32_t len, int16_t *out,
WebRtc_Word32 *state); int32_t *state);
void WebRtcSpl_DownBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, void WebRtcSpl_DownBy2ShortToInt(const int16_t *in, int32_t len,
WebRtc_Word32 *out, WebRtc_Word32 *state); int32_t *out, int32_t *state);
void WebRtcSpl_UpBy2ShortToInt(const WebRtc_Word16 *in, WebRtc_Word32 len, void WebRtcSpl_UpBy2ShortToInt(const int16_t *in, int32_t len,
WebRtc_Word32 *out, WebRtc_Word32 *state); int32_t *out, int32_t *state);
void WebRtcSpl_UpBy2IntToInt(const WebRtc_Word32 *in, WebRtc_Word32 len, WebRtc_Word32 *out, void WebRtcSpl_UpBy2IntToInt(const int32_t *in, int32_t len, int32_t *out,
WebRtc_Word32 *state); int32_t *state);
void WebRtcSpl_UpBy2IntToShort(const WebRtc_Word32 *in, WebRtc_Word32 len, void WebRtcSpl_UpBy2IntToShort(const int32_t *in, int32_t len,
WebRtc_Word16 *out, WebRtc_Word32 *state); int16_t *out, int32_t *state);
void WebRtcSpl_LPBy2ShortToInt(const WebRtc_Word16* in, WebRtc_Word32 len, void WebRtcSpl_LPBy2ShortToInt(const int16_t* in, int32_t len,
WebRtc_Word32* out, WebRtc_Word32* state); int32_t* out, int32_t* state);
void WebRtcSpl_LPBy2IntToInt(const WebRtc_Word32* in, WebRtc_Word32 len, WebRtc_Word32* out, void WebRtcSpl_LPBy2IntToInt(const int32_t* in, int32_t len, int32_t* out,
WebRtc_Word32* state); int32_t* state);
#endif // WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_ #endif // WEBRTC_SPL_RESAMPLE_BY_2_INTERNAL_H_

View File

@ -20,32 +20,32 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
// allpass filter coefficients. // allpass filter coefficients.
static const WebRtc_UWord16 kResampleAllpass1[3] = {3284, 24441, 49528}; static const uint16_t kResampleAllpass1[3] = {3284, 24441, 49528};
static const WebRtc_UWord16 kResampleAllpass2[3] = {12199, 37471, 60255}; static const uint16_t kResampleAllpass2[3] = {12199, 37471, 60255};
// Multiply a 32-bit value with a 16-bit value and accumulate to another input: // Multiply a 32-bit value with a 16-bit value and accumulate to another input:
#define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) #define MUL_ACCUM_1(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c)
#define MUL_ACCUM_2(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c) #define MUL_ACCUM_2(a, b, c) WEBRTC_SPL_SCALEDIFF32(a, b, c)
// decimator // decimator
void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in, void WebRtcSpl_DownsampleBy2(const int16_t* in,
const WebRtc_Word16 len, const int16_t len,
WebRtc_Word16* out, int16_t* out,
WebRtc_Word32* filtState) { int32_t* filtState) {
WebRtc_Word32 out32; int32_t out32;
WebRtc_Word16 i, len1; int16_t i, len1;
register WebRtc_Word32 state0 = filtState[0]; register int32_t state0 = filtState[0];
register WebRtc_Word32 state1 = filtState[1]; register int32_t state1 = filtState[1];
register WebRtc_Word32 state2 = filtState[2]; register int32_t state2 = filtState[2];
register WebRtc_Word32 state3 = filtState[3]; register int32_t state3 = filtState[3];
register WebRtc_Word32 state4 = filtState[4]; register int32_t state4 = filtState[4];
register WebRtc_Word32 state5 = filtState[5]; register int32_t state5 = filtState[5];
register WebRtc_Word32 state6 = filtState[6]; register int32_t state6 = filtState[6];
register WebRtc_Word32 state7 = filtState[7]; register int32_t state7 = filtState[7];
#if defined(MIPS_DSP_R2_LE) #if defined(MIPS_DSP_R2_LE)
WebRtc_Word32 k1Res0, k1Res1, k1Res2, k2Res0, k2Res1, k2Res2; int32_t k1Res0, k1Res1, k1Res2, k2Res0, k2Res1, k2Res2;
k1Res0= 3284; k1Res0= 3284;
k1Res1= 24441; k1Res1= 24441;
@ -55,10 +55,10 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
k2Res2= 60255; k2Res2= 60255;
len1 = (len >> 1); len1 = (len >> 1);
const WebRtc_Word32* inw = (WebRtc_Word32*)in; const int32_t* inw = (int32_t*)in;
WebRtc_Word32 tmp11, tmp12, tmp21, tmp22; int32_t tmp11, tmp12, tmp21, tmp22;
WebRtc_Word32 in322, in321; int32_t in322, in321;
WebRtc_Word32 diff1, diff2; int32_t diff1, diff2;
for (i = len1; i > 0; i--) { for (i = len1; i > 0; i--) {
__asm__ volatile ( __asm__ volatile (
"lh %[in321], 0(%[inw]) \n\t" "lh %[in321], 0(%[inw]) \n\t"
@ -148,12 +148,12 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
*out++ = WebRtcSpl_SatW32ToW16(out32); *out++ = WebRtcSpl_SatW32ToW16(out32);
} }
#else // #if defined(MIPS_DSP_R2_LE) #else // #if defined(MIPS_DSP_R2_LE)
WebRtc_Word32 tmp1, tmp2, diff; int32_t tmp1, tmp2, diff;
WebRtc_Word32 in32; int32_t in32;
len1 = (len >> 1)/4; len1 = (len >> 1)/4;
for (i = len1; i > 0; i--) { for (i = len1; i > 0; i--) {
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32; state0 = in32;
@ -165,7 +165,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
state2 = tmp2; state2 = tmp2;
// upper allpass filter // upper allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state5; diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32; state4 = in32;
@ -182,7 +182,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
// limit amplitude to prevent wrap-around, and write to output array // limit amplitude to prevent wrap-around, and write to output array
*out++ = WebRtcSpl_SatW32ToW16(out32); *out++ = WebRtcSpl_SatW32ToW16(out32);
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32; state0 = in32;
@ -194,7 +194,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
state2 = tmp2; state2 = tmp2;
// upper allpass filter // upper allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state5; diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32; state4 = in32;
@ -211,7 +211,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
// limit amplitude to prevent wrap-around, and write to output array // limit amplitude to prevent wrap-around, and write to output array
*out++ = WebRtcSpl_SatW32ToW16(out32); *out++ = WebRtcSpl_SatW32ToW16(out32);
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32; state0 = in32;
@ -223,7 +223,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
state2 = tmp2; state2 = tmp2;
// upper allpass filter // upper allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state5; diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32; state4 = in32;
@ -240,7 +240,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
// limit amplitude to prevent wrap-around, and write to output array // limit amplitude to prevent wrap-around, and write to output array
*out++ = WebRtcSpl_SatW32ToW16(out32); *out++ = WebRtcSpl_SatW32ToW16(out32);
// lower allpass filter // lower allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state1; diff = in32 - state1;
tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0); tmp1 = MUL_ACCUM_1(kResampleAllpass2[0], diff, state0);
state0 = in32; state0 = in32;
@ -252,7 +252,7 @@ void WebRtcSpl_DownsampleBy2(const WebRtc_Word16* in,
state2 = tmp2; state2 = tmp2;
// upper allpass filter // upper allpass filter
in32 = (WebRtc_Word32)(*in++) << 10; in32 = (int32_t)(*in++) << 10;
diff = in32 - state5; diff = in32 - state5;
tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4); tmp1 = MUL_ACCUM_1(kResampleAllpass1[0], diff, state4);
state4 = in32; state4 = in32;

View File

@ -18,18 +18,18 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
// interpolation coefficients // interpolation coefficients
static const WebRtc_Word16 kCoefficients48To32[2][8] = { static const int16_t kCoefficients48To32[2][8] = {
{778, -2050, 1087, 23285, 12903, -3783, 441, 222}, {778, -2050, 1087, 23285, 12903, -3783, 441, 222},
{222, 441, -3783, 12903, 23285, 1087, -2050, 778} {222, 441, -3783, 12903, 23285, 1087, -2050, 778}
}; };
static const WebRtc_Word16 kCoefficients32To24[3][8] = { static const int16_t kCoefficients32To24[3][8] = {
{767, -2362, 2434, 24406, 10620, -3838, 721, 90}, {767, -2362, 2434, 24406, 10620, -3838, 721, 90},
{386, -381, -2646, 19062, 19062, -2646, -381, 386}, {386, -381, -2646, 19062, 19062, -2646, -381, 386},
{90, 721, -3838, 10620, 24406, 2434, -2362, 767} {90, 721, -3838, 10620, 24406, 2434, -2362, 767}
}; };
static const WebRtc_Word16 kCoefficients44To32[4][9] = { static const int16_t kCoefficients44To32[4][9] = {
{117, -669, 2245, -6183, 26267, 13529, -3245, 845, -138}, {117, -669, 2245, -6183, 26267, 13529, -3245, 845, -138},
{-101, 612, -2283, 8532, 29790, -5138, 1789, -524, 91}, {-101, 612, -2283, 8532, 29790, -5138, 1789, -524, 91},
{50, -292, 1016, -3064, 32010, 3933, -1147, 315, -53}, {50, -292, 1016, -3064, 32010, 3933, -1147, 315, -53},
@ -37,20 +37,20 @@ static const WebRtc_Word16 kCoefficients44To32[4][9] = {
}; };
// Resampling ratio: 2/3 // Resampling ratio: 2/3
// input: WebRtc_Word32 (normalized, not saturated) :: size 3 * K // input: int32_t (normalized, not saturated) :: size 3 * K
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 2 * K // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 2 * K
// K: number of blocks // K: number of blocks
void WebRtcSpl_Resample48khzTo32khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, void WebRtcSpl_Resample48khzTo32khz(const int32_t *In, int32_t *Out,
const WebRtc_Word32 K) const int32_t K)
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Filter operation: // Filter operation:
// //
// Perform resampling (3 input samples -> 2 output samples); // Perform resampling (3 input samples -> 2 output samples);
// process in sub blocks of size 3 samples. // process in sub blocks of size 3 samples.
WebRtc_Word32 tmp; int32_t tmp;
WebRtc_Word32 m; int32_t m;
for (m = 0; m < K; m++) for (m = 0; m < K; m++)
{ {
@ -83,20 +83,20 @@ void WebRtcSpl_Resample48khzTo32khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out,
} }
// Resampling ratio: 3/4 // Resampling ratio: 3/4
// input: WebRtc_Word32 (normalized, not saturated) :: size 4 * K // input: int32_t (normalized, not saturated) :: size 4 * K
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 3 * K // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 3 * K
// K: number of blocks // K: number of blocks
void WebRtcSpl_Resample32khzTo24khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, void WebRtcSpl_Resample32khzTo24khz(const int32_t *In, int32_t *Out,
const WebRtc_Word32 K) const int32_t K)
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Filter operation: // Filter operation:
// //
// Perform resampling (4 input samples -> 3 output samples); // Perform resampling (4 input samples -> 3 output samples);
// process in sub blocks of size 4 samples. // process in sub blocks of size 4 samples.
WebRtc_Word32 m; int32_t m;
WebRtc_Word32 tmp; int32_t tmp;
for (m = 0; m < K; m++) for (m = 0; m < K; m++)
{ {
@ -146,13 +146,13 @@ void WebRtcSpl_Resample32khzTo24khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out,
// //
// compute two inner-products and store them to output array // compute two inner-products and store them to output array
static void WebRtcSpl_ResampDotProduct(const WebRtc_Word32 *in1, const WebRtc_Word32 *in2, static void WebRtcSpl_ResampDotProduct(const int32_t *in1, const int32_t *in2,
const WebRtc_Word16 *coef_ptr, WebRtc_Word32 *out1, const int16_t *coef_ptr, int32_t *out1,
WebRtc_Word32 *out2) int32_t *out2)
{ {
WebRtc_Word32 tmp1 = 16384; int32_t tmp1 = 16384;
WebRtc_Word32 tmp2 = 16384; int32_t tmp2 = 16384;
WebRtc_Word16 coef; int16_t coef;
coef = coef_ptr[0]; coef = coef_ptr[0];
tmp1 += coef * in1[0]; tmp1 += coef * in1[0];
@ -192,27 +192,27 @@ static void WebRtcSpl_ResampDotProduct(const WebRtc_Word32 *in1, const WebRtc_Wo
} }
// Resampling ratio: 8/11 // Resampling ratio: 8/11
// input: WebRtc_Word32 (normalized, not saturated) :: size 11 * K // input: int32_t (normalized, not saturated) :: size 11 * K
// output: WebRtc_Word32 (shifted 15 positions to the left, + offset 16384) :: size 8 * K // output: int32_t (shifted 15 positions to the left, + offset 16384) :: size 8 * K
// K: number of blocks // K: number of blocks
void WebRtcSpl_Resample44khzTo32khz(const WebRtc_Word32 *In, WebRtc_Word32 *Out, void WebRtcSpl_Resample44khzTo32khz(const int32_t *In, int32_t *Out,
const WebRtc_Word32 K) const int32_t K)
{ {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// Filter operation: // Filter operation:
// //
// Perform resampling (11 input samples -> 8 output samples); // Perform resampling (11 input samples -> 8 output samples);
// process in sub blocks of size 11 samples. // process in sub blocks of size 11 samples.
WebRtc_Word32 tmp; int32_t tmp;
WebRtc_Word32 m; int32_t m;
for (m = 0; m < K; m++) for (m = 0; m < K; m++)
{ {
tmp = 1 << 14; tmp = 1 << 14;
// first output sample // first output sample
Out[0] = ((WebRtc_Word32)In[3] << 15) + tmp; Out[0] = ((int32_t)In[3] << 15) + tmp;
// sum and accumulate filter coefficients and input samples // sum and accumulate filter coefficients and input samples
tmp += kCoefficients44To32[3][0] * In[5]; tmp += kCoefficients44To32[3][0] * In[5];

View File

@ -131,10 +131,10 @@ TEST_F(SplTest, MacroTest) {
} }
TEST_F(SplTest, InlineTest) { TEST_F(SplTest, InlineTest) {
WebRtc_Word16 a16 = 121; int16_t a16 = 121;
WebRtc_Word16 b16 = -17; int16_t b16 = -17;
WebRtc_Word32 a32 = 111121; int32_t a32 = 111121;
WebRtc_Word32 b32 = -1711; int32_t b32 = -1711;
char bVersion[8]; char bVersion[8];
EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32)); EXPECT_EQ(17, WebRtcSpl_GetSizeInBits(a32));
@ -182,16 +182,16 @@ TEST_F(SplTest, InlineTest) {
TEST_F(SplTest, MathOperationsTest) { TEST_F(SplTest, MathOperationsTest) {
int A = 1134567892; int A = 1134567892;
WebRtc_Word32 num = 117; int32_t num = 117;
WebRtc_Word32 den = -5; int32_t den = -5;
WebRtc_UWord16 denU = 5; uint16_t denU = 5;
EXPECT_EQ(33700, WebRtcSpl_Sqrt(A)); EXPECT_EQ(33700, WebRtcSpl_Sqrt(A));
EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A)); EXPECT_EQ(33683, WebRtcSpl_SqrtFloor(A));
EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num)); EXPECT_EQ(-91772805, WebRtcSpl_DivResultInQ31(den, num));
EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (WebRtc_Word16)den)); EXPECT_EQ(-23, WebRtcSpl_DivW32W16ResW16(num, (int16_t)den));
EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (WebRtc_Word16)den)); EXPECT_EQ(-23, WebRtcSpl_DivW32W16(num, (int16_t)den));
EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU)); EXPECT_EQ(23u, WebRtcSpl_DivU32U16(num, denU));
EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256)); EXPECT_EQ(0, WebRtcSpl_DivW32HiLow(128, 0, 256));
} }
@ -199,13 +199,13 @@ TEST_F(SplTest, MathOperationsTest) {
TEST_F(SplTest, BasicArrayOperationsTest) { TEST_F(SplTest, BasicArrayOperationsTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
int B[] = {4, 12, 133, 1100}; int B[] = {4, 12, 133, 1100};
WebRtc_UWord8 b8[kVectorSize]; uint8_t b8[kVectorSize];
WebRtc_Word16 b16[kVectorSize]; int16_t b16[kVectorSize];
WebRtc_Word32 b32[kVectorSize]; int32_t b32[kVectorSize];
WebRtc_UWord8 bTmp8[kVectorSize]; uint8_t bTmp8[kVectorSize];
WebRtc_Word16 bTmp16[kVectorSize]; int16_t bTmp16[kVectorSize];
WebRtc_Word32 bTmp32[kVectorSize]; int32_t bTmp32[kVectorSize];
WebRtcSpl_MemSetW16(b16, 3, kVectorSize); WebRtcSpl_MemSetW16(b16, 3, kVectorSize);
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
@ -232,9 +232,9 @@ TEST_F(SplTest, BasicArrayOperationsTest) {
EXPECT_EQ(1, b32[kk]); EXPECT_EQ(1, b32[kk]);
} }
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
bTmp8[kk] = (WebRtc_Word8)kk; bTmp8[kk] = (int8_t)kk;
bTmp16[kk] = (WebRtc_Word16)kk; bTmp16[kk] = (int16_t)kk;
bTmp32[kk] = (WebRtc_Word32)kk; bTmp32[kk] = (int32_t)kk;
} }
WEBRTC_SPL_MEMCPY_W8(b8, bTmp8, kVectorSize); WEBRTC_SPL_MEMCPY_W8(b8, bTmp8, kVectorSize);
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
@ -255,7 +255,7 @@ TEST_F(SplTest, BasicArrayOperationsTest) {
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
b32[kk] = B[kk]; b32[kk] = B[kk];
b16[kk] = (WebRtc_Word16)B[kk]; b16[kk] = (int16_t)B[kk];
} }
WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1); WebRtcSpl_VectorBitShiftW32ToW16(bTmp16, kVectorSize, b32, 1);
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
@ -372,9 +372,9 @@ TEST_F(SplTest, MinMaxOperationsTest) {
TEST_F(SplTest, VectorOperationsTest) { TEST_F(SplTest, VectorOperationsTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
int B[] = {4, 12, 133, 1100}; int B[] = {4, 12, 133, 1100};
WebRtc_Word16 a16[kVectorSize]; int16_t a16[kVectorSize];
WebRtc_Word16 b16[kVectorSize]; int16_t b16[kVectorSize];
WebRtc_Word16 bTmp16[kVectorSize]; int16_t bTmp16[kVectorSize];
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
a16[kk] = B[kk]; a16[kk] = B[kk];
@ -433,9 +433,9 @@ TEST_F(SplTest, VectorOperationsTest) {
TEST_F(SplTest, EstimatorsTest) { TEST_F(SplTest, EstimatorsTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
int B[] = {4, 12, 133, 1100}; int B[] = {4, 12, 133, 1100};
WebRtc_Word16 b16[kVectorSize]; int16_t b16[kVectorSize];
WebRtc_Word32 b32[kVectorSize]; int32_t b32[kVectorSize];
WebRtc_Word16 bTmp16[kVectorSize]; int16_t bTmp16[kVectorSize];
for (int kk = 0; kk < kVectorSize; ++kk) { for (int kk = 0; kk < kVectorSize; ++kk) {
b16[kk] = B[kk]; b16[kk] = B[kk];
@ -448,14 +448,14 @@ TEST_F(SplTest, EstimatorsTest) {
TEST_F(SplTest, FilterTest) { TEST_F(SplTest, FilterTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
const int kFilterOrder = 3; const int kFilterOrder = 3;
WebRtc_Word16 A[] = {1, 2, 33, 100}; int16_t A[] = {1, 2, 33, 100};
WebRtc_Word16 A5[] = {1, 2, 33, 100, -5}; int16_t A5[] = {1, 2, 33, 100, -5};
WebRtc_Word16 B[] = {4, 12, 133, 110}; int16_t B[] = {4, 12, 133, 110};
WebRtc_Word16 data_in[kVectorSize]; int16_t data_in[kVectorSize];
WebRtc_Word16 data_out[kVectorSize]; int16_t data_out[kVectorSize];
WebRtc_Word16 bTmp16Low[kVectorSize]; int16_t bTmp16Low[kVectorSize];
WebRtc_Word16 bState[kVectorSize]; int16_t bState[kVectorSize];
WebRtc_Word16 bStateLow[kVectorSize]; int16_t bStateLow[kVectorSize];
WebRtcSpl_ZerosArrayW16(bState, kVectorSize); WebRtcSpl_ZerosArrayW16(bState, kVectorSize);
WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize); WebRtcSpl_ZerosArrayW16(bStateLow, kVectorSize);
@ -493,9 +493,9 @@ TEST_F(SplTest, FilterTest) {
TEST_F(SplTest, RandTest) { TEST_F(SplTest, RandTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
WebRtc_Word16 BU[] = {3653, 12446, 8525, 30691}; int16_t BU[] = {3653, 12446, 8525, 30691};
WebRtc_Word16 b16[kVectorSize]; int16_t b16[kVectorSize];
WebRtc_UWord32 bSeed = 100000; uint32_t bSeed = 100000;
EXPECT_EQ(464449057u, WebRtcSpl_IncreaseSeed(&bSeed)); EXPECT_EQ(464449057u, WebRtcSpl_IncreaseSeed(&bSeed));
EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed)); EXPECT_EQ(31565, WebRtcSpl_RandU(&bSeed));
@ -559,10 +559,10 @@ TEST_F(SplTest, AutoCorrelationTest) {
TEST_F(SplTest, SignalProcessingTest) { TEST_F(SplTest, SignalProcessingTest) {
const int kVectorSize = 4; const int kVectorSize = 4;
int A[] = {1, 2, 33, 100}; int A[] = {1, 2, 33, 100};
const WebRtc_Word16 kHanning[4] = { 2399, 8192, 13985, 16384 }; const int16_t kHanning[4] = { 2399, 8192, 13985, 16384 };
WebRtc_Word16 b16[kVectorSize]; int16_t b16[kVectorSize];
WebRtc_Word16 bTmp16[kVectorSize]; int16_t bTmp16[kVectorSize];
int bScale = 0; int bScale = 0;
@ -597,7 +597,7 @@ TEST_F(SplTest, SignalProcessingTest) {
} }
TEST_F(SplTest, FFTTest) { TEST_F(SplTest, FFTTest) {
WebRtc_Word16 B[] = {1, 2, 33, 100, int16_t B[] = {1, 2, 33, 100,
2, 3, 34, 101, 2, 3, 34, 101,
3, 4, 35, 102, 3, 4, 35, 102,
4, 5, 36, 103}; 4, 5, 36, 103};

View File

@ -17,13 +17,13 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
WebRtc_Word32 WebRtcSpl_SqrtLocal(WebRtc_Word32 in); int32_t WebRtcSpl_SqrtLocal(int32_t in);
WebRtc_Word32 WebRtcSpl_SqrtLocal(WebRtc_Word32 in) int32_t WebRtcSpl_SqrtLocal(int32_t in)
{ {
WebRtc_Word16 x_half, t16; int16_t x_half, t16;
WebRtc_Word32 A, B, x2; int32_t A, B, x2;
/* The following block performs: /* The following block performs:
y=in/2 y=in/2
@ -36,39 +36,39 @@ WebRtc_Word32 WebRtcSpl_SqrtLocal(WebRtc_Word32 in)
B = in; B = in;
B = WEBRTC_SPL_RSHIFT_W32(B, 1); // B = in/2 B = WEBRTC_SPL_RSHIFT_W32(B, 1); // B = in/2
B = B - ((WebRtc_Word32)0x40000000); // B = in/2 - 1/2 B = B - ((int32_t)0x40000000); // B = in/2 - 1/2
x_half = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(B, 16);// x_half = x/2 = (in-1)/2 x_half = (int16_t)WEBRTC_SPL_RSHIFT_W32(B, 16);// x_half = x/2 = (in-1)/2
B = B + ((WebRtc_Word32)0x40000000); // B = 1 + x/2 B = B + ((int32_t)0x40000000); // B = 1 + x/2
B = B + ((WebRtc_Word32)0x40000000); // Add 0.5 twice (since 1.0 does not exist in Q31) B = B + ((int32_t)0x40000000); // Add 0.5 twice (since 1.0 does not exist in Q31)
x2 = ((WebRtc_Word32)x_half) * ((WebRtc_Word32)x_half) * 2; // A = (x/2)^2 x2 = ((int32_t)x_half) * ((int32_t)x_half) * 2; // A = (x/2)^2
A = -x2; // A = -(x/2)^2 A = -x2; // A = -(x/2)^2
B = B + (A >> 1); // B = 1 + x/2 - 0.5*(x/2)^2 B = B + (A >> 1); // B = 1 + x/2 - 0.5*(x/2)^2
A = WEBRTC_SPL_RSHIFT_W32(A, 16); A = WEBRTC_SPL_RSHIFT_W32(A, 16);
A = A * A * 2; // A = (x/2)^4 A = A * A * 2; // A = (x/2)^4
t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16);
B = B + WEBRTC_SPL_MUL_16_16(-20480, t16) * 2; // B = B - 0.625*A B = B + WEBRTC_SPL_MUL_16_16(-20480, t16) * 2; // B = B - 0.625*A
// After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4
t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16);
A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = (x/2)^5 A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = (x/2)^5
t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16);
B = B + WEBRTC_SPL_MUL_16_16(28672, t16) * 2; // B = B + 0.875*A B = B + WEBRTC_SPL_MUL_16_16(28672, t16) * 2; // B = B + 0.875*A
// After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 + 0.875*(x/2)^5 // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 + 0.875*(x/2)^5
t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(x2, 16); t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(x2, 16);
A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = x/2^3 A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = x/2^3
B = B + (A >> 1); // B = B + 0.5*A B = B + (A >> 1); // B = B + 0.5*A
// After this, B = 1 + x/2 - 0.5*(x/2)^2 + 0.5*(x/2)^3 - 0.625*(x/2)^4 + 0.875*(x/2)^5 // After this, B = 1 + x/2 - 0.5*(x/2)^2 + 0.5*(x/2)^3 - 0.625*(x/2)^4 + 0.875*(x/2)^5
B = B + ((WebRtc_Word32)32768); // Round off bit B = B + ((int32_t)32768); // Round off bit
return B; return B;
} }
WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value) int32_t WebRtcSpl_Sqrt(int32_t value)
{ {
/* /*
Algorithm: Algorithm:
@ -132,43 +132,43 @@ WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value)
*/ */
WebRtc_Word16 x_norm, nshift, t16, sh; int16_t x_norm, nshift, t16, sh;
WebRtc_Word32 A; int32_t A;
WebRtc_Word16 k_sqrt_2 = 23170; // 1/sqrt2 (==5a82) int16_t k_sqrt_2 = 23170; // 1/sqrt2 (==5a82)
A = value; A = value;
if (A == 0) if (A == 0)
return (WebRtc_Word32)0; // sqrt(0) = 0 return (int32_t)0; // sqrt(0) = 0
sh = WebRtcSpl_NormW32(A); // # shifts to normalize A sh = WebRtcSpl_NormW32(A); // # shifts to normalize A
A = WEBRTC_SPL_LSHIFT_W32(A, sh); // Normalize A A = WEBRTC_SPL_LSHIFT_W32(A, sh); // Normalize A
if (A < (WEBRTC_SPL_WORD32_MAX - 32767)) if (A < (WEBRTC_SPL_WORD32_MAX - 32767))
{ {
A = A + ((WebRtc_Word32)32768); // Round off bit A = A + ((int32_t)32768); // Round off bit
} else } else
{ {
A = WEBRTC_SPL_WORD32_MAX; A = WEBRTC_SPL_WORD32_MAX;
} }
x_norm = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); // x_norm = AH x_norm = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); // x_norm = AH
nshift = WEBRTC_SPL_RSHIFT_W16(sh, 1); // nshift = sh>>1 nshift = WEBRTC_SPL_RSHIFT_W16(sh, 1); // nshift = sh>>1
nshift = -nshift; // Negate the power for later de-normalization nshift = -nshift; // Negate the power for later de-normalization
A = (WebRtc_Word32)WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)x_norm, 16); A = (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)x_norm, 16);
A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16) A = WEBRTC_SPL_ABS_W32(A); // A = abs(x_norm<<16)
A = WebRtcSpl_SqrtLocal(A); // A = sqrt(A) A = WebRtcSpl_SqrtLocal(A); // A = sqrt(A)
if ((-2 * nshift) == sh) if ((-2 * nshift) == sh)
{ // Even shift value case { // Even shift value case
t16 = (WebRtc_Word16)WEBRTC_SPL_RSHIFT_W32(A, 16); // t16 = AH t16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(A, 16); // t16 = AH
A = WEBRTC_SPL_MUL_16_16(k_sqrt_2, t16) * 2; // A = 1/sqrt(2)*t16 A = WEBRTC_SPL_MUL_16_16(k_sqrt_2, t16) * 2; // A = 1/sqrt(2)*t16
A = A + ((WebRtc_Word32)32768); // Round off A = A + ((int32_t)32768); // Round off
A = A & ((WebRtc_Word32)0x7fff0000); // Round off A = A & ((int32_t)0x7fff0000); // Round off
A = WEBRTC_SPL_RSHIFT_W32(A, 15); // A = A>>16 A = WEBRTC_SPL_RSHIFT_W32(A, 15); // A = A>>16
@ -177,8 +177,8 @@ WebRtc_Word32 WebRtcSpl_Sqrt(WebRtc_Word32 value)
A = WEBRTC_SPL_RSHIFT_W32(A, 16); // A = A>>16 A = WEBRTC_SPL_RSHIFT_W32(A, 16); // A = A>>16
} }
A = A & ((WebRtc_Word32)0x0000ffff); A = A & ((int32_t)0x0000ffff);
A = (WebRtc_Word32)WEBRTC_SPL_SHIFT_W32(A, nshift); // De-normalize the result A = (int32_t)WEBRTC_SPL_SHIFT_W32(A, nshift); // De-normalize the result
return A; return A;
} }

View File

@ -18,7 +18,7 @@
#include <string.h> #include <string.h>
#include "signal_processing_library.h" #include "signal_processing_library.h"
WebRtc_Word16 WebRtcSpl_get_version(char* version, WebRtc_Word16 length_in_bytes) int16_t WebRtcSpl_get_version(char* version, int16_t length_in_bytes)
{ {
strncpy(version, "1.2.0", length_in_bytes); strncpy(version, "1.2.0", length_in_bytes);
return 0; return 0;

View File

@ -22,8 +22,8 @@ enum
}; };
// QMF filter coefficients in Q16. // QMF filter coefficients in Q16.
static const WebRtc_UWord16 WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261}; static const uint16_t WebRtcSpl_kAllPassFilter1[3] = {6418, 36982, 57261};
static const WebRtc_UWord16 WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}; static const uint16_t WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010};
/////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////
// WebRtcSpl_AllPassQMF(...) // WebRtcSpl_AllPassQMF(...)
@ -43,9 +43,9 @@ static const WebRtc_UWord16 WebRtcSpl_kAllPassFilter2[3] = {21333, 49062, 63010}
// |data_length| // |data_length|
// //
void WebRtcSpl_AllPassQMF(WebRtc_Word32* in_data, const WebRtc_Word16 data_length, void WebRtcSpl_AllPassQMF(int32_t* in_data, const int16_t data_length,
WebRtc_Word32* out_data, const WebRtc_UWord16* filter_coefficients, int32_t* out_data, const uint16_t* filter_coefficients,
WebRtc_Word32* filter_state) int32_t* filter_state)
{ {
// The procedure is to filter the input with three first order all pass filters // The procedure is to filter the input with three first order all pass filters
// (cascade operations). // (cascade operations).
@ -63,8 +63,8 @@ void WebRtcSpl_AllPassQMF(WebRtc_Word32* in_data, const WebRtc_Word16 data_lengt
// filter operation takes the |in_data| (which is the output from the previous cascade // filter operation takes the |in_data| (which is the output from the previous cascade
// filter) and store the output in |out_data|. // filter) and store the output in |out_data|.
// Note that the input vector values are changed during the process. // Note that the input vector values are changed during the process.
WebRtc_Word16 k; int16_t k;
WebRtc_Word32 diff; int32_t diff;
// First all-pass cascade; filter from in_data to out_data. // First all-pass cascade; filter from in_data to out_data.
// Let y_i[n] indicate the output of cascade filter i (with filter coefficient a_i) at // Let y_i[n] indicate the output of cascade filter i (with filter coefficient a_i) at
@ -116,23 +116,23 @@ void WebRtcSpl_AllPassQMF(WebRtc_Word32* in_data, const WebRtc_Word16 data_lengt
filter_state[5] = out_data[data_length - 1]; // y[N-1], becomes y[-1] next time filter_state[5] = out_data[data_length - 1]; // y[N-1], becomes y[-1] next time
} }
void WebRtcSpl_AnalysisQMF(const WebRtc_Word16* in_data, WebRtc_Word16* low_band, void WebRtcSpl_AnalysisQMF(const int16_t* in_data, int16_t* low_band,
WebRtc_Word16* high_band, WebRtc_Word32* filter_state1, int16_t* high_band, int32_t* filter_state1,
WebRtc_Word32* filter_state2) int32_t* filter_state2)
{ {
WebRtc_Word16 i; int16_t i;
WebRtc_Word16 k; int16_t k;
WebRtc_Word32 tmp; int32_t tmp;
WebRtc_Word32 half_in1[kBandFrameLength]; int32_t half_in1[kBandFrameLength];
WebRtc_Word32 half_in2[kBandFrameLength]; int32_t half_in2[kBandFrameLength];
WebRtc_Word32 filter1[kBandFrameLength]; int32_t filter1[kBandFrameLength];
WebRtc_Word32 filter2[kBandFrameLength]; int32_t filter2[kBandFrameLength];
// Split even and odd samples. Also shift them to Q10. // Split even and odd samples. Also shift them to Q10.
for (i = 0, k = 0; i < kBandFrameLength; i++, k += 2) for (i = 0, k = 0; i < kBandFrameLength; i++, k += 2)
{ {
half_in2[i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)in_data[k], 10); half_in2[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k], 10);
half_in1[i] = WEBRTC_SPL_LSHIFT_W32((WebRtc_Word32)in_data[k + 1], 10); half_in1[i] = WEBRTC_SPL_LSHIFT_W32((int32_t)in_data[k + 1], 10);
} }
// All pass filter even and odd samples, independently. // All pass filter even and odd samples, independently.
@ -155,25 +155,25 @@ void WebRtcSpl_AnalysisQMF(const WebRtc_Word16* in_data, WebRtc_Word16* low_band
} }
} }
void WebRtcSpl_SynthesisQMF(const WebRtc_Word16* low_band, const WebRtc_Word16* high_band, void WebRtcSpl_SynthesisQMF(const int16_t* low_band, const int16_t* high_band,
WebRtc_Word16* out_data, WebRtc_Word32* filter_state1, int16_t* out_data, int32_t* filter_state1,
WebRtc_Word32* filter_state2) int32_t* filter_state2)
{ {
WebRtc_Word32 tmp; int32_t tmp;
WebRtc_Word32 half_in1[kBandFrameLength]; int32_t half_in1[kBandFrameLength];
WebRtc_Word32 half_in2[kBandFrameLength]; int32_t half_in2[kBandFrameLength];
WebRtc_Word32 filter1[kBandFrameLength]; int32_t filter1[kBandFrameLength];
WebRtc_Word32 filter2[kBandFrameLength]; int32_t filter2[kBandFrameLength];
WebRtc_Word16 i; int16_t i;
WebRtc_Word16 k; int16_t k;
// Obtain the sum and difference channels out of upper and lower-band channels. // Obtain the sum and difference channels out of upper and lower-band channels.
// Also shift to Q10 domain. // Also shift to Q10 domain.
for (i = 0; i < kBandFrameLength; i++) for (i = 0; i < kBandFrameLength; i++)
{ {
tmp = (WebRtc_Word32)low_band[i] + (WebRtc_Word32)high_band[i]; tmp = (int32_t)low_band[i] + (int32_t)high_band[i];
half_in1[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); half_in1[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10);
tmp = (WebRtc_Word32)low_band[i] - (WebRtc_Word32)high_band[i]; tmp = (int32_t)low_band[i] - (int32_t)high_band[i];
half_in2[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10); half_in2[i] = WEBRTC_SPL_LSHIFT_W32(tmp, 10);
} }

View File

@ -17,12 +17,12 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16 *xQ15, int vector_length, void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t *xQ15, int vector_length,
WebRtc_Word16 *yQ15) int16_t *yQ15)
{ {
WebRtc_Word32 sq; int32_t sq;
int m; int m;
WebRtc_Word16 tmp; int16_t tmp;
for (m = 0; m < vector_length; m++) for (m = 0; m < vector_length; m++)
{ {
@ -30,6 +30,6 @@ void WebRtcSpl_SqrtOfOneMinusXSquared(WebRtc_Word16 *xQ15, int vector_length,
sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30 sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30
sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30
sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15
yQ15[m] = (WebRtc_Word16)sq; yQ15[m] = (int16_t)sq;
} }
} }

View File

@ -22,10 +22,8 @@
#include "signal_processing_library.h" #include "signal_processing_library.h"
void WebRtcSpl_VectorBitShiftW16(WebRtc_Word16 *res, void WebRtcSpl_VectorBitShiftW16(int16_t *res, int16_t length,
WebRtc_Word16 length, G_CONST int16_t *in, int16_t right_shifts)
G_CONST WebRtc_Word16 *in,
WebRtc_Word16 right_shifts)
{ {
int i; int i;
@ -44,10 +42,10 @@ void WebRtcSpl_VectorBitShiftW16(WebRtc_Word16 *res,
} }
} }
void WebRtcSpl_VectorBitShiftW32(WebRtc_Word32 *out_vector, void WebRtcSpl_VectorBitShiftW32(int32_t *out_vector,
WebRtc_Word16 vector_length, int16_t vector_length,
G_CONST WebRtc_Word32 *in_vector, G_CONST int32_t *in_vector,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
int i; int i;
@ -85,33 +83,33 @@ void WebRtcSpl_VectorBitShiftW32ToW16(int16_t* out, int length,
} }
} }
void WebRtcSpl_ScaleVector(G_CONST WebRtc_Word16 *in_vector, WebRtc_Word16 *out_vector, void WebRtcSpl_ScaleVector(G_CONST int16_t *in_vector, int16_t *out_vector,
WebRtc_Word16 gain, WebRtc_Word16 in_vector_length, int16_t gain, int16_t in_vector_length,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
// Performs vector operation: out_vector = (gain*in_vector)>>right_shifts // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts
int i; int i;
G_CONST WebRtc_Word16 *inptr; G_CONST int16_t *inptr;
WebRtc_Word16 *outptr; int16_t *outptr;
inptr = in_vector; inptr = in_vector;
outptr = out_vector; outptr = out_vector;
for (i = 0; i < in_vector_length; i++) for (i = 0; i < in_vector_length; i++)
{ {
(*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts); (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(*inptr++, gain, right_shifts);
} }
} }
void WebRtcSpl_ScaleVectorWithSat(G_CONST WebRtc_Word16 *in_vector, WebRtc_Word16 *out_vector, void WebRtcSpl_ScaleVectorWithSat(G_CONST int16_t *in_vector, int16_t *out_vector,
WebRtc_Word16 gain, WebRtc_Word16 in_vector_length, int16_t gain, int16_t in_vector_length,
WebRtc_Word16 right_shifts) int16_t right_shifts)
{ {
// Performs vector operation: out_vector = (gain*in_vector)>>right_shifts // Performs vector operation: out_vector = (gain*in_vector)>>right_shifts
int i; int i;
WebRtc_Word32 tmpW32; int32_t tmpW32;
G_CONST WebRtc_Word16 *inptr; G_CONST int16_t *inptr;
WebRtc_Word16 *outptr; int16_t *outptr;
inptr = in_vector; inptr = in_vector;
outptr = out_vector; outptr = out_vector;
@ -123,15 +121,15 @@ void WebRtcSpl_ScaleVectorWithSat(G_CONST WebRtc_Word16 *in_vector, WebRtc_Word1
} }
} }
void WebRtcSpl_ScaleAndAddVectors(G_CONST WebRtc_Word16 *in1, WebRtc_Word16 gain1, int shift1, void WebRtcSpl_ScaleAndAddVectors(G_CONST int16_t *in1, int16_t gain1, int shift1,
G_CONST WebRtc_Word16 *in2, WebRtc_Word16 gain2, int shift2, G_CONST int16_t *in2, int16_t gain2, int shift2,
WebRtc_Word16 *out, int vector_length) int16_t *out, int vector_length)
{ {
// Performs vector operation: out = (gain1*in1)>>shift1 + (gain2*in2)>>shift2 // Performs vector operation: out = (gain1*in1)>>shift1 + (gain2*in2)>>shift2
int i; int i;
G_CONST WebRtc_Word16 *in1ptr; G_CONST int16_t *in1ptr;
G_CONST WebRtc_Word16 *in2ptr; G_CONST int16_t *in2ptr;
WebRtc_Word16 *outptr; int16_t *outptr;
in1ptr = in1; in1ptr = in1;
in2ptr = in2; in2ptr = in2;
@ -139,8 +137,8 @@ void WebRtcSpl_ScaleAndAddVectors(G_CONST WebRtc_Word16 *in1, WebRtc_Word16 gain
for (i = 0; i < vector_length; i++) for (i = 0; i < vector_length; i++)
{ {
(*outptr++) = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1) (*outptr++) = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain1, *in1ptr++, shift1)
+ (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2); + (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(gain2, *in2ptr++, shift2);
} }
} }