diff options
author | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-03-11 18:36:11 +0300 |
---|---|---|
committer | Jean-Marc Valin <jean-marc.valin@octasic.com> | 2011-03-11 18:36:11 +0300 |
commit | 86da2c8b19134b84d408c4fda583abab4bcc2219 (patch) | |
tree | 9caccdbf72f4914c9b1806d854f75019f6ca9e77 | |
parent | 3e7f22d45b285186e28b3bde54db0ce9126ca073 (diff) |
Speeds up compute_allocation() by removing potential aliasing
-rw-r--r-- | libcelt/rate.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libcelt/rate.c b/libcelt/rate.c index 2acf099..24037c0 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -584,18 +584,19 @@ int compute_allocation(const CELTMode *m, int start, int end, const int *offsets int mid = (lo+hi) >> 1; for (j=end;j-->start;) { + int bitsj; int N = m->eBands[j+1]-m->eBands[j]; - bits1[j] = C*N*m->allocVectors[mid*len+j]<<LM>>2; - if (bits1[j] > 0) - bits1[j] = IMAX(0, bits1[j] + trim_offset[j]); - bits1[j] += offsets[j]; - if (bits1[j] >= thresh[j] || done) + bitsj = C*N*m->allocVectors[mid*len+j]<<LM>>2; + if (bitsj > 0) + bitsj = IMAX(0, bitsj + trim_offset[j]); + bitsj += offsets[j]; + if (bitsj >= thresh[j] || done) { done = 1; /* Don't allocate more than we can actually use */ - psum += IMIN(bits1[j], cap[j]); + psum += IMIN(bitsj, cap[j]); } else { - if (bits1[j] >= C<<BITRES) + if (bitsj >= C<<BITRES) psum += C<<BITRES; } } @@ -610,20 +611,23 @@ int compute_allocation(const CELTMode *m, int start, int end, const int *offsets /*printf ("interp between %d and %d\n", lo, hi);*/ for (j=start;j<end;j++) { + int bits1j, bits2j; int N = m->eBands[j+1]-m->eBands[j]; - bits1[j] = C*N*m->allocVectors[lo*len+j]<<LM>>2; - bits2[j] = hi>=m->nbAllocVectors ? + bits1j = C*N*m->allocVectors[lo*len+j]<<LM>>2; + bits2j = hi>=m->nbAllocVectors ? cap[j] : C*N*m->allocVectors[hi*len+j]<<LM>>2; - if (bits1[j] > 0) - bits1[j] = IMAX(0, bits1[j] + trim_offset[j]); - if (bits2[j] > 0) - bits2[j] = IMAX(0, bits2[j] + trim_offset[j]); + if (bits1j > 0) + bits1j = IMAX(0, bits1j + trim_offset[j]); + if (bits2j > 0) + bits2j = IMAX(0, bits2j + trim_offset[j]); if (lo > 0) - bits1[j] += offsets[j]; - bits2[j] += offsets[j]; + bits1j += offsets[j]; + bits2j += offsets[j]; if (offsets[j]>0) skip_start = j; - bits2[j] = IMAX(0,bits2[j]-bits1[j]); + bits2j = IMAX(0,bits2j-bits1j); + bits1[j] = bits1j; + bits2[j] = bits2j; } codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thresh, cap, total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_stereo_rsv, |