Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2016-08-06 22:49:55 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2016-08-06 22:49:55 +0300
commite806d6a74129c70d2849cf621968f905149c21e1 (patch)
tree870ce0a73e16b5895f0302ecd542d05f71bba3d2
parentc7bbc3e31fa67da78a41868576672ef01f888ae1 (diff)
Making signx[] an int in alg_quant() and removes unnecessary sign copying
No measurable speed change.
-rw-r--r--celt/vq.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/celt/vq.c b/celt/vq.c
index b64e604e..e6895952 100644
--- a/celt/vq.c
+++ b/celt/vq.c
@@ -163,7 +163,7 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc,
{
VARDECL(celt_norm, y);
VARDECL(int, iy);
- VARDECL(opus_val16, signx);
+ VARDECL(int, signx);
int i, j;
int pulsesLeft;
opus_val32 sum;
@@ -177,16 +177,15 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc,
ALLOC(y, N, celt_norm);
ALLOC(iy, N, int);
- ALLOC(signx, N, opus_val16);
+ ALLOC(signx, N, int);
exp_rotation(X, N, 1, B, K, spread);
/* Get rid of the sign */
sum = 0;
j=0; do {
- /* OPT: Make sure the following two lines result in conditional moves
- rather than branches. */
- signx[j] = X[j]>0 ? 1 : -1;
+ signx[j] = X[j]<0;
+ /* OPT: Make sure the compiler doesn't use a branch on ABS16(). */
X[j] = ABS16(X[j]);
iy[j] = 0;
y[j] = 0;
@@ -318,10 +317,10 @@ unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc,
/* Put the original sign back */
j=0;
do {
- X[j] = MULT16_16(signx[j],X[j]);
- /* OPT: Make sure your compiler uses a conditional move here rather than
- a branch. */
- iy[j] = signx[j] < 0 ? -iy[j] : iy[j];
+ /*iy[j] = signx[j] ? -iy[j] : iy[j];*/
+ /* OPT: The is more likely to be compiled without a branch than the code above
+ but has the same performance otherwise. */
+ iy[j] = (iy[j]^-signx[j]) + signx[j];
} while (++j<N);
encode_pulses(iy, N, K, enc);