compute_mdct_coefficients(): Further reducuce indentation level.
authorAndre Noll <maan@systemlinux.org>
Sat, 7 Nov 2009 15:46:41 +0000 (16:46 +0100)
committerAndre Noll <maan@systemlinux.org>
Wed, 18 Nov 2009 18:34:30 +0000 (19:34 +0100)
Put the hot path at the top of the channel loop.

wmadec_filter.c

index 007a52c..eea2750 100644 (file)
@@ -743,143 +743,143 @@ static void compute_mdct_coefficients(struct private_wmadec_data *pwd,
                mult = pow(10, total_gain * 0.05) / pwd->max_exponent[ch];
                mult *= mdct_norm;
                coefs = pwd->coefs[ch];
-               if (pwd->use_noise_coding) {
-                       mult1 = mult;
-                       /* very low freqs : noise */
-                       for (i = 0; i < pwd->coefs_start; i++) {
+               if (!pwd->use_noise_coding) {
+                       /* XXX: optimize more */
+                       for (i = 0; i < pwd->coefs_start; i++)
+                               *coefs++ = 0.0;
+                       n = nb_coefs[ch];
+                       for (i = 0; i < n; i++) {
                                *coefs++ =
-                                   pwd->noise_table[pwd->noise_index] *
+                                   coefs1[i] *
                                    exponents[i << bsize >> esize] *
-                                   mult1;
-                               pwd->noise_index =
-                                   (pwd->noise_index +
-                                    1) & (NOISE_TAB_SIZE - 1);
+                                   mult;
                        }
+                       n = pwd->block_len - pwd->coefs_end[bsize];
+                       for (i = 0; i < n; i++)
+                               *coefs++ = 0.0;
+                       continue;
+               }
+               mult1 = mult;
+               /* very low freqs : noise */
+               for (i = 0; i < pwd->coefs_start; i++) {
+                       *coefs++ =
+                           pwd->noise_table[pwd->noise_index] *
+                           exponents[i << bsize >> esize] *
+                           mult1;
+                       pwd->noise_index =
+                           (pwd->noise_index +
+                            1) & (NOISE_TAB_SIZE - 1);
+               }
 
-                       n1 = pwd->exponent_high_sizes[bsize];
+               n1 = pwd->exponent_high_sizes[bsize];
+
+               /* compute power of high bands */
+               exponents = pwd->exponents[ch] +
+                   (pwd->high_band_start[bsize] << bsize);
+               last_high_band = 0;     /* avoid warning */
+               for (j = 0; j < n1; j++) {
+                       n = pwd->exponent_high_bands[pwd->
+                                                  frame_len_bits
+                                                  -
+                                                  pwd->
+                                                  block_len_bits]
+                           [j];
+                       if (pwd->high_band_coded[ch][j]) {
+                               float e2, val;
+                               e2 = 0;
+                               for (i = 0; i < n; i++) {
+                                       val = exponents[i << bsize
+                                                     >> esize];
+                                       e2 += val * val;
+                               }
+                               exp_power[j] = e2 / n;
+                               last_high_band = j;
+                       }
+                       exponents += n << bsize;
+               }
 
-                       /* compute power of high bands */
-                       exponents = pwd->exponents[ch] +
-                           (pwd->high_band_start[bsize] << bsize);
-                       last_high_band = 0;     /* avoid warning */
-                       for (j = 0; j < n1; j++) {
+               /* main freqs and high freqs */
+               exponents =
+                   pwd->exponents[ch] +
+                   (pwd->coefs_start << bsize);
+               for (j = -1; j < n1; j++) {
+                       if (j < 0) {
+                               n = pwd->high_band_start[bsize] -
+                                   pwd->coefs_start;
+                       } else {
                                n = pwd->exponent_high_bands[pwd->
                                                           frame_len_bits
                                                           -
                                                           pwd->
                                                           block_len_bits]
                                    [j];
-                               if (pwd->high_band_coded[ch][j]) {
-                                       float e2, val;
-                                       e2 = 0;
-                                       for (i = 0; i < n; i++) {
-                                               val = exponents[i << bsize
-                                                             >> esize];
-                                               e2 += val * val;
-                                       }
-                                       exp_power[j] = e2 / n;
-                                       last_high_band = j;
-                               }
-                               exponents += n << bsize;
                        }
-
-                       /* main freqs and high freqs */
-                       exponents =
-                           pwd->exponents[ch] +
-                           (pwd->coefs_start << bsize);
-                       for (j = -1; j < n1; j++) {
-                               if (j < 0) {
-                                       n = pwd->high_band_start[bsize] -
-                                           pwd->coefs_start;
-                               } else {
-                                       n = pwd->exponent_high_bands[pwd->
-                                                                  frame_len_bits
-                                                                  -
-                                                                  pwd->
-                                                                  block_len_bits]
-                                           [j];
+                       if (j >= 0 && pwd->high_band_coded[ch][j]) {
+                               /* use noise with specified power */
+                               mult1 =
+                                   sqrt(exp_power[j] /
+                                        exp_power
+                                        [last_high_band]);
+                               /* XXX: use a table */
+                               mult1 =
+                                   mult1 * pow(10,
+                                               pwd->
+                                               high_band_values
+                                               [ch][j] * 0.05);
+                               mult1 =
+                                   mult1 /
+                                   (pwd->max_exponent[ch] *
+                                    pwd->noise_mult);
+                               mult1 *= mdct_norm;
+                               for (i = 0; i < n; i++) {
+                                       noise =
+                                           pwd->noise_table[pwd->
+                                                          noise_index];
+                                       pwd->noise_index =
+                                           (pwd->noise_index +
+                                            1) &
+                                           (NOISE_TAB_SIZE -
+                                            1);
+                                       *coefs++ =
+                                           noise *
+                                           exponents[i << bsize
+                                                     >> esize]
+                                           * mult1;
                                }
-                               if (j >= 0 && pwd->high_band_coded[ch][j]) {
-                                       /* use noise with specified power */
-                                       mult1 =
-                                           sqrt(exp_power[j] /
-                                                exp_power
-                                                [last_high_band]);
-                                       /* XXX: use a table */
-                                       mult1 =
-                                           mult1 * pow(10,
-                                                       pwd->
-                                                       high_band_values
-                                                       [ch][j] * 0.05);
-                                       mult1 =
-                                           mult1 /
-                                           (pwd->max_exponent[ch] *
-                                            pwd->noise_mult);
-                                       mult1 *= mdct_norm;
-                                       for (i = 0; i < n; i++) {
-                                               noise =
-                                                   pwd->noise_table[pwd->
-                                                                  noise_index];
-                                               pwd->noise_index =
-                                                   (pwd->noise_index +
-                                                    1) &
-                                                   (NOISE_TAB_SIZE -
-                                                    1);
-                                               *coefs++ =
-                                                   noise *
-                                                   exponents[i << bsize
-                                                             >> esize]
-                                                   * mult1;
-                                       }
-                                       exponents += n << bsize;
-                               } else {
-                                       /* coded values + small noise */
-                                       for (i = 0; i < n; i++) {
-                                               noise =
-                                                   pwd->noise_table[pwd->
-                                                                  noise_index];
-                                               pwd->noise_index =
-                                                   (pwd->noise_index +
-                                                    1) &
-                                                   (NOISE_TAB_SIZE -
-                                                    1);
-                                               *coefs++ =
-                                                   ((*coefs1++) +
-                                                    noise) *
-                                                   exponents[i << bsize
-                                                             >> esize]
-                                                   * mult;
-                                       }
-                                       exponents += n << bsize;
+                               exponents += n << bsize;
+                       } else {
+                               /* coded values + small noise */
+                               for (i = 0; i < n; i++) {
+                                       noise =
+                                           pwd->noise_table[pwd->
+                                                          noise_index];
+                                       pwd->noise_index =
+                                           (pwd->noise_index +
+                                            1) &
+                                           (NOISE_TAB_SIZE -
+                                            1);
+                                       *coefs++ =
+                                           ((*coefs1++) +
+                                            noise) *
+                                           exponents[i << bsize
+                                                     >> esize]
+                                           * mult;
                                }
+                               exponents += n << bsize;
                        }
+               }
 
-                       /* very high freqs : noise */
-                       n = pwd->block_len - pwd->coefs_end[bsize];
-                       mult1 =
-                           mult * exponents[((-1 << bsize)) >> esize];
-                       for (i = 0; i < n; i++) {
-                               *coefs++ =
-                                   pwd->noise_table[pwd->noise_index] *
-                                   mult1;
-                               pwd->noise_index =
-                                   (pwd->noise_index +
-                                    1) & (NOISE_TAB_SIZE - 1);
-                       }
-               } else {
-                       /* XXX: optimize more */
-                       for (i = 0; i < pwd->coefs_start; i++)
-                               *coefs++ = 0.0;
-                       n = nb_coefs[ch];
-                       for (i = 0; i < n; i++) {
-                               *coefs++ =
-                                   coefs1[i] *
-                                   exponents[i << bsize >> esize] *
-                                   mult;
-                       }
-                       n = pwd->block_len - pwd->coefs_end[bsize];
-                       for (i = 0; i < n; i++)
-                               *coefs++ = 0.0;
+               /* very high freqs : noise */
+               n = pwd->block_len - pwd->coefs_end[bsize];
+               mult1 =
+                   mult * exponents[((-1 << bsize)) >> esize];
+               for (i = 0; i < n; i++) {
+                       *coefs++ =
+                           pwd->noise_table[pwd->noise_index] *
+                           mult1;
+                       pwd->noise_index =
+                           (pwd->noise_index +
+                            1) & (NOISE_TAB_SIZE - 1);
                }
        }
 }