changeset 10220:76132409af55 libavcodec

AAC: use new dsputil functions
author mru
date Tue, 22 Sep 2009 00:48:45 +0000
parents 87ae4a167138
children 2791393081ff
files aac.c aactab.c
diffstat 2 files changed, 33 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/aac.c	Tue Sep 22 00:48:41 2009 +0000
+++ b/aac.c	Tue Sep 22 00:48:45 2009 +0000
@@ -861,18 +861,25 @@
                 for (group = 0; group < ics->group_len[g]; group++) {
                     float scale;
                     float band_energy = 0;
+                    float *cf = coef + group * 128;
+                    int len = offsets[i+1] - offsets[i];
+
                     for (k = offsets[i]; k < offsets[i + 1]; k++) {
                         ac->random_state  = lcg_random(ac->random_state);
                         coef[group * 128 + k] = ac->random_state;
-                        band_energy += coef[group * 128 + k] * coef[group * 128 + k];
                     }
+
+                    band_energy += ac->dsp.scalarproduct_float(cf, cf, len);
                     scale = sf[idx] / sqrtf(band_energy);
-                    for (k = offsets[i]; k < offsets[i + 1]; k++) {
-                        coef[group * 128 + k] *= scale;
-                    }
+                    ac->dsp.vector_fmul_scalar(cf, cf, scale, len);
                 }
             } else {
                 for (group = 0; group < ics->group_len[g]; group++) {
+                    const float *vq[96];
+                    const float **vqp = vq;
+                    float *cf = coef + (group << 7) + offsets[i];
+                    int len = offsets[i + 1] - offsets[i];
+
                     for (k = offsets[i]; k < offsets[i + 1]; k += dim) {
                         const int index = get_vlc2(gb, vlc_spectral[cur_band_type - 1].table, 6, 3);
                         const int coef_tmp_idx = (group << 7) + k;
@@ -885,6 +892,7 @@
                             return -1;
                         }
                         vq_ptr = &ff_aac_codebook_vectors[cur_band_type - 1][index * dim];
+                        *vqp++ = vq_ptr;
                         if (is_cb_unsigned) {
                             if (vq_ptr[0])
                                 coef[coef_tmp_idx    ] = sign_lookup[get_bits1(gb)];
@@ -912,28 +920,17 @@
                                     } else
                                         coef[coef_tmp_idx + j] *= vq_ptr[j];
                                 }
-                            } else {
-                                coef[coef_tmp_idx    ] *= vq_ptr[0];
-                                coef[coef_tmp_idx + 1] *= vq_ptr[1];
-                                if (dim == 4) {
-                                    coef[coef_tmp_idx + 2] *= vq_ptr[2];
-                                    coef[coef_tmp_idx + 3] *= vq_ptr[3];
-                                }
-                            }
-                        } else {
-                            coef[coef_tmp_idx    ] = vq_ptr[0];
-                            coef[coef_tmp_idx + 1] = vq_ptr[1];
-                            if (dim == 4) {
-                                coef[coef_tmp_idx + 2] = vq_ptr[2];
-                                coef[coef_tmp_idx + 3] = vq_ptr[3];
                             }
                         }
-                        coef[coef_tmp_idx    ] *= sf[idx];
-                        coef[coef_tmp_idx + 1] *= sf[idx];
-                        if (dim == 4) {
-                            coef[coef_tmp_idx + 2] *= sf[idx];
-                            coef[coef_tmp_idx + 3] *= sf[idx];
-                        }
+                    }
+
+                    if (is_cb_unsigned && cur_band_type != ESC_BT) {
+                        ac->dsp.vector_fmul_sv_scalar[dim>>2](
+                            cf, cf, vq, sf[idx], len);
+                    } else if (is_cb_unsigned && cur_band_type == ESC_BT) {
+                        ac->dsp.vector_fmul_scalar(cf, cf, sf[idx], len);
+                    } else {    /* !is_cb_unsigned */
+                        ac->dsp.sv_fmul_scalar[dim>>2](cf, vq, sf[idx], len);
                     }
                 }
             }
@@ -1103,23 +1100,21 @@
 /**
  * Mid/Side stereo decoding; reference: 4.6.8.1.3.
  */
-static void apply_mid_side_stereo(ChannelElement *cpe)
+static void apply_mid_side_stereo(AACContext *ac, ChannelElement *cpe)
 {
     const IndividualChannelStream *ics = &cpe->ch[0].ics;
     float *ch0 = cpe->ch[0].coeffs;
     float *ch1 = cpe->ch[1].coeffs;
-    int g, i, k, group, idx = 0;
+    int g, i, group, idx = 0;
     const uint16_t *offsets = ics->swb_offset;
     for (g = 0; g < ics->num_window_groups; g++) {
         for (i = 0; i < ics->max_sfb; i++, idx++) {
             if (cpe->ms_mask[idx] &&
                     cpe->ch[0].band_type[idx] < NOISE_BT && cpe->ch[1].band_type[idx] < NOISE_BT) {
                 for (group = 0; group < ics->group_len[g]; group++) {
-                    for (k = offsets[i]; k < offsets[i + 1]; k++) {
-                        float tmp = ch0[group * 128 + k] - ch1[group * 128 + k];
-                        ch0[group * 128 + k] += ch1[group * 128 + k];
-                        ch1[group * 128 + k]  = tmp;
-                    }
+                    ac->dsp.butterflies_float(ch0 + group * 128 + offsets[i],
+                                              ch1 + group * 128 + offsets[i],
+                                              offsets[i+1] - offsets[i]);
                 }
             }
         }
@@ -1200,7 +1195,7 @@
 
     if (common_window) {
         if (ms_present)
-            apply_mid_side_stereo(cpe);
+            apply_mid_side_stereo(ac, cpe);
         if (ac->m4ac.object_type == AOT_AAC_MAIN) {
             apply_prediction(ac, &cpe->ch[0]);
             apply_prediction(ac, &cpe->ch[1]);
--- a/aactab.c	Tue Sep 22 00:48:41 2009 +0000
+++ b/aactab.c	Tue Sep 22 00:48:45 2009 +0000
@@ -409,7 +409,7 @@
  * 64.0f is a special value indicating the existence of an escape code in the
  * bitstream.
  */
-static const float codebook_vector0[324] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector0[324]) = {
  -1.0000000, -1.0000000, -1.0000000, -1.0000000,
  -1.0000000, -1.0000000, -1.0000000,  0.0000000,
  -1.0000000, -1.0000000, -1.0000000,  1.0000000,
@@ -493,7 +493,7 @@
   1.0000000,  1.0000000,  1.0000000,  1.0000000,
 };
 
-static const float codebook_vector2[324] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector2[324]) = {
   0.0000000,  0.0000000,  0.0000000,  0.0000000,
   0.0000000,  0.0000000,  0.0000000,  1.0000000,
   0.0000000,  0.0000000,  0.0000000,  2.5198421,
@@ -577,7 +577,7 @@
   2.5198421,  2.5198421,  2.5198421,  2.5198421,
 };
 
-static const float codebook_vector4[162] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector4[162]) = {
  -6.3496042, -6.3496042, -6.3496042, -4.3267487,
  -6.3496042, -2.5198421, -6.3496042, -1.0000000,
  -6.3496042,  0.0000000, -6.3496042,  1.0000000,
@@ -621,7 +621,7 @@
   6.3496042,  6.3496042,
 };
 
-static const float codebook_vector6[128] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector6[128]) = {
   0.0000000,  0.0000000,  0.0000000,  1.0000000,
   0.0000000,  2.5198421,  0.0000000,  4.3267487,
   0.0000000,  6.3496042,  0.0000000,  8.5498797,
@@ -656,7 +656,7 @@
  13.3905183, 10.9027236, 13.3905183, 13.3905183,
 };
 
-static const float codebook_vector8[338] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector8[338]) = {
   0.0000000,  0.0000000,  0.0000000,  1.0000000,
   0.0000000,  2.5198421,  0.0000000,  4.3267487,
   0.0000000,  6.3496042,  0.0000000,  8.5498797,
@@ -744,7 +744,7 @@
  27.4731418, 27.4731418,
 };
 
-static const float codebook_vector10[578] = {
+static const DECLARE_ALIGNED_16(float, codebook_vector10[578]) = {
   0.0000000,  0.0000000,  0.0000000,  1.0000000,
   0.0000000,  2.5198421,  0.0000000,  4.3267487,
   0.0000000,  6.3496042,  0.0000000,  8.5498797,