Index: webrtc/modules/audio_coding/codecs/isac/main/source/transform.c |
diff --git a/webrtc/modules/audio_coding/codecs/isac/main/source/transform.c b/webrtc/modules/audio_coding/codecs/isac/main/source/transform.c |
index ea6b579093a5b3877bb5785eb9adb073554f9eb1..8992897f454dbfca902d9c86be2263a34ac28716 100644 |
--- a/webrtc/modules/audio_coding/codecs/isac/main/source/transform.c |
+++ b/webrtc/modules/audio_coding/codecs/isac/main/source/transform.c |
@@ -14,41 +14,33 @@ |
#include "os_specific_inline.h" |
#include <math.h> |
-static double costab1[FRAMESAMPLES_HALF]; |
-static double sintab1[FRAMESAMPLES_HALF]; |
-static double costab2[FRAMESAMPLES_QUARTER]; |
-static double sintab2[FRAMESAMPLES_QUARTER]; |
- |
-void WebRtcIsac_InitTransform() |
-{ |
+void WebRtcIsac_InitTransform(TransformTables* tables) { |
int k; |
double fact, phase; |
fact = PI / (FRAMESAMPLES_HALF); |
phase = 0.0; |
for (k = 0; k < FRAMESAMPLES_HALF; k++) { |
- costab1[k] = cos(phase); |
- sintab1[k] = sin(phase); |
+ tables->costab1[k] = cos(phase); |
+ tables->sintab1[k] = sin(phase); |
phase += fact; |
} |
fact = PI * ((double) (FRAMESAMPLES_HALF - 1)) / ((double) FRAMESAMPLES_HALF); |
phase = 0.5 * fact; |
for (k = 0; k < FRAMESAMPLES_QUARTER; k++) { |
- costab2[k] = cos(phase); |
- sintab2[k] = sin(phase); |
+ tables->costab2[k] = cos(phase); |
+ tables->sintab2[k] = sin(phase); |
phase += fact; |
} |
} |
- |
-void WebRtcIsac_Time2Spec(double *inre1, |
- double *inre2, |
- int16_t *outreQ7, |
- int16_t *outimQ7, |
- FFTstr *fftstr_obj) |
-{ |
- |
+void WebRtcIsac_Time2Spec(const TransformTables* tables, |
+ double* inre1, |
+ double* inre2, |
+ int16_t* outreQ7, |
+ int16_t* outimQ7, |
+ FFTstr* fftstr_obj) { |
int k; |
int dims[1]; |
double tmp1r, tmp1i, xr, xi, yr, yi, fact; |
@@ -61,8 +53,8 @@ void WebRtcIsac_Time2Spec(double *inre1, |
/* Multiply with complex exponentials and combine into one complex vector */ |
fact = 0.5 / sqrt(FRAMESAMPLES_HALF); |
for (k = 0; k < FRAMESAMPLES_HALF; k++) { |
- tmp1r = costab1[k]; |
- tmp1i = sintab1[k]; |
+ tmp1r = tables->costab1[k]; |
the sun
2015/06/15 15:08:51
Premature pessimization?
I hope the dereference i
kwiberg-webrtc
2015/06/15 21:57:28
I'm glad you asked. Given this small test program
the sun
2015/06/16 08:19:54
Hey, now I AM glad I asked. That was super informa
kwiberg-webrtc
2015/06/16 08:31:44
I know just enough assembly to decrypt what code l
the sun
2015/06/16 08:46:36
I was just thinking that it did auto-vectorization
|
+ tmp1i = tables->sintab1[k]; |
tmpre[k] = (inre1[k] * tmp1r + inre2[k] * tmp1i) * fact; |
tmpim[k] = (inre2[k] * tmp1r - inre1[k] * tmp1i) * fact; |
} |
@@ -78,8 +70,8 @@ void WebRtcIsac_Time2Spec(double *inre1, |
xi = tmpim[k] - tmpim[FRAMESAMPLES_HALF - 1 - k]; |
yr = tmpim[k] + tmpim[FRAMESAMPLES_HALF - 1 - k]; |
- tmp1r = costab2[k]; |
- tmp1i = sintab2[k]; |
+ tmp1r = tables->costab2[k]; |
+ tmp1i = tables->sintab2[k]; |
outreQ7[k] = (int16_t)WebRtcIsac_lrint((xr * tmp1r - xi * tmp1i) * 128.0); |
outimQ7[k] = (int16_t)WebRtcIsac_lrint((xr * tmp1i + xi * tmp1r) * 128.0); |
outreQ7[FRAMESAMPLES_HALF - 1 - k] = (int16_t)WebRtcIsac_lrint((-yr * tmp1i - yi * tmp1r) * 128.0); |
@@ -87,10 +79,12 @@ void WebRtcIsac_Time2Spec(double *inre1, |
} |
} |
- |
-void WebRtcIsac_Spec2time(double *inre, double *inim, double *outre1, double *outre2, FFTstr *fftstr_obj) |
-{ |
- |
+void WebRtcIsac_Spec2time(const TransformTables* tables, |
+ double* inre, |
+ double* inim, |
+ double* outre1, |
+ double* outre2, |
+ FFTstr* fftstr_obj) { |
int k; |
double tmp1r, tmp1i, xr, xi, yr, yi, fact; |
@@ -100,8 +94,8 @@ void WebRtcIsac_Spec2time(double *inre, double *inim, double *outre1, double *ou |
for (k = 0; k < FRAMESAMPLES_QUARTER; k++) { |
/* Move zero in time to beginning of frames */ |
- tmp1r = costab2[k]; |
- tmp1i = sintab2[k]; |
+ tmp1r = tables->costab2[k]; |
+ tmp1i = tables->sintab2[k]; |
xr = inre[k] * tmp1r + inim[k] * tmp1i; |
xi = inim[k] * tmp1r - inre[k] * tmp1i; |
yr = -inim[FRAMESAMPLES_HALF - 1 - k] * tmp1r - inre[FRAMESAMPLES_HALF - 1 - k] * tmp1i; |
@@ -122,8 +116,8 @@ void WebRtcIsac_Spec2time(double *inre, double *inim, double *outre1, double *ou |
/* Demodulate and separate */ |
fact = sqrt(FRAMESAMPLES_HALF); |
for (k = 0; k < FRAMESAMPLES_HALF; k++) { |
- tmp1r = costab1[k]; |
- tmp1i = sintab1[k]; |
+ tmp1r = tables->costab1[k]; |
+ tmp1i = tables->sintab1[k]; |
xr = (outre1[k] * tmp1r - outre2[k] * tmp1i) * fact; |
outre2[k] = (outre2[k] * tmp1r + outre1[k] * tmp1i) * fact; |
outre1[k] = xr; |