Another bunch of do-while() loops
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Mon, 21 Apr 2008 01:43:51 +0000 (11:43 +1000)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Mon, 21 Apr 2008 01:43:51 +0000 (11:43 +1000)
libcelt/bands.c
libcelt/vq.c

index a38fe6b..5ec1d95 100644 (file)
@@ -93,13 +93,19 @@ void compute_band_energies(const CELTMode *m, const celt_sig_t *X, celt_ener_t *
          int j;
          celt_word32_t maxval=0;
          celt_word32_t sum = 0;
-         for (j=eBands[i];j<eBands[i+1];j++)
-            maxval = MAX32(maxval, ABS32(X[j*C+c]));
+         
+         j=eBands[i]; do {
+            maxval = MAX32(maxval, X[j*C+c]);
+            maxval = MAX32(maxval, -X[j*C+c]);
+         } while (++j<eBands[i+1]);
+         
          if (maxval > 0)
          {
             int shift = celt_ilog2(maxval)-10;
-            for (j=eBands[i];j<eBands[i+1];j++)
-               sum += MULT16_16(EXTRACT16(VSHR32(X[j*C+c],shift)),EXTRACT16(VSHR32(X[j*C+c],shift)));
+            j=eBands[i]; do {
+               sum += MULT16_16(EXTRACT16(VSHR32(X[j*C+c],shift)),
+                                EXTRACT16(VSHR32(X[j*C+c],shift)));
+            } while (++j<eBands[i+1]);
             /* We're adding one here to make damn sure we never end up with a pitch vector that's
                larger than unity norm */
             bank[i*C+c] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);
@@ -127,8 +133,9 @@ void normalise_bands(const CELTMode *m, const celt_sig_t * restrict freq, celt_n
          shift = celt_zlog2(bank[i*C+c])-13;
          E = VSHR32(bank[i*C+c], shift);
          g = EXTRACT16(celt_rcp(SHR32(MULT16_16(E,sqrtC_1[C-1]),11)));
-         for (j=eBands[i];j<eBands[i+1];j++)
+         j=eBands[i]; do {
             X[j*C+c] = MULT16_16_Q15(VSHR32(freq[j*C+c],shift-1),g);
+         } while (++j<eBands[i+1]);
       } while (++i<m->nbEBands);
    }
    for (i=C*eBands[m->nbEBands];i<C*eBands[m->nbEBands+1];i++)
@@ -220,8 +227,9 @@ void denormalise_bands(const CELTMode *m, const celt_norm_t * restrict X, celt_s
       {
          int j;
          celt_word32_t g = MULT16_32_Q13(sqrtC_1[C-1],bank[i*C+c]);
-         for (j=eBands[i];j<eBands[i+1];j++)
+         j=eBands[i]; do {
             freq[j*C+c] = MULT16_32_Q15(X[j*C+c], g);
+         } while (++j<eBands[i+1]);
       }
    }
    for (i=C*eBands[m->nbEBands];i<C*eBands[m->nbEBands+1];i++)
index 974073f..d2c0a4d 100644 (file)
@@ -117,8 +117,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
    N_1 = 512/N;
 
    sum = 0;
-   for (j=0;j<N;j++)
-   {
+   j=0; do {
       if (X[j]>0)
          signx[j]=1;
       else
@@ -126,7 +125,7 @@ void alg_quant(celt_norm_t *X, celt_mask_t *W, int N, int K, const celt_norm_t *
       iy[j] = 0;
       y[j] = 0;
       sum = MAC16_16(sum, P[j],P[j]);
-   }
+   } while (++j<N);
    Rpp = ROUND16(sum, NORM_SHIFT);
 
    celt_assert2(Rpp<=NORM_SCALING, "Rpp should never have a norm greater than unity");