Browse code

ac3enc: use dsputil functions in apply_window()

Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 3b924294ea0ab891cf28fb30f26962a7960f7f37)

Justin Ruggles authored on 2011/01/14 05:28:06
Showing 3 changed files
... ...
@@ -161,7 +161,7 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
161 161
 
162 162
 static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in);
163 163
 
164
-static void apply_window(SampleType *output, const SampleType *input,
164
+static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input,
165 165
                          const SampleType *window, int n);
166 166
 
167 167
 static int normalize_samples(AC3EncodeContext *s);
... ...
@@ -262,7 +262,7 @@ static void apply_mdct(AC3EncodeContext *s)
262 262
             AC3Block *block = &s->blocks[blk];
263 263
             const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
264 264
 
265
-            apply_window(s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
265
+            apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
266 266
 
267 267
             block->exp_shift[ch] = normalize_samples(s);
268 268
 
... ...
@@ -251,7 +251,7 @@ static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
251 251
 /**
252 252
  * Apply KBD window to input samples prior to MDCT.
253 253
  */
254
-static void apply_window(int16_t *output, const int16_t *input,
254
+static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input,
255 255
                          const int16_t *window, int n)
256 256
 {
257 257
     int i;
... ...
@@ -48,17 +48,19 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
48 48
                              int nbits)
49 49
 {
50 50
     float *window;
51
-    int n, n2;
51
+    int i, n, n2;
52 52
 
53 53
     n  = 1 << nbits;
54 54
     n2 = n >> 1;
55 55
 
56
-    window = av_malloc(n2 * sizeof(*window));
56
+    window = av_malloc(n * sizeof(*window));
57 57
     if (!window) {
58 58
         av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory.\n");
59 59
         return AVERROR(ENOMEM);
60 60
     }
61 61
     ff_kbd_window_init(window, 5.0, n2);
62
+    for (i = 0; i < n2; i++)
63
+        window[n-1-i] = window[i];
62 64
     mdct->window = window;
63 65
 
64 66
     return ff_mdct_init(&mdct->fft, nbits, 0, -2.0 / n);
... ...
@@ -79,16 +81,10 @@ static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
79 79
 /**
80 80
  * Apply KBD window to input samples prior to MDCT.
81 81
  */
82
-static void apply_window(float *output, const float *input,
82
+static void apply_window(DSPContext *dsp, float *output, const float *input,
83 83
                          const float *window, int n)
84 84
 {
85
-    int i;
86
-    int n2 = n >> 1;
87
-
88
-    for (i = 0; i < n2; i++) {
89
-        output[i]     = input[i]     * window[i];
90
-        output[n-i-1] = input[n-i-1] * window[i];
91
-    }
85
+    dsp->vector_fmul(output, input, window, n);
92 86
 }
93 87
 
94 88