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

gitlab.com/quite/celt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2008-04-21 01:53:40 +0400
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2008-04-21 01:53:40 +0400
commitd7291d243050d86097c9cd63c4bc42e1cd6b8455 (patch)
treec2857f8535f3487fb5e5a62ae58203b8fd6cbeb0 /libcelt/cwrs.c
parent7aa9d8c7ae491259f4094877facca36934058dd7 (diff)
Further simplifications to comb2pulses() to remove all conditional branches.
Diffstat (limited to 'libcelt/cwrs.c')
-rw-r--r--libcelt/cwrs.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/libcelt/cwrs.c b/libcelt/cwrs.c
index 9680233..c678578 100644
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -269,15 +269,12 @@ celt_uint64_t icwrs64(int _n,int _m,const int *_x,const int *_s,
_x: The combination with elements sorted in ascending order. _x[_m] = -1
_s: The associated sign bits.*/
void comb2pulse(int _n,int _m,int * restrict _y,const int *_x,const int *_s){
- int j;
int k;
- int n;
+ const int signs[2]={1,-1};
CELT_MEMSET(_y, 0, _n);
- for(k=j=0;k<_m;k+=n){
- /* _x[_m] = -1 so we won't overflow */
- for(n=1;_x[k+n]==_x[k];n++);
- _y[_x[k]]=_s[k]?-n:n;
- }
+ k=0; do {
+ _y[_x[k]]+=signs[_s[k]];
+ } while (++k<_m);
}
/*Converts a pulse vector vector _y of length _n into a combination of _m unit
@@ -371,7 +368,7 @@ void decode_pulses(int *_y, int N, int K, ec_dec *dec)
VARDECL(int, signs);
SAVE_STACK;
- ALLOC(comb, K+1, int);
+ ALLOC(comb, K, int);
ALLOC(signs, K, int);
/* Simple heuristic to figure out whether it fits in 32 bits */
if((N+4)*(K+4)<250 || (celt_ilog2(N)+1)*K<31)
@@ -380,7 +377,6 @@ void decode_pulses(int *_y, int N, int K, ec_dec *dec)
} else {
decode_comb64(N, K, comb, signs, dec);
}
- comb[K] = -1;
comb2pulse(N, K, _y, comb, signs);
RESTORE_STACK;
}